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()