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.

open_ai: Trim newline before "data:" prefix and account for the possibility of no space after ":" (#37644)

ZhangJun7091c70a1e20
diff --git a/crates/open_ai/src/open_ai.rs b/crates/open_ai/src/open_ai.rs
index 279245c0b7d..fda0544be17 100644
--- a/crates/open_ai/src/open_ai.rs
+++ b/crates/open_ai/src/open_ai.rs
@@ -473,7 +473,7 @@ pub async fn stream_completion(
.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:"))?;
if line == "[DONE]" {
None
} else {