Skip to content

Commit dcec87b

Browse files
Enhance response handling for number types
Updated response handling to support number types.
1 parent f7c11c8 commit dcec87b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,16 @@ export function getMappedStream(response: Response) {
3030
partialToolCalls.push(...chunk.tool_calls);
3131
}
3232

33-
// Handle top-level response text
34-
if (chunk.response?.length) {
33+
// Handle top-level response text + Handling number responses for models like Llama4
34+
if (chunk.response?.length || typeof chunk.response === "number") {
3535
if (!textId) {
3636
textId = generateId();
3737
controller.enqueue({ type: "text-start", id: textId });
3838
}
3939
controller.enqueue({
4040
type: "text-delta",
4141
id: textId,
42-
delta: chunk.response,
42+
delta: typeof chunk.response === "number" ? String(chunk.response) : chunk.response,
4343
});
4444
}
4545

0 commit comments

Comments
 (0)