Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

anthropic: Support alternative provider SSE formatting (#47847)

Raphael Lüthy325e941289bf
diff --git a/crates/anthropic/src/anthropic.rs b/crates/anthropic/src/anthropic.rs
index bd72fe1ef3d..bc2516b8b0f 100644
--- a/crates/anthropic/src/anthropic.rs
+++ b/crates/anthropic/src/anthropic.rs
@@ -781,7 +781,10 @@ pub async fn stream_completion_with_rate_limit_info(
.filter_map(|line| async move {
match line {
Ok(line) => {
- let line = line.strip_prefix("data: ")?;
+ let line = line
+ .strip_prefix("data: ")
+ .or_else(|| line.strip_prefix("data:"))?;
+
match serde_json::from_str(line) {
Ok(response) => Some(Ok(response)),
Err(error) => Some(Err(AnthropicError::DeserializeResponse(error))),