fix: use exclude_unset for SSE streaming chunk serialization
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:
+1
-1
@@ -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"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user