apac-ops-bot/backend/app/config.py
michael 0b90fa4f8b Make Azure AD configuration optional
Azure AD fields are now optional with None defaults, allowing the app
to start without Azure AD configured (falls back to simple auth).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 17:05:35 -06:00

67 lines
1.8 KiB
Python

"""
Application configuration using Pydantic Settings.
All configuration values are loaded from environment variables.
"""
from pydantic_settings import BaseSettings
from typing import List, Optional
class Settings(BaseSettings):
"""Application settings loaded from environment variables"""
# Application
APP_NAME: str = "Seapac Ops Bot"
APP_ENV: str = "development"
DEBUG: bool = True
SECRET_KEY: str
CORS_ORIGINS: str = "http://localhost:3000"
# Database
DATABASE_URL: str
# Azure AD / MSAL (optional - app falls back to simple auth if not configured)
AZURE_TENANT_ID: Optional[str] = None
AZURE_CLIENT_ID: Optional[str] = None
AZURE_CLIENT_SECRET: Optional[str] = None
AZURE_REDIRECT_URI: Optional[str] = None
# OpenAI Responses API
OPENAI_API_KEY: str
OPENAI_VECTOR_STORE_ID: str = "vs_QkOKiQCqzCHS4iFT5lP9qUxc"
OPENAI_MODEL: str = "gpt-5-nano-2025-08-07"
OPENAI_API_BASE: str = "https://api.openai.com/v1"
# Redis
REDIS_URL: str = "redis://localhost:6399/0"
# Rate Limiting
RATE_LIMIT_PER_MINUTE: int = 30
RATE_LIMIT_PER_DAY: int = 1000
# Token Costs (USD per 1K tokens)
# gpt-5-nano-2025-08-07 pricing
PROMPT_TOKEN_COST: float = 0.00005
CACHED_PROMPT_TOKEN_COST: float = 0.000005
COMPLETION_TOKEN_COST: float = 0.0004
@property
def cors_origins_list(self) -> List[str]:
"""Parse CORS origins from comma-separated string"""
return [origin.strip() for origin in self.CORS_ORIGINS.split(",")]
class Config:
env_file = ".env"
case_sensitive = True
# Global settings instance
settings = Settings()
def get_settings() -> Settings:
"""
Dependency function to get settings instance.
Used for FastAPI dependency injection.
"""
return settings