更新记录
1.1.2(2025-01-02)
网络不通失败时,重置内部状态
1.1.1(2024-12-31)
响应回调放到ui线程
1.1.0(2024-12-31)
修复close触发之后client的状态没有重置的问题
查看更多平台兼容性
Vue2 | Vue3 |
---|---|
× | × |
App | 快应用 | 微信小程序 | 支付宝小程序 | 百度小程序 | 字节小程序 | QQ小程序 |
---|---|---|---|---|---|---|
HBuilderX 4.36,Android:5.0,iOS:不支持,HarmonyNext:不支持 | × | × | × | × | × | × |
钉钉小程序 | 快手小程序 | 飞书小程序 | 京东小程序 | 鸿蒙元服务 |
---|---|---|---|---|
× | × | × | × | × |
H5-Safari | Android Browser | 微信浏览器(Android) | QQ浏览器(Android) | Chrome | IE | Edge | Firefox | PC-Safari |
---|---|---|---|---|---|---|---|---|
× | × | × | × | × | × | × | × | × |
uminitech-sse
价格和示例仅供参考,有问题和需求私信我
开发文档
import * as UminitechSSE from '@/uni_modules/uminitech-sse'
import type { SSEOptions } from '@/uni_modules/uminitech-sse'
// 订阅
subscribeToSSE() {
if (this.sseClient == null) {
// 创建一个新的Client
this.sseClient = UminitechSSE.createSSEClient()
}
let input = {
"model": "gpt-4o-mini",
"messages": [{
"role": "user",
"content": "写一个冒泡算法"
}],
"temperature": 0.7,
"stream": true
}
let header = {
"Content-Type": "application/json",
"Authorization": "Bearer sk-xxx"
}
// 订阅到this.sseClient
UminitechSSE.subscribeToSSEClient(this.sseClient!,{
url: 'https://open.xxxx.com/v1/chat/completions',
method: "POST",
body: JSON.stringify(input),
header: header,
onOpen: (response: string) => {
console.log(response)
},
onMessage: (message: string) => {
console.log(message)
},
onError: (error: string) => {
console.log(error)
},
onClose: () => {
}
} as SSEOptions)
}
// 取消
cancelSSESubscribe() {
UminitechSSE.cancel(this.sseClient!)
},