| """ | |
| 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", | |
| ) | |
| def get_settings() -> Settings: | |
| """Returns a cached singleton Settings instance.""" | |
| return Settings() | |