Spaces:
Sleeping
Sleeping
Salma Hassan
commited on
Commit
Β·
874d6f1
1
Parent(s):
976dd0f
Revamp app.py for the Clinical Trial Matching Chatbot, introducing a new theme and enhanced CSS for improved visual appeal. Restructure content to provide clearer guidance on the tool's functionality and workflow, while optimizing the chat interface for better user interaction.
Browse files
app.py
CHANGED
|
@@ -372,37 +372,99 @@ if __name__ == "__main__":
|
|
| 372 |
def chat_function(message, history):
|
| 373 |
return get_clinical_trials(message)
|
| 374 |
|
| 375 |
-
# Create
|
| 376 |
-
with gr.Blocks(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 377 |
gr.Markdown("# π₯ Clinical Trial Matching Chatbot")
|
| 378 |
-
gr.Markdown("**AI-Powered Clinical Trial Matching
|
| 379 |
|
| 380 |
-
|
| 381 |
-
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
|
| 386 |
-
|
| 387 |
-
|
| 388 |
-
|
| 389 |
-
|
| 390 |
-
|
| 391 |
-
|
| 392 |
-
|
| 393 |
-
|
| 394 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 395 |
|
| 396 |
-
|
| 397 |
chatbot = gr.ChatInterface(
|
| 398 |
fn=chat_function,
|
| 399 |
examples=[
|
| 400 |
["A 39-year-old Thai male presents for study screening. He received his second dose of an approved mRNA COVID-19 vaccine (Pfizer) over 4 months ago and has remained in good health since. He has no history of COVID-19 infection, confirmed by a negative SARS-CoV-2 rapid antigen test today. He denies any chronic illness, does not take any medications, and has never had an adverse reaction to vaccines. He is sexually active and reports consistent condom use with his partner. He is interested in participating in a study assessing immune response to a new booster dose."],
|
| 401 |
["A 19-year-old pregnant patient, receiving prenatal care at Johns Hopkins Hospital, is 28 weeks gestation and preparing to receive her first mRNA COVID-19 vaccine dose. She has no previous history of COVID-19 and no significant medical history. She meets eligibility criteria and is interested in contributing to research on pregnancy and vaccine-related immune responses."],
|
| 402 |
["A 67-year-old male with relapsed/refractory multiple myeloma presents for enrollment into a post-trial access study. He previously participated in a Pfizer-sponsored parent study evaluating elranatamab, during which he achieved a partial response and remained clinically stable. At the time the parent trial ended, he was continuing on elranatamab with no evidence of disease progression or significant toxicity. He reports no history of psychiatric illness or lab abnormalities, and he wishes to continue treatment through this access program."]
|
| 403 |
-
]
|
| 404 |
-
title="Clinical Trial Matcher",
|
| 405 |
-
description="Enter patient details to find matching clinical trials"
|
| 406 |
)
|
| 407 |
|
| 408 |
demo.launch(share=True)
|
|
|
|
| 372 |
def chat_function(message, history):
|
| 373 |
return get_clinical_trials(message)
|
| 374 |
|
| 375 |
+
# Create optimized chatbot with simple, reliable CSS
|
| 376 |
+
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
| 377 |
+
# Add simple CSS for styling
|
| 378 |
+
gr.HTML("""
|
| 379 |
+
<style>
|
| 380 |
+
.workflow-card {
|
| 381 |
+
background: linear-gradient(135deg, #f0f9ff, #e0f2fe);
|
| 382 |
+
border: 2px solid #3b82f6;
|
| 383 |
+
border-radius: 12px;
|
| 384 |
+
padding: 15px;
|
| 385 |
+
margin: 8px;
|
| 386 |
+
text-align: center;
|
| 387 |
+
box-shadow: 0 3px 6px rgba(0,0,0,0.1);
|
| 388 |
+
}
|
| 389 |
+
.workflow-card-1 { background: linear-gradient(135deg, #fef3c7, #fde68a); border-color: #f59e0b; }
|
| 390 |
+
.workflow-card-2 { background: linear-gradient(135deg, #ddd6fe, #c4b5fd); border-color: #8b5cf6; }
|
| 391 |
+
.workflow-card-3 { background: linear-gradient(135deg, #bfdbfe, #93c5fd); border-color: #3b82f6; }
|
| 392 |
+
.workflow-card-4 { background: linear-gradient(135deg, #bbf7d0, #86efac); border-color: #10b981; }
|
| 393 |
+
.workflow-card-5 { background: linear-gradient(135deg, #fecaca, #fca5a5); border-color: #ef4444; }
|
| 394 |
+
</style>
|
| 395 |
+
""")
|
| 396 |
+
|
| 397 |
gr.Markdown("# π₯ Clinical Trial Matching Chatbot")
|
| 398 |
+
gr.Markdown("**AI-Powered Clinical Trial Matching with GPU acceleration and parallel processing.** Describe a patient's condition to find matching trials quickly.")
|
| 399 |
|
| 400 |
+
gr.Markdown("## About the Tool")
|
| 401 |
+
gr.Markdown("""
|
| 402 |
+
This AI-powered tool is designed to support **Patient Recruitment & Enrollment** by retrieving the most relevant clinical trials based on a given patient case. It is built on top of a large language model fine-tuned on clinical trial metadata, including summaries, inclusion/exclusion criteria, drugs, and target diseases. The dataset includes several actively recruiting Pfizer trials.
|
| 403 |
+
""")
|
| 404 |
+
|
| 405 |
+
gr.Markdown("## How It Works")
|
| 406 |
+
gr.Markdown("""
|
| 407 |
+
Users input a patient case describing clinical history and findings. The model then identifies and ranks the **top 5 most relevant clinical trials** based on semantic similarity, helping clinicians quickly assess suitable enrollment options.
|
| 408 |
+
""")
|
| 409 |
+
|
| 410 |
+
gr.Markdown("## Workflow")
|
| 411 |
+
|
| 412 |
+
# Row 1: Steps 1-3
|
| 413 |
+
with gr.Row():
|
| 414 |
+
with gr.Column():
|
| 415 |
+
gr.Markdown("""
|
| 416 |
+
<div style="background: linear-gradient(135deg, #fef3c7, #fde68a); border: 2px solid #f59e0b; border-radius: 12px; padding: 15px; text-align: center; margin: 5px;">
|
| 417 |
+
<div style="font-size: 2em;">π</div>
|
| 418 |
+
<strong>1. Enter Patient Summary</strong><br>
|
| 419 |
+
<small>Describe the patient's history and findings.</small>
|
| 420 |
+
</div>
|
| 421 |
+
""")
|
| 422 |
+
with gr.Column():
|
| 423 |
+
gr.Markdown("""
|
| 424 |
+
<div style="background: linear-gradient(135deg, #ddd6fe, #c4b5fd); border: 2px solid #8b5cf6; border-radius: 12px; padding: 15px; text-align: center; margin: 5px;">
|
| 425 |
+
<div style="font-size: 2em;">π</div>
|
| 426 |
+
<strong>2. Keyword Extraction</strong><br>
|
| 427 |
+
<small>AI extracts key medical conditions using GPT-4-turbo.</small>
|
| 428 |
+
</div>
|
| 429 |
+
""")
|
| 430 |
+
with gr.Column():
|
| 431 |
+
gr.Markdown("""
|
| 432 |
+
<div style="background: linear-gradient(135deg, #bfdbfe, #93c5fd); border: 2px solid #3b82f6; border-radius: 12px; padding: 15px; text-align: center; margin: 5px;">
|
| 433 |
+
<div style="font-size: 2em;">π</div>
|
| 434 |
+
<strong>3. Trial Retrieval</strong><br>
|
| 435 |
+
<small>Keywords are matched to all trials (including Pfizer).</small>
|
| 436 |
+
</div>
|
| 437 |
+
""")
|
| 438 |
+
|
| 439 |
+
# Row 2: Steps 4-5
|
| 440 |
+
with gr.Row():
|
| 441 |
+
with gr.Column():
|
| 442 |
+
gr.Markdown("""
|
| 443 |
+
<div style="background: linear-gradient(135deg, #bbf7d0, #86efac); border: 2px solid #10b981; border-radius: 12px; padding: 15px; text-align: center; margin: 5px;">
|
| 444 |
+
<div style="font-size: 2em;">β
</div>
|
| 445 |
+
<strong>4. Eligibility Check</strong><br>
|
| 446 |
+
<small>Inclusion/exclusion criteria are checked for each trial.</small>
|
| 447 |
+
</div>
|
| 448 |
+
""")
|
| 449 |
+
with gr.Column():
|
| 450 |
+
gr.Markdown("""
|
| 451 |
+
<div style="background: linear-gradient(135deg, #fecaca, #fca5a5); border: 2px solid #ef4444; border-radius: 12px; padding: 15px; text-align: center; margin: 5px;">
|
| 452 |
+
<div style="font-size: 2em;">π</div>
|
| 453 |
+
<strong>5. Ranking & Results</strong><br>
|
| 454 |
+
<small>Top 5 matching trials are ranked and displayed. Pfizer trials are highlighted if present.</small>
|
| 455 |
+
</div>
|
| 456 |
+
""")
|
| 457 |
+
with gr.Column():
|
| 458 |
+
gr.Markdown("") # Empty column for better spacing
|
| 459 |
|
| 460 |
+
gr.Markdown("## Start Matching")
|
| 461 |
chatbot = gr.ChatInterface(
|
| 462 |
fn=chat_function,
|
| 463 |
examples=[
|
| 464 |
["A 39-year-old Thai male presents for study screening. He received his second dose of an approved mRNA COVID-19 vaccine (Pfizer) over 4 months ago and has remained in good health since. He has no history of COVID-19 infection, confirmed by a negative SARS-CoV-2 rapid antigen test today. He denies any chronic illness, does not take any medications, and has never had an adverse reaction to vaccines. He is sexually active and reports consistent condom use with his partner. He is interested in participating in a study assessing immune response to a new booster dose."],
|
| 465 |
["A 19-year-old pregnant patient, receiving prenatal care at Johns Hopkins Hospital, is 28 weeks gestation and preparing to receive her first mRNA COVID-19 vaccine dose. She has no previous history of COVID-19 and no significant medical history. She meets eligibility criteria and is interested in contributing to research on pregnancy and vaccine-related immune responses."],
|
| 466 |
["A 67-year-old male with relapsed/refractory multiple myeloma presents for enrollment into a post-trial access study. He previously participated in a Pfizer-sponsored parent study evaluating elranatamab, during which he achieved a partial response and remained clinically stable. At the time the parent trial ended, he was continuing on elranatamab with no evidence of disease progression or significant toxicity. He reports no history of psychiatric illness or lab abnormalities, and he wishes to continue treatment through this access program."]
|
| 467 |
+
]
|
|
|
|
|
|
|
| 468 |
)
|
| 469 |
|
| 470 |
demo.launch(share=True)
|