Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Make serialization backwards-compatible for collab server (#27626)
Richard Feldman85740ddaa438
diff --git a/crates/anthropic/src/anthropic.rs b/crates/anthropic/src/anthropic.rsindex 2c5acfc0f2b..b4dd343d07f 100644--- a/crates/anthropic/src/anthropic.rs+++ b/crates/anthropic/src/anthropic.rs@@ -585,6 +585,13 @@ pub enum Thinking {Enabled { budget_tokens: Option<u32> },}+#[derive(Debug, Serialize, Deserialize)]+#[serde(untagged)]+pub enum StringOrContents {+ String(String),+ Content(Vec<RequestContent>),+}+#[derive(Debug, Serialize, Deserialize)]pub struct Request {pub model: String,@@ -597,7 +604,7 @@ pub struct Request {#[serde(default, skip_serializing_if = "Option::is_none")]pub tool_choice: Option<ToolChoice>,#[serde(default, skip_serializing_if = "Option::is_none")]- pub system: Option<String>,+ pub system: Option<StringOrContents>,#[serde(default, skip_serializing_if = "Option::is_none")]pub metadata: Option<Metadata>,#[serde(default, skip_serializing_if = "Vec::is_empty")]diff --git a/crates/language_models/src/provider/anthropic.rs b/crates/language_models/src/provider/anthropic.rsindex 7d2660571de..b3daaf2ecf7 100644--- a/crates/language_models/src/provider/anthropic.rs+++ b/crates/language_models/src/provider/anthropic.rs@@ -586,7 +586,11 @@ pub fn into_anthropic(model,messages: new_messages,max_tokens: max_output_tokens,- system: Some(system_message),+ system: if system_message.is_empty() {+ None+ } else {+ Some(anthropic::StringOrContents::String(system_message))+ },thinking: if let AnthropicModelMode::Thinking { budget_tokens } = mode {Some(anthropic::Thinking::Enabled { budget_tokens })} else {