fix(streaming): use iter instead of once for [DONE] marker
Some checks failed
CI / Check (push) Has been cancelled
CI / Clippy (push) Has been cancelled
CI / Formatting (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Release Build (push) Has been cancelled

This commit is contained in:
2026-03-03 11:56:16 -05:00
parent 056e0c93d2
commit ea5c725aa8

View File

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