Spaces:
Running
Running
update api/mcp
Browse files- app.py +15 -1
- requirements.txt +1 -1
app.py
CHANGED
|
@@ -100,7 +100,7 @@ DUMMY_FILTER = json.dumps(
|
|
| 100 |
|
| 101 |
# Generate cohort filter JSON from free text
|
| 102 |
@spaces.GPU(duration=15)
|
| 103 |
-
def generate_filter(query):
|
| 104 |
if DEBUG:
|
| 105 |
return DUMMY_FILTER
|
| 106 |
|
|
@@ -643,6 +643,7 @@ with gr.Blocks(css_paths="style.css") as demo:
|
|
| 643 |
fn=set_active_tab,
|
| 644 |
inputs=gr.State(name),
|
| 645 |
outputs=tab_containers + tab_buttons,
|
|
|
|
| 646 |
)
|
| 647 |
|
| 648 |
# Enable case download
|
|
@@ -650,6 +651,7 @@ with gr.Blocks(css_paths="style.css") as demo:
|
|
| 650 |
fn=None, # apparently this isn't the same as not specifying it
|
| 651 |
js=DOWNLOAD_CASES_JS,
|
| 652 |
inputs=json_output,
|
|
|
|
| 653 |
)
|
| 654 |
|
| 655 |
# Load initial counts on startup
|
|
@@ -657,6 +659,7 @@ with gr.Blocks(css_paths="style.css") as demo:
|
|
| 657 |
fn=update_cards_with_counts,
|
| 658 |
inputs=[gr.State("")] + filter_cards,
|
| 659 |
outputs=filter_cards + [case_counter],
|
|
|
|
| 660 |
)
|
| 661 |
|
| 662 |
# Update checkboxes on filter generation
|
|
@@ -668,10 +671,12 @@ with gr.Blocks(css_paths="style.css") as demo:
|
|
| 668 |
fn=process_query,
|
| 669 |
inputs=text_input,
|
| 670 |
outputs=filter_cards + [json_output],
|
|
|
|
| 671 |
).success(
|
| 672 |
fn=update_active_selections,
|
| 673 |
inputs=filter_cards,
|
| 674 |
outputs=[active_selections],
|
|
|
|
| 675 |
)
|
| 676 |
|
| 677 |
# Update JSON based on cards
|
|
@@ -683,20 +688,24 @@ with gr.Blocks(css_paths="style.css") as demo:
|
|
| 683 |
fn=update_json_from_cards,
|
| 684 |
inputs=filter_cards,
|
| 685 |
outputs=json_output,
|
|
|
|
| 686 |
).success(
|
| 687 |
fn=update_active_selections,
|
| 688 |
inputs=filter_cards,
|
| 689 |
outputs=[active_selections],
|
|
|
|
| 690 |
)
|
| 691 |
else:
|
| 692 |
filter_card.input(
|
| 693 |
fn=update_json_from_cards,
|
| 694 |
inputs=filter_cards,
|
| 695 |
outputs=json_output,
|
|
|
|
| 696 |
).success(
|
| 697 |
fn=update_active_selections,
|
| 698 |
inputs=filter_cards,
|
| 699 |
outputs=[active_selections],
|
|
|
|
| 700 |
)
|
| 701 |
|
| 702 |
# Enable functionality of the active filter selectors
|
|
@@ -704,10 +713,12 @@ with gr.Blocks(css_paths="style.css") as demo:
|
|
| 704 |
fn=update_cards_from_active,
|
| 705 |
inputs=[active_selections] + filter_cards,
|
| 706 |
outputs=[active_selections] + filter_cards,
|
|
|
|
| 707 |
).success(
|
| 708 |
fn=update_json_from_cards,
|
| 709 |
inputs=filter_cards,
|
| 710 |
outputs=json_output,
|
|
|
|
| 711 |
)
|
| 712 |
|
| 713 |
# Update checkboxes after executing filter query
|
|
@@ -715,7 +726,10 @@ with gr.Blocks(css_paths="style.css") as demo:
|
|
| 715 |
fn=update_cards_with_counts,
|
| 716 |
inputs=[json_output] + filter_cards,
|
| 717 |
outputs=filter_cards + [case_counter],
|
|
|
|
| 718 |
)
|
| 719 |
|
|
|
|
|
|
|
| 720 |
if __name__ == "__main__":
|
| 721 |
demo.launch(mcp_server=True)
|
|
|
|
| 100 |
|
| 101 |
# Generate cohort filter JSON from free text
|
| 102 |
@spaces.GPU(duration=15)
|
| 103 |
+
def generate_filter(query: str) -> str:
|
| 104 |
if DEBUG:
|
| 105 |
return DUMMY_FILTER
|
| 106 |
|
|
|
|
| 643 |
fn=set_active_tab,
|
| 644 |
inputs=gr.State(name),
|
| 645 |
outputs=tab_containers + tab_buttons,
|
| 646 |
+
api_name=False,
|
| 647 |
)
|
| 648 |
|
| 649 |
# Enable case download
|
|
|
|
| 651 |
fn=None, # apparently this isn't the same as not specifying it
|
| 652 |
js=DOWNLOAD_CASES_JS,
|
| 653 |
inputs=json_output,
|
| 654 |
+
api_name=False,
|
| 655 |
)
|
| 656 |
|
| 657 |
# Load initial counts on startup
|
|
|
|
| 659 |
fn=update_cards_with_counts,
|
| 660 |
inputs=[gr.State("")] + filter_cards,
|
| 661 |
outputs=filter_cards + [case_counter],
|
| 662 |
+
api_name=False,
|
| 663 |
)
|
| 664 |
|
| 665 |
# Update checkboxes on filter generation
|
|
|
|
| 671 |
fn=process_query,
|
| 672 |
inputs=text_input,
|
| 673 |
outputs=filter_cards + [json_output],
|
| 674 |
+
api_name=False,
|
| 675 |
).success(
|
| 676 |
fn=update_active_selections,
|
| 677 |
inputs=filter_cards,
|
| 678 |
outputs=[active_selections],
|
| 679 |
+
api_name=False,
|
| 680 |
)
|
| 681 |
|
| 682 |
# Update JSON based on cards
|
|
|
|
| 688 |
fn=update_json_from_cards,
|
| 689 |
inputs=filter_cards,
|
| 690 |
outputs=json_output,
|
| 691 |
+
api_name=False,
|
| 692 |
).success(
|
| 693 |
fn=update_active_selections,
|
| 694 |
inputs=filter_cards,
|
| 695 |
outputs=[active_selections],
|
| 696 |
+
api_name=False,
|
| 697 |
)
|
| 698 |
else:
|
| 699 |
filter_card.input(
|
| 700 |
fn=update_json_from_cards,
|
| 701 |
inputs=filter_cards,
|
| 702 |
outputs=json_output,
|
| 703 |
+
api_name=False,
|
| 704 |
).success(
|
| 705 |
fn=update_active_selections,
|
| 706 |
inputs=filter_cards,
|
| 707 |
outputs=[active_selections],
|
| 708 |
+
api_name=False,
|
| 709 |
)
|
| 710 |
|
| 711 |
# Enable functionality of the active filter selectors
|
|
|
|
| 713 |
fn=update_cards_from_active,
|
| 714 |
inputs=[active_selections] + filter_cards,
|
| 715 |
outputs=[active_selections] + filter_cards,
|
| 716 |
+
api_name=False,
|
| 717 |
).success(
|
| 718 |
fn=update_json_from_cards,
|
| 719 |
inputs=filter_cards,
|
| 720 |
outputs=json_output,
|
| 721 |
+
api_name=False,
|
| 722 |
)
|
| 723 |
|
| 724 |
# Update checkboxes after executing filter query
|
|
|
|
| 726 |
fn=update_cards_with_counts,
|
| 727 |
inputs=[json_output] + filter_cards,
|
| 728 |
outputs=filter_cards + [case_counter],
|
| 729 |
+
api_name=False,
|
| 730 |
)
|
| 731 |
|
| 732 |
+
gr.api(generate_filter)
|
| 733 |
+
|
| 734 |
if __name__ == "__main__":
|
| 735 |
demo.launch(mcp_server=True)
|
requirements.txt
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
torch==2.5.1
|
| 2 |
transformers==4.50.0
|
| 3 |
-
gradio==5.
|
| 4 |
guidance==0.2.4
|
| 5 |
gradio_rangeslider
|
| 6 |
spaces
|
|
|
|
| 1 |
torch==2.5.1
|
| 2 |
transformers==4.50.0
|
| 3 |
+
gradio==5.49.1
|
| 4 |
guidance==0.2.4
|
| 5 |
gradio_rangeslider
|
| 6 |
spaces
|