mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-16 02:15:23 +00:00
refactor(proxy): internalize sse translation and cleanup handlers
This commit is contained in:
1 parent
17187c4abd
commit
a3407093d7
7 files changed
+476
-278
No files matched your search
@@ -28,8 +28,22 @@ describe('SSEParser', () => {
|
||||
const events = parser.parse('\n\n');
|
||||
|
||||
expect(events).toHaveLength(1);
|
||||
expect((events[0]?.data as { choices?: Array<{ delta?: { content?: string } }> })?.choices?.[0]?.delta?.content).toBe(
|
||||
'Hi'
|
||||
expect(
|
||||
(events[0]?.data as { choices?: Array<{ delta?: { content?: string } }> })?.choices?.[0]
|
||||
?.delta?.content
|
||||
).toBe('Hi');
|
||||
});
|
||||
|
||||
it('accepts standalone carriage-return line endings', () => {
|
||||
const parser = new SSEParser({ throwOnMalformedJson: true });
|
||||
const events = parser.parse(
|
||||
['event: message', 'data: {"choices":[{"delta":{"content":"Legacy"}}]}', '', ''].join('\r')
|
||||
);
|
||||
|
||||
expect(events).toHaveLength(1);
|
||||
expect(
|
||||
(events[0]?.data as { choices?: Array<{ delta?: { content?: string } }> })?.choices?.[0]
|
||||
?.delta?.content
|
||||
).toBe('Legacy');
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user