深圳奥飞网络
深圳奥飞网络
  • 发布:2024-03-20 18:34
  • 更新:2024-03-20 18:34
  • 阅读:255

uni-ai自行处理流式响应报错TypeError: streamRes.on is not a function

分类:uniCloud

我需要自行处理流式响应

const newSseChannel = uniCloud.deserializeSSEChannel(sseChannel)  
const llmManager = uniCloud.ai.getLLMManager({  
   provider: 'minimax',  
   appId: clientAppId,  
})  
let streamRes = await llmManager.chatCompletion({  
   messages:messages,  
   stream: true,  
   sseChannel: sseChannel  
})  

return new Promise((resolve, reject) => {  
            streamRes.on('optimizedMessage', (message) => {   

            })  
        })  

为什么报错

TypeError: streamRes.on is not a function

以上就是官方的例子,如果不传sseChannel

let streamRes = await llmManager.chatCompletion({  
   messages:messages,  
   stream: true  
})

又报错

Error: 使用DCloud提供的AI服务接口且使用了stream模式时需传递sseChannel参数
2024-03-20 18:34 负责人:无 分享
已邀请:

要回复问题请先登录注册