From 90d169f740230ef637015677f5161d2047d9d5b6 Mon Sep 17 00:00:00 2001 From: Pliosauroidea Date: Wed, 12 Mar 2025 07:44:57 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=B0=86=E4=BB=B7=E6=A0=BCprint=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=E5=AF=B9=E5=BA=94=E7=9A=84logger=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/chat/bot.py | 4 ++-- src/plugins/utils/typo_generator.py | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/plugins/chat/bot.py b/src/plugins/chat/bot.py index f335a2ba3..f179e8ef3 100644 --- a/src/plugins/chat/bot.py +++ b/src/plugins/chat/bot.py @@ -235,10 +235,10 @@ class ChatBot: is_head=not mark_head, is_emoji=False, ) - print(f"bot_message: {bot_message}") + logger.debug(f"bot_message: {bot_message}") if not mark_head: mark_head = True - print(f"添加消息到message_set: {bot_message}") + logger.debug(f"添加消息到message_set: {bot_message}") message_set.add_message(bot_message) # message_set 可以直接加入 message_manager diff --git a/src/plugins/utils/typo_generator.py b/src/plugins/utils/typo_generator.py index aa72c387f..f99a7ab20 100644 --- a/src/plugins/utils/typo_generator.py +++ b/src/plugins/utils/typo_generator.py @@ -13,6 +13,8 @@ from pathlib import Path import jieba from pypinyin import Style, pinyin +from loguru import logger + class ChineseTypoGenerator: def __init__(self, @@ -38,7 +40,9 @@ class ChineseTypoGenerator: self.max_freq_diff = max_freq_diff # 加载数据 - print("正在加载汉字数据库,请稍候...") + # print("正在加载汉字数据库,请稍候...") + logger.info("正在加载汉字数据库,请稍候...") + self.pinyin_dict = self._create_pinyin_dict() self.char_frequency = self._load_or_create_char_frequency() From 126c9af70e8f3bc6ae3e19bf8a29a90c4c4d1155 Mon Sep 17 00:00:00 2001 From: Pliosauroidea Date: Wed, 12 Mar 2025 07:58:27 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=81=AB=E5=B1=B1?= =?UTF-8?q?=E9=83=A8=E5=88=86=E6=B5=81=E5=BC=8F=E8=BE=93=E5=87=BA=E6=B2=A1?= =?UTF-8?q?=E6=9C=89finish=5Freason=E5=AF=BC=E8=87=B4=E7=9A=84=E6=8A=A5?= =?UTF-8?q?=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/models/utils_model.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/models/utils_model.py b/src/plugins/models/utils_model.py index 75b46f611..5335e3d65 100644 --- a/src/plugins/models/utils_model.py +++ b/src/plugins/models/utils_model.py @@ -235,7 +235,7 @@ class LLM_request: delta_content = "" accumulated_content += delta_content # 检测流式输出文本是否结束 - finish_reason = chunk["choices"][0]["finish_reason"] + finish_reason = chunk["choices"][0].get("finish_reason") if finish_reason == "stop": usage = chunk.get("usage", None) if usage: