mgbam commited on
Commit
cbff2a0
·
verified ·
1 Parent(s): f3e0888

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +57 -33
app.py CHANGED
@@ -1,36 +1,60 @@
1
-
2
  import streamlit as st
3
- import requests
4
- import pandas as pd
5
-
6
- st.set_page_config(page_title="ZeroSearch Medical Q&A", layout="wide")
7
- st.title("🩺 ZeroSearch Medical Q&A – Google‑Free Clinical Answers")
8
-
9
- API_URL = st.secrets.get("API_URL", "http://localhost:8000/ask")
10
-
11
- query = st.text_input(
12
- "Enter a clinical question:",
13
- placeholder="e.g. What are the first‑line treatments for hypertension in pregnancy?",
14
- )
15
-
16
- if st.button("Search") and query:
17
- with st.spinner("Consulting internal medical knowledge…"):
18
- resp = requests.post(API_URL, json={"question": query})
19
- if resp.status_code == 200:
20
- data = resp.json()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
- st.subheader("Answer")
23
- st.write(data["answer"])
 
 
 
24
 
25
- st.subheader("UMLS Concepts")
26
- if data["umls"]:
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.")