mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2025-01-18 19:20:05 +08:00
【优化】处理 AI stream 返回,改为 map
This commit is contained in:
parent
e39513c6b2
commit
f0e4e535f4
@ -136,7 +136,7 @@ public class AiChatMessageServiceImpl implements AiChatMessageService {
|
||||
// 3.3 流式返回
|
||||
// 注意:Schedulers.immediate() 目的是,避免默认 Schedulers.parallel() 并发消费 chunk 导致 SSE 响应前端会乱序问题
|
||||
StringBuffer contentBuffer = new StringBuffer();
|
||||
return streamResponse.publishOn(Schedulers.single()).map(chunk -> {
|
||||
return streamResponse.map(chunk -> {
|
||||
String newContent = chunk.getResult() != null ? chunk.getResult().getOutput().getContent() : null;
|
||||
newContent = StrUtil.nullToDefault(newContent, ""); // 避免 null 的 情况
|
||||
contentBuffer.append(newContent);
|
||||
|
Loading…
Reference in New Issue
Block a user