From 25b27c148abd1fe0473304947c9b3a2194347326 Mon Sep 17 00:00:00 2001 From: Joseph Goulden Date: Mon, 5 Feb 2024 13:24:37 +0000 Subject: fix: do not attempt to deserialize zero byte chunks in ollama stream (#303) --- src/client/ollama.rs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/client/ollama.rs b/src/client/ollama.rs index a3e23c9..e24cffd 100644 --- a/src/client/ollama.rs +++ b/src/client/ollama.rs @@ -121,6 +121,9 @@ async fn send_message_streaming(builder: RequestBuilder, handler: &mut ReplyHand let mut stream = res.bytes_stream(); while let Some(chunk) = stream.next().await { let chunk = chunk?; + if chunk.is_empty() { + continue; + } let data: Value = serde_json::from_slice(&chunk)?; if data["done"].is_boolean() { if let Some(text) = data["message"]["content"].as_str() { -- cgit v1.2.3