fix(streaming): use iter instead of once for [DONE] marker
This commit is contained in:
@@ -283,10 +283,10 @@ async fn chat_completions(
|
|||||||
// Many OpenAI-compatible clients expect a terminal [DONE] marker.
|
// Many OpenAI-compatible clients expect a terminal [DONE] marker.
|
||||||
// Emit it when the upstream stream ends to avoid clients treating
|
// Emit it when the upstream stream ends to avoid clients treating
|
||||||
// the response as incomplete.
|
// the response as incomplete.
|
||||||
let done = futures::stream::once(async {
|
// Convert to a Vec first, then append [DONE], then stream it
|
||||||
Ok::<Event, AppError>(Event::default().data("[DONE]"))
|
let done_event = Ok::<Event, AppError>(Event::default().data("[DONE]"));
|
||||||
});
|
let done_stream = futures::stream::iter(vec![done_event]);
|
||||||
let out = sse_stream.chain(done);
|
let out = sse_stream.chain(done_stream);
|
||||||
|
|
||||||
Ok(
|
Ok(
|
||||||
Sse::new(out)
|
Sse::new(out)
|
||||||
|
|||||||
Reference in New Issue
Block a user