Spaces:
Runtime error
api_router: read ERMAP_<ROLE>_MODEL env vars
Browse filesThe Kaggle notebook (cell 5) sets:
os.environ["ERMAP_NURSE_MODEL"] = "llama-3.1-8b-instant"
os.environ["ERMAP_PATIENT_MODEL"] = "llama-3.1-8b-instant"
os.environ["ERMAP_EMPATHY_JUDGE_MODEL"] = "llama-3.3-70b-versatile"
os.environ["ERMAP_MEDICAL_JUDGE_MODEL"] = "llama-3.3-70b-versatile"
...as the documented mechanism to traffic-shape across Groq's 8B vs
70B free-tier pools (high-volume Patient/Nurse on 8B-instant, the
two Judges on 70B-versatile to preserve grading quality).
But AgentRouter.__init__ only accepted these as constructor kwargs
(nurse_model=..., etc.) and never read the env vars. Since
TriageEnv defaults all of them to None and train_grpo.py never
forwards them, every role was silently using the shared model
default ("llama-3.3-70b-versatile"). User logs from a real Kaggle
training session show all four roles on 70B:
nurse client: LIVE (Groq API, model=llama-3.3-70b-versatile)
patient client: LIVE (Groq API, model=llama-3.3-70b-versatile)
empathy_judge client: LIVE (Groq API, model=llama-3.3-70b-versatile)
medical_judge client: LIVE (Groq API, model=llama-3.3-70b-versatile)
This wastes the 70B daily quota (1000 RPD/account) on roles that
should be on the 14400 RPD 8B pool, and slows each episode by
~3-4x because 70B latency dominates short conversational replies.
Fix: resolution order for each role's model is now
1. Explicit constructor kwarg (legacy callers still win)
2. ERMAP_<ROLE>_MODEL env var (notebook/dashboard/.env path)
3. Shared `model` default
Verified: with the four env vars set, AgentRouter._models now
reports the intended split:
nurse: llama-3.1-8b-instant
patient: llama-3.1-8b-instant
empathy_judge: llama-3.3-70b-versatile
medical_judge: llama-3.3-70b-versatile
Note for users running training right now: STOP, pull this fix,
RESTART. The current run is on 70B-everywhere and will either
hit a 70B rate limit mid-episode or silently waste 3-4x wall-clock
per episode.
Made-with: Cursor
- ER_MAP/envs/api_router.py +11 -5
|
@@ -125,12 +125,18 @@ class AgentRouter:
|
|
| 125 |
|
| 126 |
# Per-role models: each role can run a different Groq model so the
|
| 127 |
# Doctor (e.g. 8B for speed/quota) is independent of the Judges
|
| 128 |
-
# (70B for nuanced grading).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 129 |
self._models: Dict[str, str] = {
|
| 130 |
-
"nurse": nurse_model or model,
|
| 131 |
-
"patient": patient_model or model,
|
| 132 |
-
"empathy_judge": empathy_judge_model or model,
|
| 133 |
-
"medical_judge": medical_judge_model or model,
|
| 134 |
}
|
| 135 |
|
| 136 |
# Resolve per-role API keys (explicit > role-specific env > shared)
|
|
|
|
| 125 |
|
| 126 |
# Per-role models: each role can run a different Groq model so the
|
| 127 |
# Doctor (e.g. 8B for speed/quota) is independent of the Judges
|
| 128 |
+
# (70B for nuanced grading). Resolution order, per role:
|
| 129 |
+
# 1. Explicit constructor kwarg (e.g. nurse_model=...)
|
| 130 |
+
# 2. ERMAP_<ROLE>_MODEL env var (set by the Kaggle notebook /
|
| 131 |
+
# dashboard / .env to traffic-shape across Groq's 8B vs 70B
|
| 132 |
+
# pools — high-volume Patient/Nurse on 8B-instant, both
|
| 133 |
+
# Judges on 70B-versatile)
|
| 134 |
+
# 3. Shared `model` default (legacy single-model behaviour)
|
| 135 |
self._models: Dict[str, str] = {
|
| 136 |
+
"nurse": nurse_model or os.environ.get("ERMAP_NURSE_MODEL", "") or model,
|
| 137 |
+
"patient": patient_model or os.environ.get("ERMAP_PATIENT_MODEL", "") or model,
|
| 138 |
+
"empathy_judge": empathy_judge_model or os.environ.get("ERMAP_EMPATHY_JUDGE_MODEL", "") or model,
|
| 139 |
+
"medical_judge": medical_judge_model or os.environ.get("ERMAP_MEDICAL_JUDGE_MODEL", "") or model,
|
| 140 |
}
|
| 141 |
|
| 142 |
# Resolve per-role API keys (explicit > role-specific env > shared)
|