from pydantic import AliasChoices, Field
from pydantic_settings import BaseSettings, SettingsConfigDict


class Settings(BaseSettings):
    model_config = SettingsConfigDict(env_file=".env", env_file_encoding="utf-8")

    hf_token: str = ""
    llm_api_key: str = Field(
        default="",
        validation_alias=AliasChoices("LLM_API_KEY", "DEEPSEEK_API_KEY", "OPENAI_API_KEY"),
    )
    llm_base_url: str = Field(
        default="https://api.deepseek.com/v1",
        validation_alias=AliasChoices("LLM_BASE_URL", "DEEPSEEK_BASE_URL", "OPENAI_BASE_URL"),
    )
    llm_model: str = Field(
        default="deepseek-chat",
        validation_alias=AliasChoices("LLM_MODEL", "DEEPSEEK_MODEL", "OPENAI_MODEL"),
    )
    llm_timeout: int = 8
    llm_max_tokens: int = 150

    webrtc_host: str = "0.0.0.0"
    webrtc_port: int = 8080
    avatar_fps: int = 25
    avatar_driver_mode: str = "blendshape_stream"
    avatar_control_protocol: str = "ws"
    avatar_blendshape_schema: str = "arkit"
    stun_url: str = "stun:stun.l.google.com:19302"
    cors_origins: str = "*"
    ssl_certfile: str = ""
    ssl_keyfile: str = ""

    # Legacy MuseTalk settings retained for migration reference only.
    musetalk_enabled: bool = True
    musetalk_repo_dir: str = "/home/xsl/work/MuseTalk"
    musetalk_infer_script: str = "/home/xsl/work/MuseTalk/scripts/inference.py"
    musetalk_source_video: str = "/home/xsl/work/MuseTalk/data/video/yongen.mp4"
    musetalk_unet_model: str = "/home/xsl/work/MuseTalk/models/musetalkV15/unet.pth"
    musetalk_unet_config: str = "/home/xsl/work/MuseTalk/models/musetalkV15/musetalk.json"
    musetalk_whisper_dir: str = "/home/xsl/work/MuseTalk/models/whisper"
    musetalk_result_dir: str = "/home/xsl/work/MuseTalk/results/visual-chat"


settings = Settings()
