Spaces:
Runtime error
Runtime error
File size: 2,567 Bytes
1ffd0a4 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | """
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()
|