fix:normal_caht未正常启动
This commit is contained in:
@@ -112,7 +112,7 @@ class BackgroundTaskManager:
|
||||
"""周期性任务主循环"""
|
||||
while True:
|
||||
start_time = asyncio.get_event_loop().time()
|
||||
logger.debug(f"开始执行后台任务: {task_name}")
|
||||
# logger.debug(f"开始执行后台任务: {task_name}")
|
||||
|
||||
try:
|
||||
await task_func(**kwargs) # 执行实际任务
|
||||
|
||||
@@ -49,7 +49,7 @@ class InterestLogger:
|
||||
logger.debug("未找到任何子心流状态")
|
||||
return results
|
||||
|
||||
logger.debug(f"正在获取 {len(all_flows)} 个子心流的兴趣状态...")
|
||||
# logger.debug(f"正在获取 {len(all_flows)} 个子心流的兴趣状态...")
|
||||
for subheartflow in all_flows:
|
||||
if self.subheartflow_manager.get_subheartflow(subheartflow.subheartflow_id):
|
||||
tasks.append(
|
||||
@@ -89,7 +89,7 @@ class InterestLogger:
|
||||
|
||||
async def log_interest_states(self):
|
||||
"""获取所有子心流的兴趣状态并写入日志文件。"""
|
||||
logger.debug("开始定期记录兴趣状态...")
|
||||
# logger.debug("开始定期记录兴趣状态...")
|
||||
try:
|
||||
current_timestamp = time.time()
|
||||
all_interest_states = await self.get_all_interest_states()
|
||||
@@ -128,7 +128,7 @@ class InterestLogger:
|
||||
}
|
||||
f.write(json.dumps(log_entry, ensure_ascii=False) + "\n")
|
||||
count += 1
|
||||
logger.debug(f"成功记录 {count} 条兴趣历史到 {self._history_log_file_path}")
|
||||
# logger.debug(f"成功记录 {count} 条兴趣历史到 {self._history_log_file_path}")
|
||||
except IOError as e:
|
||||
logger.error(f"写入兴趣历史日志到 {self._history_log_file_path} 出错: {e}")
|
||||
|
||||
|
||||
@@ -2,10 +2,15 @@ import enum
|
||||
import time
|
||||
import random
|
||||
from typing import List, Tuple, Optional
|
||||
from src.common.logger import get_module_logger
|
||||
from src.common.logger import get_module_logger, LogConfig, MAI_STATE_CONFIG
|
||||
from src.plugins.moods.moods import MoodManager
|
||||
|
||||
logger = get_module_logger("mai_state_manager")
|
||||
mai_state_config = LogConfig(
|
||||
# 使用海马体专用样式
|
||||
console_format=MAI_STATE_CONFIG["console_format"],
|
||||
file_format=MAI_STATE_CONFIG["file_format"],
|
||||
)
|
||||
logger = get_module_logger("mai_state_manager", config=mai_state_config)
|
||||
|
||||
|
||||
class MaiState(enum.Enum):
|
||||
|
||||
@@ -305,11 +305,11 @@ class SubHeartflow:
|
||||
await self.heart_fc_instance.shutdown() # 正确关闭 HeartFChatting
|
||||
self.heart_fc_instance = None
|
||||
|
||||
chat_stream = chat_manager.get_stream(self.chat_id)
|
||||
self.normal_chat_instance = NormalChat(
|
||||
chat_stream=chat_stream, interest_dict=self.get_interest_dict()
|
||||
)
|
||||
await self.normal_chat_instance.start_monitoring_interest()
|
||||
chat_stream = chat_manager.get_stream(self.chat_id)
|
||||
self.normal_chat_instance = NormalChat(
|
||||
chat_stream=chat_stream, interest_dict=self.get_interest_dict()
|
||||
)
|
||||
await self.normal_chat_instance.start_monitoring_interest()
|
||||
# NormalChat 启动/停止逻辑将在下面处理
|
||||
|
||||
elif new_state == ChatState.FOCUSED:
|
||||
|
||||
@@ -66,7 +66,7 @@ class SubHeartflowManager:
|
||||
subflow.should_stop = False # 重置停止标志
|
||||
|
||||
subflow.last_active_time = time.time() # 更新活跃时间
|
||||
logger.debug(f"获取到已存在的子心流: {subheartflow_id}")
|
||||
# logger.debug(f"获取到已存在的子心流: {subheartflow_id}")
|
||||
return subflow
|
||||
|
||||
# 创建新的子心流实例
|
||||
|
||||
Reference in New Issue
Block a user