From 156662014bb1cfbd78bb359f142fb55585b450e1 Mon Sep 17 00:00:00 2001 From: Furina-1013-create <189647097+Furina-1013-create@users.noreply.github.com> Date: Thu, 4 Sep 2025 20:57:59 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20graph=5Fnodes=20?= =?UTF-8?q?=E8=A1=A8=20weight=20=E5=AD=97=E6=AE=B5=E7=BC=BA=E5=A4=B1?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 GraphNodes 模型中添加 weight 字段,设置默认值为 1.0 - 修复 Hippocampus.py 中插入 GraphNodes 时缺少 weight 字段的问题 - 解决 sqlite3.IntegrityError: NOT NULL constraint failed: graph_nodes.weight 错误 --- src/chat/memory_system/Hippocampus.py | 2 ++ src/common/database/sqlalchemy_models.py | 1 + 2 files changed, 3 insertions(+) diff --git a/src/chat/memory_system/Hippocampus.py b/src/chat/memory_system/Hippocampus.py index c30270d36..98fd4e1c7 100644 --- a/src/chat/memory_system/Hippocampus.py +++ b/src/chat/memory_system/Hippocampus.py @@ -1017,6 +1017,7 @@ class EntorhinalCortex: "memory_items": memory_items, "weight": weight, "hash": memory_hash, + "weight": 1.0, # 默认权重为1.0 "created_time": created_time, "last_modified": last_modified, } @@ -1173,6 +1174,7 @@ class EntorhinalCortex: "concept": concept, "memory_items": memory_items_json, "hash": self.hippocampus.calculate_node_hash(concept, memory_items), + "weight": 1.0, # 默认权重为1.0 "created_time": data.get("created_time", current_time), "last_modified": data.get("last_modified", current_time), } diff --git a/src/common/database/sqlalchemy_models.py b/src/common/database/sqlalchemy_models.py index d9948408a..a5b431a1c 100644 --- a/src/common/database/sqlalchemy_models.py +++ b/src/common/database/sqlalchemy_models.py @@ -361,6 +361,7 @@ class GraphNodes(Base): concept = Column(get_string_field(255), nullable=False, unique=True, index=True) memory_items = Column(Text, nullable=False) hash = Column(Text, nullable=False) + weight = Column(Float, nullable=False, default=1.0) created_time = Column(Float, nullable=False) last_modified = Column(Float, nullable=False)