From 21dcde6899ff58f908909b982da55e7ccc626e98 Mon Sep 17 00:00:00 2001 From: Laoshancun Date: Wed, 2 Aug 2023 17:42:23 +0800 Subject: [PATCH] fix: pydantic `dumps_kwargs` keyword arguments are no longer supported. [openai-api]replace json with model_dump_json --- openai_api.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openai_api.py b/openai_api.py index 7225562..64af1fe 100644 --- a/openai_api.py +++ b/openai_api.py @@ -135,7 +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 @@ -152,7 +152,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)) choice_data = ChatCompletionResponseStreamChoice( @@ -161,7 +161,7 @@ async def predict(query: str, history: List[List[str]], model_id: str): 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]'