Spaces:
Sleeping
Sleeping
File size: 2,679 Bytes
bae0f63 befb434 f0f84fb befb434 bae0f63 befb434 bae0f63 befb434 bae0f63 befb434 bae0f63 befb434 bae0f63 befb434 bae0f63 befb434 bae0f63 befb434 bae0f63 befb434 bae0f63 | 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 | """
config.py β PsyPredict Production Configuration
All settings loaded from environment variables via Pydantic Settings.
"""
from pydantic_settings import BaseSettings, SettingsConfigDict
from functools import lru_cache
class Settings(BaseSettings):
# ββ Groq API (replaces Ollama) ββββββββββββββββββββββββββββββββββββββββββββ
GROQ_API_KEY: str = ""
GROQ_MODEL: str = "llama-3.3-70b-versatile"
# ββ Kept for backwards compatibility (health endpoint reads these) βββββββββ
OLLAMA_BASE_URL: str = "http://127.0.0.1:11434"
OLLAMA_MODEL: str = "llama-3.3-70b-versatile"
OLLAMA_TIMEOUT_S: int = 30
OLLAMA_RETRIES: int = 3
OLLAMA_RETRY_DELAY_S: float = 2.0
# ββ DistilBERT Text Emotion βββββββββββββββββββββββββββββββββββββββββββββββ
DISTILBERT_MODEL: str = "bhadresh-savani/distilbert-base-uncased-emotion"
# ββ Crisis Detection ββββββββββββββββββββββββββββββββββββββββββββββββββββββ
CRISIS_THRESHOLD: float = 0.65
# ββ Multimodal Fusion Weights (must sum to ~1.0) ββββββββββββββββββββββββββ
TEXT_WEIGHT: float = 0.65
FACE_WEIGHT: float = 0.35
# ββ Context Window ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
MAX_CONTEXT_TURNS: int = 10
# ββ Logging βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
LOG_LEVEL: str = "INFO"
# ββ Rate Limiting βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
RATE_LIMIT: str = "30/minute"
# ββ Input Sanitization βββββββββββββββββββββββββββββββββββββββββββββββββββ
MAX_INPUT_CHARS: int = 2000
model_config = SettingsConfigDict(
env_file=".env",
env_file_encoding="utf-8",
extra="ignore",
)
@lru_cache(maxsize=1)
def get_settings() -> Settings:
"""Returns a cached singleton Settings instance."""
return Settings()
|