log
This commit is contained in:
@@ -3,6 +3,7 @@ import { ModelOption, ExpertResult, MessageAttachment } from '../../types';
|
||||
import { getSynthesisPrompt } from './prompts';
|
||||
import { withRetry } from '../utils/retry';
|
||||
import { generateContentStream as generateOpenAIStream } from './openaiClient';
|
||||
import { logger } from '../logger';
|
||||
|
||||
const isGoogleProvider = (ai: any): boolean => {
|
||||
return ai?.models?.generateContentStream !== undefined;
|
||||
@@ -44,7 +45,8 @@ export const streamSynthesisResponse = async (
|
||||
contents: contents,
|
||||
config: {
|
||||
thinkingConfig: {
|
||||
thinkingBudget: budget
|
||||
thinkingBudget: budget,
|
||||
includeThoughts: true
|
||||
}
|
||||
}
|
||||
}));
|
||||
@@ -52,12 +54,23 @@ export const streamSynthesisResponse = async (
|
||||
try {
|
||||
for await (const chunk of (synthesisStream as any)) {
|
||||
if (signal.aborted) break;
|
||||
|
||||
const chunkText = chunk.text || "";
|
||||
onChunk(chunkText, "");
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
} catch (streamError) {
|
||||
console.error("Synthesis stream interrupted:", streamError);
|
||||
logger.error("Synthesis", "Stream interrupted", streamError);
|
||||
throw streamError;
|
||||
}
|
||||
} else {
|
||||
@@ -95,7 +108,7 @@ export const streamSynthesisResponse = async (
|
||||
onChunk(chunk.text, chunk.thought || '');
|
||||
}
|
||||
} catch (streamError) {
|
||||
console.error("Synthesis stream interrupted:", streamError);
|
||||
logger.error("Synthesis", "Stream interrupted (OpenAI)", streamError);
|
||||
throw streamError;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user