Spaces:
Sleeping
Sleeping
Salma Hassan
commited on
Commit
Β·
976dd0f
1
Parent(s):
5892975
Refactor app.py for the Clinical Trial Matching Chatbot, simplifying the interface by removing custom CSS and restructuring content into accordions for better organization and user experience.
Browse files
app.py
CHANGED
|
@@ -372,99 +372,37 @@ if __name__ == "__main__":
|
|
| 372 |
def chat_function(message, history):
|
| 373 |
return get_clinical_trials(message)
|
| 374 |
|
| 375 |
-
# Create
|
| 376 |
-
with gr.Blocks(
|
| 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
|
| 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.
|
| 411 |
-
|
| 412 |
-
|
| 413 |
-
|
| 414 |
-
|
| 415 |
-
|
| 416 |
-
|
| 417 |
-
|
| 418 |
-
|
| 419 |
-
|
| 420 |
-
|
| 421 |
-
|
| 422 |
-
|
| 423 |
-
|
| 424 |
-
|
| 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 |
-
|
| 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)
|
|
|
|
| 372 |
def chat_function(message, history):
|
| 373 |
return get_clinical_trials(message)
|
| 374 |
|
| 375 |
+
# Create simple interface without any custom CSS that could cause layout issues
|
| 376 |
+
with gr.Blocks(title="Clinical Trial Matching") as demo:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 377 |
gr.Markdown("# π₯ Clinical Trial Matching Chatbot")
|
| 378 |
+
gr.Markdown("**AI-Powered Clinical Trial Matching** - Describe a patient's condition to find matching trials quickly.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 379 |
|
| 380 |
+
with gr.Accordion("About This Tool", open=False):
|
| 381 |
+
gr.Markdown("""
|
| 382 |
+
This AI-powered tool helps with **Patient Recruitment & Enrollment** by finding the most relevant clinical trials based on patient cases.
|
| 383 |
+
It uses advanced language models to analyze patient descriptions and match them with trial criteria.
|
| 384 |
+
""")
|
| 385 |
+
|
| 386 |
+
with gr.Accordion("How It Works", open=False):
|
| 387 |
+
gr.Markdown("""
|
| 388 |
+
**Workflow:**
|
| 389 |
+
1. π **Patient Summary** - Enter patient details
|
| 390 |
+
2. π **Keyword Extraction** - AI extracts medical conditions
|
| 391 |
+
3. π **Trial Retrieval** - Search matching trials
|
| 392 |
+
4. β
**Eligibility Check** - Analyze inclusion/exclusion criteria
|
| 393 |
+
5. π **Results** - Rank and display top 5 matches
|
| 394 |
+
""")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 395 |
|
| 396 |
+
# Simple chat interface
|
| 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)
|