From 90c705c16a04f3da5eedf78a810f21dbd5aa2248 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sat, 5 Jul 2025 14:57:17 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=A4=96=20=E8=87=AA=E5=8A=A8=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E5=8C=96=E4=BB=A3=E7=A0=81=20[skip=20ci]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/chat/heart_flow/sub_heartflow.py | 1 - src/chat/message_receive/message_sender.py | 1 - src/chat/normal_chat/normal_chat.py | 32 +++++++++---------- .../normal_chat/willing/mode_classical.py | 1 - src/chat/normal_chat/willing/mode_mxp.py | 2 +- .../normal_chat/willing/willing_manager.py | 1 - src/config/official_configs.py | 1 - 7 files changed, 16 insertions(+), 23 deletions(-) diff --git a/src/chat/heart_flow/sub_heartflow.py b/src/chat/heart_flow/sub_heartflow.py index cd417f872..206c00364 100644 --- a/src/chat/heart_flow/sub_heartflow.py +++ b/src/chat/heart_flow/sub_heartflow.py @@ -368,7 +368,6 @@ class SubHeartflow: return self.normal_chat_instance.get_action_manager() return None - async def get_full_state(self) -> dict: """获取子心流的完整状态,包括兴趣、思维和聊天状态。""" return { diff --git a/src/chat/message_receive/message_sender.py b/src/chat/message_receive/message_sender.py index e54f37d12..aa6721db3 100644 --- a/src/chat/message_receive/message_sender.py +++ b/src/chat/message_receive/message_sender.py @@ -191,7 +191,6 @@ class MessageManager: container = await self.get_container(chat_stream.stream_id) container.add_message(message) - async def _handle_sending_message(self, container: MessageContainer, message: MessageSending): """处理单个 MessageSending 消息 (包含 set_reply 逻辑)""" try: diff --git a/src/chat/normal_chat/normal_chat.py b/src/chat/normal_chat/normal_chat.py index 128ce94d7..a737d5bec 100644 --- a/src/chat/normal_chat/normal_chat.py +++ b/src/chat/normal_chat/normal_chat.py @@ -116,7 +116,7 @@ class NormalChat: self.get_cooldown_progress_callback = get_cooldown_progress_callback self._disabled = False # 增加停用标志 - + self.timeout_count = 0 # 加载持久化的缓存 @@ -489,7 +489,6 @@ class NormalChat: f"[{self.stream_name}] 从队列中取出消息进行处理: User {message.message_info.user_info.user_id}, Time: {time.strftime('%H:%M:%S', time.localtime(message.message_info.time))}" ) - # 检查是否有用户满足关系构建条件 asyncio.create_task(self._check_relation_building_conditions(message)) @@ -716,9 +715,8 @@ class NormalChat: if self.priority_manager: self.priority_manager.add_message(message) return - - - # 新增:在auto模式下检查是否需要直接切换到focus模式 + + # 新增:在auto模式下检查是否需要直接切换到focus模式 if global_config.chat.chat_mode == "auto": if await self._check_should_switch_to_focus(): logger.info(f"[{self.stream_name}] 检测到切换到focus聊天模式的条件,尝试执行切换") @@ -742,8 +740,6 @@ class NormalChat: if self._disabled: return - - # 检查是否有用户满足关系构建条件 asyncio.create_task(self._check_relation_building_conditions(message)) @@ -769,7 +765,7 @@ class NormalChat: # 处理表情包 if message.is_emoji or message.is_picid: - reply_probability = 0 + reply_probability = 0 # 应用疲劳期回复频率调整 fatigue_multiplier = self._get_fatigue_reply_multiplier() @@ -799,8 +795,7 @@ class NormalChat: await willing_manager.before_generate_reply_handle(message.message_info.message_id) do_reply = await self.reply_one_message(message) response_set = do_reply if do_reply else None - - + # 输出性能计时结果 if do_reply and response_set: # 确保 response_set 不是 None timing_str = " | ".join([f"{step}: {duration:.2f}秒" for step, duration in timing_results.items()]) @@ -852,7 +847,6 @@ class NormalChat: return None try: - no_action = { "action_result": { "action_type": "no_action", @@ -921,12 +915,16 @@ class NormalChat: ) response_set, plan_result = results except asyncio.TimeoutError: - logger.warning(f"[{self.stream_name}] 并行执行回复生成和动作规划超时 ({gather_timeout}秒),正在取消相关任务...") + logger.warning( + f"[{self.stream_name}] 并行执行回复生成和动作规划超时 ({gather_timeout}秒),正在取消相关任务..." + ) self.timeout_count += 1 if self.timeout_count > 5: - logger.error(f"[{self.stream_name}] 连续回复超时,{global_config.normal_chat.thinking_timeout}秒 内大模型没有返回有效内容,请检查你的api是否速度过慢或配置错误。建议不要使用推理模型,推理模型生成速度过慢。") + logger.error( + f"[{self.stream_name}] 连续回复超时,{global_config.normal_chat.thinking_timeout}秒 内大模型没有返回有效内容,请检查你的api是否速度过慢或配置错误。建议不要使用推理模型,推理模型生成速度过慢。" + ) return False - + # 取消未完成的任务 if not gen_task.done(): gen_task.cancel() @@ -935,7 +933,7 @@ class NormalChat: # 清理思考消息 await self._cleanup_thinking_message_by_id(thinking_id) - + response_set = None plan_result = None @@ -1252,12 +1250,12 @@ class NormalChat: async def _check_relation_building_conditions(self, message: MessageRecv): """检查person_engaged_cache中是否有满足关系构建条件的用户""" - # 执行定期清理 + # 执行定期清理 self._cleanup_old_segments() # 更新消息段信息 self._update_user_message_segments(message) - + users_to_build_relationship = [] for person_id, segments in list(self.person_engaged_cache.items()): diff --git a/src/chat/normal_chat/willing/mode_classical.py b/src/chat/normal_chat/willing/mode_classical.py index a6929338c..0b296bbf4 100644 --- a/src/chat/normal_chat/willing/mode_classical.py +++ b/src/chat/normal_chat/willing/mode_classical.py @@ -53,6 +53,5 @@ class ClassicalWillingManager(BaseWillingManager): if current_willing < 1: self.chat_reply_willing[chat_id] = min(1.0, current_willing + 0.4) - async def not_reply_handle(self, message_id): return await super().not_reply_handle(message_id) diff --git a/src/chat/normal_chat/willing/mode_mxp.py b/src/chat/normal_chat/willing/mode_mxp.py index 89f6b4757..7b9e55568 100644 --- a/src/chat/normal_chat/willing/mode_mxp.py +++ b/src/chat/normal_chat/willing/mode_mxp.py @@ -171,7 +171,7 @@ class MxpWillingManager(BaseWillingManager): self.logger.debug("进行中消息惩罚:归0") probability = self._willing_to_probability(current_willing) - + self.temporary_willing = current_willing return probability diff --git a/src/chat/normal_chat/willing/willing_manager.py b/src/chat/normal_chat/willing/willing_manager.py index 9a7ce4857..0fa701f94 100644 --- a/src/chat/normal_chat/willing/willing_manager.py +++ b/src/chat/normal_chat/willing/willing_manager.py @@ -136,7 +136,6 @@ class BaseWillingManager(ABC): """抽象方法:获取回复概率""" raise NotImplementedError - async def get_willing(self, chat_id: str): """获取指定聊天流的回复意愿""" async with self.lock: diff --git a/src/config/official_configs.py b/src/config/official_configs.py index 3cfeecf51..7dc63089b 100644 --- a/src/config/official_configs.py +++ b/src/config/official_configs.py @@ -285,7 +285,6 @@ class NormalChatConfig(ConfigBase): response_interested_rate_amplifier: float = 1.0 """回复兴趣度放大系数""" - mentioned_bot_inevitable_reply: bool = False """提及 bot 必然回复"""