From c948fe935ff60a55bfb4cd60f98bcdc281abb739 Mon Sep 17 00:00:00 2001 From: Fernando Freire Date: Tue, 3 Jun 2025 03:37:06 -0700 Subject: [PATCH] google_ai: Parse thought parts in Gemini responses (#31925) Fixes thinking Gemini models. Closes #31902 Release Notes: - Updated Google Gemini client to match the latest API --- crates/google_ai/src/google_ai.rs | 8 ++++++++ crates/language_models/src/provider/google.rs | 1 + 2 files changed, 9 insertions(+) diff --git a/crates/google_ai/src/google_ai.rs b/crates/google_ai/src/google_ai.rs index d620bd63e2f18607c5648983e23abf5d35197b23..9a2c8b8abca8db0736ecf842886c3e1d9f4c6084 100644 --- a/crates/google_ai/src/google_ai.rs +++ b/crates/google_ai/src/google_ai.rs @@ -202,6 +202,7 @@ pub enum Part { InlineDataPart(InlineDataPart), FunctionCallPart(FunctionCallPart), FunctionResponsePart(FunctionResponsePart), + ThoughtPart(ThoughtPart), } #[derive(Debug, Serialize, Deserialize)] @@ -235,6 +236,13 @@ pub struct FunctionResponsePart { pub function_response: FunctionResponse, } +#[derive(Debug, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct ThoughtPart { + pub thought: bool, + pub thought_signature: String, +} + #[derive(Debug, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct CitationSource { diff --git a/crates/language_models/src/provider/google.rs b/crates/language_models/src/provider/google.rs index 2203dc261f99f31ef946c5f79481fa1299277d1f..5784358147fc8191cea2c0c85bcb96607b589cbb 100644 --- a/crates/language_models/src/provider/google.rs +++ b/crates/language_models/src/provider/google.rs @@ -623,6 +623,7 @@ impl GoogleEventMapper { ))); } Part::FunctionResponsePart(_) => {} + Part::ThoughtPart(_) => {} }); } }