from datetime import datetime

from sqlalchemy import Column, Integer, String, Boolean, DateTime, UniqueConstraint

from app.database import Base


class AIModelConfig(Base):
    __tablename__ = "ai_model_configs"
    __table_args__ = (
        UniqueConstraint("model_id", "task", name="uq_model_id_task"),
    )

    id = Column(Integer, primary_key=True, index=True)
    name = Column(String, nullable=False)  # display name
    model_id = Column(String, nullable=False)  # litellm model id e.g. gpt-4o-mini
    task = Column(String, nullable=False)  # extraction, tts, general
    api_key = Column(String, nullable=True)  # override api key, if null uses default
    is_active = Column(Boolean, default=True)
    is_default = Column(Boolean, default=False)
    created_at = Column(DateTime, default=datetime.utcnow)
