File size: 1,563 Bytes
6793beb | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | """
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()
|