Spaces:
Running
Running
Ryan Christian D. Deniega
Fix: Overhaul Facebook post detection to filtered comments using [role='feed'] strategy and improve button positioning
7e55328 | """ | |
| PhilVerify β Application Settings | |
| Loaded via pydantic-settings from environment variables / .env file. | |
| """ | |
| from functools import lru_cache | |
| from pydantic_settings import BaseSettings, SettingsConfigDict | |
| class Settings(BaseSettings): | |
| model_config = SettingsConfigDict( | |
| env_file=".env", | |
| env_file_encoding="utf-8", | |
| case_sensitive=False, | |
| extra="ignore", | |
| ) | |
| # ββ API Keys ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| news_api_key: str = "" | |
| google_vision_api_key: str = "" | |
| # ββ Facebook Scraper Cookies ββββββββββββββββββββββββββββββββββββββββββββββ | |
| # Paste the value of the `c_user` and `xs` cookies from a logged-in | |
| # Facebook session (browser DevTools β Application β Cookies β facebook.com). | |
| # These unlock private/friends-only posts and reduce rate-limiting. | |
| # Leave empty to scrape public posts only. | |
| facebook_c_user: str = "" | |
| facebook_xs: str = "" | |
| def facebook_cookies(self) -> dict | None: | |
| """Return cookie dict for facebook-scraper, or None if not configured.""" | |
| if self.facebook_c_user and self.facebook_xs: | |
| return {"c_user": self.facebook_c_user, "xs": self.facebook_xs} | |
| return None | |
| # ββ Database ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| database_url: str = "sqlite+aiosqlite:///./philverify_dev.db" # Dev fallback | |
| # ββ Redis βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| redis_url: str = "" # Empty = disable caching | |
| # ββ App βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| app_env: str = "development" | |
| debug: bool = True | |
| log_level: str = "INFO" | |
| allowed_origins: str = "http://localhost:3000,http://localhost:5173" | |
| def allowed_origins_list(self) -> list[str]: | |
| return [o.strip() for o in self.allowed_origins.split(",") if o.strip()] | |
| # ββ ML Models βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| ml_model_name: str = "xlm-roberta-base" | |
| whisper_model_size: str = "base" | |
| use_gpu: bool = False | |
| # ββ Scoring Weights βββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| ml_weight: float = 0.40 | |
| evidence_weight: float = 0.60 | |
| credible_threshold: float = 70.0 | |
| fake_threshold: float = 40.0 | |
| def is_production(self) -> bool: | |
| return self.app_env == "production" | |
| def get_settings() -> Settings: | |
| """Return a cached singleton Settings instance.""" | |
| return Settings() | |