更新记录
1.0.9(2024-12-21)
提升稳定性
1.0.8(2024-12-20)
修复编译错误
1.0.7(2024-12-20)
修正编译错误
查看更多
平台兼容性
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!)
},