Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Change `tool_calls` to be an Option in response (#13778)
Allison Durham995b082c6487
diff --git a/crates/collab/src/rpc.rs b/crates/collab/src/rpc.rsindex fb2788a3814..61aaa98144b 100644--- a/crates/collab/src/rpc.rs+++ b/crates/collab/src/rpc.rs@@ -4462,6 +4462,7 @@ async fn complete_with_open_ai(tool_calls: choice.delta.tool_calls+ .unwrap_or_default().into_iter().map(|delta| proto::ToolCallDelta {index: delta.index as u32,diff --git a/crates/open_ai/src/open_ai.rs b/crates/open_ai/src/open_ai.rsindex 0e4dc580fb5..df5d30786d8 100644--- a/crates/open_ai/src/open_ai.rs+++ b/crates/open_ai/src/open_ai.rs@@ -9,6 +9,10 @@ use strum::EnumIter;pub const OPEN_AI_API_URL: &str = "https://api.openai.com/v1";+fn is_none_or_empty<T: AsRef<[U]>, U>(opt: &Option<T>) -> bool {+ opt.as_ref().map_or(true, |v| v.as_ref().is_empty())+}+#[derive(Clone, Copy, Serialize, Deserialize, Debug, Eq, PartialEq)]#[serde(rename_all = "lowercase")]pub enum Role {@@ -182,8 +186,8 @@ pub struct FunctionContent {pub struct ResponseMessageDelta {pub role: Option<Role>,pub content: Option<String>,- #[serde(default, skip_serializing_if = "Vec::is_empty")]- pub tool_calls: Vec<ToolCallChunk>,+ #[serde(default, skip_serializing_if = "is_none_or_empty")]+ pub tool_calls: Option<Vec<ToolCallChunk>>,}#[derive(Serialize, Deserialize, Debug, Eq, PartialEq)]