File size: 1,131 Bytes
e549219
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e84fe91
 
e549219
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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