File size: 3,390 Bytes
fa2487d
6cf4e36
017d770
3a2fa09
017d770
 
3a2fa09
017d770
c84a11b
f2c76c4
3a2fa09
017d770
04c0a3b
6cf4e36
04c0a3b
 
 
 
 
6cf4e36
 
017d770
3a2fa09
6cf4e36
3a2fa09
6cf4e36
3a2fa09
017d770
3a2fa09
 
 
 
6cf4e36
 
 
 
3a2fa09
6cf4e36
3a2fa09
6cf4e36
017d770
 
3a2fa09
6cf4e36
017d770
 
 
3a2fa09
 
6cf4e36
3a2fa09
a8e6509
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c84a11b
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
61
62
63
64
65
66
67
import os
from typing import Dict, Any, List
# Residency (informational; enforce via your infra)
CANADA_RESIDENCY_REQUIRED = True
CLOUD_REGION = os.getenv("CLOUD_REGION", "ca")
# ---- Cohere API ----
COHERE_API_KEY = os.getenv("COHERE_API_KEY", "")
COHERE_API_URL = os.getenv("COHERE_API_URL", "")  # optional private base
COHERE_TIMEOUT_S = float(os.getenv("COHERE_TIMEOUT_S", "180"))  # Increased from 60 to 180 seconds
COHERE_MODEL_PRIMARY = os.getenv("COHERE_MODEL_PRIMARY", "command-a-03-2025")
COHERE_EMBED_MODEL = os.getenv("COHERE_EMBED_MODEL", "embed-english-v3.0")
# ---- Open-model fallback (opt-in) ----
USE_OPEN_FALLBACKS = os.getenv("USE_OPEN_FALLBACKS", "0") in ("1", "true", "True")
OPEN_LLM_CANDIDATES: List[str] = [
    "Qwen/Qwen2.5-72B-Instruct",
    "meta-llama/Meta-Llama-3.1-70B-Instruct",
    "mistralai/Mixtral-8x22B-Instruct-v0.1",
    "NousResearch/Meta-Llama-3.1-8B-Instruct",
    "mistralai/Mistral-7B-Instruct-v0.3",
]
LOCAL_MAX_NEW_TOKENS = int(os.getenv("LOCAL_MAX_NEW_TOKENS", "1200"))
# ---- App knobs ----
MODEL_SETTINGS: Dict[str, Any] = {
    "temperature": float(os.getenv("TEMP", "0.3")),
    "top_p": float(os.getenv("TOP_P", "0.9")),
    "repetition_penalty": float(os.getenv("REP_PEN", "1.12")),
    "max_new_tokens": int(os.getenv("MAX_NEW_TOKENS", "1500")),
    "timeout_s": COHERE_TIMEOUT_S,
}
HEALTHCARE_SETTINGS = {
    "supported_file_types": [".csv", ".txt", ".md", ".pdf"],
    "healthcare_keywords": [
        "hospital", "clinic", "surgery", "surgical", "wait time", "consult", "triage",
        "beds", "occupancy", "icu", "ambulatory", "perioperative", "zone", "health authority",
        "province", "nova scotia", "iwk"
    ]
}
GENERAL_CONVERSATION_PROMPT = "You are a helpful, concise assistant."
HEALTHCARE_SYSTEM_PROMPT = (
    "You are a Canadian healthcare operations copilot. "
    "Follow the scenario tasks exactly. Calculations are done deterministically in code; "
    "do not invent numbers."
)
USE_SCENARIO_ENGINE = os.getenv("USE_SCENARIO_ENGINE", "1") not in ("0", "false", "False")
# Debug flags
DEBUG_PLAN = os.getenv("DEBUG_PLAN", "1") in ("1", "true", "True")
# Storage/local
DATA_DIR = os.getenv("DATA_DIR", "./data")
RAG_INDEX_DIR = os.getenv("RAG_INDEX_DIR", "./rag_index")
PERSIST_CONTENT = False
SNAPSHOT_PATH = os.getenv("SNAPSHOT_PATH", "./snapshots")
# Existing settings you already have:
# GENERAL_CONVERSATION_PROMPT = os.getenv("GENERAL_CONVERSATION_PROMPT", "You are a helpful data analyst.")
# COHERE_MODEL_PRIMARY = os.getenv("COHERE_MODEL_PRIMARY", "command-r-plus")
# COHERE_TIMEOUT_S = int(os.getenv("COHERE_TIMEOUT_S", "60"))
#USE_OPEN_FALLBACKS = os.getenv("USE_OPEN_FALLBACKS", "false").lower() == "true"
# --- HIPAA flags ---
# Master switch for PHI-aware behavior
PHI_MODE = os.getenv("PHI_MODE", "true").lower() == "true"
# Persist history? Default OFF under PHI mode (in-memory only if True).
PERSIST_HISTORY = os.getenv("PERSIST_HISTORY", "false").lower() == "true"
# For persistent stores, set a non-zero TTL policy (days). 0 = no persistence.
HISTORY_TTL_DAYS = int(os.getenv("HISTORY_TTL_DAYS", "0"))
# Redact obvious identifiers before external LLM calls
REDACT_BEFORE_LLM = os.getenv("REDACT_BEFORE_LLM", "true").lower() == "true"
# Allow sending PHI to external LLM vendors (requires BAA!). Default: False
ALLOW_EXTERNAL_PHI = os.getenv("ALLOW_EXTERNAL_PHI", "false").lower() == "true"