From 30f9c82d73db2fec0a3dfe96b31e4d31ae3b9f1c Mon Sep 17 00:00:00 2001 From: ikechan8370 Date: Mon, 18 Nov 2024 12:02:41 +0800 Subject: [PATCH] fix: gemini tool optional --- client/CustomGoogleGeminiClient.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/client/CustomGoogleGeminiClient.js b/client/CustomGoogleGeminiClient.js index dfe79865..7dd9fdbe 100644 --- a/client/CustomGoogleGeminiClient.js +++ b/client/CustomGoogleGeminiClient.js @@ -163,13 +163,20 @@ export class CustomGoogleGeminiClient extends GoogleGeminiClient { temperature: opt.temperature || 0.9, topP: opt.topP || 0.95, topK: opt.tokK || 16 - }, - tools: [ + } + } + if (this.tools?.length > 0) { + body.tools = [ { - functionDeclarations: this.tools.map(tool => tool.function()) + function_declarations: this.tools.map(tool => tool.function()) // codeExecution: {} } ] + body.tool_config = { + function_calling_config: { + mode: 'ANY' + } + } } if (opt.image) { delete body.tools