ciro-backend / src /backend /core /config.py
HAK-16's picture
Initial deploy
1ffd0a4 verified
Raw History Blame Contribute Delete
2.57 kB
"""
CIRO Backend β€” Application Configuration
All environment variables are loaded from .env via pydantic-settings.
Import `settings` (the singleton instance), never the class directly.
"""
import os
from pydantic_settings import BaseSettings, SettingsConfigDict
class Settings(BaseSettings):
"""Typed, validated application settings loaded from environment variables."""
model_config = SettingsConfigDict(
env_file=".env",
env_file_encoding="utf-8",
case_sensitive=False,
extra="ignore",
)
# ── LLM / Agent Keys ─────────────────────────────────────────────
gemini_api_key: str = ""
openai_api_key: str = ""
# ── Google Maps ───────────────────────────────────────────────────
google_maps_api_key: str = ""
# ── Weather ───────────────────────────────────────────────────────
openweathermap_api_key: str = ""
# ── Firebase ──────────────────────────────────────────────────────
firebase_credentials_path: str = ""
# ── WhatsApp (Meta Cloud API β€” test mode) ─────────────────────────
whatsapp_token: str = ""
whatsapp_phone_id: str = ""
whatsapp_fire_brigade_number: str = ""
whatsapp_police_number: str = ""
whatsapp_ambulance_number: str = ""
# ── Application ───────────────────────────────────────────────────
environment: str = "development"
debug: bool = False
port: int = 8080
def __init__(self, **kwargs):
super().__init__(**kwargs)
# Bridge pydantic-settings β†’ os.environ for third-party SDKs
# (OpenAI Agents SDK reads OPENAI_API_KEY from os.environ)
if self.openai_api_key and not os.environ.get("OPENAI_API_KEY"):
os.environ["OPENAI_API_KEY"] = self.openai_api_key
if self.gemini_api_key and not os.environ.get("GEMINI_API_KEY"):
os.environ["GEMINI_API_KEY"] = self.gemini_api_key
# Global settings instance β€” import this, not the class
settings = Settings()