diff --git a/src/providers/google/chatComplete.ts b/src/providers/google/chatComplete.ts index d9ab17a71..0f3bed681 100644 --- a/src/providers/google/chatComplete.ts +++ b/src/providers/google/chatComplete.ts @@ -29,6 +29,10 @@ import { getFakeId, } from '../utils'; +type ToolCallWithSignature = ToolCall & { + thoughtSignature: string | undefined; +}; + const joinSystemMessages = (messages: Message[]) => messages ?.filter((message) => message.role === 'system') @@ -238,7 +242,7 @@ export const GoogleChatCompleteConfig: ProviderConfig = { let parts = []; if (message.role === 'assistant' && message.tool_calls) { - message.tool_calls.forEach((tool_call: ToolCall) => { + message.tool_calls.forEach((tool_call: ToolCallWithSignature) => { let args; try { args = JSON.parse(tool_call.function.arguments); @@ -253,6 +257,7 @@ export const GoogleChatCompleteConfig: ProviderConfig = { name: tool_call.function.name, args, }, + thoughtSignature: tool_call.thoughtSignature, }); }); } else if ( @@ -476,6 +481,7 @@ interface GoogleResponseCandidate { text?: string; thought?: string; // for models like gemini-2.0-flash-thinking-exp refer: https://ai.google.dev/gemini-api/docs/thinking-mode#streaming_model_thinking functionCall?: GoogleGenerateFunctionCall; + thoughtSignature?: string; }[]; }; logprobsResult?: { @@ -569,7 +575,7 @@ export const GoogleChatCompleteResponseTransform: ( choices: response.candidates?.map((generation, idx) => { // transform tool calls and content by iterating over the content parts - const toolCalls: ToolCall[] = []; + const toolCalls: ToolCallWithSignature[] = []; let content: string | undefined; const contentBlocks = []; for (const part of generation.content?.parts ?? []) { @@ -581,6 +587,7 @@ export const GoogleChatCompleteResponseTransform: ( name: part.functionCall.name, arguments: JSON.stringify(part.functionCall.args), }, + thoughtSignature: part.thoughtSignature, }); } else if (part.text) { if (part.thought) { @@ -722,6 +729,7 @@ export const GoogleChatCompleteStreamChunkTransform: ( name: part.functionCall.name, arguments: JSON.stringify(part.functionCall.args), }, + thoughtSignature: part.thoughtSignature, }; } }),