fix: use exclude_unset for SSE streaming chunk serialization
Build and Push / test (push) Failing after 1m46s
Build and Push / build (push) Has been skipped
Build and Push / release (push) Has been skipped

exclude_none was too aggressive — it stripped finish_reason: null from
intermediate chunks (which OpenAI includes). exclude_unset correctly
omits only fields never passed to the constructor (like reasoning_content
on content-only chunks) while preserving explicitly-set finish_reason: null.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-05 21:18:20 +01:00
co-authored by Claude Opus 4.6
parent a3c7fcf8c3
commit f49c5ac02c
3 changed files with 17 additions and 3 deletions
+1 -1
View File
@@ -31,7 +31,7 @@ async def _stream_response(
"""
try:
async for chunk in service.create_chat_completion_stream(request):
yield f"data: {chunk.model_dump_json(exclude_none=True)}\n\n"
yield f"data: {chunk.model_dump_json(exclude_unset=True)}\n\n"
yield "data: [DONE]\n\n"