mirror of
https://github.com/CJackHwang/ds2api.git
synced 2026-05-08 18:35:35 +08:00
feat: implement trimContinuationOverlap utility to remove redundant stream prefixes and add associated tests.
This commit is contained in:
@@ -22,6 +22,7 @@ const {
|
||||
shouldSkipPath,
|
||||
isNodeStreamSupportedPath,
|
||||
extractPathname,
|
||||
trimContinuationOverlap,
|
||||
} = handler.__test;
|
||||
|
||||
test('chat-stream exposes parser test hooks', () => {
|
||||
@@ -368,3 +369,10 @@ test('extractPathname strips query only', () => {
|
||||
assert.equal(extractPathname('/v1/chat/completions?stream=true'), '/v1/chat/completions');
|
||||
assert.equal(extractPathname('/v1beta/models/gemini-2.5-flash:streamGenerateContent?key=1'), '/v1beta/models/gemini-2.5-flash:streamGenerateContent');
|
||||
});
|
||||
|
||||
test('trimContinuationOverlap preserves short normal tokens and trims long snapshots', () => {
|
||||
assert.equal(trimContinuationOverlap('我们被问到', '我们'), '我们');
|
||||
const existing = '我们被问到:这是一个很长的续答快照前缀,用来验证去重逻辑不会误伤正常 token。';
|
||||
const incoming = `${existing}继续分析`;
|
||||
assert.equal(trimContinuationOverlap(existing, incoming), '继续分析');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user