refactor:重构聊天状态切换模式,移除限额,精简切换逻辑
This commit is contained in:
@@ -22,11 +22,11 @@ from src.chat.emoji_system.emoji_manager import emoji_manager
|
||||
from src.chat.normal_chat.willing.willing_manager import willing_manager
|
||||
from src.config.config import global_config
|
||||
|
||||
logger = get_logger("chat")
|
||||
logger = get_logger("normal_chat")
|
||||
|
||||
|
||||
class NormalChat:
|
||||
def __init__(self, chat_stream: ChatStream, interest_dict: dict = None):
|
||||
def __init__(self, chat_stream: ChatStream, interest_dict: dict = {}):
|
||||
"""初始化 NormalChat 实例。只进行同步操作。"""
|
||||
|
||||
# Basic info from chat_stream (sync)
|
||||
@@ -200,7 +200,7 @@ class NormalChat:
|
||||
logger.info(f"[{self.stream_name}] 兴趣监控任务被取消或置空,退出")
|
||||
break
|
||||
|
||||
# 获取待处理消息列表
|
||||
|
||||
items_to_process = list(self.interest_dict.items())
|
||||
if not items_to_process:
|
||||
continue
|
||||
@@ -481,7 +481,7 @@ class NormalChat:
|
||||
try:
|
||||
if exc := task.exception():
|
||||
logger.error(f"[{self.stream_name}] 任务异常: {exc}")
|
||||
logger.error(traceback.format_exc())
|
||||
traceback.print_exc()
|
||||
except asyncio.CancelledError:
|
||||
logger.debug(f"[{self.stream_name}] 任务已取消")
|
||||
except Exception as e:
|
||||
@@ -522,4 +522,4 @@ class NormalChat:
|
||||
logger.info(f"[{self.stream_name}] 清理了 {len(thinking_messages)} 条未处理的思考消息。")
|
||||
except Exception as e:
|
||||
logger.error(f"[{self.stream_name}] 清理思考消息时出错: {e}")
|
||||
logger.error(traceback.format_exc())
|
||||
traceback.print_exc()
|
||||
|
||||
Reference in New Issue
Block a user