Stream errors

This commit is contained in:
Clément Renault 2025-05-20 12:23:22 +02:00 committed by Kerollmops
parent a074384d69
commit 0fcc7e1377
No known key found for this signature in database
GPG Key ID: F250A4C4E3AE5F5F

View File

@ -400,13 +400,21 @@ async fn streamed_chat(
}
}
Err(err) => {
// writeln!(lock, "error: {err}").unwrap();
tracing::error!("{err:?}");
if let Err(SendError(_)) = tx.send(Event::Data(sse::Data::new_json(&json!({
"object": "chat.completion.error",
"tool": err.to_string(),
})).unwrap())).await {
return;
}
break 'main;
}
}
}
}
let _ = tx.send(Event::Data(sse::Data::new("[DONE]")));
});
Sse::from_infallible_receiver(rx).with_retry_duration(Duration::from_secs(10))