feat(memory): 移除传统内存系统并优化内存图谱
- 移除整个传统内存系统,包括内存系统模块及所有相关组件 - 删除弃用的内存组件:增强型内存激活器、海马体采样器、内存构建器、内存块、内存遗忘引擎、内存格式器、内存融合器、内存管理器、内存元数据索引、内存查询规划器、内存系统、消息集合处理器、消息集合存储、向量内存存储_v2 - 更新内存图配置,采用增强型检索设置 - 优化内存管理器查询功能,以分析完整对话上下文 - 更新机器人配置模板版本至7.6.1,新增内存图表检索参数 重大变更:旧版内存系统已被完全移除。所有内存功能现依赖于内存图系统。请更新配置以包含新的内存图检索参数。
This commit is contained in:
@@ -163,6 +163,14 @@ class MemoryGraphConfig:
|
||||
activation_propagation_depth=getattr(mg_config, 'activation_propagation_depth', 1),
|
||||
max_memory_nodes_per_memory=getattr(mg_config, 'max_memory_nodes_per_memory', 10),
|
||||
max_related_memories=getattr(mg_config, 'max_related_memories', 5),
|
||||
# 检索配置
|
||||
retrieval=RetrievalConfig(
|
||||
max_expand_depth=getattr(mg_config, 'search_max_expand_depth', 2),
|
||||
vector_weight=getattr(mg_config, 'search_vector_weight', 0.4),
|
||||
graph_distance_weight=getattr(mg_config, 'search_graph_distance_weight', 0.2),
|
||||
importance_weight=getattr(mg_config, 'search_importance_weight', 0.2),
|
||||
recency_weight=getattr(mg_config, 'search_recency_weight', 0.2),
|
||||
),
|
||||
)
|
||||
|
||||
return config
|
||||
@@ -206,7 +214,14 @@ class MemoryGraphConfig:
|
||||
max_related_memories=config_dict.get("max_related_memories", 5),
|
||||
# 旧配置字段(向后兼容)
|
||||
consolidation=ConsolidationConfig(**config_dict.get("consolidation", {})),
|
||||
retrieval=RetrievalConfig(**config_dict.get("retrieval", {})),
|
||||
retrieval=RetrievalConfig(
|
||||
max_expand_depth=config_dict.get("search_max_expand_depth", 2),
|
||||
vector_weight=config_dict.get("search_vector_weight", 0.4),
|
||||
graph_distance_weight=config_dict.get("search_graph_distance_weight", 0.2),
|
||||
importance_weight=config_dict.get("search_importance_weight", 0.2),
|
||||
recency_weight=config_dict.get("search_recency_weight", 0.2),
|
||||
**config_dict.get("retrieval", {})
|
||||
),
|
||||
node_merger=NodeMergerConfig(**config_dict.get("node_merger", {})),
|
||||
storage=StorageConfig(**config_dict.get("storage", {})),
|
||||
decay_rates=config_dict.get("decay_rates", cls().decay_rates),
|
||||
|
||||
@@ -365,20 +365,26 @@ class MemoryManager:
|
||||
chat_history = context.get("chat_history", "")
|
||||
sender = context.get("sender", "")
|
||||
|
||||
prompt = f"""你是一个记忆检索查询优化助手。请将用户的查询转换为更适合语义搜索的表述。
|
||||
prompt = f"""你是一个记忆检索查询优化助手。你的任务是分析对话历史,生成一个综合性的搜索查询。
|
||||
|
||||
要求:
|
||||
1. 提取查询的核心意图和关键信息
|
||||
2. 使用更具体、描述性的语言
|
||||
3. 如果查询涉及人物,明确指出是谁
|
||||
4. 保持简洁,只输出优化后的查询文本
|
||||
**任务说明:**
|
||||
不要只优化单个消息,而是要综合分析整个对话上下文,提取出最核心的检索意图。
|
||||
|
||||
当前查询: {query}
|
||||
**要求:**
|
||||
1. 仔细阅读对话历史,理解对话的主题和脉络
|
||||
2. 识别关键人物、事件、关系和话题
|
||||
3. 提取最值得检索的核心信息点
|
||||
4. 生成一个简洁但信息丰富的搜索查询(15-30字)
|
||||
5. 如果涉及特定人物,必须明确指出人名
|
||||
6. 只输出查询文本,不要解释
|
||||
|
||||
{f"发言人: {sender}" if sender else ""}
|
||||
{f"最近对话: {chat_history[-200:]}" if chat_history else ""}
|
||||
**对话上下文:**
|
||||
{chat_history[-500:] if chat_history else "(无历史对话)"}
|
||||
|
||||
优化后的查询:"""
|
||||
**当前消息:**
|
||||
{sender}: {query}
|
||||
|
||||
**生成综合查询:**"""
|
||||
|
||||
optimized_query, _ = await llm.generate_response_async(
|
||||
prompt,
|
||||
|
||||
Reference in New Issue
Block a user