fix quick try
Browse files
app.py
CHANGED
@@ -206,6 +206,8 @@ def chat_with_model(messages, pid):
|
|
206 |
patient_conversations[current_id] = updated_messages
|
207 |
yield updated_messages
|
208 |
|
|
|
|
|
209 |
if in_think:
|
210 |
output_text += "*"
|
211 |
|
@@ -255,25 +257,11 @@ def format_prompt(messages):
|
|
255 |
return prompt
|
256 |
|
257 |
def add_user_message(user_input, history, pid):
|
258 |
-
if not pid:
|
259 |
return "", []
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
return "", [msg for msg in ([{
|
264 |
-
"role": "assistant",
|
265 |
-
"content": (
|
266 |
-
"**Welcome to the Radiologist's Companion!**\n\n"
|
267 |
-
"You can ask me about the patient's medical history or available imaging data.\n"
|
268 |
-
"- I can summarize key details from the EHR.\n"
|
269 |
-
"- I can tell you which medical images are available.\n"
|
270 |
-
"- If you'd like an organ segmentation (e.g. spleen, liver, kidney_left, colon, femur_right) on an abdominal CT scan, just ask!\n\n"
|
271 |
-
"**Example Requests:**\n"
|
272 |
-
"- \"What do we know about this patient?\"\n"
|
273 |
-
"- \"Which images are available for this patient?\"\n"
|
274 |
-
"- \"Can you segment the spleen from the CT scan?\"\n"
|
275 |
-
)
|
276 |
-
}] + conv)]
|
277 |
|
278 |
def autofill_patient(patient_key):
|
279 |
if patient_key in patient_db:
|
@@ -297,22 +285,23 @@ def load_patient_conversation(patient_key):
|
|
297 |
if patient_key in patient_db:
|
298 |
patient_id_val = patient_db[patient_key]["id"]
|
299 |
history = patient_conversations.get(patient_id_val, [])
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
|
|
316 |
return []
|
317 |
|
318 |
|
|
|
206 |
patient_conversations[current_id] = updated_messages
|
207 |
yield updated_messages
|
208 |
|
209 |
+
thread.join()
|
210 |
+
|
211 |
if in_think:
|
212 |
output_text += "*"
|
213 |
|
|
|
257 |
return prompt
|
258 |
|
259 |
def add_user_message(user_input, history, pid):
|
260 |
+
if not pid:
|
261 |
return "", []
|
262 |
+
history.append({"role": "user", "content": user_input})
|
263 |
+
patient_conversations[pid] = history # single source of truth
|
264 |
+
return "", history # no extra welcome
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
265 |
|
266 |
def autofill_patient(patient_key):
|
267 |
if patient_key in patient_db:
|
|
|
285 |
if patient_key in patient_db:
|
286 |
patient_id_val = patient_db[patient_key]["id"]
|
287 |
history = patient_conversations.get(patient_id_val, [])
|
288 |
+
if not history:
|
289 |
+
welcome_message = {
|
290 |
+
"role": "assistant",
|
291 |
+
"content": (
|
292 |
+
"**Welcome to the Radiologist's Companion!**\n\n"
|
293 |
+
"You can ask me about the patient's medical history or available imaging data.\n"
|
294 |
+
"- I can summarize key details from the EHR.\n"
|
295 |
+
"- I can tell you which medical images are available.\n"
|
296 |
+
"- If you'd like an organ segmentation (e.g. spleen, liver, kidney_left, colon, femur_right) on an abdominal CT scan, just ask!\n\n"
|
297 |
+
"**Example Requests:**\n"
|
298 |
+
"- \"What do we know about this patient?\"\n"
|
299 |
+
"- \"Which images are available for this patient?\"\n"
|
300 |
+
"- \"Can you segment the spleen from the CT scan?\"\n"
|
301 |
+
)
|
302 |
+
}
|
303 |
+
history = [welcome_message]
|
304 |
+
return history
|
305 |
return []
|
306 |
|
307 |
|