from functools import lru_cache from pathlib import Path from pydantic_settings import BaseSettings, SettingsConfigDict class Settings(BaseSettings): model_config = SettingsConfigDict(env_file=".env", env_file_encoding="utf-8", extra="ignore") app_env: str = "production" public_base_url: str = "https://dzen.nstarikov.ru" sqlite_path: str = "/app/data/dzen.sqlite3" storage_dir: str = "/app/data" redis_url: str = "redis://redis:6379/0" celery_broker_url: str = "redis://redis:6379/0" celery_result_backend: str = "redis://redis:6379/1" admin_token: str = "change-me" whisper_command: str = "/LLM/Whisper/whisper --model medium --language ru --output_format txt" ytdlp_cookies_path: str = "/app/data/cookies.txt" vk_api_token: str = "" vk_video_owner_id: str = "-9828339" llm_api_url: str = "" llm_api_key: str = "" llm_model: str = "agent" llm_timeout_seconds: int = 120 llm_max_transcript_chars: int = 45000 max_concurrent_videos: int = 1 frame_candidates: int = 12 rss_limit: int = 100 @property def sqlite_url(self) -> str: return f"sqlite:///{self.sqlite_path}" @property def storage_path(self) -> Path: return Path(self.storage_dir) @property def media_path(self) -> Path: return self.storage_path / "media" @property def videos_path(self) -> Path: return self.storage_path / "videos" @property def transcripts_path(self) -> Path: return self.storage_path / "transcripts" @property def posts_path(self) -> Path: return self.storage_path / "posts" @lru_cache def get_settings() -> Settings: return Settings()