🤖 自动格式化代码 [skip ci]
This commit is contained in:
@@ -1495,21 +1495,24 @@ class ParahippocampalGyrus:
|
||||
# 从原始列表中移除信息量较低的项
|
||||
try:
|
||||
memory_items.remove(item_to_remove)
|
||||
logger.info(f"[整合] 已合并节点 '{node}' 中的记忆,保留: '{item_to_keep[:60]}...', 移除: '{item_to_remove[:60]}...'" )
|
||||
logger.info(
|
||||
f"[整合] 已合并节点 '{node}' 中的记忆,保留: '{item_to_keep[:60]}...', 移除: '{item_to_remove[:60]}...'"
|
||||
)
|
||||
merged_count += 1
|
||||
nodes_modified.add(node)
|
||||
node_data['last_modified'] = current_timestamp # 更新修改时间
|
||||
node_data["last_modified"] = current_timestamp # 更新修改时间
|
||||
_merged_in_this_node = True
|
||||
break # 每个节点每次检查只合并一对
|
||||
except ValueError:
|
||||
# 如果项已经被移除(例如,在之前的迭代中作为 item_to_keep),则跳过
|
||||
logger.warning(f"[整合] 尝试移除节点 '{node}' 中不存在的项 '{item_to_remove[:30]}...',可能已被合并。")
|
||||
logger.warning(
|
||||
f"[整合] 尝试移除节点 '{node}' 中不存在的项 '{item_to_remove[:30]}...',可能已被合并。"
|
||||
)
|
||||
continue
|
||||
# # 如果节点内发生了合并,更新节点数据 (这种方式不安全,会丢失其他属性)
|
||||
# if merged_in_this_node:
|
||||
# self.memory_graph.G.nodes[node]["memory_items"] = memory_items
|
||||
|
||||
|
||||
if merged_count > 0:
|
||||
logger.info(f"[整合] 共合并了 {merged_count} 对相似记忆项,分布在 {len(nodes_modified)} 个节点中。")
|
||||
sync_start = time.time()
|
||||
|
||||
@@ -31,7 +31,9 @@ class MemoryConfig:
|
||||
"""从全局配置创建记忆系统配置"""
|
||||
# 使用 getattr 提供默认值,防止全局配置缺少这些项
|
||||
return cls(
|
||||
memory_build_distribution=getattr(global_config, "memory_build_distribution", (24, 12, 0.5, 168, 72, 0.5)), # 添加默认值
|
||||
memory_build_distribution=getattr(
|
||||
global_config, "memory_build_distribution", (24, 12, 0.5, 168, 72, 0.5)
|
||||
), # 添加默认值
|
||||
build_memory_sample_num=getattr(global_config, "build_memory_sample_num", 5),
|
||||
build_memory_sample_length=getattr(global_config, "build_memory_sample_length", 30),
|
||||
memory_compress_rate=getattr(global_config, "memory_compress_rate", 0.1),
|
||||
@@ -42,5 +44,7 @@ class MemoryConfig:
|
||||
consolidate_memory_percentage=getattr(global_config, "consolidate_memory_percentage", 0.01),
|
||||
consolidate_memory_interval=getattr(global_config, "consolidate_memory_interval", 1000),
|
||||
llm_topic_judge=getattr(global_config, "llm_topic_judge", "default_judge_model"), # 添加默认模型名
|
||||
llm_summary_by_topic=getattr(global_config, "llm_summary_by_topic", "default_summary_model"), # 添加默认模型名
|
||||
llm_summary_by_topic=getattr(
|
||||
global_config, "llm_summary_by_topic", "default_summary_model"
|
||||
), # 添加默认模型名
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user