Update app.py
Browse files
app.py
CHANGED
|
@@ -6,13 +6,18 @@ from fastapi import FastAPI
|
|
| 6 |
from fastapi.middleware.cors import CORSMiddleware
|
| 7 |
from mcp.orchestrator import orchestrate_search, answer_ai_question
|
| 8 |
from mcp.schemas import UnifiedSearchInput, UnifiedSearchResult
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
# --- FASTAPI BACKEND ---
|
| 11 |
|
| 12 |
api = FastAPI(
|
| 13 |
-
title="
|
| 14 |
version="2.0.0",
|
| 15 |
-
description="AI
|
| 16 |
)
|
| 17 |
|
| 18 |
api.add_middleware(
|
|
@@ -34,18 +39,21 @@ async def ask_ai_endpoint(question: str, context: str = ""):
|
|
| 34 |
# --- STREAMLIT UI ---
|
| 35 |
|
| 36 |
def render_ui():
|
| 37 |
-
st.set_page_config(page_title="
|
| 38 |
|
| 39 |
-
# Header with logo
|
| 40 |
col1, col2 = st.columns([0.15, 0.85])
|
| 41 |
with col1:
|
| 42 |
-
|
|
|
|
|
|
|
|
|
|
| 43 |
with col2:
|
| 44 |
st.markdown("""
|
| 45 |
-
## 𧬠**
|
| 46 |
-
*
|
| 47 |
""")
|
| 48 |
-
st.caption("
|
| 49 |
|
| 50 |
st.markdown("---")
|
| 51 |
|
|
@@ -55,7 +63,7 @@ def render_ui():
|
|
| 55 |
|
| 56 |
if st.button("Run Search π"):
|
| 57 |
with st.spinner("Thinking... Gathering and analyzing data across 5 systems..."):
|
| 58 |
-
results = orchestrate_search(query)
|
| 59 |
st.success("Search complete! π")
|
| 60 |
|
| 61 |
# Papers
|
|
@@ -91,7 +99,7 @@ def render_ui():
|
|
| 91 |
follow_up = st.text_input("What do you want to ask based on the above?", placeholder="e.g. What's the most promising therapy?")
|
| 92 |
if st.button("Ask AI"):
|
| 93 |
with st.spinner("Analyzing and responding..."):
|
| 94 |
-
ai_answer = answer_ai_question(follow_up, context=query)
|
| 95 |
st.success("AI's Response:")
|
| 96 |
st.write(ai_answer["answer"])
|
| 97 |
|
|
|
|
| 6 |
from fastapi.middleware.cors import CORSMiddleware
|
| 7 |
from mcp.orchestrator import orchestrate_search, answer_ai_question
|
| 8 |
from mcp.schemas import UnifiedSearchInput, UnifiedSearchResult
|
| 9 |
+
from pathlib import Path
|
| 10 |
+
import asyncio
|
| 11 |
+
|
| 12 |
+
ROOT_DIR = Path(__file__).resolve().parent
|
| 13 |
+
LOGO_PATH = ROOT_DIR / "assets" / "logo.png"
|
| 14 |
|
| 15 |
# --- FASTAPI BACKEND ---
|
| 16 |
|
| 17 |
api = FastAPI(
|
| 18 |
+
title="MedGenesis MCP Server",
|
| 19 |
version="2.0.0",
|
| 20 |
+
description="MedGenesis AI unifies PubMed, ArXiv, OpenFDA, UMLS, and GPT-4o into a single biomedical intelligence platform."
|
| 21 |
)
|
| 22 |
|
| 23 |
api.add_middleware(
|
|
|
|
| 39 |
# --- STREAMLIT UI ---
|
| 40 |
|
| 41 |
def render_ui():
|
| 42 |
+
st.set_page_config(page_title="MedGenesis AI", layout="wide")
|
| 43 |
|
| 44 |
+
# Header with logo and branding
|
| 45 |
col1, col2 = st.columns([0.15, 0.85])
|
| 46 |
with col1:
|
| 47 |
+
if LOGO_PATH.exists():
|
| 48 |
+
st.image(str(LOGO_PATH), width=100)
|
| 49 |
+
else:
|
| 50 |
+
st.markdown("π§¬")
|
| 51 |
with col2:
|
| 52 |
st.markdown("""
|
| 53 |
+
## 𧬠**MedGenesis AI** β Biomedical Research Reimagined
|
| 54 |
+
*Unified Intelligence from PubMed, ArXiv, OpenFDA, UMLS, and GPT-4o*
|
| 55 |
""")
|
| 56 |
+
st.caption("Created by Oluwafemi Idiakhoa | Hugging Face Spaces")
|
| 57 |
|
| 58 |
st.markdown("---")
|
| 59 |
|
|
|
|
| 63 |
|
| 64 |
if st.button("Run Search π"):
|
| 65 |
with st.spinner("Thinking... Gathering and analyzing data across 5 systems..."):
|
| 66 |
+
results = asyncio.run(orchestrate_search(query))
|
| 67 |
st.success("Search complete! π")
|
| 68 |
|
| 69 |
# Papers
|
|
|
|
| 99 |
follow_up = st.text_input("What do you want to ask based on the above?", placeholder="e.g. What's the most promising therapy?")
|
| 100 |
if st.button("Ask AI"):
|
| 101 |
with st.spinner("Analyzing and responding..."):
|
| 102 |
+
ai_answer = asyncio.run(answer_ai_question(follow_up, context=query))
|
| 103 |
st.success("AI's Response:")
|
| 104 |
st.write(ai_answer["answer"])
|
| 105 |
|