From 29a1954ef4c11c0301f2942a62e4f8f8ae90f265 Mon Sep 17 00:00:00 2001 From: yym68686 Date: Mon, 18 Dec 2023 00:53:04 +0800 Subject: [PATCH] Fixed bug: Fix the bug of Chinese display in log. The json.dumps function defaults to using ASCII encoding when serializing Chinese, so it will convert Chinese characters to the corresponding ASCII code. --- utils/chatgpt2api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/chatgpt2api.py b/utils/chatgpt2api.py index a1d38e49..7b371a59 100644 --- a/utils/chatgpt2api.py +++ b/utils/chatgpt2api.py @@ -538,7 +538,7 @@ def ask_stream( self.reset(convo_id=convo_id, system_prompt=self.system_prompt) self.add_to_conversation(prompt, role, convo_id=convo_id, function_name=function_name) json_post, message_token = self.truncate_conversation(prompt, role, convo_id, model, pass_history, **kwargs) - print(json.dumps(json_post, indent=4)) + print(json.dumps(json_post, indent=4, ensure_ascii=False)) # print(self.conversation[convo_id]) if self.engine == "gpt-4-1106-preview" or self.engine == "gpt-3.5-turbo-1106":