Spaces:
Running
Running
Commit
·
e4f421b
1
Parent(s):
4469a4a
updated with home page and question submission form
Browse files
app.py
CHANGED
|
@@ -171,6 +171,8 @@ def get_evaluator_questions(email, disease_map_data, user_all_specs, all_files,
|
|
| 171 |
|
| 172 |
return full_question_ids_list, data_by_filename
|
| 173 |
|
|
|
|
|
|
|
| 174 |
|
| 175 |
def go_to_eval_progress_modal(name, email, specialty_dd, subspecialty_dd, years_exp_radio, exp_explanation_tb):
|
| 176 |
|
|
@@ -412,25 +414,60 @@ with gr.Blocks(css=centered_col_css) as demo:
|
|
| 412 |
specialties_list = ["Error parsing specialties"]
|
| 413 |
subspecialties_list = ["Error parsing subspecialties"]
|
| 414 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 415 |
# Page 0: Welcome / Informational page.
|
| 416 |
-
with gr.Column(visible=
|
| 417 |
-
gr.Markdown("## Welcome to the TxAgent
|
| 418 |
gr.Markdown("Please read the following instructions and then enter your information to begin:")
|
| 419 |
# Existing informational markdown...
|
| 420 |
-
gr.Markdown("""
|
| 421 |
-
|
| 422 |
-
|
| 423 |
-
|
| 424 |
-
|
| 425 |
-
|
| 426 |
-
|
| 427 |
-
|
| 428 |
-
|
| 429 |
-
|
|
|
|
|
|
|
| 430 |
name = gr.Textbox(label="Name")
|
| 431 |
-
email = gr.Textbox(label="Email
|
| 432 |
-
specialty_dd = gr.Dropdown(choices=specialties_list, label="Primary Medical Specialty (select one
|
| 433 |
-
subspecialty_dd = gr.Dropdown(choices=subspecialties_list, label="Subspecialty (if applicable, select one
|
| 434 |
years_exp_radio = gr.Radio(
|
| 435 |
choices=["0-2 years", "3-5 years", "6-10 years", "11-20 years", "20+ years", "Not Applicable"],
|
| 436 |
label="How many years have you been involved in clinical and/or research activities related to your biomedical area of expertise?"
|
|
@@ -438,7 +475,10 @@ with gr.Blocks(css=centered_col_css) as demo:
|
|
| 438 |
exp_explanation_tb = gr.Textbox(label="Please briefly explain your expertise/experience relevant to evaluating AI for clinical decision support (optional)")
|
| 439 |
|
| 440 |
page0_error_box = gr.Markdown("")
|
| 441 |
-
|
|
|
|
|
|
|
|
|
|
| 442 |
|
| 443 |
|
| 444 |
with Modal(visible=False) as eval_progress_modal:
|
|
@@ -502,8 +542,11 @@ with gr.Blocks(css=centered_col_css) as demo:
|
|
| 502 |
page1_error_box = gr.Markdown("") # ADDED: display validation errors
|
| 503 |
with gr.Row():
|
| 504 |
back_btn_0 = gr.Button("Back")
|
| 505 |
-
home_btn_1 = gr.Button("Home / FAQ") # ADDED: FAQ button on page1
|
| 506 |
next_btn_1 = gr.Button("Next: Rate Responses")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 507 |
|
| 508 |
# Page 2: Combined Rating Page for both responses.
|
| 509 |
with gr.Column(visible=False) as page2:
|
|
@@ -658,8 +701,13 @@ with gr.Blocks(css=centered_col_css) as demo:
|
|
| 658 |
ratings_B.append(rating_b)
|
| 659 |
with gr.Row():
|
| 660 |
back_btn_2 = gr.Button("Back")
|
| 661 |
-
|
| 662 |
submit_btn = gr.Button("Submit (Note: Once submitted, you cannot edit your responses)", elem_id="submit_btn")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 663 |
result_text = gr.Textbox(label="Validation Result")
|
| 664 |
|
| 665 |
# Final Page: Thank you message.
|
|
@@ -902,6 +950,15 @@ with gr.Blocks(css=centered_col_css) as demo:
|
|
| 902 |
|
| 903 |
# --- Define Transitions Between Pages ---
|
| 904 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 905 |
# Transition from Page 0 (Welcome) to Page 1.
|
| 906 |
next_btn_0.click(
|
| 907 |
fn=go_to_eval_progress_modal,
|
|
@@ -917,9 +974,14 @@ with gr.Blocks(css=centered_col_css) as demo:
|
|
| 917 |
scroll_to_output=True
|
| 918 |
)
|
| 919 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 920 |
# FAQ buttons simply bring back to page0
|
| 921 |
-
|
| 922 |
-
|
| 923 |
|
| 924 |
# Transition from Page 1 to Page 0 (Back button).
|
| 925 |
back_btn_0.click(
|
|
|
|
| 171 |
|
| 172 |
return full_question_ids_list, data_by_filename
|
| 173 |
|
| 174 |
+
def go_to_page0_from_minus1():
|
| 175 |
+
return gr.update(visible=False), gr.update(visible=True)
|
| 176 |
|
| 177 |
def go_to_eval_progress_modal(name, email, specialty_dd, subspecialty_dd, years_exp_radio, exp_explanation_tb):
|
| 178 |
|
|
|
|
| 414 |
specialties_list = ["Error parsing specialties"]
|
| 415 |
subspecialties_list = ["Error parsing subspecialties"]
|
| 416 |
|
| 417 |
+
# Page -1: Page to link them to question submission form or evaluation portal
|
| 418 |
+
with gr.Column(visible=True, elem_id="page-1") as page_minus1:
|
| 419 |
+
gr.HTML("""
|
| 420 |
+
<div>
|
| 421 |
+
<h1>TxAgent Evaluation Portal</h1>
|
| 422 |
+
<p>Welcome to the TxAgent Evaluation Portal.</p>
|
| 423 |
+
<p><strong>About TxAgent:</strong> TxAgent is a first-of-its-kind AI model developed in the Zitnik Lab at Harvard Medical School. It leverages multi-step reasoning and real-time biomedical knowledge retrieval from a toolbox of 211 tools to analyze drug interactions, contraindications, and patient-specific treatment strategies. It is designed to provide personalized treatment recommendations across a wide range of diseases, including rare diseases.</p>
|
| 424 |
+
<p>TxAgent evaluates how drugs interact at molecular, pharmacokinetic, and clinical levels, identifies contraindications based on patient comorbidities and concurrent medications, and tailors treatment strategies to individual patient characteristics, including age, genetic factors, and disease progression. It achieves 92.1% accuracy in open-ended drug reasoning tasks, surpassing GPT-4o by up to 25.8% and outperforming DeepSeek-R1 (671B) in structured multi-step reasoning.</p>
|
| 425 |
+
<p>TxAgent's toolbox, ToolUniverse, consolidates 211 tools from trusted sources, including all US FDA-approved drugs since 1939 and validated clinical insights from Open Targets. By integrating multi-step inference, real-time knowledge grounding, and tool-assisted decision-making, TxAgent ensures that treatment recommendations align with established clinical guidelines and real-world evidence, reducing the risk of adverse events and improving therapeutic decision-making.</p>
|
| 426 |
+
<p>We are currently conducting a user study with physicians, rare disease experts, and others with relevant medical background to assess TxAgent's performance on personalized therapeutic reasoning across multiple criteria, including helpfulness, clinical consensus, and scientific accuracy.</p>
|
| 427 |
+
<p>Please choose one of the options below:</p>
|
| 428 |
+
<ul>
|
| 429 |
+
<li>If you would like to submit new questions for TxAgent to be evaluated on, please click the "Submit Questions" button.</li>
|
| 430 |
+
<li>If you are here to participate in the evaluation of TxAgent's responses to existing questions, please click the "Participate in Evaluation" button.</li>
|
| 431 |
+
</ul>
|
| 432 |
+
<p>Your contribution is invaluable to us. Thank you for your time and expertise!</p>
|
| 433 |
+
</div>
|
| 434 |
+
""")
|
| 435 |
+
with gr.Row():
|
| 436 |
+
submit_questions_btn = gr.Button("Submit Questions for TxAgent Evaluation")
|
| 437 |
+
participate_eval_btn = gr.Button("Participate in TxAgent Evaluation")
|
| 438 |
+
|
| 439 |
+
# Define actions for the new buttons
|
| 440 |
+
# For the Google Form button, we'll use JavaScript to open a new tab.
|
| 441 |
+
# The URL for the Google Form should be replaced with the actual link.
|
| 442 |
+
google_form_url = "https://forms.gle/pYvyvEQQwS5gdupQA" # Replace with your actual Google Form link
|
| 443 |
+
submit_questions_btn.click(
|
| 444 |
+
fn=None,
|
| 445 |
+
inputs=None,
|
| 446 |
+
outputs=None,
|
| 447 |
+
js=f"() => {{ window.open('{google_form_url}', '_blank'); }}"
|
| 448 |
+
)
|
| 449 |
+
|
| 450 |
# Page 0: Welcome / Informational page.
|
| 451 |
+
with gr.Column(visible=False, elem_id="page0") as page0:
|
| 452 |
+
gr.Markdown("## Welcome to the TxAgent Evalution Study!")
|
| 453 |
gr.Markdown("Please read the following instructions and then enter your information to begin:")
|
| 454 |
# Existing informational markdown...
|
| 455 |
+
gr.Markdown("""
|
| 456 |
+
- Each session requires a minimum commitment of 5-10 minutes to complete one question.
|
| 457 |
+
- If you wish to evaluate multiple questions, you may do so; you will never be asked to re-evaluate questions you have already seen.
|
| 458 |
+
- When evaluating a question, you will be asked to compare the responses of two different models to the question and then rate each model's response on a scale of 1-5.
|
| 459 |
+
- You may use the Back and Next buttons at the bottom of each page to edit any of your responses before submitting.
|
| 460 |
+
- You may use the Instruction Page and Home Page buttons at the bottom of each page to return to this page or the home page. Your progress will be saved but not submitted.
|
| 461 |
+
- You must submit your answers to the current question before moving on to evaluate the next question.
|
| 462 |
+
- You may stop in between questions and return at a later time; however, you must submit your answers to the current question if you would like them saved.
|
| 463 |
+
|
| 464 |
+
By clicking 'Next' below, you will start the study, with your progress saved after submitting each question. If you have any other questions or concerns, please contact us directly. Thank you for your participation!
|
| 465 |
+
""")
|
| 466 |
+
gr.Markdown("## Please enter your information to get a question to evaluate. Please use the same email every time you log onto this evaluation portal, as we use your email to prevent showing repeat questions.")
|
| 467 |
name = gr.Textbox(label="Name")
|
| 468 |
+
email = gr.Textbox(label="Email. Please use the same email every time you log onto this evaluation portal, as we use your email to prevent showing repeat questions.")
|
| 469 |
+
specialty_dd = gr.Dropdown(choices=specialties_list, label="Primary Medical Specialty (if applicable, select one). Go to https://www.abms.org/member-boards/specialty-subspecialty-certificates/ for categorization)", multiselect=True)
|
| 470 |
+
subspecialty_dd = gr.Dropdown(choices=subspecialties_list, label="Subspecialty (if applicable, select one). Go to https://www.abms.org/member-boards/specialty-subspecialty-certificates/ for categorization)", multiselect=True)
|
| 471 |
years_exp_radio = gr.Radio(
|
| 472 |
choices=["0-2 years", "3-5 years", "6-10 years", "11-20 years", "20+ years", "Not Applicable"],
|
| 473 |
label="How many years have you been involved in clinical and/or research activities related to your biomedical area of expertise?"
|
|
|
|
| 475 |
exp_explanation_tb = gr.Textbox(label="Please briefly explain your expertise/experience relevant to evaluating AI for clinical decision support (optional)")
|
| 476 |
|
| 477 |
page0_error_box = gr.Markdown("")
|
| 478 |
+
with gr.Row():
|
| 479 |
+
next_btn_0 = gr.Button("Next")
|
| 480 |
+
with gr.Row():
|
| 481 |
+
home_btn_0 = gr.Button("Home (your registration info will be saved)")
|
| 482 |
|
| 483 |
|
| 484 |
with Modal(visible=False) as eval_progress_modal:
|
|
|
|
| 542 |
page1_error_box = gr.Markdown("") # ADDED: display validation errors
|
| 543 |
with gr.Row():
|
| 544 |
back_btn_0 = gr.Button("Back")
|
|
|
|
| 545 |
next_btn_1 = gr.Button("Next: Rate Responses")
|
| 546 |
+
|
| 547 |
+
with gr.Row():
|
| 548 |
+
home_btn_1 = gr.Button("Home Page (your progress on this question will be saved but not submitted)") # ADDED: Home button on page1
|
| 549 |
+
instructions_btn_1 = gr.Button("Instructions Page (your progress on this question will be saved but not submitted)") # ADDED: FAQ button on page1
|
| 550 |
|
| 551 |
# Page 2: Combined Rating Page for both responses.
|
| 552 |
with gr.Column(visible=False) as page2:
|
|
|
|
| 701 |
ratings_B.append(rating_b)
|
| 702 |
with gr.Row():
|
| 703 |
back_btn_2 = gr.Button("Back")
|
| 704 |
+
instructions_btn_2 = gr.Button("Instructions Page (your progress on this question will be saved but not submitted)") # ADDED: FAQ button on page1
|
| 705 |
submit_btn = gr.Button("Submit (Note: Once submitted, you cannot edit your responses)", elem_id="submit_btn")
|
| 706 |
+
|
| 707 |
+
with gr.Row():
|
| 708 |
+
home_btn_2 = gr.Button("Home Page (your progress on this question will be saved but not submitted)")
|
| 709 |
+
instructions_btn_2 = gr.Button("Instructions Page (your progress on this question will be saved but not submitted)") # ADDED: FAQ button on page1
|
| 710 |
+
|
| 711 |
result_text = gr.Textbox(label="Validation Result")
|
| 712 |
|
| 713 |
# Final Page: Thank you message.
|
|
|
|
| 950 |
|
| 951 |
# --- Define Transitions Between Pages ---
|
| 952 |
|
| 953 |
+
|
| 954 |
+
# For the "Participate in Evaluation" button, transition to page0
|
| 955 |
+
participate_eval_btn.click(
|
| 956 |
+
fn=go_to_page0_from_minus1,
|
| 957 |
+
inputs=None,
|
| 958 |
+
outputs=[page_minus1, page0]
|
| 959 |
+
)
|
| 960 |
+
|
| 961 |
+
|
| 962 |
# Transition from Page 0 (Welcome) to Page 1.
|
| 963 |
next_btn_0.click(
|
| 964 |
fn=go_to_eval_progress_modal,
|
|
|
|
| 974 |
scroll_to_output=True
|
| 975 |
)
|
| 976 |
|
| 977 |
+
#Home page buttons to simply shown page-1
|
| 978 |
+
home_btn_0.click(lambda: (gr.update(visible=True), gr.update(visible=False)), None, [page_minus1, page0])
|
| 979 |
+
home_btn_1.click(lambda: (gr.update(visible=True), gr.update(visible=False)), None, [page_minus1, page1])
|
| 980 |
+
home_btn_2.click(lambda: (gr.update(visible=True), gr.update(visible=False)), None, [page_minus1, page2])
|
| 981 |
+
|
| 982 |
# FAQ buttons simply bring back to page0
|
| 983 |
+
instructions_btn_1.click(lambda: (gr.update(visible=True), gr.update(visible=False)), None, [page0, page1])
|
| 984 |
+
instructions_btn_2.click(lambda: (gr.update(visible=True), gr.update(visible=False)), None, [page0, page2])
|
| 985 |
|
| 986 |
# Transition from Page 1 to Page 0 (Back button).
|
| 987 |
back_btn_0.click(
|