From 1b31f741434711ac2d7041093d93dfc4108bdfe3 Mon Sep 17 00:00:00 2001 From: Wizerd Date: Fri, 15 Dec 2023 15:52:32 +0800 Subject: [PATCH] =?UTF-8?q?[fix]=20=E4=BF=AE=E5=A4=8D=E4=B8=80=E4=BA=9B?= =?UTF-8?q?=E5=81=B6=E7=8E=B0=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Readme.md | 4 ++++ main.py | 10 +++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Readme.md b/Readme.md index f6c6587..edde635 100644 --- a/Readme.md +++ b/Readme.md @@ -8,6 +8,10 @@ # 更新日志 +### 0.0.11 + +- 修复一些偶现的bug + ### 0.0.10 - 已支持非流式响应 diff --git a/main.py b/main.py index 5d9793f..87a82cd 100644 --- a/main.py +++ b/main.py @@ -26,8 +26,8 @@ BASE_URL = os.getenv('BASE_URL', '') PROXY_API_PREFIX = os.getenv('PROXY_API_PREFIX', '') UPLOAD_BASE_URL = os.getenv('UPLOAD_BASE_URL', '') -VERSION = '0.0.10' -UPDATE_INFO = '支持非流式响应' +VERSION = '0.0.11' +UPDATE_INFO = '修复一些偶现的bug' with app.app_context(): # 输出版本信息 @@ -379,6 +379,10 @@ def chat_completions(): data_json = json.loads(complete_data.replace('data: ', '')) # print(f"data_json: {data_json}") message = data_json.get("message", {}) + + if message == {} or message == None: + print(f"message 为空: data_json: {data_json}") + message_status = message.get("status") content = message.get("content", {}) role = message.get("author", {}).get("role") @@ -633,7 +637,7 @@ def chat_completions(): # 累积 new_text all_new_text += ''.join("```\n" + error_message + "\n```") yield 'data: ' + json.dumps(error_data) + '\n\n' - except json.JSONDecodeError: + except: # print("JSON 解析错误") print(f"[{datetime.now()}] 发送最后的数据: {buffer}") yield buffer