File size: 1,442 Bytes
1786f57
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76418d6
1786f57
 
 
 
76418d6
1786f57
 
defde16
1786f57
76418d6
1786f57
 
c17cf5b
1786f57
 
 
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
# app.py
import asyncio, streamlit as st, pandas as pd
from mcp.orchestrator import orchestrate_search

st.set_page_config(layout="wide", page_title="MedGenesis AI")
if "res" not in st.session_state: st.session_state.res = None

st.title("🧬 MedGenesis AI")
llm = st.radio("LLM engine", ["openai","gemini"], horizontal=True)
q = st.text_input("Enter biomedical question")
if st.button("Run Search") and q:
    with st.spinner("Fetching data…"):
        st.session_state.res = asyncio.run(orchestrate_search(q, llm=llm))

res = st.session_state.res
if res:
    st.subheader("🔬 Papers")
    for p in res["papers"]:
        st.markdown(f"**[{p['title']}]({p['link']})**  –  {p['authors']}")
        st.write(p["summary"])
    st.subheader("💡 AI Summary")
    st.info(res["ai_summary"])

    tabs = st.tabs(["Graph","Variants","Trials"])
    with tabs[0]:
        from mcp.knowledge_graph import build_agraph
        nodes, edges, cfg = build_agraph(res)
        from streamlit_agraph import agraph
        agraph(nodes, edges, cfg)
    with tabs[1]:
        if res["variants"]:
            st.json(res["variants"])
        else:
            st.warning("No variants found. Try TP53 or BRCA1.")
    with tabs[2]:
        if res["trials"]:
            st.json(res["trials"])
        else:
            st.warning("No trials. Try a disease e.g. ‘Breast Neoplasms’ or a drug.")
else:
    st.info("Enter a query and press Run Search.")