fix:尝试优化pfc复读

This commit is contained in:
SengokuCola
2025-04-19 20:34:35 +08:00
parent 560fb738fc
commit 357c72fc4f
5 changed files with 217 additions and 21 deletions

View File

@@ -14,10 +14,10 @@ class GetMemoryTool(BaseTool):
parameters = {
"type": "object",
"properties": {
"text": {"type": "string", "description": "要查询的相关文本"},
"topic": {"type": "string", "description": "要查询的相关主题,用逗号隔开"},
"max_memory_num": {"type": "integer", "description": "最大返回记忆数量"},
},
"required": ["text"],
"required": ["topic"],
}
async def execute(self, function_args: Dict[str, Any], message_txt: str = "") -> Dict[str, Any]:
@@ -31,12 +31,15 @@ class GetMemoryTool(BaseTool):
Dict: 工具执行结果
"""
try:
text = function_args.get("text", message_txt)
topic = function_args.get("topic", message_txt)
max_memory_num = function_args.get("max_memory_num", 2)
# 将主题字符串转换为列表
topic_list = topic.split(",")
# 调用记忆系统
related_memory = await HippocampusManager.get_instance().get_memory_from_text(
text=text, max_memory_num=max_memory_num, max_memory_length=2, max_depth=3, fast_retrieval=False
related_memory = await HippocampusManager.get_instance().get_memory_from_topic(
valid_keywords=topic_list, max_memory_num=max_memory_num, max_memory_length=2, max_depth=3
)
memory_info = ""
@@ -47,7 +50,7 @@ class GetMemoryTool(BaseTool):
if memory_info:
content = f"你记得这些事情: {memory_info}"
else:
content = f"你不太记得有关{text}的记忆,你对此不太了解"
content = f"你不太记得有关{topic}的记忆,你对此不太了解"
return {"name": "get_memory", "content": content}
except Exception as e: