fix: gemini tool optional

This commit is contained in:
ikechan8370 2024-11-18 12:02:41 +08:00
parent 7c2961cdcd
commit 30f9c82d73

View file

@ -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