Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,8 +1,8 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
|
| 3 |
-
from main2 import search_trials # Importing from main2.py
|
| 4 |
|
| 5 |
def run_search(age, sex, state, keywords):
|
|
|
|
| 6 |
results = search_trials(
|
| 7 |
user_age=age,
|
| 8 |
user_sex=sex,
|
|
@@ -13,37 +13,45 @@ def run_search(age, sex, state, keywords):
|
|
| 13 |
|
| 14 |
with gr.Blocks() as demo:
|
| 15 |
with gr.Tabs() as tabs:
|
| 16 |
-
with gr.Tab("Search Trials")
|
| 17 |
-
gr.Markdown("#
|
| 18 |
gr.Markdown(
|
| 19 |
"Find **recruiting US clinical trials** that match your **age**, **sex**, "
|
| 20 |
"**state**, and optional **keywords**."
|
| 21 |
)
|
| 22 |
-
|
| 23 |
with gr.Row():
|
| 24 |
age_input = gr.Number(label="Your Age", value=30)
|
| 25 |
sex_input = gr.Dropdown(["Male", "Female"], label="Sex", value="Male")
|
| 26 |
-
|
| 27 |
with gr.Row():
|
| 28 |
-
state_input = gr.Dropdown([
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
keywords_input = gr.Textbox(label="Keywords (comma separated)", placeholder="e.g., cancer, diabetes")
|
| 30 |
-
|
| 31 |
search_btn = gr.Button("Search Trials")
|
| 32 |
-
|
| 33 |
-
with gr.Tab("Results")
|
| 34 |
output_table = gr.DataFrame(label="Matching Trials", interactive=False)
|
| 35 |
-
|
| 36 |
def show_results(age, sex, state, keywords):
|
| 37 |
results = run_search(age, sex, state, keywords)
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
search_btn.click(
|
| 42 |
fn=show_results,
|
| 43 |
inputs=[age_input, sex_input, state_input, keywords_input],
|
| 44 |
-
outputs=[output_table,
|
| 45 |
)
|
| 46 |
|
| 47 |
-
|
| 48 |
if __name__ == "__main__":
|
| 49 |
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from main2 import search_trials # Your existing search function
|
|
|
|
| 3 |
|
| 4 |
def run_search(age, sex, state, keywords):
|
| 5 |
+
# Calls your imported function and returns results in tabular form
|
| 6 |
results = search_trials(
|
| 7 |
user_age=age,
|
| 8 |
user_sex=sex,
|
|
|
|
| 13 |
|
| 14 |
with gr.Blocks() as demo:
|
| 15 |
with gr.Tabs() as tabs:
|
| 16 |
+
with gr.Tab("Search Trials"):
|
| 17 |
+
gr.Markdown("# Clinical Trials Search Tool")
|
| 18 |
gr.Markdown(
|
| 19 |
"Find **recruiting US clinical trials** that match your **age**, **sex**, "
|
| 20 |
"**state**, and optional **keywords**."
|
| 21 |
)
|
| 22 |
+
|
| 23 |
with gr.Row():
|
| 24 |
age_input = gr.Number(label="Your Age", value=30)
|
| 25 |
sex_input = gr.Dropdown(["Male", "Female"], label="Sex", value="Male")
|
| 26 |
+
|
| 27 |
with gr.Row():
|
| 28 |
+
state_input = gr.Dropdown([
|
| 29 |
+
"Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", "Connecticut",
|
| 30 |
+
"Delaware", "Florida", "Georgia", "Hawaii", "Idaho", "Illinois", "Indiana", "Iowa",
|
| 31 |
+
"Kansas", "Kentucky", "Louisiana", "Maine", "Massachusetts", "Michigan", "Minnesota",
|
| 32 |
+
"Mississippi", "Missouri", "Montana", "Nebraska", "Nevada", "New Hampshire", "New Jersey",
|
| 33 |
+
"New York", "North Carolina", "North Dakota", "Ohio", "Oklahoma", "Oregon",
|
| 34 |
+
"Pennsylvania", "Rhode Island", "South Carolina", "South Dakota", "Tennessee",
|
| 35 |
+
"Texas", "Utah", "Vermont", "Virginia", "Washington", "West Virginia", "Wisconsin",
|
| 36 |
+
"Wyoming"
|
| 37 |
+
], label="State (full name or abbreviation)", value="California")
|
| 38 |
keywords_input = gr.Textbox(label="Keywords (comma separated)", placeholder="e.g., cancer, diabetes")
|
| 39 |
+
|
| 40 |
search_btn = gr.Button("Search Trials")
|
| 41 |
+
|
| 42 |
+
with gr.Tab("Results"):
|
| 43 |
output_table = gr.DataFrame(label="Matching Trials", interactive=False)
|
| 44 |
+
|
| 45 |
def show_results(age, sex, state, keywords):
|
| 46 |
results = run_search(age, sex, state, keywords)
|
| 47 |
+
# Return results and switch to results tab (index 1)
|
| 48 |
+
return results, gr.Tabs.update(selected=1)
|
| 49 |
+
|
| 50 |
search_btn.click(
|
| 51 |
fn=show_results,
|
| 52 |
inputs=[age_input, sex_input, state_input, keywords_input],
|
| 53 |
+
outputs=[output_table, tabs]
|
| 54 |
)
|
| 55 |
|
|
|
|
| 56 |
if __name__ == "__main__":
|
| 57 |
demo.launch()
|