From 748371f9260b4f2e43949cc6db1fb7561ad9d8f1 Mon Sep 17 00:00:00 2001 From: Chessing234 Date: Sun, 17 May 2026 06:55:11 +0530 Subject: [PATCH] fix(openai_api_server): use exclude_none for completion stream finish chunks generate_completion_stream_generator's finish loop carried over the same '...so exclude_none to exclude field "content"' comment as the chat variant but called model_dump_json(exclude_unset=True). The chat counterpart (chat_completion_stream_generator) correctly uses exclude_none=True. Switch the completion path to exclude_none so the final-chunk None fields (e.g. logprobs) are stripped as the comment and the parallel chat-stream path intend. --- fastchat/serve/openai_api_server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fastchat/serve/openai_api_server.py b/fastchat/serve/openai_api_server.py index a6ffee96b..8b804ddde 100644 --- a/fastchat/serve/openai_api_server.py +++ b/fastchat/serve/openai_api_server.py @@ -673,7 +673,7 @@ async def generate_completion_stream_generator( yield f"data: {chunk.model_dump_json(exclude_unset=True)}\n\n" # There is not "content" field in the last delta message, so exclude_none to exclude field "content". for finish_chunk in finish_stream_events: - yield f"data: {finish_chunk.model_dump_json(exclude_unset=True)}\n\n" + yield f"data: {finish_chunk.model_dump_json(exclude_none=True)}\n\n" yield "data: [DONE]\n\n"