fix(streaming): remove keep-alive to debug [DONE] marker issue
This commit is contained in:
@@ -283,20 +283,11 @@ 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.
|
||||||
// Convert to a Vec first, then append [DONE], then stream it
|
|
||||||
let done_event = 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 done_stream = futures::stream::iter(vec![done_event]);
|
||||||
let out = sse_stream.chain(done_stream);
|
let out = sse_stream.chain(done_stream);
|
||||||
|
|
||||||
Ok(
|
Ok(Sse::new(out).into_response())
|
||||||
Sse::new(out)
|
|
||||||
.keep_alive(
|
|
||||||
axum::response::sse::KeepAlive::new()
|
|
||||||
.interval(Duration::from_secs(15))
|
|
||||||
.text(": keep-alive"),
|
|
||||||
)
|
|
||||||
.into_response(),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
// Record provider failure
|
// Record provider failure
|
||||||
|
|||||||
Reference in New Issue
Block a user