Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
gemini: Fix "invalid argument" error when request contains no tools (#28747)
Bennet Bo Fennere1c42315dc07
diff --git a/crates/language_models/src/provider/google.rs b/crates/language_models/src/provider/google.rsindex 4da5f255d20..36a01a30c2b 100644--- a/crates/language_models/src/provider/google.rs+++ b/crates/language_models/src/provider/google.rs@@ -417,17 +417,19 @@ pub fn into_google(top_k: None,}),safety_settings: None,- tools: Some(vec![google_ai::Tool {- function_declarations: request- .tools- .into_iter()- .map(|tool| FunctionDeclaration {- name: tool.name,- description: tool.description,- parameters: tool.input_schema,- })- .collect(),- }]),+ tools: (request.tools.len() > 0).then(|| {+ vec![google_ai::Tool {+ function_declarations: request+ .tools+ .into_iter()+ .map(|tool| FunctionDeclaration {+ name: tool.name,+ description: tool.description,+ parameters: tool.input_schema,+ })+ .collect(),+ }]+ }),tool_config: None,}}