Spaces:
Sleeping
Sleeping
Remove disclaimer from AIHealthcare backend and frontend
Browse files
AIHealthcare/app/main.py
CHANGED
|
@@ -24,7 +24,6 @@ class TriageResponse(BaseModel):
|
|
| 24 |
rationale: str
|
| 25 |
red_flags: List[str]
|
| 26 |
suggested_actions: List[str]
|
| 27 |
-
disclaimer: str
|
| 28 |
|
| 29 |
|
| 30 |
app = FastAPI(title="AI Symptom Triage (Demo)", version="0.1.0")
|
|
@@ -81,7 +80,6 @@ SYSTEM_PROMPT = (
|
|
| 81 |
"- rationale: 1–3 short sentences justifying disposition (mention key findings and uncertainties).\n"
|
| 82 |
"- red_flags: list only when present (name each one clearly).\n"
|
| 83 |
"- suggested_actions: actionable but non‑diagnostic (e.g., 'seek urgent care now', 'book primary care in 1–2 weeks', 'rest, fluids, OTC analgesic per label').\n"
|
| 84 |
-
"- disclaimer: include a clear statement that this is educational only, not medical advice, and to contact a clinician/emergency services when indicated.\n\n"
|
| 85 |
"Return STRICT JSON only matching the schema."
|
| 86 |
)
|
| 87 |
|
|
@@ -117,14 +115,13 @@ class SymptomTriageService:
|
|
| 117 |
"name": "TriageResponse",
|
| 118 |
"schema": {
|
| 119 |
"type": "object",
|
| 120 |
-
"required": ["disposition", "rationale", "red_flags", "suggested_actions"
|
| 121 |
"additionalProperties": False,
|
| 122 |
"properties": {
|
| 123 |
"disposition": {"type": "string", "enum": ["urgent", "routine", "self-care"]},
|
| 124 |
"rationale": {"type": "string"},
|
| 125 |
"red_flags": {"type": "array", "items": {"type": "string"}},
|
| 126 |
-
"suggested_actions": {"type": "array", "items": {"type": "string"}}
|
| 127 |
-
"disclaimer": {"type": "string"}
|
| 128 |
}
|
| 129 |
}
|
| 130 |
}
|
|
@@ -134,7 +131,7 @@ class SymptomTriageService:
|
|
| 134 |
resp = self.client.chat.completions.create(
|
| 135 |
model=self.model,
|
| 136 |
messages=[
|
| 137 |
-
{"role": "system", "content": SYSTEM_PROMPT + "\nReturn ONLY JSON with disposition, rationale, red_flags[], suggested_actions[]
|
| 138 |
{"role": "user", "content": user},
|
| 139 |
],
|
| 140 |
temperature=0.15,
|
|
@@ -207,14 +204,6 @@ class SymptomTriageService:
|
|
| 207 |
data["rationale"] = (prefix + rationale) if rationale else prefix
|
| 208 |
data["disposition"] = disp if disp in {"urgent", "routine", "self-care"} else "urgent" if red_found else "routine"
|
| 209 |
data["red_flags"] = red_flags
|
| 210 |
-
# Enforce a standard disclaimer if missing/weak
|
| 211 |
-
disclaimer = (data.get("disclaimer") or "").strip()
|
| 212 |
-
min_disclaimer = (
|
| 213 |
-
"This is an educational triage demo, not medical advice. If symptoms are severe or you are concerned, "
|
| 214 |
-
"seek care from a licensed clinician or emergency services."
|
| 215 |
-
)
|
| 216 |
-
if len(disclaimer) < 80:
|
| 217 |
-
data["disclaimer"] = min_disclaimer
|
| 218 |
except Exception:
|
| 219 |
pass
|
| 220 |
|
|
|
|
| 24 |
rationale: str
|
| 25 |
red_flags: List[str]
|
| 26 |
suggested_actions: List[str]
|
|
|
|
| 27 |
|
| 28 |
|
| 29 |
app = FastAPI(title="AI Symptom Triage (Demo)", version="0.1.0")
|
|
|
|
| 80 |
"- rationale: 1–3 short sentences justifying disposition (mention key findings and uncertainties).\n"
|
| 81 |
"- red_flags: list only when present (name each one clearly).\n"
|
| 82 |
"- suggested_actions: actionable but non‑diagnostic (e.g., 'seek urgent care now', 'book primary care in 1–2 weeks', 'rest, fluids, OTC analgesic per label').\n"
|
|
|
|
| 83 |
"Return STRICT JSON only matching the schema."
|
| 84 |
)
|
| 85 |
|
|
|
|
| 115 |
"name": "TriageResponse",
|
| 116 |
"schema": {
|
| 117 |
"type": "object",
|
| 118 |
+
"required": ["disposition", "rationale", "red_flags", "suggested_actions"],
|
| 119 |
"additionalProperties": False,
|
| 120 |
"properties": {
|
| 121 |
"disposition": {"type": "string", "enum": ["urgent", "routine", "self-care"]},
|
| 122 |
"rationale": {"type": "string"},
|
| 123 |
"red_flags": {"type": "array", "items": {"type": "string"}},
|
| 124 |
+
"suggested_actions": {"type": "array", "items": {"type": "string"}}
|
|
|
|
| 125 |
}
|
| 126 |
}
|
| 127 |
}
|
|
|
|
| 131 |
resp = self.client.chat.completions.create(
|
| 132 |
model=self.model,
|
| 133 |
messages=[
|
| 134 |
+
{"role": "system", "content": SYSTEM_PROMPT + "\nReturn ONLY JSON with disposition, rationale, red_flags[], suggested_actions[]."},
|
| 135 |
{"role": "user", "content": user},
|
| 136 |
],
|
| 137 |
temperature=0.15,
|
|
|
|
| 204 |
data["rationale"] = (prefix + rationale) if rationale else prefix
|
| 205 |
data["disposition"] = disp if disp in {"urgent", "routine", "self-care"} else "urgent" if red_found else "routine"
|
| 206 |
data["red_flags"] = red_flags
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 207 |
except Exception:
|
| 208 |
pass
|
| 209 |
|
AIHealthcare/app/static/index.html
CHANGED
|
@@ -78,7 +78,6 @@
|
|
| 78 |
<p>${data.rationale||''}</p>
|
| 79 |
${ (data.red_flags||[]).length ? '<p><strong>Red flags</strong></p><ul>'+data.red_flags.map(x=>'<li>'+x+'</li>').join('')+'</ul>' : '' }
|
| 80 |
${ (data.suggested_actions||[]).length ? '<p><strong>Suggested actions</strong></p><ul>'+data.suggested_actions.map(x=>'<li>'+x+'</li>').join('')+'</ul>' : '' }
|
| 81 |
-
<p class="muted" style="margin-top:8px">${data.disclaimer||''}</p>
|
| 82 |
</div>`;
|
| 83 |
});
|
| 84 |
</script>
|
|
|
|
| 78 |
<p>${data.rationale||''}</p>
|
| 79 |
${ (data.red_flags||[]).length ? '<p><strong>Red flags</strong></p><ul>'+data.red_flags.map(x=>'<li>'+x+'</li>').join('')+'</ul>' : '' }
|
| 80 |
${ (data.suggested_actions||[]).length ? '<p><strong>Suggested actions</strong></p><ul>'+data.suggested_actions.map(x=>'<li>'+x+'</li>').join('')+'</ul>' : '' }
|
|
|
|
| 81 |
</div>`;
|
| 82 |
});
|
| 83 |
</script>
|