""" Application configuration loaded from environment variables. """ from pydantic import model_validator from pydantic_settings import BaseSettings, SettingsConfigDict class Settings(BaseSettings): """Central application settings — loaded from .env file.""" model_config = SettingsConfigDict( env_file=".env", env_file_encoding="utf-8", extra="ignore", ) # --- LLM (OpenAI) --- OPENAI_API_KEY: str = "" LLM_BASE_URL: str = "https://api.openai.com/v1" LLM_MODEL: str = "gpt-6-luna" EMBEDDING_MODEL: str = "text-embedding-3-small" # --- Email / IMAP --- EMAIL_HOST: str = "imap.gmail.com" EMAIL_PORT: int = 993 SMTP_HOST: str = "smtp.gmail.com" SMTP_PORT: int = 587 EMAIL_USERNAME: str = "" EMAIL_PASSWORD: str = "" # --- Persistence (Supabase) --- SUPABASE_URL: str = "" SUPABASE_KEY: str = "" # --- Security --- # Secret token to protect the backend on public platforms (HF Spaces) API_TOKEN: str = "" # --- App --- APP_ENV: str = "development" LOG_LEVEL: str = "DEBUG" @property def DEBUG(self) -> bool: return self.APP_ENV == "development" @model_validator(mode="after") def require_production_api_token(self) -> "Settings": """Never start a production backend without an API token.""" if self.APP_ENV.lower() == "production" and not self.API_TOKEN.strip(): raise ValueError("API_TOKEN must be configured when APP_ENV=production") return self settings = Settings()