diff --git a/api/app/core/memory/storage_services/forgetting_engine/access_history_manager.py b/api/app/core/memory/storage_services/forgetting_engine/access_history_manager.py index acc2a717..729a5542 100644 --- a/api/app/core/memory/storage_services/forgetting_engine/access_history_manager.py +++ b/api/app/core/memory/storage_services/forgetting_engine/access_history_manager.py @@ -246,7 +246,7 @@ class AccessHistoryManager: if not node_data: return ConsistencyCheckResult.CONSISTENT, None - access_history = node_data.get('access_history', []) + access_history = node_data.get('access_history') or [] last_access_time = node_data.get('last_access_time') access_count = node_data.get('access_count', 0) activation_value = node_data.get('activation_value') @@ -409,7 +409,7 @@ class AccessHistoryManager: logger.error(f"节点不存在,无法修复: {node_label}[{node_id}]") return False - access_history = node_data.get('access_history', []) + access_history = node_data.get('access_history') or [] importance_score = node_data.get('importance_score', 0.5) # 准备修复数据 @@ -530,7 +530,7 @@ class AccessHistoryManager: Returns: Dict[str, Any]: 更新数据,包含所有需要更新的字段 """ - access_history = node_data.get('access_history', []) + access_history = node_data.get('access_history') or [] importance_score = node_data.get('importance_score', 0.5) # 追加新的访问时间 diff --git a/api/app/repositories/neo4j/cypher_queries.py b/api/app/repositories/neo4j/cypher_queries.py index 259b1325..ed8f6100 100644 --- a/api/app/repositories/neo4j/cypher_queries.py +++ b/api/app/repositories/neo4j/cypher_queries.py @@ -722,7 +722,12 @@ SET m += { chunk_ids: summary.chunk_ids, content: summary.content, summary_embedding: summary.summary_embedding, - config_id: summary.config_id + config_id: summary.config_id, + importance_score: CASE WHEN summary.importance_score IS NOT NULL THEN summary.importance_score ELSE coalesce(m.importance_score, 0.5) END, + activation_value: CASE WHEN summary.activation_value IS NOT NULL THEN summary.activation_value ELSE m.activation_value END, + access_history: CASE WHEN summary.access_history IS NOT NULL THEN summary.access_history ELSE coalesce(m.access_history, []) END, + last_access_time: CASE WHEN summary.last_access_time IS NOT NULL THEN summary.last_access_time ELSE m.last_access_time END, + access_count: CASE WHEN summary.access_count IS NOT NULL THEN summary.access_count ELSE coalesce(m.access_count, 0) END } RETURN m.id AS uuid """ diff --git a/api/app/repositories/neo4j/entity_repository.py b/api/app/repositories/neo4j/entity_repository.py index cb18feca..f4ca35c8 100644 --- a/api/app/repositories/neo4j/entity_repository.py +++ b/api/app/repositories/neo4j/entity_repository.py @@ -58,7 +58,7 @@ class EntityRepository(BaseNeo4jRepository[ExtractedEntityNode]): # 处理 ACT-R 属性 - 确保字段存在且有默认值 n['importance_score'] = n.get('importance_score', 0.5) n['activation_value'] = n.get('activation_value') - n['access_history'] = n.get('access_history', []) + n['access_history'] = n.get('access_history') or [] n['last_access_time'] = n.get('last_access_time') n['access_count'] = n.get('access_count', 0) diff --git a/api/app/repositories/neo4j/statement_repository.py b/api/app/repositories/neo4j/statement_repository.py index 22343e10..cd9f2fac 100644 --- a/api/app/repositories/neo4j/statement_repository.py +++ b/api/app/repositories/neo4j/statement_repository.py @@ -78,7 +78,7 @@ class StatementRepository(BaseNeo4jRepository[StatementNode]): # 处理 ACT-R 属性 - 确保字段存在且有默认值 n['importance_score'] = n.get('importance_score', 0.5) n['activation_value'] = n.get('activation_value') - n['access_history'] = n.get('access_history', []) + n['access_history'] = n.get('access_history') or [] n['last_access_time'] = n.get('last_access_time') n['access_count'] = n.get('access_count', 0)