From b158ee60cacc1e34c0244206938cd2232b28138f Mon Sep 17 00:00:00 2001 From: Bennet Bo Fenner Date: Wed, 2 Apr 2025 12:35:17 +0200 Subject: [PATCH] Fix Gemini function calling (#27905) This seems to improve the performance of `gemini-2.5-pro-exp-03-25` significantly. We know define a single `Tool` that has multiple `FunctionDeclaration`s, instead of defining multiple `Tool`s with a single `FunctionDeclaration`. Oddly enough the `flash` models seemed to work perfectly fine with the multiple `Tool { ... }` definitions Release Notes: - N/A --- crates/language_models/src/provider/google.rs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/crates/language_models/src/provider/google.rs b/crates/language_models/src/provider/google.rs index a631038e8fd3645400a361565b8128bf6eb8091e..3f74bbb7dc7aa88a558986137df8fd5d4acc7ab4 100644 --- a/crates/language_models/src/provider/google.rs +++ b/crates/language_models/src/provider/google.rs @@ -472,19 +472,17 @@ pub fn into_google( top_k: None, }), safety_settings: None, - tools: Some( - request + tools: Some(vec![google_ai::Tool { + function_declarations: request .tools .into_iter() - .map(|tool| google_ai::Tool { - function_declarations: vec![FunctionDeclaration { - name: tool.name, - description: tool.description, - parameters: tool.input_schema, - }], + .map(|tool| FunctionDeclaration { + name: tool.name, + description: tool.description, + parameters: tool.input_schema, }) .collect(), - ), + }]), tool_config: None, } }