Skip to content

Commit 5aa9995

Browse files
jmsegrevDoral Pipeline
andauthored
fix: handle missing parts field in gemini flash responses (#2272)
Gemini Flash 2.0 & 2.5 sometimes omits the parts field when returning very short responses (e.g., single words), causing deserialization to fail with `missing field parts` error. This pr adds `#[serde(default)]` to `Content.parts` to gracefully handle these cases by defaulting to an empty vector. Fixes #1749 <!-- ELLIPSIS_HIDDEN --> ---- > [!IMPORTANT] > Adds `#[serde(default)]` to `Content.parts` in `types.rs` to handle missing `parts` field, fixing deserialization errors for short responses. > > - **Behavior**: > - Adds `#[serde(default)]` to `Content.parts` in `types.rs` to handle missing `parts` field by defaulting to an empty vector. > - Fixes deserialization errors for short responses from Gemini Flash 2.0 & 2.5. > - **Misc**: > - Fixes issue #1749. > > <sup>This description was created by </sup>[<img alt="Ellipsis" src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=BoundaryML%2Fbaml&utm_source=github&utm_medium=referral)<sup> for c523f8b. You can [customize](https://app.ellipsis.dev/BoundaryML/settings/summaries) this summary. It will automatically update as commits are pushed.</sup> <!-- ELLIPSIS_HIDDEN --> Co-authored-by: Doral Pipeline <pipelines@doralhw.org>
1 parent faeace8 commit 5aa9995

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

  • engine/baml-runtime/src/internal/llm_client/primitive/google

engine/baml-runtime/src/internal/llm_client/primitive/google/types.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ pub struct Candidate {
234234
#[serde(rename_all = "camelCase")]
235235
pub struct Content {
236236
pub role: Option<String>,
237+
#[serde(default)]
237238
pub parts: Vec<Part>,
238239
}
239240

0 commit comments

Comments
 (0)