Merge branch 'MaiM-with-u:dev' into dev
This commit is contained in:
@@ -30,7 +30,7 @@ class Heartflow:
|
||||
# 注册子心流
|
||||
self.subheartflows[subheartflow_id] = new_subflow
|
||||
heartflow_name = get_chat_manager().get_stream_name(subheartflow_id) or subheartflow_id
|
||||
logger.info(f"[{heartflow_name}] 开始接收消息")
|
||||
logger.debug(f"[{heartflow_name}] 开始接收消息")
|
||||
|
||||
return new_subflow
|
||||
except Exception as e:
|
||||
|
||||
@@ -119,7 +119,8 @@ class MemoryActivator:
|
||||
valid_keywords=keywords, max_memory_num=3, max_memory_length=2, max_depth=3
|
||||
)
|
||||
|
||||
logger.info(f"当前记忆关键词: {self.cached_keywords} 。获取到的记忆: {related_memory}")
|
||||
logger.debug(f"当前记忆关键词: {self.cached_keywords} ")
|
||||
logger.debug(f"获取到的记忆: {related_memory}")
|
||||
|
||||
# 激活时,所有已有记忆的duration+1,达到3则移除
|
||||
for m in self.running_memory[:]:
|
||||
|
||||
@@ -166,6 +166,7 @@ class ChatBot:
|
||||
message_data["message_info"]["group_info"]["group_id"] = str(
|
||||
message_data["message_info"]["group_info"]["group_id"]
|
||||
)
|
||||
if message_data["message_info"].get("user_info") is not None:
|
||||
message_data["message_info"]["user_info"]["user_id"] = str(
|
||||
message_data["message_info"]["user_info"]["user_id"]
|
||||
)
|
||||
|
||||
@@ -469,9 +469,6 @@ class NormalChat:
|
||||
) -> Optional[list]:
|
||||
"""生成普通回复"""
|
||||
try:
|
||||
logger.info(
|
||||
f"NormalChat思考:{message.processed_plain_text[:30] + '...' if len(message.processed_plain_text) > 30 else message.processed_plain_text}"
|
||||
)
|
||||
person_info_manager = get_person_info_manager()
|
||||
person_id = person_info_manager.get_person_id(
|
||||
message.chat_stream.user_info.platform, message.chat_stream.user_info.user_id
|
||||
@@ -491,10 +488,6 @@ class NormalChat:
|
||||
logger.info(f"对 {message.processed_plain_text} 的回复生成失败")
|
||||
return None
|
||||
|
||||
content = " ".join([item[1] for item in reply_set if item[0] == "text"])
|
||||
if content:
|
||||
logger.info(f"{global_config.bot.nickname}的备选回复是:{content}")
|
||||
|
||||
return reply_set
|
||||
|
||||
except Exception as e:
|
||||
@@ -532,7 +525,15 @@ class NormalChat:
|
||||
reasoning = plan_result["action_result"]["reasoning"]
|
||||
is_parallel = plan_result["action_result"].get("is_parallel", False)
|
||||
|
||||
logger.info(f"[{self.stream_name}] Planner决策: {action_type}, 理由: {reasoning}, 并行执行: {is_parallel}")
|
||||
if action_type == "no_action":
|
||||
logger.info(f"[{self.stream_name}] {global_config.bot.nickname} 决定进行回复")
|
||||
elif is_parallel:
|
||||
logger.info(
|
||||
f"[{self.stream_name}] {global_config.bot.nickname} 决定进行回复, 同时执行{action_type}动作"
|
||||
)
|
||||
else:
|
||||
logger.info(f"[{self.stream_name}] {global_config.bot.nickname} 决定执行{action_type}动作")
|
||||
|
||||
self.action_type = action_type # 更新实例属性
|
||||
self.is_parallel_action = is_parallel # 新增:保存并行执行标志
|
||||
|
||||
@@ -623,18 +624,23 @@ class NormalChat:
|
||||
elif plan_result:
|
||||
logger.debug(f"[{self.stream_name}] 额外动作处理完成: {self.action_type}")
|
||||
|
||||
if response_set:
|
||||
content = " ".join([item[1] for item in response_set if item[0] == "text"])
|
||||
|
||||
if not response_set or (
|
||||
self.enable_planner and self.action_type not in ["no_action"] and not self.is_parallel_action
|
||||
):
|
||||
if not response_set:
|
||||
logger.info(f"[{self.stream_name}] 模型未生成回复内容")
|
||||
logger.warning(f"[{self.stream_name}] 模型未生成回复内容")
|
||||
elif self.enable_planner and self.action_type not in ["no_action"] and not self.is_parallel_action:
|
||||
logger.info(f"[{self.stream_name}] 模型选择其他动作(非并行动作)")
|
||||
logger.info(
|
||||
f"[{self.stream_name}] {global_config.bot.nickname} 原本想要回复:{content},但选择执行{self.action_type},不发表回复"
|
||||
)
|
||||
# 如果模型未生成回复,移除思考消息
|
||||
await self._cleanup_thinking_message_by_id(thinking_id)
|
||||
return False
|
||||
|
||||
# logger.info(f"[{self.stream_name}] 回复内容: {response_set}")
|
||||
logger.info(f"[{self.stream_name}] {global_config.bot.nickname} 决定的回复内容: {content}")
|
||||
|
||||
if self._disabled:
|
||||
logger.info(f"[{self.stream_name}] 已停用,忽略 normal_response。")
|
||||
|
||||
@@ -96,7 +96,7 @@ class ActionManager:
|
||||
f"从插件系统加载Action组件: {action_name} (插件: {getattr(action_info, 'plugin_name', 'unknown')})"
|
||||
)
|
||||
|
||||
logger.info(f"从插件系统加载了 {len(action_components)} 个Action组件")
|
||||
logger.info(f"加载了 {len(action_components)} 个Action动作")
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"从插件系统加载Action组件失败: {e}")
|
||||
|
||||
@@ -124,6 +124,11 @@ class ActionPlanner:
|
||||
logger.info(f"{self.log_prefix}规划器原始响应: {llm_content}")
|
||||
if reasoning_content:
|
||||
logger.info(f"{self.log_prefix}规划器推理: {reasoning_content}")
|
||||
else:
|
||||
logger.debug(f"{self.log_prefix}规划器原始提示词: {prompt}")
|
||||
logger.debug(f"{self.log_prefix}规划器原始响应: {llm_content}")
|
||||
if reasoning_content:
|
||||
logger.debug(f"{self.log_prefix}规划器推理: {reasoning_content}")
|
||||
|
||||
except Exception as req_e:
|
||||
logger.error(f"{self.log_prefix}LLM 请求执行失败: {req_e}")
|
||||
|
||||
@@ -188,7 +188,7 @@ class DefaultReplyer:
|
||||
}
|
||||
for key, value in reply_data.items():
|
||||
if not value:
|
||||
logger.info(f"{self.log_prefix} 回复数据跳过{key},生成回复时将忽略。")
|
||||
logger.debug(f"{self.log_prefix} 回复数据跳过{key},生成回复时将忽略。")
|
||||
|
||||
# 3. 构建 Prompt
|
||||
with Timer("构建Prompt", {}): # 内部计时器,可选保留
|
||||
@@ -218,11 +218,13 @@ class DefaultReplyer:
|
||||
)
|
||||
|
||||
if global_config.debug.show_prompt:
|
||||
logger.info(f"{self.log_prefix}Prompt:\n{prompt}\n")
|
||||
logger.info(f"{self.log_prefix}\n{prompt}\n")
|
||||
else:
|
||||
logger.debug(f"{self.log_prefix}\n{prompt}\n")
|
||||
|
||||
content, (reasoning_content, model_name) = await express_model.generate_response_async(prompt)
|
||||
|
||||
logger.info(f"最终回复: {content}")
|
||||
logger.debug(f"replyer生成内容: {content}")
|
||||
|
||||
except Exception as llm_e:
|
||||
# 精简报错信息
|
||||
@@ -331,7 +333,7 @@ class DefaultReplyer:
|
||||
)
|
||||
|
||||
if selected_expressions:
|
||||
logger.info(f"{self.log_prefix} 使用处理器选中的{len(selected_expressions)}个表达方式")
|
||||
logger.debug(f"{self.log_prefix} 使用处理器选中的{len(selected_expressions)}个表达方式")
|
||||
for expr in selected_expressions:
|
||||
if isinstance(expr, dict) and "situation" in expr and "style" in expr:
|
||||
expr_type = expr.get("type", "style")
|
||||
|
||||
@@ -322,7 +322,7 @@ MODULE_COLORS = {
|
||||
"main": "\033[1;97m", # 亮白色+粗体 (主程序)
|
||||
"api": "\033[92m", # 亮绿色
|
||||
"emoji": "\033[92m", # 亮绿色
|
||||
"chat": "\033[94m", # 亮蓝色
|
||||
"chat": "\033[92m", # 亮蓝色
|
||||
"config": "\033[93m", # 亮黄色
|
||||
"common": "\033[95m", # 亮紫色
|
||||
"tools": "\033[96m", # 亮青色
|
||||
@@ -346,10 +346,7 @@ MODULE_COLORS = {
|
||||
# 聊天相关模块
|
||||
"normal_chat": "\033[38;5;81m", # 亮蓝绿色
|
||||
"normal_chat_response": "\033[38;5;123m", # 青绿色
|
||||
"normal_chat_action_modifier": "\033[38;5;111m", # 蓝色
|
||||
"normal_chat_planner": "\033[38;5;75m", # 浅蓝色
|
||||
"heartflow": "\033[38;5;213m", # 粉色
|
||||
"heartflow_utils": "\033[38;5;219m", # 浅粉色
|
||||
"sub_heartflow": "\033[38;5;207m", # 粉紫色
|
||||
"subheartflow_manager": "\033[38;5;201m", # 深粉色
|
||||
"background_tasks": "\033[38;5;240m", # 灰色
|
||||
|
||||
@@ -140,7 +140,7 @@ class RelationshipBuilder:
|
||||
segments.append(new_segment)
|
||||
|
||||
person_name = get_person_info_manager().get_value_sync(person_id, "person_name") or person_id
|
||||
logger.info(
|
||||
logger.debug(
|
||||
f"{self.log_prefix} 眼熟用户 {person_name} 在 {time.strftime('%H:%M:%S', time.localtime(potential_start_time))} - {time.strftime('%H:%M:%S', time.localtime(message_time))} 之间有 {new_segment['message_count']} 条消息"
|
||||
)
|
||||
self._save_cache()
|
||||
@@ -187,7 +187,9 @@ class RelationshipBuilder:
|
||||
segments.append(new_segment)
|
||||
person_info_manager = get_person_info_manager()
|
||||
person_name = person_info_manager.get_value_sync(person_id, "person_name") or person_id
|
||||
logger.info(f"{self.log_prefix} 重新眼熟用户 {person_name} 创建新消息段(超过10条消息间隔): {new_segment}")
|
||||
logger.debug(
|
||||
f"{self.log_prefix} 重新眼熟用户 {person_name} 创建新消息段(超过10条消息间隔): {new_segment}"
|
||||
)
|
||||
|
||||
self._save_cache()
|
||||
|
||||
@@ -384,7 +386,7 @@ class RelationshipBuilder:
|
||||
total_message_count = self._get_total_message_count(person_id)
|
||||
if total_message_count >= 45:
|
||||
users_to_build_relationship.append(person_id)
|
||||
logger.info(
|
||||
logger.debug(
|
||||
f"{self.log_prefix} 用户 {person_id} 满足关系构建条件,总消息数:{total_message_count},消息段数:{len(segments)}"
|
||||
)
|
||||
elif total_message_count > 0:
|
||||
@@ -422,7 +424,7 @@ class RelationshipBuilder:
|
||||
|
||||
# 获取该段的消息(包含边界)
|
||||
segment_messages = get_raw_msg_by_timestamp_with_chat_inclusive(self.chat_id, start_time, end_time)
|
||||
logger.info(
|
||||
logger.debug(
|
||||
f"消息段 {i + 1}: {start_date} - {time.strftime('%Y-%m-%d %H:%M', time.localtime(end_time))}, 消息数: {len(segment_messages)}"
|
||||
)
|
||||
|
||||
@@ -450,7 +452,7 @@ class RelationshipBuilder:
|
||||
# 按时间排序所有消息(包括间隔标识)
|
||||
processed_messages.sort(key=lambda x: x["time"])
|
||||
|
||||
logger.info(f"为 {person_id} 获取到总共 {len(processed_messages)} 条消息(包含间隔标识)用于印象更新")
|
||||
logger.debug(f"为 {person_id} 获取到总共 {len(processed_messages)} 条消息(包含间隔标识)用于印象更新")
|
||||
relationship_manager = get_relationship_manager()
|
||||
|
||||
# 调用原有的更新方法
|
||||
|
||||
@@ -11,7 +11,7 @@ from src.plugin_system.apis import emoji_api
|
||||
from src.plugins.built_in.core_actions.no_reply import NoReplyAction
|
||||
|
||||
|
||||
logger = get_logger("core_actions")
|
||||
logger = get_logger("emoji")
|
||||
|
||||
|
||||
class EmojiAction(BaseAction):
|
||||
@@ -65,7 +65,7 @@ class EmojiAction(BaseAction):
|
||||
return False, f"未找到匹配 '{description}' 的表情包"
|
||||
|
||||
emoji_base64, emoji_description, matched_emotion = emoji_result
|
||||
logger.info(f"{self.log_prefix} 找到表情包: {emoji_description}, 匹配情感: {matched_emotion}")
|
||||
logger.info(f"{self.log_prefix} 找到表达{matched_emotion}的表情包")
|
||||
|
||||
# 使用BaseAction的便捷方法发送表情包
|
||||
success = await self.send_emoji(emoji_base64)
|
||||
|
||||
Reference in New Issue
Block a user