This commit is contained in:
从何开始123
2026-01-12 17:45:36 +08:00
parent 586cf48a5a
commit bd297716b0
6 changed files with 41 additions and 89 deletions

View File

@@ -44,8 +44,7 @@ export const streamSynthesisResponse = async (
contents: contents,
config: {
thinkingConfig: {
thinkingBudget: budget,
includeThoughts: true
thinkingBudget: budget
}
}
}));
@@ -53,20 +52,9 @@ export const streamSynthesisResponse = async (
try {
for await (const chunk of (synthesisStream as any)) {
if (signal.aborted) break;
let chunkText = "";
let chunkThought = "";
if (chunk.candidates?.[0]?.content?.parts) {
for (const part of chunk.candidates[0].content.parts) {
if (part.thought) {
chunkThought += (part.text || "");
} else if (part.text) {
chunkText += part.text;
}
}
onChunk(chunkText, chunkThought);
}
const chunkText = chunk.text || "";
onChunk(chunkText, "");
}
} catch (streamError) {
console.error("Synthesis stream interrupted:", streamError);