fix:修复normal_chat不回复

This commit is contained in:
SengokuCola
2025-05-20 23:44:53 +08:00
parent de2736fccd
commit 1f59fd5802
3 changed files with 3 additions and 19 deletions

View File

@@ -261,20 +261,6 @@ class SubHeartflow:
f"{log_prefix} 尝试将状态从 {current_state.value} 变为 {new_state.value},但未成功或未执行更改。"
)
async def subheartflow_start_working(self):
"""启动子心流的后台任务
功能说明:
- 负责子心流的主要后台循环
- 每30秒检查一次停止标志
"""
logger.trace(f"{self.log_prefix} 子心流开始工作...")
while not self.should_stop:
await asyncio.sleep(30) # 30秒检查一次停止标志
logger.info(f"{self.log_prefix} 子心流后台任务已停止。")
def add_observation(self, observation: Observation):
for existing_obs in self.observations:
if existing_obs.observe_id == observation.observe_id:

View File

@@ -117,9 +117,6 @@ class SubHeartflowManager:
heartflow_name = chat_manager.get_stream_name(subheartflow_id) or subheartflow_id
logger.info(f"[{heartflow_name}] 开始接收消息")
# 启动后台任务
asyncio.create_task(new_subflow.subheartflow_start_working())
return new_subflow
except Exception as e:
logger.error(f"创建子心流 {subheartflow_id} 失败: {e}", exc_info=True)

View File

@@ -36,7 +36,7 @@ class NormalChat:
self.stream_name = chat_manager.get_stream_name(self.stream_id) or self.stream_id
# Interest dict
self.interest_dict = interest_dict or {}
self.interest_dict = interest_dict
self.is_group_chat: bool = False
self.chat_target_info: Optional[dict] = None
@@ -457,10 +457,11 @@ class NormalChat:
await self.initialize() # Ensure initialized before starting tasks
if self._chat_task is None or self._chat_task.done():
logger.info(f"[{self.stream_name}] 开始后台处理初始兴趣消息和轮询任务...")
logger.info(f"[{self.stream_name}] 开始回顾消息...")
# Process initial messages first
await self._process_initial_interest_messages()
# Then start polling task
logger.info(f"[{self.stream_name}] 开始处理兴趣消息...")
polling_task = asyncio.create_task(self._reply_interested_message())
polling_task.add_done_callback(lambda t: self._handle_task_completion(t))
self._chat_task = polling_task