mirror of
https://github.com/CJackHwang/ds2api.git
synced 2026-05-08 02:15:27 +08:00
fix: ignore INCOMPLETE status messages in SSE stream parsing to prevent stream interruption
This commit is contained in:
@@ -291,6 +291,19 @@ test('parseChunkForContent preserves output tokens on FINISHED lines', () => {
|
||||
assert.deepEqual(parsed.parts, []);
|
||||
});
|
||||
|
||||
test('parseChunkForContent filters INCOMPLETE status text without stopping stream', () => {
|
||||
const parsed = parseChunkForContent(
|
||||
{ p: 'response/status', v: 'INCOMPLETE', accumulated_token_usage: 190 },
|
||||
false,
|
||||
'text',
|
||||
);
|
||||
assert.equal(parsed.parsed, true);
|
||||
assert.equal(parsed.finished, false);
|
||||
assert.equal(parsed.contentFilter, false);
|
||||
assert.equal(parsed.outputTokens, 190);
|
||||
assert.deepEqual(parsed.parts, []);
|
||||
});
|
||||
|
||||
test('parseChunkForContent strips leaked CONTENT_FILTER suffix and preserves line breaks', () => {
|
||||
const leaked = parseChunkForContent(
|
||||
{ p: 'response/content', v: '正常输出CONTENT_FILTER你好,这个问题我暂时无法回答' },
|
||||
|
||||
Reference in New Issue
Block a user