更新记录

1.0.1(2026-01-07)

截图

1.0.0(2026-01-07)

init


平台兼容性

uni-app(4.87)

Vue2 Vue3 Chrome Safari app-vue app-nvue Android iOS 鸿蒙
- - - - - - -
微信小程序 支付宝小程序 抖音小程序 百度小程序 快手小程序 京东小程序 鸿蒙元服务 QQ小程序 飞书小程序 快应用-华为 快应用-联盟
- - - - - - - - - - -

uni-app x(4.87)

Chrome Safari Android iOS 鸿蒙 微信小程序
- - - -

hans-langgraph-sdk

LangGraph SDK for uni-app / uni-app X(APP-PLUS),基于 hans-request 网络层实现。

功能

  • Assistants: assistantsCreate / assistantsSearch / assistantsGet / assistantsUpdate / assistantsDelete / assistantsCount / assistantsGetVersions / assistantsSetLatest / assistantsGetGraph / assistantsGetSchemas / assistantsGetSubgraphs
  • Threads: threadsCreate / threadsGet / threadsUpdate / threadsDelete / threadsCopy / threadsSearch / threadsCount / threadsState / threadsHistory / threadsUpdateState / threadsPatchState / threadsJoinStream
  • Runs: runsCreate / runsCreateBatch / runsWait / runsStream / runsList / runsGet / runsCancel / runsJoin / runsJoinStream / runsDelete

平台支持

  • APP-PLUS:Android / iOS(uni-app / uni-app X)
  • 其它平台:未实现(H5 / 小程序 / Harmony 等)

设计说明

  • 所有请求入参使用 UTSJSONObject(或普通对象)纯透传:SDK 不做字段映射/过滤/类型修正,便于后端参数变更时保持兼容。
  • apiKey 会自动作为 Authorization: Bearer <apiKey> 请求头发送;不传则不带鉴权头(如需自定义鉴权方式请用 defaultHeaders)。
  • 注意:如果后端对字段类型校验严格,请避免传 null(部分平台可能会把“未传字段”桥接成 key: null)。
  • 当前版本:非流式 API 直接返回 JSON.parse(...) 后的结果(any | null),页面侧可直接使用;如遇 iOS 桥接不一致,可改回返回 raw string。
  • 流式 SSE 回调建议使用 stream.onEvent/onError/onComplete 注册(避免 iOS keepalive 限制导致回调被回收)。

使用示例

import { createClient, type ClientOptions } from '@/uni_modules/hans-langgraph-sdk'

const options: ClientOptions = {
    apiUrl: 'http://10.0.2.2:8788',
    apiKey: 'your-api-key',
    timeoutMs: 60000,
}

const client = createClient(options)

// 创建 Assistant
const assistant = await client.assistantsCreate({
    graph_id: 'your-graph-id',
    name: 'demo assistant',
    metadata: {},
})

// 创建 Thread
const thread = await client.threadsCreate({ metadata: {} })

// 等待 Run 完成
const result = await client.runsWait(thread.thread_id, assistant.assistant_id, {
    input: { text: 'hello' },
})

// 流式 Run
const stream = client.runsStream(
    thread.thread_id,
  assistant.assistant_id,
    {
        input: { text: 'hello' },
        stream_mode: 'values',
    },
    null,
)
stream.onEvent((evt) => {
    console.log('Stream event:', evt)
})
stream.onError((err) => {
    console.error('Stream error:', err)
})
stream.onComplete(() => {
    console.log('Stream completed')
})

// 取消流
// stream.abort()

// Join stream(可选:传入 query/headers)
// const join = client.runsJoinStream(thread.thread_id, run.run_id, {
//  query: { stream_mode: 'values' },
//  headers: { 'Last-Event-ID': 'xxx' },
// }, null)

隐私、权限声明

1. 本插件需要申请的系统权限列表:

2. 本插件采集的数据、发送的服务器地址、以及数据用途说明:

3. 本插件是否包含广告,如包含需详细说明广告表达方式、展示频率:

暂无用户评论。