better:优化hfc逻辑

This commit is contained in:
SengokuCola
2025-04-19 18:48:59 +08:00
parent b1dc34f7b1
commit c9ab9d4935
11 changed files with 227 additions and 475 deletions

View File

@@ -6,7 +6,6 @@ from src.config.config import global_config
from src.common.database import db
from src.common.logger import get_module_logger
import traceback
import asyncio
logger = get_module_logger("observation")
@@ -39,7 +38,20 @@ class ChattingObservation(Observation):
self.mid_memory_info = ""
self.now_message_info = ""
self._observe_lock = asyncio.Lock() # 添加
# self._observe_lock = asyncio.Lock() # 移除
# 初始化时加载最近的10条消息
initial_messages_cursor = (
db.messages.find({"chat_id": self.chat_id, "time": {"$lt": self.last_observe_time}})
.sort("time", -1) # 按时间倒序
.limit(10) # 获取最多10条
)
initial_messages = list(initial_messages_cursor)
initial_messages.reverse() # 恢复时间正序
self.talking_message = initial_messages # 将这些消息设为初始上下文
self.now_message_info = self.translate_message_list_to_str(self.talking_message) # 更新初始的 now_message_info
self.llm_summary = LLMRequest(
model=global_config.llm_observation, temperature=0.7, max_tokens=300, request_type="chat_observation"
@@ -73,139 +85,101 @@ class ChattingObservation(Observation):
return self.now_message_info
async def observe(self):
async with self._observe_lock: # 获取
# 查找新消息,最多获取 self.max_now_obs_len 条
new_messages_cursor = (
# async with self._observe_lock: # 移除
# 查找新消息,最多获取 self.max_now_obs_len 条
new_messages_cursor = (
db.messages.find({"chat_id": self.chat_id, "time": {"$gt": self.last_observe_time}})
.sort("time", -1) # 按时间倒序排序
.limit(self.max_now_obs_len) # 限制数量
)
new_messages = list(new_messages_cursor)
new_messages.reverse() # 反转列表,使消息按时间正序排列
if not new_messages:
# 如果没有获取到限制数量内的较新消息,可能仍然有更早的消息,但我们只关注最近的
# 检查是否有任何新消息(即使超出限制),以决定是否更新 last_observe_time
# 注意:这里的查询也可能与其他并发 observe 冲突,但锁保护了状态更新
# 由于外部已加锁,此处的并发冲突担忧不再需要
any_new_message = db.messages.find_one(
{"chat_id": self.chat_id, "time": {"$gt": self.last_observe_time}}
)
if not any_new_message:
return # 确实没有新消息
# 如果有超过限制的更早的新消息,仍然需要更新时间戳,防止重复获取旧消息
# 但不将它们加入 talking_message
latest_message_time_cursor = (
db.messages.find({"chat_id": self.chat_id, "time": {"$gt": self.last_observe_time}})
.sort("time", -1) # 按时间倒序排序
.limit(self.max_now_obs_len) # 限制数量
.sort("time", -1)
.limit(1)
)
new_messages = list(new_messages_cursor)
new_messages.reverse() # 反转列表,使消息按时间正序排列
latest_time_doc = next(latest_message_time_cursor, None)
if latest_time_doc:
# 确保只在严格大于时更新,避免因并发查询导致时间戳回退
if latest_time_doc["time"] > self.last_observe_time:
self.last_observe_time = latest_time_doc["time"]
return # 返回,因为我们只关心限制内的最新消息
if not new_messages:
# 如果没有获取到限制数量内的较新消息,可能仍然有更早的消息,但我们只关注最近的
# 检查是否有任何新消息(即使超出限制),以决定是否更新 last_observe_time
# 注意:这里的查询也可能与其他并发 observe 冲突,但锁保护了状态更新
any_new_message = db.messages.find_one(
{"chat_id": self.chat_id, "time": {"$gt": self.last_observe_time}}
)
if not any_new_message:
return # 确实没有新消息
# 如果有超过限制的更早的新消息,仍然需要更新时间戳,防止重复获取旧消息
# 但不将它们加入 talking_message
latest_message_time_cursor = (
db.messages.find({"chat_id": self.chat_id, "time": {"$gt": self.last_observe_time}})
.sort("time", -1)
.limit(1)
)
latest_time_doc = next(latest_message_time_cursor, None)
if latest_time_doc:
# 确保只在严格大于时更新,避免因并发查询导致时间戳回退
if latest_time_doc["time"] > self.last_observe_time:
self.last_observe_time = latest_time_doc["time"]
return # 返回,因为我们只关心限制内的最新消息
self.last_observe_time = new_messages[-1]["time"]
self.talking_message.extend(new_messages)
# 在持有锁的情况下,再次过滤,确保只处理真正新的消息
# 防止处理在等待锁期间已被其他协程处理的消息
truly_new_messages = [msg for msg in new_messages if msg["time"] > self.last_observe_time]
if not truly_new_messages:
logger.debug(
f"Chat {self.chat_id}: Fetched messages, but already processed by another concurrent observe call."
)
return # 所有获取的消息都已被处理
if len(self.talking_message) > self.max_now_obs_len:
try: # 使用 try...finally 仅用于可能的LLM调用错误处理
# 计算需要移除的消息数量,保留最新的 max_now_obs_len 条
messages_to_remove_count = len(self.talking_message) - self.max_now_obs_len
oldest_messages = self.talking_message[:messages_to_remove_count]
self.talking_message = self.talking_message[messages_to_remove_count:] # 保留后半部分,即最新的
oldest_messages_str = "\n".join(
[msg["detailed_plain_text"] for msg in oldest_messages if "detailed_plain_text" in msg]
) # 增加检查
oldest_timestamps = [msg["time"] for msg in oldest_messages]
# 如果获取到了 truly_new_messages (在限制内且时间戳大于上次记录)
self.last_observe_time = truly_new_messages[-1]["time"] # 更新时间戳为获取到的最新消息的时间
# 调用 LLM 总结主题
prompt = f"请总结以下聊天记录的主题:\n{oldest_messages_str}\n主题,用一句话概括包括人物事件和主要信息,不要分点:"
summary = "无法总结主题" # 默认值
try:
summary_result, _ = await self.llm_summary.generate_response_async(prompt)
if summary_result: # 确保结果不为空
summary = summary_result
except Exception as e:
logger.error(f"总结主题失败 for chat {self.chat_id}: {e}")
# 保留默认总结 "无法总结主题"
self.talking_message.extend(truly_new_messages)
mid_memory = {
"id": str(int(datetime.now().timestamp())),
"theme": summary,
"messages": oldest_messages, # 存储原始消息对象
"timestamps": oldest_timestamps,
"chat_id": self.chat_id,
"created_at": datetime.now().timestamp(),
}
# print(f"mid_memory{mid_memory}")
# 存入内存中的 mid_memorys
self.mid_memorys.append(mid_memory)
if len(self.mid_memorys) > self.max_mid_memory_len:
self.mid_memorys.pop(0) # 移除最旧的
# 将新消息转换为字符串格式 (此变量似乎未使用,暂时注释掉)
# new_messages_str = ""
# for msg in truly_new_messages:
# if "detailed_plain_text" in msg:
# new_messages_str += f"{msg['detailed_plain_text']}"
mid_memory_str = "之前聊天的内容概括是:\n"
for mid_memory_item in self.mid_memorys: # 重命名循环变量以示区分
time_diff = int((datetime.now().timestamp() - mid_memory_item["created_at"]) / 60)
mid_memory_str += f"距离现在{time_diff}分钟前(聊天记录id:{mid_memory_item['id']}){mid_memory_item['theme']}\n"
self.mid_memory_info = mid_memory_str
except Exception as e: # 将异常处理移至此处以覆盖整个总结过程
logger.error(f"处理和总结旧消息时出错 for chat {self.chat_id}: {e}")
traceback.print_exc() # 记录详细堆栈
# print(f"new_messages_str{new_messages_str}")
# print(f"处理后self.talking_message{self.talking_message}")
# 锁保证了这部分逻辑的原子性
if len(self.talking_message) > self.max_now_obs_len:
try: # 使用 try...finally 仅用于可能的LLM调用错误处理
# 计算需要移除的消息数量,保留最新的 max_now_obs_len 条
messages_to_remove_count = len(self.talking_message) - self.max_now_obs_len
oldest_messages = self.talking_message[:messages_to_remove_count]
self.talking_message = self.talking_message[messages_to_remove_count:] # 保留后半部分,即最新的
oldest_messages_str = "\n".join(
[msg["detailed_plain_text"] for msg in oldest_messages if "detailed_plain_text" in msg]
) # 增加检查
oldest_timestamps = [msg["time"] for msg in oldest_messages]
now_message_str = ""
# 使用 self.translate_message_list_to_str 更新当前聊天内容
now_message_str += self.translate_message_list_to_str(talking_message=self.talking_message)
self.now_message_info = now_message_str
# 调用 LLM 总结主题
prompt = f"请总结以下聊天记录的主题:\n{oldest_messages_str}\n主题,用一句话概括包括人物事件和主要信息,不要分点:"
summary = "无法总结主题" # 默认值
try:
summary_result, _ = await self.llm_summary.generate_response_async(prompt)
if summary_result: # 确保结果不为空
summary = summary_result
except Exception as e:
logger.error(f"总结主题失败 for chat {self.chat_id}: {e}")
# 保留默认总结 "无法总结主题"
mid_memory = {
"id": str(int(datetime.now().timestamp())),
"theme": summary,
"messages": oldest_messages, # 存储原始消息对象
"timestamps": oldest_timestamps,
"chat_id": self.chat_id,
"created_at": datetime.now().timestamp(),
}
# print(f"mid_memory{mid_memory}")
# 存入内存中的 mid_memorys
self.mid_memorys.append(mid_memory)
if len(self.mid_memorys) > self.max_mid_memory_len:
self.mid_memorys.pop(0) # 移除最旧的
mid_memory_str = "之前聊天的内容概括是:\n"
for mid_memory_item in self.mid_memorys: # 重命名循环变量以示区分
time_diff = int((datetime.now().timestamp() - mid_memory_item["created_at"]) / 60)
mid_memory_str += f"距离现在{time_diff}分钟前(聊天记录id:{mid_memory_item['id']}){mid_memory_item['theme']}\n"
self.mid_memory_info = mid_memory_str
except Exception as e: # 将异常处理移至此处以覆盖整个总结过程
logger.error(f"处理和总结旧消息时出错 for chat {self.chat_id}: {e}")
traceback.print_exc() # 记录详细堆栈
# print(f"处理后self.talking_message{self.talking_message}")
now_message_str = ""
# 使用 self.translate_message_list_to_str 更新当前聊天内容
now_message_str += self.translate_message_list_to_str(talking_message=self.talking_message)
self.now_message_info = now_message_str
logger.debug(
f"Chat {self.chat_id} - 压缩早期记忆:{self.mid_memory_info}\n现在聊天内容:{self.now_message_info}"
)
# 锁在退出 async with 块时自动释放
async def update_talking_summary(self, new_messages_str):
prompt = ""
# prompt += f"{personality_info}"
prompt += f"你的名字叫:{self.name}\n,标识'{self.name}'的都是你自己说的话"
prompt += f"你正在参与一个qq群聊的讨论你记得这个群之前在聊的内容是{self.observe_info}\n"
prompt += f"现在群里的群友们产生了新的讨论,有了新的发言,具体内容如下:{new_messages_str}\n"
prompt += """以上是群里在进行的聊天,请你对这个聊天内容进行总结,总结内容要包含聊天的大致内容,目前最新讨论的话题
以及聊天中的一些重要信息,记得不要分点,精简的概括成一段文本\n"""
prompt += "总结概括:"
try:
updated_observe_info, reasoning_content = await self.llm_summary.generate_response_async(prompt)
except Exception as e:
print(f"获取总结失败: {e}")
updated_observe_info = ""
return updated_observe_info
# print(f"prompt{prompt}")
# print(f"self.observe_info{self.observe_info}")
logger.debug(
f"Chat {self.chat_id} - 压缩早期记忆:{self.mid_memory_info}\n现在聊天内容:{self.now_message_info}"
)
@staticmethod
def translate_message_list_to_str(talking_message):

View File

@@ -7,7 +7,6 @@ import time
from typing import Optional
from datetime import datetime
import traceback
from src.plugins.chat.message import UserInfo
from src.plugins.chat.utils import parse_text_timestamps
# from src.plugins.schedule.schedule_generator import bot_schedule
@@ -21,7 +20,6 @@ from src.individuality.individuality import Individuality
import random
from src.plugins.chat.chat_stream import ChatStream
from src.plugins.person_info.relationship_manager import relationship_manager
from src.plugins.chat.utils import get_recent_group_speaker
from ..plugins.utils.prompt_builder import Prompt, global_prompt_manager
subheartflow_config = LogConfig(
@@ -39,40 +37,16 @@ def init_prompt():
# prompt += "{prompt_schedule}\n"
# prompt += "{relation_prompt_all}\n"
prompt += "{prompt_personality}\n"
prompt += "刚刚你的想法是{current_thinking_info}可以适当转换话题\n"
prompt += "刚刚你的想法是\n{current_thinking_info}\n可以适当转换话题\n"
prompt += "-----------------------------------\n"
prompt += "现在是{time_now}你正在上网和qq群里的网友们聊天群里正在聊的话题是\n{chat_observe_info}\n"
prompt += "你现在{mood_info}\n"
# prompt += "你注意到{sender_name}刚刚说:{message_txt}\n"
prompt += "思考时可以想想如何对群聊内容进行回复,关注新话题,大家正在说的话才是聊天的主题。回复的要求是:平淡一些,简短一些,说中文,尽量不要说你说过的话。如果你要回复,最好只回复一个人的一个话题\n"
prompt += "现在请你根据刚刚的想法继续思考,思考时可以想想如何对群聊内容进行回复,关注新话题,大家正在说的话才是聊天的主题。\n"
prompt += "回复的要求是:平淡一些,简短一些,说中文,尽量不要说你说过的话。如果你要回复,最好只回复一个人的一个话题\n"
prompt += "请注意不要输出多余内容(包括前后缀,冒号和引号,括号, 表情,等),不要带有括号和动作描写"
prompt += "记得结合上述的消息,不要分点输出,生成内心想法,文字不要浮夸,注意{bot_name}指的就是你。"
Prompt(prompt, "sub_heartflow_prompt_before")
prompt = ""
# prompt += f"你现在正在做的事情是:{schedule_info}\n"
prompt += "{extra_info}\n"
prompt += "{prompt_personality}\n"
prompt += "现在是{time_now}你正在上网和qq群里的网友们聊天群里正在聊的话题是\n{chat_observe_info}\n"
prompt += "刚刚你的想法是{current_thinking_info}"
prompt += "你现在看到了网友们发的新消息:{message_new_info}\n"
prompt += "你刚刚回复了群友们:{reply_info}"
prompt += "你现在{mood_info}"
prompt += "现在你接下去继续思考,产生新的想法,记得保留你刚刚的想法,不要分点输出,输出连贯的内心独白"
prompt += "不要太长,但是记得结合上述的消息,要记得你的人设,关注聊天和新内容,关注你回复的内容,不要思考太多:"
Prompt(prompt, "sub_heartflow_prompt_after")
# prompt += f"你现在正在做的事情是:{schedule_info}\n"
prompt += "{extra_info}\n"
prompt += "{prompt_personality}\n"
prompt += "现在是{time_now}你正在上网和qq群里的网友们聊天群里正在聊的话题是\n{chat_observe_info}\n"
prompt += "刚刚你的想法是{current_thinking_info}"
prompt += "你现在看到了网友们发的新消息:{message_new_info}\n"
# prompt += "你刚刚回复了群友们:{reply_info}"
prompt += "你现在{mood_info}"
prompt += "现在你接下去继续思考,产生新的想法,记得保留你刚刚的想法,不要分点输出,输出连贯的内心独白"
prompt += "不要思考太多,不要输出多余内容(包括前后缀,冒号和引号,括号, 表情,等),不要带有括号和动作描写"
prompt += "记得结合上述的消息,生成内心想法,文字不要浮夸,注意{bot_name}指的就是你。"
Prompt(prompt, "sub_heartflow_prompt_after_observe")
class CurrentState:
@@ -97,7 +71,7 @@ class SubHeartflow:
self.llm_model = LLMRequest(
model=global_config.llm_sub_heartflow,
temperature=global_config.llm_sub_heartflow["temp"],
max_tokens=600,
max_tokens=800,
request_type="sub_heart_flow",
)
@@ -156,13 +130,6 @@ class SubHeartflow:
# 这个后台循环现在主要负责检查是否需要自我销毁
# 不再主动进行思考或状态更新,这些由 HeartFC_Chat 驱动
# 检查是否需要冻结(这个逻辑可能需要重新审视,因为激活状态现在由外部驱动)
# if current_time - self.last_reply_time > global_config.sub_heart_flow_freeze_time:
# self.is_active = False
# else:
# self.is_active = True
# self.last_active_time = current_time # 由外部调用(如 thinking更新
# 检查是否超过指定时间没有激活 (例如,没有被调用进行思考)
if current_time - self.last_active_time > global_config.sub_heart_flow_stop_time: # 例如 5 分钟
logger.info(
@@ -173,11 +140,6 @@ class SubHeartflow:
# heartflow.remove_subheartflow(self.subheartflow_id) # 假设有这样的方法
break # 退出循环以停止任务
# 不再需要内部驱动的状态更新和思考
# self.current_state.update_current_state_info()
# await self.do_a_thinking()
# await self.judge_willing()
await asyncio.sleep(global_config.sub_heart_flow_update_interval) # 定期检查销毁条件
async def ensure_observed(self):
@@ -275,13 +237,16 @@ class SubHeartflow:
prompt = await relationship_manager.convert_all_person_sign_to_person_name(prompt)
prompt = parse_text_timestamps(prompt, mode="lite")
logger.debug(f"[{self.subheartflow_id}] Thinking Prompt:\n{prompt}")
logger.debug(f"[{self.subheartflow_id}] 心流思考prompt:\n{prompt}\n")
try:
response, reasoning_content = await self.llm_model.generate_response_async(prompt)
logger.debug(f"[{self.subheartflow_id}] 心流思考结果:\n{response}\n")
if not response: # 如果 LLM 返回空,给一个默认想法
response = "(不知道该想些什么...)"
logger.warning(f"[{self.subheartflow_id}] LLM returned empty response for thinking.")
logger.warning(f"[{self.subheartflow_id}] LLM 返回空结果,思考失败。")
except Exception as e:
logger.error(f"[{self.subheartflow_id}] 内心独白获取失败: {e}")
response = "(思考时发生错误...)" # 错误时的默认想法
@@ -290,186 +255,14 @@ class SubHeartflow:
# self.current_mind 已经在 update_current_mind 中更新
logger.info(f"[{self.subheartflow_id}] 思考前脑内状态:{self.current_mind}")
# logger.info(f"[{self.subheartflow_id}] 思考前脑内状态:{self.current_mind}")
return self.current_mind, self.past_mind
async def do_thinking_after_observe(
self, message_txt: str, sender_info: UserInfo, chat_stream: ChatStream, extra_info: str, obs_id: int = None
):
current_thinking_info = self.current_mind
mood_info = self.current_state.mood
# mood_info = "你很生气,很愤怒"
observation = self.observations[0]
if obs_id:
# print(f"11111111111有id,开始获取观察信息{obs_id}")
chat_observe_info = observation.get_observe_info(obs_id)
else:
chat_observe_info = observation.get_observe_info()
extra_info_prompt = ""
for tool_name, tool_data in extra_info.items():
extra_info_prompt += f"{tool_name} 相关信息:\n"
for item in tool_data:
extra_info_prompt += f"- {item['name']}: {item['content']}\n"
# 开始构建prompt
prompt_personality = f"你的名字是{self.bot_name},你"
# person
individuality = Individuality.get_instance()
personality_core = individuality.personality.personality_core
prompt_personality += personality_core
personality_sides = individuality.personality.personality_sides
random.shuffle(personality_sides)
prompt_personality += f",{personality_sides[0]}"
identity_detail = individuality.identity.identity_detail
random.shuffle(identity_detail)
prompt_personality += f",{identity_detail[0]}"
# 关系
who_chat_in_group = [
(chat_stream.user_info.platform, chat_stream.user_info.user_id, chat_stream.user_info.user_nickname)
]
who_chat_in_group += get_recent_group_speaker(
chat_stream.stream_id,
(chat_stream.user_info.platform, chat_stream.user_info.user_id),
limit=global_config.MAX_CONTEXT_SIZE,
)
relation_prompt = ""
for person in who_chat_in_group:
relation_prompt += await relationship_manager.build_relationship_info(person)
# relation_prompt_all = (
# f"{relation_prompt}关系等级越大,关系越好,请分析聊天记录,"
# f"根据你和说话者{sender_name}的关系和态度进行回复,明确你的立场和情感。"
# )
relation_prompt_all = (await global_prompt_manager.get_prompt_async("relationship_prompt")).format(
relation_prompt, sender_info.user_nickname
)
sender_name_sign = (
f"<{chat_stream.platform}:{sender_info.user_id}:{sender_info.user_nickname}:{sender_info.user_cardname}>"
)
time_now = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
prompt = (await global_prompt_manager.get_prompt_async("sub_heartflow_prompt_after_observe")).format(
extra_info_prompt,
# prompt_schedule,
relation_prompt_all,
prompt_personality,
current_thinking_info,
time_now,
chat_observe_info,
mood_info,
sender_name_sign,
message_txt,
self.bot_name,
)
prompt = await relationship_manager.convert_all_person_sign_to_person_name(prompt)
prompt = parse_text_timestamps(prompt, mode="lite")
try:
response, reasoning_content = await self.llm_model.generate_response_async(prompt)
except Exception as e:
logger.error(f"回复前内心独白获取失败: {e}")
response = ""
self.update_current_mind(response)
self.current_mind = response
logger.info(f"prompt:\n{prompt}\n")
logger.info(f"麦麦的思考前脑内状态:{self.current_mind}")
return self.current_mind, self.past_mind
# async def do_thinking_after_reply(self, reply_content, chat_talking_prompt, extra_info):
# # print("麦麦回复之后脑袋转起来了")
# # 开始构建prompt
# prompt_personality = f"你的名字是{self.bot_name},你"
# # person
# individuality = Individuality.get_instance()
# personality_core = individuality.personality.personality_core
# prompt_personality += personality_core
# extra_info_prompt = ""
# for tool_name, tool_data in extra_info.items():
# extra_info_prompt += f"{tool_name} 相关信息:\n"
# for item in tool_data:
# extra_info_prompt += f"- {item['name']}: {item['content']}\n"
# personality_sides = individuality.personality.personality_sides
# random.shuffle(personality_sides)
# prompt_personality += f",{personality_sides[0]}"
# identity_detail = individuality.identity.identity_detail
# random.shuffle(identity_detail)
# prompt_personality += f",{identity_detail[0]}"
# current_thinking_info = self.current_mind
# mood_info = self.current_state.mood
# observation = self.observations[0]
# chat_observe_info = observation.observe_info
# message_new_info = chat_talking_prompt
# reply_info = reply_content
# time_now = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
# prompt = (await global_prompt_manager.get_prompt_async("sub_heartflow_prompt_after")).format(
# extra_info_prompt,
# prompt_personality,
# time_now,
# chat_observe_info,
# current_thinking_info,
# message_new_info,
# reply_info,
# mood_info,
# )
# prompt = await relationship_manager.convert_all_person_sign_to_person_name(prompt)
# prompt = parse_text_timestamps(prompt, mode="lite")
# try:
# response, reasoning_content = await self.llm_model.generate_response_async(prompt)
# except Exception as e:
# logger.error(f"回复后内心独白获取失败: {e}")
# response = ""
# self.update_current_mind(response)
# self.current_mind = response
# logger.info(f"麦麦回复后的脑内状态:{self.current_mind}")
# self.last_reply_time = time.time()
def update_current_mind(self, response):
self.past_mind.append(self.current_mind)
self.current_mind = response
async def check_reply_trigger(self) -> bool:
"""根据观察到的信息和内部状态,判断是否应该触发一次回复。
TODO: 实现具体的判断逻辑。
例如:检查 self.observations[0].now_message_info 是否包含提及、问题,
或者 self.current_mind 中是否包含强烈的回复意图等。
"""
# Placeholder: 目前始终返回 False需要后续实现
logger.trace(f"[{self.subheartflow_id}] check_reply_trigger called. (Logic Pending)")
# --- 实现触发逻辑 --- #
# 示例:如果观察到的最新消息包含自己的名字,则有一定概率触发
# observation = self._get_primary_observation()
# if observation and self.bot_name in observation.now_message_info[-100:]: # 检查最后100个字符
# if random.random() < 0.3: # 30% 概率触发
# logger.info(f"[{self.subheartflow_id}] Triggering reply based on mention.")
# return True
# ------------------ #
return False # 默认不触发
init_prompt()
# subheartflow = SubHeartflow()