from sqlalchemy import Boolean, Enum, Integer, String from sqlalchemy.orm import Mapped, mapped_column from app.db.base import Base from app.models.mixins import TimestampMixin class PromptTemplate(TimestampMixin, Base): """提示词模板元数据:保存 Markdown 模板路径、场景、版本和启用状态。""" __tablename__ = "prompt_templates" id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True, comment="提示词模板ID") template_code: Mapped[str] = mapped_column(String(64), nullable=False, index=True, comment="模板编码") agent_type: Mapped[str] = mapped_column( Enum("patient", "scoring", "report", "polish", "hint", "knowledge"), nullable=False, index=True, comment="Agent类型", ) scene: Mapped[str] = mapped_column(String(64), nullable=False, index=True, comment="使用场景") version_no: Mapped[str] = mapped_column(String(32), nullable=False, comment="版本号") model_type: Mapped[str] = mapped_column(Enum("fast", "reason"), nullable=False, comment="模型类型") output_format: Mapped[str] = mapped_column(Enum("text", "json"), nullable=False, comment="输出格式") file_path: Mapped[str] = mapped_column(String(512), nullable=False, comment="Markdown文件路径") is_active: Mapped[bool] = mapped_column(Boolean, default=True, comment="是否启用") __table_args__ = {"comment": "提示词模板元数据表"}