fix: move language selector global + fix diagnosis prompt echo bug
Browse files- Language dropdown moved above main content row (global selector)
- Prompt now explicitly instructs model to return a clinical condition
name (e.g. 'Contact Dermatitis'), not a restatement of symptoms
- Fixes VI/other language diagnosis echoing patient description
- app.py +10 -5
- src/agent.py +8 -4
app.py
CHANGED
|
@@ -382,6 +382,16 @@ with gr.Blocks(css=CSS, theme=gr.themes.Base(), title="MediVision — AMD MI300X
|
|
| 382 |
|
| 383 |
gr.HTML(HEADER_HTML)
|
| 384 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 385 |
# Connection status bar — auto-populated on load, refreshed after each analysis
|
| 386 |
status_bar = gr.HTML(value="<div style='height:36px;'></div>")
|
| 387 |
|
|
@@ -402,11 +412,6 @@ with gr.Blocks(css=CSS, theme=gr.themes.Base(), title="MediVision — AMD MI300X
|
|
| 402 |
),
|
| 403 |
lines=4,
|
| 404 |
)
|
| 405 |
-
lang_radio = gr.Dropdown(
|
| 406 |
-
choices=["English", "Tiếng Việt", "中文", "Español", "Français", "日本語"],
|
| 407 |
-
value="English",
|
| 408 |
-
label="Language / Ngôn ngữ",
|
| 409 |
-
)
|
| 410 |
submit_btn = gr.Button(
|
| 411 |
"🔬 Analyze / Phân tích",
|
| 412 |
variant="primary",
|
|
|
|
| 382 |
|
| 383 |
gr.HTML(HEADER_HTML)
|
| 384 |
|
| 385 |
+
# ── Global language selector ──────────────────────────────────────────────
|
| 386 |
+
with gr.Row():
|
| 387 |
+
with gr.Column(scale=0, min_width=220):
|
| 388 |
+
lang_radio = gr.Dropdown(
|
| 389 |
+
choices=["English", "Tiếng Việt", "中文", "Español", "Français", "日本語"],
|
| 390 |
+
value="English",
|
| 391 |
+
label="🌐 Language",
|
| 392 |
+
container=True,
|
| 393 |
+
)
|
| 394 |
+
|
| 395 |
# Connection status bar — auto-populated on load, refreshed after each analysis
|
| 396 |
status_bar = gr.HTML(value="<div style='height:36px;'></div>")
|
| 397 |
|
|
|
|
| 412 |
),
|
| 413 |
lines=4,
|
| 414 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 415 |
submit_btn = gr.Button(
|
| 416 |
"🔬 Analyze / Phân tích",
|
| 417 |
variant="primary",
|
src/agent.py
CHANGED
|
@@ -23,10 +23,14 @@ def _build_prompt(image_path: str | None, text_description: str, lang: str) -> s
|
|
| 23 |
"The user has provided"
|
| 24 |
+ (" an image of a skin condition and" if has_image else "")
|
| 25 |
+ f" the following symptom description:\n\n{text_description}\n\n"
|
| 26 |
-
"
|
| 27 |
-
" diagnosis
|
| 28 |
-
"
|
| 29 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
)
|
| 31 |
|
| 32 |
|
|
|
|
| 23 |
"The user has provided"
|
| 24 |
+ (" an image of a skin condition and" if has_image else "")
|
| 25 |
+ f" the following symptom description:\n\n{text_description}\n\n"
|
| 26 |
+
"Analyze the above and respond with a single JSON object using these exact keys:\n"
|
| 27 |
+
" \"diagnosis\": a concise clinical condition name (e.g. 'Contact Dermatitis', "
|
| 28 |
+
"'Superficial Laceration', 'Cellulitis') — NOT a restatement of the patient's "
|
| 29 |
+
"symptoms. Use the standard medical term, translated into the response language.\n"
|
| 30 |
+
" \"severity\": one of Low | Medium | High | Urgent\n"
|
| 31 |
+
" \"recommended_actions\": list of 3-5 actionable strings\n"
|
| 32 |
+
" \"confidence_score\": integer 0-100\n"
|
| 33 |
+
"Return only the JSON object, no extra text."
|
| 34 |
)
|
| 35 |
|
| 36 |
|