Spaces:
Build error
Build error
| import gradio as gr | |
| import os | |
| from components import pubmed_search | |
| from components import model_utils | |
| import time | |
| # ---------------------------- Configuration ---------------------------- | |
| ENTREZ_EMAIL = os.environ.get("ENTREZ_EMAIL", "ENTREZ_EMAIL") | |
| HUGGINGFACE_API_TOKEN = os.environ.get("HUGGINGFACE_API_TOKEN", "HUGGINGFACE_API_TOKEN") | |
| # ---------------------------- Global Variables ---------------------------- | |
| # ---------------------------- Gradio Interface ---------------------------- | |
| def launch_gradio(): | |
| """Launches the Gradio interface.""" | |
| css = """ | |
| .article { | |
| border: 1px solid #ddd; | |
| margin-bottom: 10px; | |
| padding: 10px; | |
| border-radius: 5px; | |
| } | |
| .article.error { | |
| border-color: #f00; | |
| } | |
| .article-id { | |
| font-size: 1.2em; | |
| margin-bottom: 5px; | |
| } | |
| .abstract { | |
| font-style: italic; | |
| } | |
| .error-message { | |
| color: #f00; | |
| } | |
| """ | |
| with gr.Blocks(css=css) as iface: | |
| gr.Markdown("# MedAI: Medical Literature Review") | |
| gr.Markdown("Enter a medical query to retrieve abstracts from PubMed.") | |
| query_input = gr.Textbox(lines=3, placeholder="Enter your medical query (e.g., 'new treatments for diabetes')...") | |
| submit_button = gr.Button("Submit") | |
| output_results = gr.HTML() # Use HTML for formatted output | |
| # Get data | |
| submit_button.click(pubmed_search.medai_agent, inputs=query_input, outputs=output_results) | |
| iface.launch() | |
| # ---------------------------- Main Execution ---------------------------- | |
| if __name__ == "__main__": | |
| launch_gradio() |