"""治理域模型:生成偏好(其余旧枢治理表随 M8 退役)。""" from datetime import datetime from sqlalchemy import Boolean, DateTime, Float, Integer, String from app.core.config import settings from sqlalchemy.orm import Mapped, mapped_column from app.core.time import utc_now from app.db.base import Base class GenerationPreferences(Base): """生成参数偏好(模型网关 §4.3)。本地单用户单行,按 owner_scope 固定。""" __tablename__ = "generation_preferences" owner_scope: Mapped[str] = mapped_column( String(80), primary_key=True, default=settings.default_owner_scope ) default_model_hint: Mapped[str] = mapped_column(String(120), nullable=False) temperature: Mapped[float] = mapped_column(Float, nullable=False, default=0.7) top_p: Mapped[float] = mapped_column(Float, nullable=False, default=1.0) max_output_tokens: Mapped[int] = mapped_column(Integer, nullable=False, default=4096) streaming: Mapped[bool] = mapped_column(Boolean, nullable=False, default=True) updated_at: Mapped[datetime] = mapped_column( DateTime(timezone=True), default=utc_now, onupdate=utc_now )