fix:微操

This commit is contained in:
SengokuCola
2025-03-30 00:40:58 +08:00
parent 1641d89ca2
commit 74836e4f53
4 changed files with 17 additions and 19 deletions

View File

@@ -56,7 +56,7 @@ class Heartflow:
del self._subheartflows[subheartflow_id]
logger.info(f"已清理不活跃的子心流: {subheartflow_id}")
await asyncio.sleep(60) # 每分钟检查一次
await asyncio.sleep(30) # 每分钟检查一次
async def heartflow_start_working(self):
# 启动清理任务
@@ -65,7 +65,7 @@ class Heartflow:
while True:
# 检查是否存在子心流
if not self._subheartflows:
logger.debug("当前没有子心流,等待新的子心流创建...")
logger.info("当前没有子心流,等待新的子心流创建...")
await asyncio.sleep(60) # 每分钟检查一次是否有新的子心流
continue
@@ -73,7 +73,7 @@ class Heartflow:
await asyncio.sleep(300) # 5分钟思考一次
async def do_a_thinking(self):
logger.info("麦麦大脑袋转起来了")
logger.debug("麦麦大脑袋转起来了")
self.current_state.update_current_state_info()
personality_info = self.personality_info
@@ -157,7 +157,7 @@ class Heartflow:
asyncio.create_task(subheartflow.subheartflow_start_working())
logger.debug(f"创建异步任务 成功")
self._subheartflows[subheartflow_id] = subheartflow
logger.debug(f"添加 subheartflow 成功")
logger.info(f"添加 subheartflow 成功")
return self._subheartflows[subheartflow_id]
def get_subheartflow(self, observe_chat_id):

View File

@@ -79,7 +79,7 @@ class SubHeartflow:
async def subheartflow_start_working(self):
while True:
current_time = time.time()
if current_time - self.last_reply_time > 180: # 3分钟 = 180秒
if current_time - self.last_reply_time > 120: # 120秒无回复/不在场,冻结
self.is_active = False
await asyncio.sleep(60) # 每60秒检查一次
else:
@@ -87,7 +87,7 @@ class SubHeartflow:
self.last_active_time = current_time # 更新最后激活时间
observation = self.observations[0]
observation.observe()
await observation.observe()
self.current_state.update_current_state_info()
@@ -96,8 +96,8 @@ class SubHeartflow:
await asyncio.sleep(60)
# 检查是否超过10分钟没有激活
if current_time - self.last_active_time > 600: # 10分钟 = 600秒
logger.info(f"子心流 {self.subheartflow_id} 已经10分钟没有激活,正在销毁...")
if current_time - self.last_active_time > 600: # 5分钟无回复/不在场,销毁
logger.info(f"子心流 {self.subheartflow_id} 已经5分钟没有激活,正在销毁...")
break # 退出循环,销毁自己
async def do_a_thinking(self):
@@ -146,7 +146,7 @@ class SubHeartflow:
self.update_current_mind(reponse)
self.current_mind = reponse
logger.info(f"prompt:\n{prompt}\n")
logger.debug(f"prompt:\n{prompt}\n")
logger.info(f"麦麦的脑内状态:{self.current_mind}")
async def do_after_reply(self,reply_content,chat_talking_prompt):