import tempfile import os from pydantic_settings import BaseSettings, SettingsConfigDict from functools import lru_cache class Settings(BaseSettings): model_config = SettingsConfigDict(env_file=".env", case_sensitive=False, extra="ignore") # Set OPENROUTER_API_KEY as a HF Space Secret openrouter_api_key: str = "" api_key: str = "" llm_model: str = "meta-llama/llama-3.3-70b-instruct" llm_model_cheap: str = "meta-llama/llama-3.1-8b-instruct" llm_model_expensive: str = "meta-llama/llama-3.3-70b-instruct" app_env: str = "production" log_level: str = "info" # Uses /tmp inside HF Space container — no hardcoded local paths repo_clone_dir: str = os.path.join(tempfile.gettempdir(), "ai-code-review-repos") max_repo_size_mb: int = 300 # Redis / Celery — async job queue for /analyze/async + /jobs/{id} redis_url: str = "redis://localhost:6379/0" celery_result_backend: str | None = None celery_task_always_eager: bool = False # Result cache — caches EngineeringReport by (repo_url, head_sha) cache_ttl_seconds: int = 86400 # 24h @lru_cache() def get_settings() -> Settings: return Settings() def _clear_settings_cache() -> None: # test helper only get_settings.cache_clear()