Skip to content

Commit

Permalink
Remove exclude_unset parameter (#2654)
Browse files Browse the repository at this point in the history
  • Loading branch information
snapshotpl authored Nov 9, 2023
1 parent ab01027 commit 18f5692
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions fastchat/serve/openai_api_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ async def chat_completion_stream_generator(
chunk = ChatCompletionStreamResponse(
id=id, choices=[choice_data], model=model_name
)
yield f"data: {chunk.json(exclude_unset=True, ensure_ascii=False)}\n\n"
yield f"data: {chunk.json(ensure_ascii=False)}\n\n"

previous_text = ""
async for content in generate_completion_stream(gen_params, worker_addr):
Expand Down Expand Up @@ -482,7 +482,7 @@ async def chat_completion_stream_generator(
if content.get("finish_reason", None) is not None:
finish_stream_events.append(chunk)
continue
yield f"data: {chunk.json(exclude_unset=True, ensure_ascii=False)}\n\n"
yield f"data: {chunk.json(ensure_ascii=False)}\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.json(exclude_none=True, ensure_ascii=False)}\n\n"
Expand Down Expand Up @@ -615,10 +615,10 @@ async def generate_completion_stream_generator(
if content.get("finish_reason", None) is not None:
finish_stream_events.append(chunk)
continue
yield f"data: {chunk.json(exclude_unset=True, ensure_ascii=False)}\n\n"
yield f"data: {chunk.json(ensure_ascii=False)}\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.json(exclude_unset=True, ensure_ascii=False)}\n\n"
yield f"data: {finish_chunk.json(exclude_none=True, ensure_ascii=False)}\n\n"
yield "data: [DONE]\n\n"


Expand Down

0 comments on commit 18f5692

Please sign in to comment.