Add support for the Google Search tool

- Gemini 2.0 and above use a google_search tool instead of a
google_search_retrieval tool. This commit adds support for the new tool.
This commit is contained in:
2025-03-26 20:47:48 +00:00
parent 83663680c9
commit de9b14b984
3 changed files with 75 additions and 2 deletions

View File

@@ -29,8 +29,13 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
..Default::default()
};
println!(
"Request: {}",
serde_json::to_string_pretty(&request).unwrap()
);
let result = gemini
.generate_content(&request, "gemini-1.0-pro-002")
.generate_content(&request, "gemini-1.5-flash-002")
.await?;
println!("Response: {:?}", result.candidates[0].get_text().unwrap());