from pydantic_settings import BaseSettings, SettingsConfigDict from pydantic import Field from functools import lru_cache class Settings(BaseSettings): # Make most values optional to allow app import without env; validate when used app_secret: str | None = Field(None, alias="APP_SECRET") github_token: str | None = Field(None, alias="GITHUB_TOKEN") github_username: str | None = Field(None, alias="GITHUB_USERNAME") github_email: str | None = Field(None, alias="GITHUB_EMAIL") database_url: str = Field("sqlite:///./local.db", alias="DATABASE_URL") # AIpipe / OpenAI-compatible openai_api_key: str | None = Field(None, alias="OPENAI_API_KEY") openai_base_url: str = Field("https://aipipe.org/openrouter/v1/chat/completions", alias="OPENAI_BASE_URL") aipipe_model: str = Field("qwen/qwen3-coder", alias="AIPIPE_MODEL") # Pages polling # Pages polling: now internal defaults in app.services.pages.wait_for_200 model_config = SettingsConfigDict(env_file=".env", extra="ignore") @lru_cache(maxsize=1) def get_settings() -> Settings: return Settings() # type: ignore