This commit is contained in:
SengokuCola
2025-07-09 02:09:39 +08:00
6 changed files with 29 additions and 23 deletions

View File

@@ -131,9 +131,7 @@ class HeartFCMessageReceiver:
picid_pattern = r"\[picid:([^\]]+)\]" picid_pattern = r"\[picid:([^\]]+)\]"
processed_plain_text = re.sub(picid_pattern, "[图片]", message.processed_plain_text) processed_plain_text = re.sub(picid_pattern, "[图片]", message.processed_plain_text)
logger.info( logger.info(f"[{mes_name}]{userinfo.user_nickname}:{processed_plain_text}")
f"[{mes_name}]{userinfo.user_nickname}:{processed_plain_text}"
)
logger.debug(f"[{mes_name}][当前时段回复频率: {current_talk_frequency}]") logger.debug(f"[{mes_name}][当前时段回复频率: {current_talk_frequency}]")

View File

@@ -596,7 +596,9 @@ class NormalChat:
timeout_source = "".join(timeout_details) timeout_source = "".join(timeout_details)
logger.warning(f"[{self.stream_name}] {timeout_source} 任务超时 ({global_config.chat.thinking_timeout}秒),正在取消相关任务...") logger.warning(
f"[{self.stream_name}] {timeout_source} 任务超时 ({global_config.chat.thinking_timeout}秒),正在取消相关任务..."
)
# print(f"111{self.timeout_count}") # print(f"111{self.timeout_count}")
self.timeout_count += 1 self.timeout_count += 1
if self.timeout_count > 5: if self.timeout_count > 5:

View File

@@ -24,7 +24,6 @@ class RelationshipManager:
request_type="relationship", # 用于动作规划 request_type="relationship", # 用于动作规划
) )
@staticmethod @staticmethod
async def is_known_some_one(platform, user_id): async def is_known_some_one(platform, user_id):
"""判断是否认识某人""" """判断是否认识某人"""
@@ -111,7 +110,6 @@ class RelationshipManager:
return relation_prompt return relation_prompt
async def update_person_impression(self, person_id, timestamp, bot_engaged_messages=None): async def update_person_impression(self, person_id, timestamp, bot_engaged_messages=None):
"""更新用户印象 """更新用户印象
@@ -171,7 +169,7 @@ class RelationshipManager:
user_count += 1 user_count += 1
name_mapping[replace_person_name] = f"用户{current_user}{user_count if user_count > 1 else ''}" name_mapping[replace_person_name] = f"用户{current_user}{user_count if user_count > 1 else ''}"
current_user = chr(ord(current_user) + 1) current_user = chr(ord(current_user) + 1)
readable_messages = build_readable_messages( readable_messages = build_readable_messages(
messages=user_messages, replace_bot_name=True, timestamp_mode="normal_no_YMD", truncate=True messages=user_messages, replace_bot_name=True, timestamp_mode="normal_no_YMD", truncate=True
) )
@@ -341,7 +339,7 @@ class RelationshipManager:
await person_info_manager.update_one_field( await person_info_manager.update_one_field(
person_id, "points", json.dumps(current_points, ensure_ascii=False, indent=None) person_id, "points", json.dumps(current_points, ensure_ascii=False, indent=None)
) )
await person_info_manager.update_one_field(person_id, "know_times", know_times + 1) await person_info_manager.update_one_field(person_id, "know_times", know_times + 1)
know_since = await person_info_manager.get_value(person_id, "know_since") or 0 know_since = await person_info_manager.get_value(person_id, "know_since") or 0
if know_since == 0: if know_since == 0:
@@ -349,17 +347,16 @@ class RelationshipManager:
await person_info_manager.update_one_field(person_id, "last_know", timestamp) await person_info_manager.update_one_field(person_id, "last_know", timestamp)
logger.debug(f"{person_name} 的印象更新完成") logger.debug(f"{person_name} 的印象更新完成")
async def _update_impression(self, person_id, current_points, timestamp): async def _update_impression(self, person_id, current_points, timestamp):
# 获取现有forgotten_points # 获取现有forgotten_points
person_info_manager = get_person_info_manager() person_info_manager = get_person_info_manager()
person_name = await person_info_manager.get_value(person_id, "person_name") person_name = await person_info_manager.get_value(person_id, "person_name")
nickname = await person_info_manager.get_value(person_id, "nickname") nickname = await person_info_manager.get_value(person_id, "nickname")
know_times = await person_info_manager.get_value(person_id, "know_times") or 0 know_times = await person_info_manager.get_value(person_id, "know_times") or 0
attitude = await person_info_manager.get_value(person_id, "attitude") or 50 attitude = await person_info_manager.get_value(person_id, "attitude") or 50
# 根据熟悉度,调整印象和简短印象的最大长度 # 根据熟悉度,调整印象和简短印象的最大长度
if know_times > 300: if know_times > 300:
max_impression_length = 2000 max_impression_length = 2000
@@ -376,14 +373,12 @@ class RelationshipManager:
else: else:
max_impression_length = 100 max_impression_length = 100
max_short_impression_length = 50 max_short_impression_length = 50
# 根据好感度,调整印象和简短印象的最大长度 # 根据好感度,调整印象和简短印象的最大长度
attitude_multiplier = (abs(100-attitude) / 100) + 1 attitude_multiplier = (abs(100 - attitude) / 100) + 1
max_impression_length = max_impression_length * attitude_multiplier max_impression_length = max_impression_length * attitude_multiplier
max_short_impression_length = max_short_impression_length * attitude_multiplier max_short_impression_length = max_short_impression_length * attitude_multiplier
forgotten_points = await person_info_manager.get_value(person_id, "forgotten_points") or [] forgotten_points = await person_info_manager.get_value(person_id, "forgotten_points") or []
if isinstance(forgotten_points, str): if isinstance(forgotten_points, str):
try: try:
@@ -553,9 +548,8 @@ class RelationshipManager:
await person_info_manager.update_one_field( await person_info_manager.update_one_field(
person_id, "forgotten_points", json.dumps(forgotten_points, ensure_ascii=False, indent=None) person_id, "forgotten_points", json.dumps(forgotten_points, ensure_ascii=False, indent=None)
) )
return current_points
return current_points
def calculate_time_weight(self, point_time: str, current_time: str) -> float: def calculate_time_weight(self, point_time: str, current_time: str) -> float:
"""计算基于时间的权重系数""" """计算基于时间的权重系数"""

