Fix block indexing in Google provider impl

This commit is contained in:
Mario Zechner 2025-09-19 00:10:43 +02:00
parent 2296dc4052
commit 9e86079386

View file

@ -99,12 +99,13 @@ export const streamGoogle: StreamFunction<"google-generative-ai"> = (
} }
if (isThinking) { if (isThinking) {
currentBlock = { type: "thinking", thinking: "", thinkingSignature: undefined }; currentBlock = { type: "thinking", thinking: "", thinkingSignature: undefined };
output.content.push(currentBlock);
stream.push({ type: "thinking_start", contentIndex: blockIndex(), partial: output }); stream.push({ type: "thinking_start", contentIndex: blockIndex(), partial: output });
} else { } else {
currentBlock = { type: "text", text: "" }; currentBlock = { type: "text", text: "" };
output.content.push(currentBlock);
stream.push({ type: "text_start", contentIndex: blockIndex(), partial: output }); stream.push({ type: "text_start", contentIndex: blockIndex(), partial: output });
} }
output.content.push(currentBlock);
} }
if (currentBlock.type === "thinking") { if (currentBlock.type === "thinking") {
currentBlock.thinking += part.text; currentBlock.thinking += part.text;