Spaces:
Runtime error
Runtime error
Yew Chong
commited on
Commit
·
6c06eaa
1
Parent(s):
534b6f7
ui changes
Browse files- app_final.py +260 -266
app_final.py
CHANGED
@@ -243,17 +243,6 @@ else:
|
|
243 |
st.rerun()
|
244 |
|
245 |
scenario_tab, dashboard_tab = st.tabs(["Training", "Dashboard"])
|
246 |
-
# st.header("head")
|
247 |
-
# st.markdown("## markdown")
|
248 |
-
# st.caption("caption")
|
249 |
-
# st.divider()
|
250 |
-
# import pandas as pd
|
251 |
-
# import numpy as np
|
252 |
-
# map_data = pd.DataFrame(
|
253 |
-
# np.random.randn(1000, 2) / [50, 50] + [37.76, -122.4],
|
254 |
-
# columns=['lat', 'lon'])
|
255 |
-
|
256 |
-
# st.map(map_data)
|
257 |
|
258 |
class ScenarioTabIndex:
|
259 |
SELECT_SCENARIO = 0
|
@@ -264,9 +253,6 @@ else:
|
|
264 |
st.session_state.scenario_tab_index=x
|
265 |
return None
|
266 |
|
267 |
-
# def select_scenario_and_change_tab(_):
|
268 |
-
# set_scenario_tab_index(ScenarioTabIndex.PATIENT_LLM)
|
269 |
-
|
270 |
def go_to_patient_llm():
|
271 |
selected_scenario = st.session_state.get('selected_scenario')
|
272 |
if selected_scenario is None or selected_scenario < 0:
|
@@ -283,264 +269,272 @@ else:
|
|
283 |
set_scenario_tab_index(ScenarioTabIndex.SELECT_SCENARIO)
|
284 |
|
285 |
with scenario_tab:
|
286 |
-
##
|
287 |
-
if
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
rows = list()
|
295 |
-
# for _ in range(0, number_of_indexes, total_cols):
|
296 |
-
# rows.extend(st.columns(total_cols))
|
297 |
-
|
298 |
-
st.header(f"Selected Scenario: {st.session_state.scenario_list[st.session_state.selected_scenario] if st.session_state.selected_scenario>=0 else 'None'}")
|
299 |
-
for i, scenario in enumerate(st.session_state.scenario_list):
|
300 |
-
if i % total_cols == 0:
|
301 |
-
rows.extend(st.columns(total_cols))
|
302 |
-
curr_col = rows[(-total_cols + i % total_cols)]
|
303 |
-
tile = curr_col.container(height=120)
|
304 |
-
## TODO: Implement highlight box if index is selected
|
305 |
-
# if st.session_state.selected_scenario == i:
|
306 |
-
# tile.markdown("<style>background: pink !important;</style>", unsafe_allow_html=True)
|
307 |
-
tile.write(":balloon:")
|
308 |
-
tile.button(label=scenario, on_click=change_scenario, args=[i])
|
309 |
-
|
310 |
-
select_scenario_btn = st.button("Select Scenario", on_click=go_to_patient_llm, args=[])
|
311 |
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
|
|
329 |
|
330 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
331 |
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
373 |
</div>
|
374 |
-
|
375 |
-
|
376 |
-
<script>
|
377 |
-
|
378 |
-
var x = setInterval(function() {{
|
379 |
-
var start_time_str = "{st.session_state.start_time}";
|
380 |
-
var start_date = new Date(start_time_str);
|
381 |
-
var curr_date = new Date();
|
382 |
-
var time_difference = curr_date - start_date;
|
383 |
-
var time_diff_secs = Math.floor(time_difference / 1000);
|
384 |
-
var time_left = {TIME_LIMIT} - time_diff_secs;
|
385 |
-
var mins = Math.floor(time_left / 60);
|
386 |
-
var secs = time_left % 60;
|
387 |
-
var fmins = mins.toString().padStart(2, '0');
|
388 |
-
var fsecs = secs.toString().padStart(2, '0');
|
389 |
-
console.log("run");
|
390 |
-
|
391 |
-
if (start_time_str == "False") {{
|
392 |
-
document.getElementById("ttime").innerHTML = 'Press "Start" to start!';
|
393 |
-
clearInterval(x);
|
394 |
-
}}
|
395 |
-
else if (time_left <= 0) {{
|
396 |
-
document.getElementById("ttime").innerHTML = "Time's Up!!!";
|
397 |
-
clearInterval(x);
|
398 |
-
}}
|
399 |
-
else {{
|
400 |
-
document.getElementById("ttime").innerHTML = `${{fmins}}:${{fsecs}}`;
|
401 |
-
}}
|
402 |
-
}}, 999)
|
403 |
-
|
404 |
-
</script>
|
405 |
-
""",
|
406 |
-
)
|
407 |
-
|
408 |
-
with open("./public/chars/Female_talk.gif", "rb") as f:
|
409 |
-
contents = f.read()
|
410 |
-
student_url = base64.b64encode(contents).decode("utf-8")
|
411 |
-
|
412 |
-
with open("./public/chars/Male_talk.gif", "rb") as f:
|
413 |
-
contents = f.read()
|
414 |
-
patient_url = base64.b64encode(contents).decode("utf-8")
|
415 |
-
interactive_container = st.container()
|
416 |
-
user_input_col ,r = st.columns([4,1])
|
417 |
-
def to_grader_llm():
|
418 |
-
init_grader_llm()
|
419 |
-
set_scenario_tab_index(ScenarioTabIndex.GRADER_LLM)
|
420 |
-
|
421 |
-
with r:
|
422 |
-
to_grader_btn = st.button("To Grader", on_click=to_grader_llm)
|
423 |
-
with user_input_col:
|
424 |
-
user_inputs = st.text_input("", placeholder="Chat with the patient here!", key="user_inputs")
|
425 |
-
if user_inputs:
|
426 |
-
response = st.session_state.chain.invoke(user_inputs).get("text")
|
427 |
-
st.session_state.patient_response = response
|
428 |
-
with interactive_container:
|
429 |
-
html(f"""
|
430 |
-
<style>
|
431 |
-
.conversation-container {{
|
432 |
-
display: grid;
|
433 |
-
grid-template-columns: 1fr 1fr;
|
434 |
-
grid-template-rows: 1fr 1fr;
|
435 |
-
gap: 10px;
|
436 |
-
width: 100%;
|
437 |
-
height: 100%;
|
438 |
-
background-color: #add8e6; /* Soothing blue background */
|
439 |
-
}}
|
440 |
-
|
441 |
-
.doctor-image {{
|
442 |
-
grid-column: 1;
|
443 |
-
grid-row: 2;
|
444 |
-
display: flex;
|
445 |
-
justify-content: center;
|
446 |
-
align-items: center;
|
447 |
-
}}
|
448 |
-
|
449 |
-
.patient-image {{
|
450 |
-
grid-column: 2;
|
451 |
-
grid-row: 1;
|
452 |
-
display: flex;
|
453 |
-
justify-content: center;
|
454 |
-
align-items: center;
|
455 |
-
}}
|
456 |
-
|
457 |
-
.doctor-input {{
|
458 |
-
grid-column: 2;
|
459 |
-
grid-row: 2;
|
460 |
-
display: flex;
|
461 |
-
justify-content: center;
|
462 |
-
align-items: center;
|
463 |
-
}}
|
464 |
-
|
465 |
-
.patient-input {{
|
466 |
-
grid-column: 1;
|
467 |
-
grid-row: 1;
|
468 |
-
display: flex;
|
469 |
-
justify-content: center;
|
470 |
-
align-items: center;
|
471 |
-
}}
|
472 |
-
|
473 |
-
img {{
|
474 |
-
max-width: 100%;
|
475 |
-
height: auto;
|
476 |
-
border-radius: 8px; /* Rounded corners for the images */
|
477 |
-
}}
|
478 |
-
|
479 |
-
input[type="text"] {{
|
480 |
-
width: 90%;
|
481 |
-
padding: 10px;
|
482 |
-
margin: 10px;
|
483 |
-
border: none;
|
484 |
-
border-radius: 5px;
|
485 |
-
}}
|
486 |
-
</style>
|
487 |
-
</head>
|
488 |
-
<body>
|
489 |
-
<div class="conversation-container">
|
490 |
-
<div class="doctor-image">
|
491 |
-
<img src="data:image/png;base64,{student_url}" alt="Doctor" />
|
492 |
-
</div>
|
493 |
-
<div class="patient-image">
|
494 |
-
<img src="data:image/gif;base64,{patient_url}" alt="Patient" />
|
495 |
-
</div>
|
496 |
-
<div class="doctor-input">
|
497 |
-
<span id="doctor_message">You: {st.session_state.get('user_inputs') or ''}</span>
|
498 |
-
</div>
|
499 |
-
<div class="patient-input">
|
500 |
-
<span id="patient_message">{'Patient: '+st.session_state.get('patient_response') if st.session_state.get('patient_response') else '...'}</span>
|
501 |
</div>
|
502 |
-
</
|
503 |
-
</
|
504 |
-
</html>
|
505 |
-
|
506 |
-
""", height=500)
|
507 |
-
|
508 |
-
elif st.session_state.scenario_tab_index == ScenarioTabIndex.GRADER_LLM:
|
509 |
-
st.session_state.grader_output = "" if not st.session_state.get("grader_output") else st.session_state.grader_output
|
510 |
-
def get_grades():
|
511 |
-
txt = f"""
|
512 |
-
<summary>
|
513 |
-
{st.session_state.diagnosis}
|
514 |
-
</summary>
|
515 |
-
<differential-1>
|
516 |
-
{st.session_state.differential_1}
|
517 |
-
</differential-1>
|
518 |
-
<differential-2>
|
519 |
-
{st.session_state.differential_2}
|
520 |
-
</differential-2>
|
521 |
-
<differential-3>
|
522 |
-
{st.session_state.differential_3}
|
523 |
-
</differential-3>
|
524 |
-
"""
|
525 |
-
response = st.session_state.chain2.invoke(txt)
|
526 |
-
st.session_state.grader_output = response
|
527 |
-
st.session_state.has_llm_output = bool(st.session_state.get("grader_output"))
|
528 |
-
## TODO: False for now, need check llm output!
|
529 |
-
with st.expander("Your Diagnosis and Differentials", expanded=not st.session_state.has_llm_output):
|
530 |
-
st.session_state.diagnosis = st.text_area("Input your case summary and **main** diagnosis:", placeholder="This is a young gentleman with significant family history of stroke, and medical history of poorly-controlled hypertension. He presents with acute onset of bitemporal headache associated with dysarthria and meningism symptoms. Important negatives include the absence of focal neurological deficits, ataxia, and recent trauma.")
|
531 |
-
st.divider()
|
532 |
-
st.session_state.differential_1 = st.text_input("Differential 1")
|
533 |
-
st.session_state.differential_2 = st.text_input("Differential 2")
|
534 |
-
st.session_state.differential_3 = st.text_input("Differential 3")
|
535 |
-
with st.columns(6)[5]:
|
536 |
-
send_for_grading = st.button("Get grades!", on_click=get_grades)
|
537 |
-
with st.expander("Your grade", expanded=st.session_state.has_llm_output):
|
538 |
-
if st.session_state.grader_output:
|
539 |
-
st.write(st.session_state.grader_output.get("text").get("text"))
|
540 |
-
|
541 |
-
# back_btn = st.button("back to LLM?", on_click=set_scenario_tab_index, args=[ScenarioTabIndex.PATIENT_LLM])
|
542 |
-
back_btn = st.button("New Scenario?", on_click=set_scenario_tab_index, args=[ScenarioTabIndex.SELECT_SCENARIO])
|
543 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
544 |
with dashboard_tab:
|
545 |
cred = db.cred
|
546 |
# cred = credentials.Certificate(json.loads(os.environ.get("FIREBASE_CREDENTIAL")))
|
|
|
243 |
st.rerun()
|
244 |
|
245 |
scenario_tab, dashboard_tab = st.tabs(["Training", "Dashboard"])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
246 |
|
247 |
class ScenarioTabIndex:
|
248 |
SELECT_SCENARIO = 0
|
|
|
253 |
st.session_state.scenario_tab_index=x
|
254 |
return None
|
255 |
|
|
|
|
|
|
|
256 |
def go_to_patient_llm():
|
257 |
selected_scenario = st.session_state.get('selected_scenario')
|
258 |
if selected_scenario is None or selected_scenario < 0:
|
|
|
269 |
set_scenario_tab_index(ScenarioTabIndex.SELECT_SCENARIO)
|
270 |
|
271 |
with scenario_tab:
|
272 |
+
##
|
273 |
+
if True:
|
274 |
+
## Check in select scenario
|
275 |
+
if st.session_state.scenario_tab_index == ScenarioTabIndex.SELECT_SCENARIO:
|
276 |
+
def change_scenario(scenario_index):
|
277 |
+
st.session_state.selected_scenario = scenario_index
|
278 |
+
if st.session_state.get("selected_scenario", None) is None:
|
279 |
+
st.session_state.selected_scenario = -1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
280 |
|
281 |
+
total_cols = 3
|
282 |
+
rows = list()
|
283 |
+
# for _ in range(0, number_of_indexes, total_cols):
|
284 |
+
# rows.extend(st.columns(total_cols))
|
285 |
+
|
286 |
+
st.header(f"Selected Scenario: {st.session_state.scenario_list[st.session_state.selected_scenario] if st.session_state.selected_scenario>=0 else 'None'}")
|
287 |
+
for i, scenario in enumerate(st.session_state.scenario_list):
|
288 |
+
if i % total_cols == 0:
|
289 |
+
rows.extend(st.columns(total_cols))
|
290 |
+
curr_col = rows[(-total_cols + i % total_cols)]
|
291 |
+
tile = curr_col.container(height=120)
|
292 |
+
## TODO: Implement highlight box if index is selected
|
293 |
+
# if st.session_state.selected_scenario == i:
|
294 |
+
# tile.markdown("<style>background: pink !important;</style>", unsafe_allow_html=True)
|
295 |
+
tile.write(":balloon:")
|
296 |
+
tile.button(label=scenario, on_click=change_scenario, args=[i])
|
297 |
+
|
298 |
+
select_scenario_btn = st.button("Select Scenario", on_click=go_to_patient_llm, args=[])
|
299 |
|
300 |
+
elif st.session_state.scenario_tab_index == ScenarioTabIndex.PATIENT_LLM:
|
301 |
+
st.header("Patient info")
|
302 |
+
## TODO: Put the patient's info here, from SCENARIO
|
303 |
+
# st.write("Pull the info here!!!")
|
304 |
+
col1, col2, col3 = st.columns([1,3,1])
|
305 |
+
with col1:
|
306 |
+
back_to_scenario_btn = st.button("Back to selection", on_click=set_scenario_tab_index, args=[ScenarioTabIndex.SELECT_SCENARIO])
|
307 |
+
# with col3:
|
308 |
+
# start_timer_button = st.button("START")
|
309 |
+
|
310 |
+
with col2:
|
311 |
+
TIME_LIMIT = 60*10 ## to change to 10 minutes
|
312 |
+
time.sleep(1)
|
313 |
+
# if start_timer_button:
|
314 |
+
# st.session_state.start_time = datetime.datetime.now()
|
315 |
+
# st.session_state.time = -1 if not st.session_state.get('time') else st.session_state.get('time')
|
316 |
+
st.session_state.start_time = False if not st.session_state.get('start_time') else st.session_state.start_time
|
317 |
+
|
318 |
+
from streamlit.components.v1 import html
|
319 |
|
320 |
+
|
321 |
+
html(f"""
|
322 |
+
<style>
|
323 |
+
@import url('https://fonts.googleapis.com/css2?family=Pixelify+Sans&display=swap');
|
324 |
+
@import url('https://fonts.googleapis.com/css2?family=VT323&display=swap');
|
325 |
+
@import url('https://fonts.googleapis.com/css2?family=Monofett&display=swap');
|
326 |
+
</style>
|
327 |
+
|
328 |
+
<style>
|
329 |
+
html {{
|
330 |
+
font-family: 'Pixelify Sans', monospace, serif;
|
331 |
+
font-family: 'VT323', monospace, sans-serif;
|
332 |
+
font-family: 'Monofett', monospace, sans-serif;
|
333 |
+
font-family: 'Times New Roman', sans-serif;
|
334 |
+
background-color: #0E1117 !important;
|
335 |
+
color: RGB(250,250,250);
|
336 |
+
// border-radius: 25%;
|
337 |
+
// border: 1px solid #0E1117;
|
338 |
+
}}
|
339 |
+
html, body {{
|
340 |
+
// background-color: transparent !important;
|
341 |
+
// margin: 10px;
|
342 |
+
// border: 1px solid pink;
|
343 |
+
text-align: center;
|
344 |
+
}}
|
345 |
+
body {{
|
346 |
+
background-color: #0E1117;
|
347 |
+
// margin: 10px;
|
348 |
+
// border: 1px solid pink;
|
349 |
+
}}
|
350 |
+
|
351 |
+
body #ttime {{
|
352 |
+
font-weight: bold;
|
353 |
+
font-family: 'VT323', monospace, sans-serif;
|
354 |
+
// font-family: 'Pixelify Sans', monospace, serif;
|
355 |
+
}}
|
356 |
+
</style>
|
357 |
+
|
358 |
+
<div>
|
359 |
+
<h1>Time left</h1>
|
360 |
+
<h1 id="ttime"> </h1>
|
361 |
+
</div>
|
362 |
+
|
363 |
+
|
364 |
+
<script>
|
365 |
+
|
366 |
+
var x = setInterval(function() {{
|
367 |
+
var start_time_str = "{st.session_state.start_time}";
|
368 |
+
var start_date = new Date(start_time_str);
|
369 |
+
var curr_date = new Date();
|
370 |
+
var time_difference = curr_date - start_date;
|
371 |
+
var time_diff_secs = Math.floor(time_difference / 1000);
|
372 |
+
var time_left = {TIME_LIMIT} - time_diff_secs;
|
373 |
+
var mins = Math.floor(time_left / 60);
|
374 |
+
var secs = time_left % 60;
|
375 |
+
var fmins = mins.toString().padStart(2, '0');
|
376 |
+
var fsecs = secs.toString().padStart(2, '0');
|
377 |
+
console.log("run");
|
378 |
+
|
379 |
+
if (start_time_str == "False") {{
|
380 |
+
document.getElementById("ttime").innerHTML = 'Press "Start" to start!';
|
381 |
+
clearInterval(x);
|
382 |
+
}}
|
383 |
+
else if (time_left <= 0) {{
|
384 |
+
document.getElementById("ttime").innerHTML = "Time's Up!!!";
|
385 |
+
clearInterval(x);
|
386 |
+
}}
|
387 |
+
else {{
|
388 |
+
document.getElementById("ttime").innerHTML = `${{fmins}}:${{fsecs}}`;
|
389 |
+
}}
|
390 |
+
}}, 999)
|
391 |
+
|
392 |
+
</script>
|
393 |
+
""",
|
394 |
+
)
|
395 |
+
|
396 |
+
with open("./public/chars/Female_talk.gif", "rb") as f:
|
397 |
+
contents = f.read()
|
398 |
+
student_url = base64.b64encode(contents).decode("utf-8")
|
399 |
+
|
400 |
+
with open("./public/chars/Male_talk.gif", "rb") as f:
|
401 |
+
contents = f.read()
|
402 |
+
patient_url = base64.b64encode(contents).decode("utf-8")
|
403 |
+
interactive_container = st.container()
|
404 |
+
user_input_col ,r = st.columns([4,1])
|
405 |
+
def to_grader_llm():
|
406 |
+
init_grader_llm()
|
407 |
+
set_scenario_tab_index(ScenarioTabIndex.GRADER_LLM)
|
408 |
+
|
409 |
+
with r:
|
410 |
+
to_grader_btn = st.button("To Grader", on_click=to_grader_llm)
|
411 |
+
with user_input_col:
|
412 |
+
user_inputs = st.text_input("", placeholder="Chat with the patient here!", key="user_inputs")
|
413 |
+
if user_inputs:
|
414 |
+
response = st.session_state.chain.invoke(user_inputs).get("text")
|
415 |
+
st.session_state.patient_response = response
|
416 |
+
with interactive_container:
|
417 |
+
html(f"""
|
418 |
+
<style>
|
419 |
+
body {{
|
420 |
+
font-family: 'VT323', monospace, sans-serif;
|
421 |
+
}}
|
422 |
+
|
423 |
+
.conversation-container {{
|
424 |
+
display: grid;
|
425 |
+
grid-template-columns: 1fr 1fr;
|
426 |
+
grid-template-rows: 1fr 1fr;
|
427 |
+
gap: 10px;
|
428 |
+
width: calc(100% - 20px);
|
429 |
+
height: calc(100% - 20px);
|
430 |
+
background-color: #add8e6; /* Soothing blue background */
|
431 |
+
padding: 10px;
|
432 |
+
}}
|
433 |
+
|
434 |
+
.doctor-image {{
|
435 |
+
grid-column: 1;
|
436 |
+
grid-row: 2;
|
437 |
+
display: flex;
|
438 |
+
justify-content: center;
|
439 |
+
align-items: center;
|
440 |
+
}}
|
441 |
+
|
442 |
+
.patient-image {{
|
443 |
+
grid-column: 2;
|
444 |
+
grid-row: 1;
|
445 |
+
display: flex;
|
446 |
+
justify-content: center;
|
447 |
+
align-items: center;
|
448 |
+
}}
|
449 |
+
|
450 |
+
.doctor-input {{
|
451 |
+
grid-column: 2;
|
452 |
+
grid-row: 2;
|
453 |
+
display: flex;
|
454 |
+
justify-content: center;
|
455 |
+
align-items: center;
|
456 |
+
}}
|
457 |
+
|
458 |
+
.patient-input {{
|
459 |
+
grid-column: 1;
|
460 |
+
grid-row: 1;
|
461 |
+
display: flex;
|
462 |
+
justify-content: center;
|
463 |
+
align-items: center;
|
464 |
+
}}
|
465 |
+
|
466 |
+
img {{
|
467 |
+
max-width: 100%;
|
468 |
+
height: auto;
|
469 |
+
border-radius: 8px; /* Rounded corners for the images */
|
470 |
+
}}
|
471 |
+
|
472 |
+
input[type="text"] {{
|
473 |
+
width: 90%;
|
474 |
+
padding: 10px;
|
475 |
+
margin: 10px;
|
476 |
+
border: none;
|
477 |
+
border-radius: 5px;
|
478 |
+
}}
|
479 |
+
</style>
|
480 |
+
</head>
|
481 |
+
<body>
|
482 |
+
<div class="conversation-container">
|
483 |
+
<div class="doctor-image">
|
484 |
+
<img src="data:image/png;base64,{student_url}" alt="Doctor" />
|
485 |
+
</div>
|
486 |
+
<div class="patient-image">
|
487 |
+
<img src="data:image/gif;base64,{patient_url}" alt="Patient" />
|
488 |
+
</div>
|
489 |
+
<div class="doctor-input">
|
490 |
+
<span id="doctor_message">You: {st.session_state.get('user_inputs') or ''}</span>
|
491 |
+
</div>
|
492 |
+
<div class="patient-input">
|
493 |
+
<span id="patient_message">{'Patient: '+st.session_state.get('patient_response') if st.session_state.get('patient_response') else '...'}</span>
|
494 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
495 |
</div>
|
496 |
+
</body>
|
497 |
+
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
498 |
|
499 |
+
""", height=500)
|
500 |
+
|
501 |
+
elif st.session_state.scenario_tab_index == ScenarioTabIndex.GRADER_LLM:
|
502 |
+
st.session_state.grader_output = "" if not st.session_state.get("grader_output") else st.session_state.grader_output
|
503 |
+
def get_grades():
|
504 |
+
txt = f"""
|
505 |
+
<summary>
|
506 |
+
{st.session_state.diagnosis}
|
507 |
+
</summary>
|
508 |
+
<differential-1>
|
509 |
+
{st.session_state.differential_1}
|
510 |
+
</differential-1>
|
511 |
+
<differential-2>
|
512 |
+
{st.session_state.differential_2}
|
513 |
+
</differential-2>
|
514 |
+
<differential-3>
|
515 |
+
{st.session_state.differential_3}
|
516 |
+
</differential-3>
|
517 |
+
"""
|
518 |
+
response = st.session_state.chain2.invoke(txt)
|
519 |
+
st.session_state.grader_output = response
|
520 |
+
st.session_state.has_llm_output = bool(st.session_state.get("grader_output"))
|
521 |
+
## TODO: False for now, need check llm output!
|
522 |
+
with st.expander("Your Diagnosis and Differentials", expanded=not st.session_state.has_llm_output):
|
523 |
+
st.session_state.diagnosis = st.text_area("Input your case summary and **main** diagnosis:", placeholder="This is a young gentleman with significant family history of stroke, and medical history of poorly-controlled hypertension. He presents with acute onset of bitemporal headache associated with dysarthria and meningism symptoms. Important negatives include the absence of focal neurological deficits, ataxia, and recent trauma.")
|
524 |
+
st.divider()
|
525 |
+
st.session_state.differential_1 = st.text_input("Differential 1")
|
526 |
+
st.session_state.differential_2 = st.text_input("Differential 2")
|
527 |
+
st.session_state.differential_3 = st.text_input("Differential 3")
|
528 |
+
with st.columns(6)[5]:
|
529 |
+
send_for_grading = st.button("Get grades!", on_click=get_grades)
|
530 |
+
with st.expander("Your grade", expanded=st.session_state.has_llm_output):
|
531 |
+
if st.session_state.grader_output:
|
532 |
+
st.write(st.session_state.grader_output.get("text").get("text"))
|
533 |
+
|
534 |
+
# back_btn = st.button("back to LLM?", on_click=set_scenario_tab_index, args=[ScenarioTabIndex.PATIENT_LLM])
|
535 |
+
back_btn = st.button("New Scenario?", on_click=set_scenario_tab_index, args=[ScenarioTabIndex.SELECT_SCENARIO])
|
536 |
+
else:
|
537 |
+
pass
|
538 |
with dashboard_tab:
|
539 |
cred = db.cred
|
540 |
# cred = credentials.Certificate(json.loads(os.environ.get("FIREBASE_CREDENTIAL")))
|