补齐平台模板与场景 DSL、预算控制、执行看板和企业场景脚本,增强 Windows 启动/迁移与前端代理和聊天会话记忆,修复执行创建阶段 500 与异步链路排障体验。 Made-with: Cursor
35 lines
1.3 KiB
Python
35 lines
1.3 KiB
Python
"""
|
||
智能体模型
|
||
"""
|
||
from sqlalchemy import Column, String, Text, Integer, DateTime, JSON, ForeignKey, func
|
||
from sqlalchemy.dialects.mysql import CHAR
|
||
from sqlalchemy.orm import relationship
|
||
from app.core.database import Base
|
||
import uuid
|
||
|
||
|
||
class Agent(Base):
|
||
"""智能体表"""
|
||
__tablename__ = "agents"
|
||
|
||
id = Column(CHAR(36), primary_key=True, default=lambda: str(uuid.uuid4()), comment="智能体ID")
|
||
name = Column(String(100), nullable=False, comment="智能体名称")
|
||
description = Column(Text, comment="描述")
|
||
workflow_config = Column(JSON, nullable=False, comment="工作流配置")
|
||
budget_config = Column(
|
||
JSON,
|
||
nullable=True,
|
||
comment="执行预算:max_steps/max_llm_invocations/max_tool_calls(可选,覆盖全局默认)",
|
||
)
|
||
version = Column(Integer, default=1, comment="版本号")
|
||
status = Column(String(20), default="draft", comment="状态: draft/published/running/stopped")
|
||
user_id = Column(CHAR(36), ForeignKey("users.id"), comment="创建者ID")
|
||
created_at = Column(DateTime, default=func.now(), comment="创建时间")
|
||
updated_at = Column(DateTime, default=func.now(), onupdate=func.now(), comment="更新时间")
|
||
|
||
# 关系
|
||
user = relationship("User", backref="agents")
|
||
|
||
def __repr__(self):
|
||
return f"<Agent(id={self.id}, name={self.name})>"
|