fix: 修复最后一个流为[xxxx]格式时会重复输出1次 (#5673)

* fix: 修复最后一个流为[xxxx]格式时会重复输出1次

issue #5292
当最后一个流中包含[xxxx]格式时,会输出2次。第一次在parseCite方法中if (isStreamEnd) {分支内输出,第二次在调用getResponseData时会输出buffer中的内容,导致重复。

* add test case

---------

Co-authored-by: archer <545436317@qq.com>
This commit is contained in:
John Chen
2025-09-19 10:58:48 +08:00
committed by GitHub
parent 206fd7e4a8
commit 91269c91a1
2 changed files with 18 additions and 7 deletions

View File

@@ -243,6 +243,7 @@ export const parseLLMStreamResponse = () => {
// 结束时,返回所有剩余内容
if (isStreamEnd) {
const content = citeBuffer + text;
citeBuffer = ''; // 清空缓冲区,避免重复输出
return {
content: removeDatasetCiteText(content, false)
};