From c09c5cfefb0d3cd65a68c031808072bea2598f88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?MSI-7950X=5C=E5=88=98=E6=B3=BD=E6=98=8E?= Date: Mon, 18 May 2026 14:53:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=90=AF=E5=8A=A8bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/models/__init__.py | 2 +- backend/modules/custom_tool/router.py | 6 +++--- backend/modules/memory/manager.py | 5 +++-- backend/schemas/__init__.py | 8 ++++---- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/backend/models/__init__.py b/backend/models/__init__.py index 6ff3fea..c665c9d 100644 --- a/backend/models/__init__.py +++ b/backend/models/__init__.py @@ -324,7 +324,7 @@ class MemoryAtom(Base): content = Column(Text, nullable=False) priority = Column(Integer, default=50) source_session_id = Column(UUID(as_uuid=True), nullable=True) - metadata = Column(JSON, default=dict) + metadata_ = Column("metadata", JSON, default=dict) created_at = Column(DateTime, default=datetime.utcnow) updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow) diff --git a/backend/modules/custom_tool/router.py b/backend/modules/custom_tool/router.py index a9cfb19..2873a80 100644 --- a/backend/modules/custom_tool/router.py +++ b/backend/modules/custom_tool/router.py @@ -121,7 +121,7 @@ async def create_custom_tool(req: CustomToolCreate, request: Request, db: AsyncS await db.flush() return created_tool - schema_json = req.schema_json or {} + schema_json = req.tool_schema or {} if not schema_json and req.endpoint_url: schema_json = { "type": "object", @@ -196,8 +196,8 @@ async def update_custom_tool(tool_id: uuid.UUID, req: CustomToolUpdate, db: Asyn tool.auth_type = req.auth_type if req.auth_config is not None: tool.auth_config = req.auth_config - if req.schema_json is not None: - tool.schema_json = req.schema_json + if req.tool_schema is not None: + tool.schema_json = req.tool_schema if req.is_active is not None: tool.is_active = req.is_active await db.flush() diff --git a/backend/modules/memory/manager.py b/backend/modules/memory/manager.py index e18669f..bb24958 100644 --- a/backend/modules/memory/manager.py +++ b/backend/modules/memory/manager.py @@ -783,6 +783,7 @@ class MemoryManager: results = [] try: async with self.db_factory() as db: + flow_filter = "AND (flow_id = :fid OR flow_id IS NULL)" if fid else "" if embedding and len(embedding) > 0: emb_str = "[" + ",".join(str(v) for v in embedding) + "]" vector_results = await db.execute( @@ -791,7 +792,7 @@ class MemoryManager: (1.0 - (embedding <=> :emb::vector)) AS similarity FROM memory_atoms WHERE user_id = :uid - {"""AND (flow_id = :fid OR flow_id IS NULL)""" if fid else ""} + {flow_filter} AND embedding IS NOT NULL ORDER BY embedding <=> :emb::vector LIMIT :limit @@ -811,7 +812,7 @@ class MemoryManager: ts_rank(content_tsv, plainto_tsquery('simple', :query)) AS text_score FROM memory_atoms WHERE user_id = :uid - {"""AND (flow_id = :fid OR flow_id IS NULL)""" if fid else ""} + {flow_filter} AND content_tsv @@ plainto_tsquery('simple', :query) ORDER BY text_score DESC LIMIT :limit diff --git a/backend/schemas/__init__.py b/backend/schemas/__init__.py index 8fc3a32..15de640 100644 --- a/backend/schemas/__init__.py +++ b/backend/schemas/__init__.py @@ -365,7 +365,7 @@ class CustomToolCreate(BaseModel): headers: dict = {} auth_type: str = "none" auth_config: dict = {} - schema_json: dict | None = None + tool_schema: dict | None = None class CustomToolUpdate(BaseModel): @@ -378,16 +378,16 @@ class CustomToolUpdate(BaseModel): headers: dict | None = None auth_type: str | None = None auth_config: dict | None = None - schema_json: dict | None = None + tool_schema: dict | None = None is_active: bool | None = None class CustomToolOut(BaseModel): - model_config = ConfigDict(from_attributes=True, protected_namespaces=()) + model_config = ConfigDict(from_attributes=True, populate_by_name=True, protected_namespaces=()) id: uuid.UUID name: str description: str | None = None - schema_json: dict + tool_schema: dict = Field(alias="schema_json") endpoint_url: str method: str path: str