"""Application configuration via environment variables.""" from pathlib import Path from pydantic_settings import BaseSettings class Settings(BaseSettings): # Default LLM: Groq-hosted model via its OpenAI-compatible API. Fast and # capable enough to plan messy multi-file reshapes. Set LLM_API_KEY in .env. # NOTE: raw cell grids are sent to Groq's API, so this is not on-prem private. # Override LLM_BASE_URL / LLM_MODEL in .env to point at any other endpoint. llm_model: str = "llama-3.3-70b-versatile" llm_api_key: str = "" llm_base_url: str = "https://api.groq.com/openai/v1" # Secure LLM — used when reference files are attached (may contain sensitive content) # Falls back to default LLM if not configured secure_llm_model: str = "" secure_llm_api_key: str | None = None secure_llm_base_url: str | None = None # Upload limits max_upload_size_mb: int = 200 # max file size per uploaded file (MB) # LLM timeout llm_timeout_seconds: int = 60 # max seconds to wait for LLM response # Session session_ttl_hours: int = 4 # reduced from 24 to save memory on HF Spaces # Directories upload_dir: Path = Path("./uploads") output_dir: Path = Path("./output") log_dir: Path = Path("./audit_logs") model_config = { "env_file": ".env", "env_file_encoding": "utf-8", "env_file_ignore_missing": True, } def ensure_dirs(self) -> None: for d in (self.upload_dir, self.output_dir, self.log_dir): d.mkdir(parents=True, exist_ok=True) @property def has_secure_llm(self) -> bool: """Check if a secure LLM is configured for sensitive content.""" return bool(self.secure_llm_model and self.secure_llm_api_key) settings = Settings()