72 lines
2.0 KiB
Python
72 lines
2.0 KiB
Python
"""Configuration management using pydantic-settings."""
|
|
|
|
from pydantic import field_validator
|
|
from pydantic_settings import BaseSettings
|
|
from typing import Optional
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
"""Application configuration loaded from environment variables."""
|
|
|
|
# App
|
|
APP_NAME: str = "Sanctum Chronicler"
|
|
APP_ENV: str = "development"
|
|
DEBUG: bool = False
|
|
ADMIN_API_KEY: Optional[str] = None
|
|
|
|
@field_validator("DEBUG", mode="before")
|
|
@classmethod
|
|
def parse_debug(cls, value: object) -> bool:
|
|
"""Parse permissive runtime DEBUG values from shell environments."""
|
|
if isinstance(value, bool):
|
|
return value
|
|
if isinstance(value, str):
|
|
normalized = value.strip().lower()
|
|
if normalized in {"1", "true", "t", "yes", "y", "on", "debug"}:
|
|
return True
|
|
if normalized in {
|
|
"0",
|
|
"false",
|
|
"f",
|
|
"no",
|
|
"n",
|
|
"off",
|
|
"release",
|
|
"prod",
|
|
"production",
|
|
}:
|
|
return False
|
|
return False
|
|
|
|
# Database
|
|
DATABASE_URL: str = "postgresql+asyncpg://sanctum:password@localhost:5432/sanctum"
|
|
|
|
# Twitch
|
|
TWITCH_CLIENT_ID: Optional[str] = None
|
|
TWITCH_CLIENT_SECRET: Optional[str] = None
|
|
TWITCH_BOT_USERNAME: Optional[str] = None
|
|
TWITCH_CHANNEL_NAME: Optional[str] = None
|
|
TWITCH_ACCESS_TOKEN: Optional[str] = None
|
|
TWITCH_CHAT_ENABLED: bool = True
|
|
|
|
# LLM
|
|
LLM_PROVIDER: Optional[str] = None # "openai", "ollama", "lm_studio", or None
|
|
LLM_BASE_URL: Optional[str] = None
|
|
LLM_API_KEY: Optional[str] = None
|
|
LLM_MODEL: str = "gpt-3.5-turbo"
|
|
|
|
# Agent loop
|
|
AGENT_LOOP_INTERVAL_SECONDS: float = 60.0
|
|
HEARTHKEEPER_PROMPT_INTERVAL_MINUTES: int = 15
|
|
|
|
# Export
|
|
EXPORT_PATH: str = "exports"
|
|
|
|
class Config:
|
|
env_file = ".env"
|
|
env_file_encoding = "utf-8"
|
|
case_sensitive = True
|
|
|
|
|
|
settings = Settings()
|