Update app.py
Browse files
app.py
CHANGED
@@ -1,36 +1,60 @@
|
|
1 |
-
|
2 |
import streamlit as st
|
3 |
-
import
|
4 |
-
import
|
5 |
-
|
6 |
-
|
7 |
-
st.
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
)
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
-
|
23 |
-
|
|
|
|
|
|
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
st.dataframe(pd.DataFrame(data["umls"]))
|
28 |
-
else:
|
29 |
-
st.info("No UMLS concepts detected.")
|
30 |
-
|
31 |
-
st.subheader("Simulated Search Documents")
|
32 |
-
for i, doc in enumerate(data["docs"], 1):
|
33 |
-
with st.expander(f"Document {i}"):
|
34 |
-
st.write(doc)
|
35 |
-
else:
|
36 |
-
st.error(f"API error: {resp.status_code} – {resp.text}")
|
|
|
|
|
1 |
import streamlit as st
|
2 |
+
from agent.gemini_agent import run_gemini_chat
|
3 |
+
from agent.clinical_nlp import umls_concept_lookup, bioportal_concept_lookup
|
4 |
+
from quantum.optimizer import optimize_treatment
|
5 |
+
|
6 |
+
st.set_page_config(page_title="Quantum Healthcare AI", layout="wide")
|
7 |
+
|
8 |
+
st.markdown("""
|
9 |
+
<div style='display:flex;align-items:center'>
|
10 |
+
<img src='https://cdn-icons-png.flaticon.com/512/891/891419.png' width='56' style='margin-right:15px;'/>
|
11 |
+
<h1 style='display:inline'>Quantum-AI Healthcare Assistant</h1>
|
12 |
+
</div>
|
13 |
+
""", unsafe_allow_html=True)
|
14 |
+
|
15 |
+
st.write("**Ask anything about symptoms, conditions, diagnosis, or optimal care. Get instant LLM answers, clinical concept mapping, and even quantum-inspired optimization.**")
|
16 |
+
|
17 |
+
query = st.text_area("Describe symptoms, a clinical problem, or a medical question:", height=70)
|
18 |
+
|
19 |
+
cols = st.columns([1,1])
|
20 |
+
with cols[0]:
|
21 |
+
get_ai = st.button("Get AI & Clinical Insight")
|
22 |
+
with cols[1]:
|
23 |
+
run_quantum = st.button("Quantum Optimize Care Plan")
|
24 |
+
|
25 |
+
if get_ai and query.strip():
|
26 |
+
with st.spinner("Gemini AI is reviewing your query..."):
|
27 |
+
ai_response = run_gemini_chat(query)
|
28 |
+
st.markdown(f"**Gemini Agent:**\n\n{ai_response}")
|
29 |
+
|
30 |
+
st.markdown("---")
|
31 |
+
with st.expander("🔎 UMLS Concept Mapping"):
|
32 |
+
concepts = umls_concept_lookup(query)
|
33 |
+
if concepts:
|
34 |
+
for c in concepts:
|
35 |
+
if 'error' in c:
|
36 |
+
st.error(c['error'])
|
37 |
+
else:
|
38 |
+
st.write(f"**{c['name']}** | ID: `{c['ui']}` | Source: *{c['rootSource']}*")
|
39 |
+
else:
|
40 |
+
st.info("No UMLS concepts found.")
|
41 |
+
|
42 |
+
with st.expander("🔬 BioPortal Ontology Lookup"):
|
43 |
+
concepts = bioportal_concept_lookup(query)
|
44 |
+
if concepts:
|
45 |
+
for c in concepts:
|
46 |
+
if 'error' in c:
|
47 |
+
st.error(c['error'])
|
48 |
+
else:
|
49 |
+
st.write(f"**{c['prefLabel']}** | [Ontology]({c['ontology']}) | [Concept ID]({c['id']})")
|
50 |
+
else:
|
51 |
+
st.info("No BioPortal concepts found.")
|
52 |
|
53 |
+
if run_quantum and query.strip():
|
54 |
+
with st.spinner("Quantum optimizer working..."):
|
55 |
+
plan = optimize_treatment(query)
|
56 |
+
st.markdown("### 🧬 Optimized Care Plan")
|
57 |
+
st.json(plan)
|
58 |
|
59 |
+
st.markdown("---")
|
60 |
+
st.caption("Powered by Gemini LLM, UMLS, BioPortal, and quantum-inspired algorithms. For research use only. No patient data is stored.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|