config.py 923 B

1234567891011121314151617181920212223242526272829303132
  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 (Optional - for backward compatibility)
  6. # In multi-user mode, each user provides their own credentials
  7. abs_url: str | None = None
  8. abs_api_token: str | None = None
  9. # AI Configuration
  10. gemini_api_key: str | None = None
  11. anthropic_api_key: str | None = None
  12. openai_api_key: str | None = None
  13. # Application Configuration
  14. database_url: str = "sqlite:///./absrecommend.db"
  15. secret_key: str = "change-me-in-production-please-use-a-strong-random-key"
  16. host: str = "0.0.0.0"
  17. port: int = 8000
  18. class Config:
  19. env_file = ".env"
  20. case_sensitive = False
  21. @lru_cache()
  22. def get_settings() -> Settings:
  23. """Get cached settings instance."""
  24. return Settings()