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
This commit is contained in:
Bennet Bo Fenner 2025-04-02 12:35:17 +02:00 committed by GitHub
parent 9b7b4a9d2d
commit b158ee60ca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -472,19 +472,17 @@ pub fn into_google(
top_k: None, top_k: None,
}), }),
safety_settings: None, safety_settings: None,
tools: Some( tools: Some(vec![google_ai::Tool {
request function_declarations: request
.tools .tools
.into_iter() .into_iter()
.map(|tool| google_ai::Tool { .map(|tool| FunctionDeclaration {
function_declarations: vec![FunctionDeclaration {
name: tool.name, name: tool.name,
description: tool.description, description: tool.description,
parameters: tool.input_schema, parameters: tool.input_schema,
}],
}) })
.collect(), .collect(),
), }]),
tool_config: None, tool_config: None,
} }
} }