Browse Source

修复启动bug

master
MSI-7950X\刘泽明 1 day ago
parent
commit
c09c5cfefb
  1. 2
      backend/models/__init__.py
  2. 6
      backend/modules/custom_tool/router.py
  3. 5
      backend/modules/memory/manager.py
  4. 8
      backend/schemas/__init__.py

2
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)

6
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()

5
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

8
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

Loading…
Cancel
Save