Update app.py
Browse files
app.py
CHANGED
@@ -7,11 +7,13 @@ 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 mcp.workspace import get_workspace, save_query
|
|
|
10 |
from pathlib import Path
|
11 |
import pandas as pd
|
12 |
from fpdf import FPDF
|
13 |
import asyncio
|
14 |
import plotly.express as px
|
|
|
15 |
|
16 |
ROOT_DIR = Path(__file__).resolve().parent
|
17 |
LOGO_PATH = ROOT_DIR / "assets" / "logo.png"
|
@@ -121,6 +123,13 @@ def render_ui():
|
|
121 |
fig = px.histogram(pub_years, nbins=10, title="Publication Year Distribution")
|
122 |
st.plotly_chart(fig)
|
123 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
# Export as CSV
|
125 |
if results["papers"]:
|
126 |
df = pd.DataFrame(results["papers"])
|
|
|
7 |
from mcp.orchestrator import orchestrate_search, answer_ai_question
|
8 |
from mcp.schemas import UnifiedSearchInput, UnifiedSearchResult
|
9 |
from mcp.workspace import get_workspace, save_query
|
10 |
+
from mcp.knowledge_graph import build_knowledge_graph
|
11 |
from pathlib import Path
|
12 |
import pandas as pd
|
13 |
from fpdf import FPDF
|
14 |
import asyncio
|
15 |
import plotly.express as px
|
16 |
+
import streamlit.components.v1 as components
|
17 |
|
18 |
ROOT_DIR = Path(__file__).resolve().parent
|
19 |
LOGO_PATH = ROOT_DIR / "assets" / "logo.png"
|
|
|
123 |
fig = px.histogram(pub_years, nbins=10, title="Publication Year Distribution")
|
124 |
st.plotly_chart(fig)
|
125 |
|
126 |
+
# --- INTERACTIVE KNOWLEDGE GRAPH ---
|
127 |
+
st.markdown("### 🗺️ Knowledge Graph Explorer")
|
128 |
+
kg_html_path = build_knowledge_graph(results["papers"], results["umls"], results["drug_safety"])
|
129 |
+
with open(kg_html_path, 'r', encoding='utf-8') as f:
|
130 |
+
kg_html = f.read()
|
131 |
+
components.html(kg_html, height=600)
|
132 |
+
|
133 |
# Export as CSV
|
134 |
if results["papers"]:
|
135 |
df = pd.DataFrame(results["papers"])
|