| | """ |
| | Application configuration with environment variable support. |
| | """ |
| |
|
| | import os |
| | from functools import lru_cache |
| | from pydantic_settings import BaseSettings |
| | from typing import Optional |
| |
|
| |
|
| | class Settings(BaseSettings): |
| | """Application settings loaded from environment variables.""" |
| | |
| | |
| | |
| | |
| | |
| | HF_FUSION_REPO_ID: str = "DeepFakeDetector/fusion-logreg-final" |
| | HF_CACHE_DIR: str = ".hf_cache" |
| | HF_TOKEN: Optional[str] = None |
| | |
| | |
| | GOOGLE_API_KEY: Optional[str] = None |
| | GEMINI_MODEL: str = "gemini-2.5-flash" |
| | |
| | @property |
| | def llm_enabled(self) -> bool: |
| | """Check if LLM explanations are available.""" |
| | return self.GOOGLE_API_KEY is not None and len(self.GOOGLE_API_KEY) > 0 |
| | |
| | |
| | ENABLE_DEBUG: bool = False |
| | LOG_LEVEL: str = "INFO" |
| | |
| | |
| | HOST: str = "0.0.0.0" |
| | PORT: int = 8000 |
| | |
| | |
| | CORS_ORIGINS: str = "http://localhost:5173,http://localhost:3000,https://www.deepfake-detector.app,https://deepfake-detector.app" |
| | |
| | @property |
| | def cors_origins_list(self) -> list[str]: |
| | """Parse CORS origins from comma-separated string.""" |
| | return [origin.strip() for origin in self.CORS_ORIGINS.split(",") if origin.strip()] |
| | |
| | |
| | API_V1_PREFIX: str = "/api/v1" |
| | PROJECT_NAME: str = "DeepFake Detector API" |
| | VERSION: str = "0.1.0" |
| | |
| | class Config: |
| | env_file = ".env" |
| | env_file_encoding = "utf-8" |
| | case_sensitive = True |
| |
|
| |
|
| | @lru_cache() |
| | def get_settings() -> Settings: |
| | """Get cached settings instance.""" |
| | return Settings() |
| |
|
| |
|
| | settings = get_settings() |
| |
|