mgbam commited on
Commit
6349b6e
·
verified ·
1 Parent(s): 6865442

Upload app.py

Browse files
Files changed (1) hide show
  1. frontend/app.py +36 -0
frontend/app.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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}")