fix: 修复 graph_nodes 表 weight 字段缺失问题

- 在 GraphNodes 模型中添加 weight 字段,设置默认值为 1.0
- 修复 Hippocampus.py 中插入 GraphNodes 时缺少 weight 字段的问题
- 解决 sqlite3.IntegrityError: NOT NULL constraint failed: graph_nodes.weight 错误
This commit is contained in:
Furina-1013-create
2025-09-04 20:57:59 +08:00
parent 7b537e96d0
commit ac1253acc5
2 changed files with 3 additions and 0 deletions

View File

@@ -928,6 +928,7 @@ class EntorhinalCortex:
"concept": concept, "concept": concept,
"memory_items": memory_items_json, "memory_items": memory_items_json,
"hash": memory_hash, "hash": memory_hash,
"weight": 1.0, # 默认权重为1.0
"created_time": created_time, "created_time": created_time,
"last_modified": last_modified, "last_modified": last_modified,
} }
@@ -1084,6 +1085,7 @@ class EntorhinalCortex:
"concept": concept, "concept": concept,
"memory_items": memory_items_json, "memory_items": memory_items_json,
"hash": self.hippocampus.calculate_node_hash(concept, memory_items), "hash": self.hippocampus.calculate_node_hash(concept, memory_items),
"weight": 1.0, # 默认权重为1.0
"created_time": data.get("created_time", current_time), "created_time": data.get("created_time", current_time),
"last_modified": data.get("last_modified", current_time), "last_modified": data.get("last_modified", current_time),
} }

View File

@@ -361,6 +361,7 @@ class GraphNodes(Base):
concept = Column(get_string_field(255), nullable=False, unique=True, index=True) concept = Column(get_string_field(255), nullable=False, unique=True, index=True)
memory_items = Column(Text, nullable=False) memory_items = Column(Text, nullable=False)
hash = Column(Text, nullable=False) hash = Column(Text, nullable=False)
weight = Column(Float, nullable=False, default=1.0)
created_time = Column(Float, nullable=False) created_time = Column(Float, nullable=False)
last_modified = Column(Float, nullable=False) last_modified = Column(Float, nullable=False)