Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# app.py
|
2 |
+
"""
|
3 |
+
The main Gradio user interface for Project Asclepius.
|
4 |
+
This file defines the layout and connects UI components to the backend logic.
|
5 |
+
"""
|
6 |
+
import gradio as gr
|
7 |
+
from modules import orchestrator
|
8 |
+
|
9 |
+
# --- UI Layout and Components ---
|
10 |
+
|
11 |
+
# Load custom CSS for a polished look
|
12 |
+
with open("static/style.css", "r", encoding="utf-8") as f:
|
13 |
+
custom_css = f.read()
|
14 |
+
|
15 |
+
# Define the main application blocks
|
16 |
+
with gr.Blocks(theme=gr.themes.Soft(), css=custom_css) as demo:
|
17 |
+
# Header
|
18 |
+
with gr.Row():
|
19 |
+
# You can add your own logo.png to the static folder
|
20 |
+
# gr.Image("static/logo.png", width=100, show_label=False, show_download_button=False)
|
21 |
+
gr.Markdown("# 🧠 Project Asclepius: The Cognitive Medical Nexus")
|
22 |
+
|
23 |
+
gr.Markdown("An AI-powered system that synthesizes public medical data to provide clear, evidence-based information. **This is not a diagnostic tool.**")
|
24 |
+
|
25 |
+
# Define the main tabs for different functionalities
|
26 |
+
with gr.Tabs():
|
27 |
+
# --- TAB 1: Symptom Synthesizer ---
|
28 |
+
with gr.TabItem("Symptom Synthesizer"):
|
29 |
+
with gr.Row():
|
30 |
+
with gr.Column(scale=2):
|
31 |
+
symptom_input = gr.Textbox(
|
32 |
+
lines=5,
|
33 |
+
label="Describe Symptoms or Ask a Medical Question",
|
34 |
+
placeholder="e.g., 'I have a sharp pain in my chest and feel dizzy' or 'What are the latest treatments for migraines?'"
|
35 |
+
)
|
36 |
+
# Optional image input can be added here
|
37 |
+
# image_input = gr.Image(type="pil", label="Upload a relevant image (e.g., skin rash)", optional=True)
|
38 |
+
|
39 |
+
with gr.Column(scale=1):
|
40 |
+
submit_btn = gr.Button("Synthesize Information", variant="primary")
|
41 |
+
|
42 |
+
gr.Markdown("---")
|
43 |
+
synthesis_output = gr.Markdown(label="Synthesized Report")
|
44 |
+
|
45 |
+
# --- TAB 2: Research Deep Dive (Placeholder) ---
|
46 |
+
with gr.TabItem("Research Deep Dive"):
|
47 |
+
gr.Markdown("## Feature Coming Soon\nThis section will allow you to do a deep dive on a specific disease, gene, or drug, pulling in comprehensive research data.")
|
48 |
+
# Add inputs and outputs for this tab here
|
49 |
+
|
50 |
+
# --- TAB 3: Drug Interaction Analyzer (Placeholder) ---
|
51 |
+
with gr.TabItem("Drug Interaction Analyzer"):
|
52 |
+
gr.Markdown("## Feature Coming Soon\nThis tool will analyze potential interactions and safety concerns for a list of medications.")
|
53 |
+
# Add inputs and outputs for this tab here
|
54 |
+
|
55 |
+
# --- Event Handlers ---
|
56 |
+
submit_btn.click(
|
57 |
+
fn=orchestrator.run_symptom_synthesis,
|
58 |
+
inputs=[symptom_input], # Add image_input here if using
|
59 |
+
outputs=[synthesis_output],
|
60 |
+
api_name="symptom_synthesis",
|
61 |
+
show_progress="full" # Provides a great user experience
|
62 |
+
)
|
63 |
+
|
64 |
+
# Launch the application
|
65 |
+
if __name__ == "__main__":
|
66 |
+
demo.launch(debug=True)
|