From 510aa7a12d8e6fd3821812d28f3e5721974fe302 Mon Sep 17 00:00:00 2001 From: SengokuCola <1026294844@qq.com> Date: Sat, 26 Apr 2025 12:21:11 +0800 Subject: [PATCH] fix:ruff --- src/heart_flow/sub_heartflow.py | 6 +++--- src/heart_flow/subheartflow_manager.py | 20 +------------------- 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/src/heart_flow/sub_heartflow.py b/src/heart_flow/sub_heartflow.py index cbdcd2748..dd9364f30 100644 --- a/src/heart_flow/sub_heartflow.py +++ b/src/heart_flow/sub_heartflow.py @@ -241,7 +241,7 @@ class SubHeartflow: # 这个聊天流的状态 self.chat_state: ChatStateInfo = ChatStateInfo() - + # 兴趣检测器 self.interest_chatting = None @@ -249,7 +249,7 @@ class SubHeartflow: self.last_active_time = time.time() # 最后活跃时间 self.should_stop = False # 停止标志 self.task: Optional[asyncio.Task] = None # 后台任务 - + # 随便水群 normal_chat 和 认真水群 heartFC_chat 实例 # CHAT模式激活 随便水群 FOCUS模式激活 认真水群 self.heart_fc_instance: Optional[HeartFChatting] = None # 该sub_heartflow的HeartFChatting实例 @@ -304,7 +304,7 @@ class SubHeartflow: """ 启动 NormalChat 实例, 进入 CHAT 状态时使用 - + 确保 HeartFChatting 已停止 """ await self._stop_heart_fc_chat() # 确保 专注聊天已停止 diff --git a/src/heart_flow/subheartflow_manager.py b/src/heart_flow/subheartflow_manager.py index 0bfa40cc7..ce9ec39a7 100644 --- a/src/heart_flow/subheartflow_manager.py +++ b/src/heart_flow/subheartflow_manager.py @@ -111,11 +111,6 @@ class SubHeartflowManager: # 设置状态为ABSENT释放资源 if subheartflow.chat_state.chat_status != ChatState.ABSENT: logger.debug(f"[子心流管理] 设置 {stream_name} 状态为ABSENT") - states_num = ( - self.count_subflows_by_state(ChatState.ABSENT), - self.count_subflows_by_state(ChatState.CHAT), - self.count_subflows_by_state(ChatState.FOCUSED), - ) await subheartflow.set_chat_state(ChatState.ABSENT) else: logger.debug(f"[子心流管理] {stream_name} 已是ABSENT状态") @@ -237,7 +232,7 @@ class SubHeartflowManager: current_chat_count = self.count_subflows_by_state(ChatState.CHAT) if current_chat_count >= limit: logger.warning(f"[激活] 跳过{stream_name}, 普通聊天已达上限 ({current_chat_count}/{limit})") - continue # 跳过此子心流,继续尝试激活下一个 + continue # 跳过此子心流,继续尝试激活下一个 # --- 结束限额检查 --- # # 移除 states_num 参数 @@ -284,12 +279,6 @@ class SubHeartflowManager: logger.debug(f"{log_prefix} 已达专注上限 ({current_focused_count}/{focused_limit})") return - states_num = ( - self.count_subflows_by_state(ChatState.ABSENT), - self.count_subflows_by_state(ChatState.CHAT), - current_focused_count, - ) - for sub_hf in list(self.subheartflows.values()): flow_id = sub_hf.subheartflow_id stream_name = chat_manager.get_stream_name(flow_id) or flow_id @@ -340,13 +329,6 @@ class SubHeartflowManager: subflows_snapshot = list(self.subheartflows.values()) deactivated_count = 0 - # 预先计算状态数量,因为 set_chat_state 需要 - states_num_before = ( - self.count_subflows_by_state(ChatState.ABSENT), - self.count_subflows_by_state(ChatState.CHAT), - self.count_subflows_by_state(ChatState.FOCUSED), - ) - try: for sub_hf in subflows_snapshot: flow_id = sub_hf.subheartflow_id