config.py 719 B

123456789101112131415161718192021222324252627282930
  1. from pydantic_settings import BaseSettings
  2. from functools import lru_cache
  3. class Settings(BaseSettings):
  4. """Application settings loaded from environment variables."""
  5. # Audiobookshelf Configuration
  6. abs_url: str
  7. abs_api_token: str
  8. # AI Configuration
  9. anthropic_api_key: str | None = None
  10. openai_api_key: str | None = None
  11. # Application Configuration
  12. database_url: str = "sqlite:///./absrecommend.db"
  13. secret_key: str = "change-me-in-production"
  14. host: str = "0.0.0.0"
  15. port: int = 8000
  16. class Config:
  17. env_file = ".env"
  18. case_sensitive = False
  19. @lru_cache()
  20. def get_settings() -> Settings:
  21. """Get cached settings instance."""
  22. return Settings()