Skip to content

Commit 8bb65dd

Browse files
committed
comments
Signed-off-by: [email protected] <[email protected]>
1 parent 773834b commit 8bb65dd

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lib/llm/src/http/service/openai.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -935,11 +935,16 @@ async fn chat_completions(
935935
// note - we might do this as part of the post processing set to make it more generic
936936

937937
if streaming {
938+
// For streaming responses, we return HTTP 200 immediately without checking for errors.
939+
// Once HTTP 200 OK is sent, we cannot change the status code, so any backend errors
940+
// must be delivered as SSE events with `event: error` in the stream (handled by
941+
// EventConverter and monitor_for_disconnects). This is standard SSE behavior.
938942
stream_handle.arm(); // allows the system to detect client disconnects and cancel the LLM generation
939943

940944
let mut http_queue_guard = Some(http_queue_guard);
941945
let stream = stream.map(move |response| {
942946
// Calls observe_response() on each token
947+
// EventConverter will detect `event: "error"` and convert to SSE error events
943948
process_response_using_event_converter_and_observe_metrics(
944949
EventConverter::from(response),
945950
&mut response_collector,

0 commit comments

Comments
 (0)