"""配置管理."""

from pydantic_settings import BaseSettings


class Settings(BaseSettings):
    """应用配置."""

    port: int = 3008
    # LLM 配置（可选，为空时降级返回骨架响应）
    openai_api_key: str = ""
    openai_base_url: str = "https://api.openai.com/v1"
    anthropic_api_key: str = ""
    # 开发模式：true 时跳过 OTel exporter 初始化，避免本地无 collector 时报错
    dev_mode: bool = False
    # 可观测性
    otel_endpoint: str = "http://localhost:4318"
    log_level: str = "info"

    model_config = {"env_file": ".env", "env_prefix": ""}

    @property
    def is_dev(self) -> bool:
        """是否处于开发模式."""
        return self.dev_mode

    @property
    def llm_available(self) -> bool:
        """LLM 是否可用（至少一个 provider 配置了 API key）."""
        return bool(self.openai_api_key or self.anthropic_api_key)


settings = Settings()
