fix:拯救大兵ruff 2
This commit is contained in:
@@ -15,11 +15,12 @@ import enum
|
||||
import os # 新增
|
||||
import json # 新增
|
||||
from src.plugins.chat.chat_stream import chat_manager # 新增
|
||||
|
||||
# --- Add imports for merged dependencies ---
|
||||
from src.plugins.heartFC_chat.heartFC_generator import ResponseGenerator
|
||||
from src.do_tool.tool_use import ToolUser
|
||||
from src.plugins.chat.emoji_manager import emoji_manager # Module instance
|
||||
from src.plugins.person_info.relationship_manager import relationship_manager # Module instance
|
||||
from src.plugins.chat.emoji_manager import emoji_manager # Module instance
|
||||
from src.plugins.person_info.relationship_manager import relationship_manager # Module instance
|
||||
# --- End imports ---
|
||||
|
||||
heartflow_config = LogConfig(
|
||||
@@ -31,9 +32,10 @@ logger = get_module_logger("heartflow", config=heartflow_config)
|
||||
|
||||
# Type hinting for circular dependency
|
||||
if TYPE_CHECKING:
|
||||
from src.heart_flow.sub_heartflow import SubHeartflow, ChatState # Keep SubHeartflow here too
|
||||
from src.heart_flow.sub_heartflow import SubHeartflow, ChatState # Keep SubHeartflow here too
|
||||
# from src.plugins.heartFC_chat.heartFC_controler import HeartFCController # No longer needed
|
||||
|
||||
|
||||
def init_prompt():
|
||||
prompt = ""
|
||||
prompt += "你刚刚在做的事情是:{schedule_info}\n"
|
||||
@@ -64,7 +66,7 @@ LOG_INTERVAL_SECONDS = 3 # 日志记录间隔 (例如:3秒) - 保持与 inter
|
||||
# --- 结束新增常量 ---
|
||||
|
||||
# --- 新增:状态更新常量 ---
|
||||
STATE_UPDATE_INTERVAL_SECONDS = 30 # 状态更新检查间隔(秒)
|
||||
STATE_UPDATE_INTERVAL_SECONDS = 30 # 状态更新检查间隔(秒)
|
||||
FIVE_MINUTES = 1 * 60
|
||||
FIFTEEN_MINUTES = 5 * 60
|
||||
TWENTY_MINUTES = 10 * 60
|
||||
@@ -109,12 +111,11 @@ class MaiState(enum.Enum):
|
||||
|
||||
class MaiStateInfo:
|
||||
def __init__(self):
|
||||
|
||||
# 使用枚举类型初始化状态,默认为正常聊天
|
||||
self.mai_status: MaiState = MaiState.OFFLINE
|
||||
self.mai_status_history = [] # 历史状态,包含 状态,最后时间
|
||||
self.last_status_change_time: float = time.time() # 新增:状态最后改变时间
|
||||
self.last_5min_check_time: float = time.time() # 新增:上次5分钟规则检查时间
|
||||
self.mai_status_history = [] # 历史状态,包含 状态,最后时间
|
||||
self.last_status_change_time: float = time.time() # 新增:状态最后改变时间
|
||||
self.last_5min_check_time: float = time.time() # 新增:上次5分钟规则检查时间
|
||||
|
||||
self.normal_chatting = []
|
||||
self.focused_chatting = []
|
||||
@@ -125,11 +126,11 @@ class MaiStateInfo:
|
||||
# 新增更新聊天状态的方法
|
||||
def update_mai_status(self, new_status: MaiState):
|
||||
"""更新聊天状态"""
|
||||
if isinstance(new_status, MaiState) and new_status != self.mai_status: # 只有状态实际改变时才更新
|
||||
if isinstance(new_status, MaiState) and new_status != self.mai_status: # 只有状态实际改变时才更新
|
||||
self.mai_status = new_status
|
||||
current_time = time.time()
|
||||
self.last_status_change_time = current_time # 更新状态改变时间
|
||||
self.last_5min_check_time = current_time # 重置5分钟检查计时器
|
||||
self.last_status_change_time = current_time # 更新状态改变时间
|
||||
self.last_5min_check_time = current_time # 重置5分钟检查计时器
|
||||
# 将新状态和时间戳添加到历史记录
|
||||
self.mai_status_history.append((new_status, current_time))
|
||||
logger.info(f"麦麦状态更新为: {self.mai_status.value}")
|
||||
@@ -148,14 +149,16 @@ class Heartflow:
|
||||
model=global_config.llm_heartflow, temperature=0.6, max_tokens=1000, request_type="heart_flow"
|
||||
)
|
||||
|
||||
self._subheartflows: Dict[Any, 'SubHeartflow'] = {} # Update type hint
|
||||
self._subheartflows: Dict[Any, "SubHeartflow"] = {} # Update type hint
|
||||
|
||||
# --- Dependencies moved from HeartFCController ---
|
||||
self.gpt_instance = ResponseGenerator()
|
||||
self.mood_manager = MoodManager.get_instance() # Note: MaiStateInfo also has one, consider consolidating later if needed
|
||||
self.mood_manager = (
|
||||
MoodManager.get_instance()
|
||||
) # Note: MaiStateInfo also has one, consider consolidating later if needed
|
||||
self.tool_user_instance = ToolUser()
|
||||
self.emoji_manager_instance = emoji_manager # Module instance
|
||||
self.relationship_manager_instance = relationship_manager # Module instance
|
||||
self.emoji_manager_instance = emoji_manager # Module instance
|
||||
self.relationship_manager_instance = relationship_manager # Module instance
|
||||
# --- End moved dependencies ---
|
||||
|
||||
# --- Background Task Management ---
|
||||
@@ -163,7 +166,7 @@ class Heartflow:
|
||||
self._ensure_log_directory() # 初始化时确保目录存在
|
||||
self._cleanup_task: Optional[asyncio.Task] = None
|
||||
self._logging_task: Optional[asyncio.Task] = None
|
||||
self._state_update_task: Optional[asyncio.Task] = None # 新增:状态更新任务
|
||||
self._state_update_task: Optional[asyncio.Task] = None # 新增:状态更新任务
|
||||
# 注意:衰减任务 (_decay_task) 不再需要,衰减在 SubHeartflow 的 InterestChatting 内部处理
|
||||
# --- End moved dependencies ---
|
||||
|
||||
@@ -243,24 +246,24 @@ class Heartflow:
|
||||
current_time = time.time()
|
||||
# 获取更新前的状态
|
||||
previous_status = self.current_state.mai_status
|
||||
current_status = self.current_state.mai_status # 保持此行以进行后续逻辑
|
||||
current_status = self.current_state.mai_status # 保持此行以进行后续逻辑
|
||||
time_in_current_status = current_time - self.current_state.last_status_change_time
|
||||
time_since_last_5min_check = current_time - self.current_state.last_5min_check_time
|
||||
next_state = None # 预设下一状态为 None
|
||||
next_state = None # 预设下一状态为 None
|
||||
|
||||
# --- 状态转换逻辑 (保持不变) ---
|
||||
# 1. 通用规则:每5分钟检查 (对于非 OFFLINE 状态)
|
||||
if time_since_last_5min_check >= FIVE_MINUTES:
|
||||
self.current_state.last_5min_check_time = current_time # 重置5分钟检查计时器(无论是否切换)
|
||||
self.current_state.last_5min_check_time = current_time # 重置5分钟检查计时器(无论是否切换)
|
||||
if current_status != MaiState.OFFLINE:
|
||||
if random.random() < 0.10: # 10% 概率切换到 OFFLINE
|
||||
if random.random() < 0.10: # 10% 概率切换到 OFFLINE
|
||||
logger.debug(f"[Heartflow State] 触发5分钟规则,从 {current_status.value} 切换到 OFFLINE")
|
||||
next_state = MaiState.OFFLINE # 设置 next_state 而不是直接更新
|
||||
next_state = MaiState.OFFLINE # 设置 next_state 而不是直接更新
|
||||
# self.current_state.update_mai_status(MaiState.OFFLINE)
|
||||
# continue # 状态已改变,进入下一轮循环
|
||||
|
||||
# 2. 状态持续时间规则 (仅在未被5分钟规则覆盖时执行)
|
||||
if next_state is None: # 仅当5分钟规则未触发切换时检查持续时间
|
||||
if next_state is None: # 仅当5分钟规则未触发切换时检查持续时间
|
||||
if current_status == MaiState.OFFLINE:
|
||||
# OFFLINE 状态下,检查是否已持续5分钟
|
||||
if time_in_current_status >= FIVE_MINUTES:
|
||||
@@ -274,26 +277,26 @@ class Heartflow:
|
||||
# 保持 OFFLINE,重置计时器以开始新的5分钟计时
|
||||
logger.debug("[Heartflow State] OFFLINE 持续时间达到,保持 OFFLINE,重置计时器")
|
||||
self.current_state.last_status_change_time = current_time
|
||||
self.current_state.last_5min_check_time = current_time # 保持一致
|
||||
self.current_state.last_5min_check_time = current_time # 保持一致
|
||||
# 显式将 next_state 设为 OFFLINE 以便后续处理
|
||||
next_state = MaiState.OFFLINE
|
||||
|
||||
elif current_status == MaiState.PEEKING:
|
||||
if time_in_current_status >= FIVE_MINUTES: # PEEKING 最多持续 5 分钟
|
||||
if time_in_current_status >= FIVE_MINUTES: # PEEKING 最多持续 5 分钟
|
||||
weights = [50, 30, 20]
|
||||
choices_list = [MaiState.OFFLINE, MaiState.NORMAL_CHAT, MaiState.FOCUSED_CHAT]
|
||||
next_state = random.choices(choices_list, weights=weights, k=1)[0]
|
||||
logger.debug(f"[Heartflow State] PEEKING 持续时间达到,切换到 {next_state.value}")
|
||||
|
||||
elif current_status == MaiState.NORMAL_CHAT:
|
||||
if time_in_current_status >= FIFTEEN_MINUTES: # NORMAL_CHAT 最多持续 15 分钟
|
||||
if time_in_current_status >= FIFTEEN_MINUTES: # NORMAL_CHAT 最多持续 15 分钟
|
||||
weights = [50, 50]
|
||||
choices_list = [MaiState.OFFLINE, MaiState.FOCUSED_CHAT]
|
||||
next_state = random.choices(choices_list, weights=weights, k=1)[0]
|
||||
logger.debug(f"[Heartflow State] NORMAL_CHAT 持续时间达到,切换到 {next_state.value}")
|
||||
|
||||
elif current_status == MaiState.FOCUSED_CHAT:
|
||||
if time_in_current_status >= TWENTY_MINUTES: # FOCUSED_CHAT 最多持续 20 分钟
|
||||
if time_in_current_status >= TWENTY_MINUTES: # FOCUSED_CHAT 最多持续 20 分钟
|
||||
weights = [80, 20]
|
||||
choices_list = [MaiState.OFFLINE, MaiState.NORMAL_CHAT]
|
||||
next_state = random.choices(choices_list, weights=weights, k=1)[0]
|
||||
@@ -325,7 +328,7 @@ class Heartflow:
|
||||
if time_in_current_status >= FIVE_MINUTES:
|
||||
# 确保计时器已在上面重置,这里无需操作,只记录日志
|
||||
logger.debug("[Heartflow State] 保持 OFFLINE 状态,计时器已重置。")
|
||||
pass # 无需状态转换,也无需调用激活/停用逻辑
|
||||
pass # 无需状态转换,也无需调用激活/停用逻辑
|
||||
|
||||
# --- 如果没有确定 next_state (即没有触发任何切换规则) --- #
|
||||
# logger.debug(f"[Heartflow State] 状态未改变,保持 {current_status.value}") # 减少日志噪音
|
||||
@@ -340,10 +343,15 @@ class Heartflow:
|
||||
|
||||
for sub_hf in subflows_snapshot:
|
||||
# Double-check if subflow still exists and is in CHAT state
|
||||
if sub_hf.subheartflow_id in self._subheartflows and sub_hf.chat_state.chat_status == ChatState.CHAT:
|
||||
if (
|
||||
sub_hf.subheartflow_id in self._subheartflows
|
||||
and sub_hf.chat_state.chat_status == ChatState.CHAT
|
||||
):
|
||||
evaluated_count += 1
|
||||
if sub_hf.should_evaluate_reply():
|
||||
stream_name = chat_manager.get_stream_name(sub_hf.subheartflow_id) or sub_hf.subheartflow_id
|
||||
stream_name = (
|
||||
chat_manager.get_stream_name(sub_hf.subheartflow_id) or sub_hf.subheartflow_id
|
||||
)
|
||||
log_prefix = f"[{stream_name}]"
|
||||
logger.info(f"{log_prefix} 兴趣概率触发,尝试将状态从 CHAT 提升到 FOCUSED")
|
||||
# set_chat_state handles limit checks and HeartFChatting creation internally
|
||||
@@ -352,10 +360,12 @@ class Heartflow:
|
||||
if sub_hf.chat_state.chat_status == ChatState.FOCUSED:
|
||||
promoted_count += 1
|
||||
# else: # No need to log every non-trigger event
|
||||
# logger.trace(f"[{sub_hf.subheartflow_id}] In CHAT state, but should_evaluate_reply returned False.")
|
||||
# logger.trace(f"[{sub_hf.subheartflow_id}] In CHAT state, but should_evaluate_reply returned False.")
|
||||
|
||||
if evaluated_count > 0:
|
||||
logger.debug(f"[Heartflow Interest Eval] Evaluated {evaluated_count} CHAT flows. Promoted {promoted_count} to FOCUSED.")
|
||||
logger.debug(
|
||||
f"[Heartflow Interest Eval] Evaluated {evaluated_count} CHAT flows. Promoted {promoted_count} to FOCUSED."
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"[Heartflow] 兴趣评估任务出错: {e}")
|
||||
@@ -431,7 +441,6 @@ class Heartflow:
|
||||
# logger.info(f"[Heartflow] 清理完成。没有流符合移除条件。当前数量: {initial_count}") # 减少日志噪音
|
||||
pass
|
||||
|
||||
|
||||
async def heartflow_start_working(self):
|
||||
# 启动清理任务 (使用新的 periodic_cleanup_task)
|
||||
if self._cleanup_task is None or self._cleanup_task.done():
|
||||
@@ -593,7 +602,7 @@ class Heartflow:
|
||||
return "(想法汇总时发生错误...)"
|
||||
|
||||
# --- Add helper method to count subflows by state --- #
|
||||
def count_subflows_by_state(self, target_state: 'ChatState') -> int:
|
||||
def count_subflows_by_state(self, target_state: "ChatState") -> int:
|
||||
"""Counts the number of subheartflows currently in the specified state."""
|
||||
count = 0
|
||||
# Use items() directly for read-only iteration if thread safety isn't a major concern here
|
||||
@@ -604,9 +613,10 @@ class Heartflow:
|
||||
if flow.subheartflow_id in self._subheartflows and flow.chat_state.chat_status == target_state:
|
||||
count += 1
|
||||
return count
|
||||
|
||||
# --- End helper method --- #
|
||||
|
||||
async def create_subheartflow(self, subheartflow_id: Any) -> Optional['SubHeartflow']:
|
||||
async def create_subheartflow(self, subheartflow_id: Any) -> Optional["SubHeartflow"]:
|
||||
"""
|
||||
获取或创建一个新的SubHeartflow实例。
|
||||
创建本身不受限,因为初始状态是ABSENT。
|
||||
@@ -627,7 +637,6 @@ class Heartflow:
|
||||
await observation.initialize()
|
||||
subheartflow.add_observation(observation)
|
||||
|
||||
|
||||
# 创建并存储后台任务 (SubHeartflow 自己的后台任务)
|
||||
subheartflow.task = asyncio.create_task(subheartflow.subheartflow_start_working())
|
||||
logger.debug(f"[Heartflow] 为 {subheartflow_id} 创建后台任务成功,添加 observation 成功")
|
||||
@@ -641,7 +650,7 @@ class Heartflow:
|
||||
logger.error(traceback.format_exc())
|
||||
return None
|
||||
|
||||
def get_subheartflow(self, observe_chat_id: Any) -> Optional['SubHeartflow']:
|
||||
def get_subheartflow(self, observe_chat_id: Any) -> Optional["SubHeartflow"]:
|
||||
"""获取指定ID的SubHeartflow实例"""
|
||||
return self._subheartflows.get(observe_chat_id)
|
||||
|
||||
@@ -659,13 +668,13 @@ class Heartflow:
|
||||
# --- 新增:在取消任务和删除前,先设置状态为 ABSENT 以关闭 HeartFChatting ---
|
||||
try:
|
||||
if subheartflow.chat_state.chat_status != ChatState.ABSENT:
|
||||
logger.debug(f"[Heartflow Limits] 将子心流 {stream_name} 状态设置为 ABSENT 以确保资源释放...")
|
||||
await subheartflow.set_chat_state(ChatState.ABSENT) # 调用异步方法
|
||||
logger.debug(f"[Heartflow Limits] 将子心流 {stream_name} 状态设置为 ABSENT 以确保资源释放...")
|
||||
await subheartflow.set_chat_state(ChatState.ABSENT) # 调用异步方法
|
||||
else:
|
||||
logger.debug(f"[Heartflow Limits] 子心流 {stream_name} 已经是 ABSENT 状态。")
|
||||
logger.debug(f"[Heartflow Limits] 子心流 {stream_name} 已经是 ABSENT 状态。")
|
||||
except Exception as e:
|
||||
logger.error(f"[Heartflow Limits] 在停止子心流 {stream_name} 时设置状态为 ABSENT 出错: {e}")
|
||||
# 即使出错,仍继续尝试停止任务和移除
|
||||
logger.error(f"[Heartflow Limits] 在停止子心流 {stream_name} 时设置状态为 ABSENT 出错: {e}")
|
||||
# 即使出错,仍继续尝试停止任务和移除
|
||||
# --- 结束新增逻辑 ---
|
||||
|
||||
# 标记停止并取消任务
|
||||
@@ -692,12 +701,14 @@ class Heartflow:
|
||||
"""根据当前的 MaiState 强制执行 SubHeartflow 数量限制"""
|
||||
normal_limit = current_mai_state.get_normal_chat_max_num()
|
||||
focused_limit = current_mai_state.get_focused_chat_max_num()
|
||||
logger.debug(f"[Heartflow Limits] 执行限制检查。当前状态: {current_mai_state.value}, Normal上限: {normal_limit}, Focused上限: {focused_limit}")
|
||||
logger.debug(
|
||||
f"[Heartflow Limits] 执行限制检查。当前状态: {current_mai_state.value}, Normal上限: {normal_limit}, Focused上限: {focused_limit}"
|
||||
)
|
||||
|
||||
# 分类并统计当前 subheartflows
|
||||
normal_flows = []
|
||||
focused_flows = []
|
||||
other_flows = [] # e.g., ABSENT
|
||||
other_flows = [] # e.g., ABSENT
|
||||
|
||||
# 创建快照以安全迭代
|
||||
items_snapshot = list(self._subheartflows.items())
|
||||
@@ -713,7 +724,9 @@ class Heartflow:
|
||||
else:
|
||||
other_flows.append((flow_id, flow.last_active_time))
|
||||
|
||||
logger.debug(f"[Heartflow Limits] 当前计数 - Normal: {len(normal_flows)}, Focused: {len(focused_flows)}, Other: {len(other_flows)}")
|
||||
logger.debug(
|
||||
f"[Heartflow Limits] 当前计数 - Normal: {len(normal_flows)}, Focused: {len(focused_flows)}, Other: {len(other_flows)}"
|
||||
)
|
||||
|
||||
stopped_count = 0
|
||||
|
||||
@@ -726,32 +739,40 @@ class Heartflow:
|
||||
# 停止最不活跃的超额部分
|
||||
for i in range(excess_count):
|
||||
flow_id_to_stop = normal_flows[i][0]
|
||||
if await self._stop_subheartflow(flow_id_to_stop, f"Normal (CHAT) 状态超出上限 ({normal_limit}),停止最不活跃的实例"):
|
||||
if await self._stop_subheartflow(
|
||||
flow_id_to_stop, f"Normal (CHAT) 状态超出上限 ({normal_limit}),停止最不活跃的实例"
|
||||
):
|
||||
stopped_count += 1
|
||||
|
||||
# 重新获取 focused_flows 列表,因为上面的停止操作可能已经改变了状态或移除了实例
|
||||
focused_flows = []
|
||||
items_snapshot_after_normal = list(self._subheartflows.items())
|
||||
for flow_id, flow in items_snapshot_after_normal:
|
||||
if flow_id not in self._subheartflows:
|
||||
continue # Double check
|
||||
if flow_id not in self._subheartflows:
|
||||
continue # Double check
|
||||
if flow.chat_state.chat_status == ChatState.FOCUSED:
|
||||
focused_flows.append((flow_id, flow.last_active_time))
|
||||
|
||||
# 检查 Focused (FOCUSED) 限制
|
||||
if len(focused_flows) > focused_limit:
|
||||
excess_count = len(focused_flows) - focused_limit
|
||||
logger.info(f"[Heartflow Limits] 检测到 Focused (FOCUSED) 状态超额 {excess_count} 个。上限: {focused_limit}")
|
||||
logger.info(
|
||||
f"[Heartflow Limits] 检测到 Focused (FOCUSED) 状态超额 {excess_count} 个。上限: {focused_limit}"
|
||||
)
|
||||
# 按 last_active_time 升序排序
|
||||
focused_flows.sort(key=lambda item: item[1])
|
||||
# 停止最不活跃的超额部分
|
||||
for i in range(excess_count):
|
||||
flow_id_to_stop = focused_flows[i][0]
|
||||
if await self._stop_subheartflow(flow_id_to_stop, f"Focused (FOCUSED) 状态超出上限 ({focused_limit}),停止最不活跃的实例"):
|
||||
if await self._stop_subheartflow(
|
||||
flow_id_to_stop, f"Focused (FOCUSED) 状态超出上限 ({focused_limit}),停止最不活跃的实例"
|
||||
):
|
||||
stopped_count += 1
|
||||
|
||||
if stopped_count > 0:
|
||||
logger.info(f"[Heartflow Limits] 限制执行完成,共停止了 {stopped_count} 个子心流。当前总数: {len(self._subheartflows)}")
|
||||
logger.info(
|
||||
f"[Heartflow Limits] 限制执行完成,共停止了 {stopped_count} 个子心流。当前总数: {len(self._subheartflows)}"
|
||||
)
|
||||
else:
|
||||
logger.debug(f"[Heartflow Limits] 限制检查完成,无需停止子心流。当前总数: {len(self._subheartflows)}")
|
||||
|
||||
@@ -765,7 +786,11 @@ class Heartflow:
|
||||
|
||||
# 使用快照进行迭代
|
||||
all_flows_snapshot = list(self._subheartflows.values())
|
||||
absent_flows = [flow for flow in all_flows_snapshot if flow.subheartflow_id in self._subheartflows and flow.chat_state.chat_status == ChatState.ABSENT]
|
||||
absent_flows = [
|
||||
flow
|
||||
for flow in all_flows_snapshot
|
||||
if flow.subheartflow_id in self._subheartflows and flow.chat_state.chat_status == ChatState.ABSENT
|
||||
]
|
||||
|
||||
num_to_activate = min(limit, len(absent_flows))
|
||||
|
||||
@@ -773,13 +798,18 @@ class Heartflow:
|
||||
logger.info(f"[Heartflow Activate] 没有处于 ABSENT 状态的子心流可供激活至 CHAT (上限: {limit})。")
|
||||
return
|
||||
|
||||
logger.info(f"[Heartflow Activate] 将随机选择 {num_to_activate} 个 (上限 {limit}) ABSENT 子心流激活至 CHAT 状态。")
|
||||
logger.info(
|
||||
f"[Heartflow Activate] 将随机选择 {num_to_activate} 个 (上限 {limit}) ABSENT 子心流激活至 CHAT 状态。"
|
||||
)
|
||||
selected_flows = random.sample(absent_flows, num_to_activate)
|
||||
|
||||
activated_count = 0
|
||||
for flow in selected_flows:
|
||||
# 再次检查 flow 是否仍然存在且状态为 ABSENT (以防并发修改)
|
||||
if flow.subheartflow_id in self._subheartflows and self._subheartflows[flow.subheartflow_id].chat_state.chat_status == ChatState.ABSENT:
|
||||
if (
|
||||
flow.subheartflow_id in self._subheartflows
|
||||
and self._subheartflows[flow.subheartflow_id].chat_state.chat_status == ChatState.ABSENT
|
||||
):
|
||||
stream_name = chat_manager.get_stream_name(flow.subheartflow_id) or flow.subheartflow_id
|
||||
logger.debug(f"[Heartflow Activate] 正在将子心流 {stream_name} 状态设置为 CHAT。")
|
||||
# 调用 set_chat_state,它内部会处理日志记录
|
||||
@@ -809,7 +839,7 @@ class Heartflow:
|
||||
for flow_id in flow_ids_snapshot:
|
||||
subflow = self._subheartflows.get(flow_id)
|
||||
if not subflow:
|
||||
continue # Subflow 可能在迭代过程中被清理
|
||||
continue # Subflow 可能在迭代过程中被清理
|
||||
|
||||
stream_name = chat_manager.get_stream_name(flow_id) or flow_id
|
||||
|
||||
@@ -835,11 +865,14 @@ class Heartflow:
|
||||
logger.error(f"[Heartflow Deactivate] 停用子心流 {stream_name} 时出错: {e}")
|
||||
logger.error(traceback.format_exc())
|
||||
|
||||
logger.info(f"[Heartflow Deactivate] 完成停用,共将 {deactivated_count} 个子心流设置为 ABSENT 状态 (不包括已是 ABSENT 的)。")
|
||||
logger.info(
|
||||
f"[Heartflow Deactivate] 完成停用,共将 {deactivated_count} 个子心流设置为 ABSENT 状态 (不包括已是 ABSENT 的)。"
|
||||
)
|
||||
except Exception as e:
|
||||
logger.error(f"[Heartflow Deactivate] 停用所有子心流时出错: {e}")
|
||||
logger.error(traceback.format_exc())
|
||||
|
||||
|
||||
init_prompt()
|
||||
# 创建一个全局的管理器实例
|
||||
heartflow = Heartflow()
|
||||
|
||||
Reference in New Issue
Block a user