fix: preserve whitespace-only chunks in SSE stream (#139)
* fix: preserve whitespace-only chunks in SSE stream Fixes issue #138 where Claude models would swallow spaces between words because whitespace-only chunks (e.g., " ") were being filtered out as empty. Changes: - Modified sse-streamer.js to only skip truly empty strings (""), preserving strings that contain only whitespace. - Added regression test case in tests/test-streaming-whitespace.cjs to verify whitespace preservation. * test: add streaming whitespace regression test to main suite --------- Co-authored-by: walczak <walczak@ial.ruhr>
This commit is contained in:
@@ -123,8 +123,8 @@ export async function* streamSSEResponse(response, originalModel) {
|
||||
};
|
||||
|
||||
} else if (part.text !== undefined) {
|
||||
// Skip empty text parts
|
||||
if (!part.text || part.text.trim().length === 0) {
|
||||
// Skip empty text parts (but preserve whitespace-only chunks for proper spacing)
|
||||
if (part.text === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user