summaryrefslogtreecommitdiffstats
path: root/src/client
diff options
context:
space:
mode:
authorJoseph Goulden <joegoulden@protonmail.com>2024-02-05 13:24:37 +0000
committerGitHub <noreply@github.com>2024-02-05 21:24:37 +0800
commit25b27c148abd1fe0473304947c9b3a2194347326 (patch)
tree068ced0c0c04daec7a24a268be8d4c952ec6b2ad /src/client
parent176ff6f83ecfcf044a7deffad61a33b43480cdc5 (diff)
downloadaichat-25b27c148abd1fe0473304947c9b3a2194347326.tar.gz
fix: do not attempt to deserialize zero byte chunks in ollama stream (#303)
Diffstat (limited to 'src/client')
-rw-r--r--src/client/ollama.rs3
1 files changed, 3 insertions, 0 deletions
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() {