Add brain memory services and APIs
Introduce the backend pieces for brain memory ingestion, routing, and system telemetry so the new knowledge workflows can project data into a brain view. The supporting tests lock in the new behavior and keep the expanded backend surface stable. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from sqlalchemy import Column, String, Text, DateTime, Index, Enum as SQLEnum
|
||||
from sqlalchemy import Column, String, Text, Integer, Index
|
||||
from app.models.base import BaseModel
|
||||
import enum
|
||||
|
||||
@@ -22,12 +22,20 @@ class Log(BaseModel):
|
||||
level = Column(String(20), default=LogLevel.INFO.value, index=True) # debug/info/warning/error
|
||||
type = Column(String(20), default=LogType.SYSTEM.value, index=True) # agent/system/chat
|
||||
user_id = Column(String(36), nullable=True, index=True) # 关联用户
|
||||
request_id = Column(String(64), nullable=True, index=True)
|
||||
route = Column(String(255), nullable=True, index=True)
|
||||
method = Column(String(16), nullable=True, index=True)
|
||||
status_code = Column(Integer, nullable=True, index=True)
|
||||
error_type = Column(String(100), nullable=True)
|
||||
operation = Column(String(100), nullable=True, index=True)
|
||||
message = Column(Text, nullable=False) # 日志内容
|
||||
details = Column(Text, nullable=True) # 详细信息(JSON)
|
||||
source = Column(String(100), nullable=True) # 来源模块
|
||||
duration_ms = Column(String(20), nullable=True) # 执行耗时
|
||||
duration_ms = Column(Integer, nullable=True) # 执行耗时
|
||||
|
||||
__table_args__ = (
|
||||
Index('idx_logs_type_level', 'type', 'level'),
|
||||
Index('idx_logs_created_at', 'created_at'),
|
||||
Index('idx_logs_request_id', 'request_id'),
|
||||
Index('idx_logs_operation_status', 'operation', 'status_code'),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user