Skip to content

Commit 00fb220

Browse files
celestial-roseRoz
authored andcommitted
Enhance response handling for number types
Updated response handling to support number types.
1 parent f7c11c8 commit 00fb220

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

packages/workers-ai-provider/src/streaming.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,19 @@ export function getMappedStream(response: Response) {
4343
});
4444
}
4545

46+
// Handling number responses for models like Llama4
47+
if (typeof chunk.response === "number") {
48+
if (!textId) {
49+
textId = generateId();
50+
controller.enqueue({ type: "text-start", id: textId });
51+
}
52+
controller.enqueue({
53+
type: "text-delta",
54+
id: textId,
55+
delta: String(chunk.response),
56+
});
57+
}
58+
4659
// Handle reasoning content
4760
const reasoningDelta = chunk?.choices?.[0]?.delta?.reasoning_content;
4861
if (reasoningDelta?.length) {

0 commit comments

Comments
 (0)