mirror of https://github.com/Mai-with-u/MaiBot.git
🤖 自动格式化代码 [skip ci]
parent
a034ea6103
commit
dff8fef129
|
|
@ -1,9 +1,11 @@
|
|||
import time
|
||||
from typing import Tuple, Optional
|
||||
from src.plugins.memory_system.Hippocampus import HippocampusManager
|
||||
|
||||
# --- NEW IMPORT ---
|
||||
# 从 heartflow 导入知识检索和数据库查询函数/实例
|
||||
from src.plugins.heartFC_chat.heartflow_prompt_builder import prompt_builder
|
||||
|
||||
# --- END NEW IMPORT ---
|
||||
# import jieba # 如果需要旧版知识库的回退,可能需要
|
||||
# import re # 如果需要旧版知识库的回退,可能需要
|
||||
|
|
@ -268,7 +270,6 @@ class ActionPlanner:
|
|||
logger.error(f"[私聊][{self.private_name}]构建对话目标字符串时出错: {e}")
|
||||
goals_str = "- 构建对话目标时出错。\n"
|
||||
|
||||
|
||||
# 获取聊天历史记录 (chat_history_text)
|
||||
try:
|
||||
if hasattr(observation_info, "chat_history") and observation_info.chat_history:
|
||||
|
|
@ -392,9 +393,13 @@ class ActionPlanner:
|
|||
# 调用导入的 prompt_builder.get_prompt_info
|
||||
logger.debug(f"[私聊][{self.private_name}] (ActionPlanner) 开始自动检索知识 (使用导入函数)...")
|
||||
# 使用导入的 prompt_builder 实例及其方法
|
||||
retrieved_knowledge_str_planner = await prompt_builder.get_prompt_info(message=retrieval_context, threshold=0.38)
|
||||
retrieved_knowledge_str_planner = await prompt_builder.get_prompt_info(
|
||||
message=retrieval_context, threshold=0.38
|
||||
)
|
||||
# --- END MODIFIED KNOWLEDGE RETRIEVAL ---
|
||||
logger.info(f"[私聊][{self.private_name}] (ActionPlanner) 自动检索知识 {'完成' if retrieved_knowledge_str_planner else '无结果'}。")
|
||||
logger.info(
|
||||
f"[私聊][{self.private_name}] (ActionPlanner) 自动检索知识 {'完成' if retrieved_knowledge_str_planner else '无结果'}。"
|
||||
)
|
||||
|
||||
except Exception as retrieval_err:
|
||||
logger.error(f"[私聊][{self.private_name}] (ActionPlanner) 自动检索时出错: {retrieval_err}")
|
||||
|
|
@ -528,4 +533,4 @@ class ActionPlanner:
|
|||
except Exception as e:
|
||||
# 外层异常处理保持不变
|
||||
logger.error(f"[私聊][{self.private_name}]规划行动时调用 LLM 或处理结果出错: {str(e)}")
|
||||
return "wait", f"行动规划处理中发生错误,暂时等待: {str(e)}"
|
||||
return "wait", f"行动规划处理中发生错误,暂时等待: {str(e)}"
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ from src.plugins.memory_system.Hippocampus import HippocampusManager
|
|||
# --- NEW IMPORT ---
|
||||
# 从 heartflow 导入知识检索和数据库查询函数/实例
|
||||
from src.plugins.heartFC_chat.heartflow_prompt_builder import prompt_builder
|
||||
|
||||
# --- END NEW IMPORT ---
|
||||
# 可能用于旧知识库提取主题 (如果需要回退到旧方法)
|
||||
# import jieba # 如果报错说找不到 jieba,可能需要安装: pip install jieba
|
||||
|
|
@ -187,7 +188,6 @@ class ReplyGenerator:
|
|||
else:
|
||||
goals_str = "- 目前没有明确对话目标\n" # 简化无目标情况
|
||||
|
||||
|
||||
# 获取聊天历史记录 (chat_history_text)
|
||||
chat_history_text = observation_info.chat_history_str
|
||||
if observation_info.new_messages_count > 0 and observation_info.unprocessed_messages:
|
||||
|
|
@ -223,7 +223,9 @@ class ReplyGenerator:
|
|||
# 提取知识 (调用导入的 prompt_builder.get_prompt_info)
|
||||
logger.debug(f"[私聊][{self.private_name}]开始自动检索知识 (使用导入函数)...")
|
||||
# 使用导入的 prompt_builder 实例及其方法
|
||||
retrieved_knowledge_str = await prompt_builder.get_prompt_info(message=retrieval_context, threshold=0.38)
|
||||
retrieved_knowledge_str = await prompt_builder.get_prompt_info(
|
||||
message=retrieval_context, threshold=0.38
|
||||
)
|
||||
# --- END MODIFIED KNOWLEDGE RETRIEVAL ---
|
||||
|
||||
if retrieved_knowledge_str:
|
||||
|
|
@ -257,8 +259,10 @@ class ReplyGenerator:
|
|||
goals_str=goals_str,
|
||||
chat_history_text=chat_history_text,
|
||||
# knowledge_info_str=knowledge_info_str, # 移除了这个旧的知识展示方式
|
||||
retrieved_memory_str=retrieved_memory_str if retrieved_memory_str else "无相关记忆。", # 如果为空则提示无
|
||||
retrieved_knowledge_str=retrieved_knowledge_str if retrieved_knowledge_str else "无相关知识。" # 如果为空则提示无
|
||||
retrieved_memory_str=retrieved_memory_str if retrieved_memory_str else "无相关记忆。", # 如果为空则提示无
|
||||
retrieved_knowledge_str=retrieved_knowledge_str
|
||||
if retrieved_knowledge_str
|
||||
else "无相关知识。", # 如果为空则提示无
|
||||
)
|
||||
|
||||
# --- 调用 LLM 生成 ---
|
||||
|
|
|
|||
Loading…
Reference in New Issue