Skip to content

Commit

Permalink
fix: pydantic dumps_kwargs keyword arguments are no longer supported. T…
Browse files Browse the repository at this point in the history
…HUDM#415 @laoshancunlaoshancun committed on Aug 2
  • Loading branch information
hiddenblue committed Sep 11, 2023
1 parent 743d251 commit a3e7a99
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions openai_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,7 @@ async def predict(query: str, history: List[List[str]], model_id: str):
finish_reason=None
)
chunk = ChatCompletionResponse(model=model_id, choices=[choice_data], object="chat.completion.chunk")
yield "{}".format(chunk.json(exclude_unset=True, ensure_ascii=False))

yield "{}".format(chunk.model_dump_json(exclude_unset=True, ensure_ascii=False))
current_length = 0

for new_response, _ in model.stream_chat(tokenizer, query, history):
Expand All @@ -152,16 +151,15 @@ async def predict(query: str, history: List[List[str]], model_id: str):
finish_reason=None
)
chunk = ChatCompletionResponse(model=model_id, choices=[choice_data], object="chat.completion.chunk")
yield "{}".format(chunk.json(exclude_unset=True, ensure_ascii=False))

yield "{}".format(chunk.model_dump_json(exclude_unset=True, ensure_ascii=False))

choice_data = ChatCompletionResponseStreamChoice(
index=0,
delta=DeltaMessage(),
finish_reason="stop"
)
chunk = ChatCompletionResponse(model=model_id, choices=[choice_data], object="chat.completion.chunk")
yield "{}".format(chunk.json(exclude_unset=True, ensure_ascii=False))
yield "{}".format(chunk.model_dump_json(exclude_unset=True, ensure_ascii=False))
yield '[DONE]'


Expand Down

0 comments on commit a3e7a99

Please sign in to comment.