View File

@@ -103,7 +103,6 @@ class NoReplyAction(BaseAction):
logger.info(f"{self.log_prefix} 选择不回复(第{count}次),开始摸鱼,原因: {reason}") logger.info(f"{self.log_prefix} 选择不回复(第{count}次),开始摸鱼,原因: {reason}")
# 进入等待状态 # 进入等待状态
while True: while True:
current_time = time.time() current_time = time.time()
@@ -387,7 +386,9 @@ class NoReplyAction(BaseAction):
f"{self.log_prefix} 发言过多(超过{over_count}条)随机决定跳过此次LLM判断(概率{skip_probability * 100:.0f}%)" f"{self.log_prefix} 发言过多(超过{over_count}条)随机决定跳过此次LLM判断(概率{skip_probability * 100:.0f}%)"
) )
logger.info(f"{self.log_prefix} 过去10分钟发言{bot_message_count}条,超过阈值{talk_frequency_threshold},添加疲惫提示") logger.info(
f"{self.log_prefix} 过去10分钟发言{bot_message_count}条,超过阈值{talk_frequency_threshold},添加疲惫提示"
)
return frequency_block, should_skip_judge return frequency_block, should_skip_judge
else: else:
# 回复次数少时的正向提示 # 回复次数少时的正向提示
@@ -398,7 +399,9 @@ class NoReplyAction(BaseAction):
elif under_count >= talk_frequency_threshold * 0.5: elif under_count >= talk_frequency_threshold * 0.5:
frequency_block = "你感觉状态不错。\n" frequency_block = "你感觉状态不错。\n"
logger.info(f"{self.log_prefix} 过去10分钟发言{bot_message_count}条,未超过阈值{talk_frequency_threshold},添加正向提示") logger.info(
f"{self.log_prefix} 过去10分钟发言{bot_message_count}条,未超过阈值{talk_frequency_threshold},添加正向提示"
)
return frequency_block, False return frequency_block, False
except Exception as e: except Exception as e:

View File

@@ -59,6 +59,11 @@ class TTSAction(BaseAction):
# 发送TTS消息 # 发送TTS消息
await self.send_custom(message_type="tts_text", content=processed_text) await self.send_custom(message_type="tts_text", content=processed_text)
# 记录动作信息
await self.store_action_info(
action_build_into_prompt=True, action_prompt_display="已经发送了语音消息。", action_done=True
)
logger.info(f"{self.log_prefix} TTS动作执行成功文本长度: {len(processed_text)}") logger.info(f"{self.log_prefix} TTS动作执行成功文本长度: {len(processed_text)}")
return True, "TTS动作执行成功" return True, "TTS动作执行成功"

View File

@@ -187,7 +187,11 @@ class ToolExecutor:
tool_results.append(tool_info) tool_results.append(tool_info)
logger.info(f"{self.log_prefix}工具{tool_name}执行成功,类型: {tool_info['type']}") logger.info(f"{self.log_prefix}工具{tool_name}执行成功,类型: {tool_info['type']}")
logger.debug(f"{self.log_prefix}工具{tool_name}结果内容: {tool_info['content'][:200]}...") content = tool_info["content"]
if not isinstance(content, (str, list, tuple)):
content = str(content)
preview = content[:200]
logger.debug(f"{self.log_prefix}工具{tool_name}结果内容: {preview}...")
except Exception as e: except Exception as e:
logger.error(f"{self.log_prefix}工具{tool_name}执行失败: {e}") logger.error(f"{self.log_prefix}工具{tool_name}执行失败: {e}")