from sqlalchemy import Boolean, CheckConstraint, Integer, String from sqlalchemy.orm import Mapped, mapped_column from app.models.base import Base, TimestampMixin class VideoEngine(Base, TimestampMixin): __tablename__ = "video_engines" __table_args__ = ( CheckConstraint("max_generation_count BETWEEN 1 AND 5", name="ck_video_engines_max_generation_count"), ) id: Mapped[str] = mapped_column(String(32), primary_key=True) name: Mapped[str] = mapped_column(String(64), nullable=False) provider: Mapped[str] = mapped_column(String(32), nullable=False) api_base: Mapped[str] = mapped_column(String(512), nullable=False) api_key: Mapped[str] = mapped_column(String(256), default="") model_name: Mapped[str] = mapped_column(String(128), default="") supported_ratios: Mapped[str] = mapped_column(String(256), default='["16:9","4:3","1:1","3:4","9:16","21:9"]') supported_resolutions: Mapped[str] = mapped_column(String(256), default='["480p","720p","1080p"]') supported_durations: Mapped[str] = mapped_column(String(256), nullable=True, default='[4,5,6,7,8,9,10,11,12,13,14,15]') max_duration: Mapped[int] = mapped_column(Integer, default=15) max_image_count: Mapped[int] = mapped_column(Integer, default=2) max_video_count: Mapped[int] = mapped_column(Integer, default=0) max_audio_count: Mapped[int] = mapped_column(Integer, default=0) # 管理后台只配置能力开关与数量上限;本次实际生成数量保存在 ChatGenerationTask.generation_count。 multi_generation_enabled: Mapped[bool] = mapped_column( Boolean, default=False, server_default="false", nullable=False, ) max_generation_count: Mapped[int] = mapped_column( Integer, default=1, server_default="1", nullable=False, ) supports_first_last_frame: Mapped[bool] = mapped_column(Boolean, default=False) supports_universal_reference: Mapped[bool] = mapped_column(Boolean, default=True) generate_url: Mapped[str | None] = mapped_column(String(512), nullable=True, default="") query_url: Mapped[str | None] = mapped_column(String(512), nullable=True, default="") is_active: Mapped[bool] = mapped_column(Boolean, default=True) priority: Mapped[int] = mapped_column(Integer, default=0)