fix: ensure responses stream always completes
Emit a fallback response.completed and [DONE] when upstream SSE closes early so OpenAI /v1/responses clients do not fail on incomplete streams. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
15
app/main.py
15
app/main.py
@@ -1193,6 +1193,21 @@ async def _responses_stream_from_chat_stream(
|
||||
}
|
||||
)
|
||||
|
||||
yield _sse_data(
|
||||
{
|
||||
"type": "response.completed",
|
||||
"response": {
|
||||
"id": response_id,
|
||||
"object": "response",
|
||||
"created_at": created_at,
|
||||
"status": "completed",
|
||||
"model": model,
|
||||
"usage": usage,
|
||||
},
|
||||
}
|
||||
)
|
||||
yield "data: [DONE]\\n\\n"
|
||||
|
||||
|
||||
|
||||
@app.post("/v1/responses", dependencies=[Depends(auth_guard)])
|
||||
|
||||
Reference in New Issue
Block a user