Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Fix error when deserializing Gemini streams (#29470)
Antonio Scandurra3fdbc3090d2c
diff --git a/crates/google_ai/src/google_ai.rs b/crates/google_ai/src/google_ai.rsindex a20bedd8908..70b13b9b6e3 100644--- a/crates/google_ai/src/google_ai.rs+++ b/crates/google_ai/src/google_ai.rs@@ -48,7 +48,10 @@ pub async fn stream_generate_content(if let Some(line) = line.strip_prefix("data: ") {match serde_json::from_str(line) {Ok(response) => Some(Ok(response)),- Err(error) => Some(Err(anyhow!(error))),+ Err(error) => Some(Err(anyhow!(format!(+ "Error parsing JSON: {:?}\n{:?}",+ error, line+ )))),}} else {None@@ -152,6 +155,7 @@ pub struct GenerateContentCandidate {#[derive(Debug, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]pub struct Content {+ #[serde(default)]pub parts: Vec<Part>,pub role: Role,}