You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
request={async(messages: any)=>{// 正常业务中如下:constresponse=awaitfetch('/stream-sse',{method: 'POST',headers: {'Content-Type': 'application/json;charset=UTF-8',},body: JSON.stringify({
messages,stream: true,}),});console.log('messages',messages);// 确保服务器响应是成功的if(!response.ok||!response.body){thrownewError(`HTTP error! status: ${response.status}`);}console.log('getting response');constdecoder=newTextDecoder('utf-8');constencoder=newTextEncoder();constreader=response.body?.getReader()constreadableStream=newReadableStream({asyncstart(controller){functionpush(){reader.read().then(({ done, value })=>{// If there is no more data to readif(done){console.log("done",done);controller.close();return;}console.log(done,value);constchunk=decoder.decode(value,{stream: true})// Check chunks by logging to the consoleconsole.log(done,chunk);// Get the data and send it to the browser via the controllercontroller.enqueue(encoder.encode(chunk));push();});}push();},})returnnewResponse(readableStream);}
🚑 其他信息
The text was updated successfully, but these errors were encountered:
🧐 问题描述
按照 这里 的方法做了一个flask的server,发送sse消息,但是pro-chat无法递进式的接收数据。总是等到消息全部结束了以后才能收到。不知是否是flask的设置有问题。如果可以能否提供一个完整的flask端example+pro-chat客户端例子
💻 示例代码
服务器端代码与这里 基本一致,prochat端代码如下
🚑 其他信息
The text was updated successfully, but these errors were encountered: