fix: do not attempt to deserialize zero byte chunks in ollama stream (#303)

pull/308/head
Joseph Goulden 4 months ago committed by GitHub
parent 176ff6f83e
commit 25b27c148a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -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() {

Loading…
Cancel
Save