modcomms/backend/app/config.py
Vadym Samoilenko 538a32505e Fix LlamaParse 401 + update logo to v5
- Add LLAMA_CLOUD_BASE_URL config option so the LlamaCloud regional
  endpoint can be set without code changes (fixes 401/region errors
  on production); pass it through to AsyncLlamaCloud client init
- Document LLAMA_CLOUD_BASE_URL in .env.deploy.example with EU endpoint
- Copy BAR-ModComms-logo-v5.png to frontend/public
- Sidebar: update logo reference v4 → v5
- PDF header: update logo v4 → v5, wrap in black (#000) band for
  legibility, remove duplicate "Oliver" wordmark

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-16 12:22:31 +00:00

61 lines
2.5 KiB
Python
Executable file

import os
from pathlib import Path
from dotenv import load_dotenv
# Load environment variables from .env file
load_dotenv()
class Settings:
"""Application settings loaded from environment variables."""
GEMINI_API_KEY: str = os.getenv("GEMINI_API_KEY", "")
CORS_ORIGINS: str = os.getenv("CORS_ORIGINS", "http://localhost:3000")
HOST: str = os.getenv("HOST", "0.0.0.0")
PORT: int = int(os.getenv("PORT", "8000"))
# Reference docs path - defaults to ../reference_docs relative to backend/
_default_ref_docs = Path(__file__).parent.parent.parent / "reference_docs"
REFERENCE_DOCS_PATH: str = os.getenv("REFERENCE_DOCS_PATH", str(_default_ref_docs))
# Azure AD Configuration for token verification
AZURE_TENANT_ID: str = os.getenv("AZURE_TENANT_ID", "")
AZURE_CLIENT_ID: str = os.getenv("AZURE_CLIENT_ID", "")
# Auth bypass for development (set to "true" to skip auth)
DISABLE_AUTH: bool = os.getenv("DISABLE_AUTH", "false").lower() == "true"
# Database configuration
DATABASE_URL: str = os.getenv(
"DATABASE_URL",
"postgresql+asyncpg://modcomms:modcomms_dev@localhost:5432/modcomms"
)
# File storage path for uploaded proofs
_default_storage = Path(__file__).parent.parent.parent / "storage"
FILE_STORAGE_PATH: str = os.getenv("FILE_STORAGE_PATH", str(_default_storage))
# LlamaParse API key (optional - KB processing pipeline disabled if not set)
LLAMA_CLOUD_API_KEY: str = os.getenv("LLAMA_CLOUD_API_KEY", "")
# LlamaParse region base URL (optional - defaults to US; set for EU: https://api.cloud.llamaindex.ai)
LLAMA_CLOUD_BASE_URL: str = os.getenv("LLAMA_CLOUD_BASE_URL", "")
# Mailgun Configuration for support emails
MAILGUN_API_URL: str = os.getenv("MAILGUN_API_URL", "")
MAILGUN_API_KEY: str = os.getenv("MAILGUN_API_KEY", "")
MAILGUN_FROM: str = os.getenv("MAILGUN_FROM", "")
SUPPORT_EMAIL: str = os.getenv("SUPPORT_EMAIL", "BAICsupport@oliver.agency")
def validate(self) -> None:
"""Validate required settings are present."""
if not self.GEMINI_API_KEY:
raise ValueError("GEMINI_API_KEY environment variable is required")
if not self.DISABLE_AUTH:
if not self.AZURE_TENANT_ID:
raise ValueError("AZURE_TENANT_ID environment variable is required (or set DISABLE_AUTH=true)")
if not self.AZURE_CLIENT_ID:
raise ValueError("AZURE_CLIENT_ID environment variable is required (or set DISABLE_AUTH=true)")
settings = Settings()