feat: 添加路径评分扩展算法和内存去重工具
- 基于图路径传播,实现了一种路径评分扩展算法,以优化内存检索。 引入了内存去重工具,以识别和合并相似的内存,从而提高结果质量。 - 更新了路径扩展的配置选项,包括最大跳数、阻尼因子和剪枝阈值。 - 在路径扩展中增加了对首选节点类型的支持,以提高内存检索的相关性。 - 增强的日志记录功能,以便更好地跟踪路径扩展和去重过程。
This commit is contained in:
@@ -384,6 +384,7 @@ class MemoryManager:
|
||||
use_multi_query: bool = True,
|
||||
expand_depth: int | None = None,
|
||||
context: dict[str, Any] | None = None,
|
||||
prefer_node_types: list[str] | None = None, # 🆕 偏好节点类型
|
||||
) -> list[Memory]:
|
||||
"""
|
||||
搜索记忆
|
||||
@@ -404,6 +405,7 @@ class MemoryManager:
|
||||
use_multi_query: 是否使用多查询策略(推荐,默认True)
|
||||
expand_depth: 图扩展深度(0=禁用, 1=推荐, 2-3=深度探索)
|
||||
context: 查询上下文(用于优化)
|
||||
prefer_node_types: 偏好节点类型列表(如 ["ENTITY", "EVENT"])🆕
|
||||
|
||||
Returns:
|
||||
记忆列表
|
||||
@@ -423,6 +425,7 @@ class MemoryManager:
|
||||
"use_multi_query": use_multi_query,
|
||||
"expand_depth": expand_depth or global_config.memory.search_max_expand_depth, # 传递图扩展深度
|
||||
"context": context,
|
||||
"prefer_node_types": prefer_node_types or [], # 🆕 传递偏好节点类型
|
||||
}
|
||||
|
||||
if memory_types:
|
||||
|
||||
Reference in New Issue
Block a user