File size: 1,602 Bytes
1b899cb
3c8dbea
 
 
 
1b899cb
3c8dbea
 
f5128b8
1b899cb
f5128b8
 
1b899cb
 
 
4087716
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e7d54ba
4087716
 
 
 
 
 
 
 
3c8dbea
 
 
1b899cb
 
4087716
1b899cb
3c8dbea
 
1b899cb
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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()