|
|
|
import streamlit as st |
|
import requests |
|
import pandas as pd |
|
|
|
st.set_page_config(page_title="ZeroSearch Medical Q&A", layout="wide") |
|
st.title("🩺 ZeroSearch Medical Q&A – Google‑Free Clinical Answers") |
|
|
|
API_URL = st.secrets.get("API_URL", "http://localhost:8000/ask") |
|
|
|
query = st.text_input( |
|
"Enter a clinical question:", |
|
placeholder="e.g. What are the first‑line treatments for hypertension in pregnancy?", |
|
) |
|
|
|
if st.button("Search") and query: |
|
with st.spinner("Consulting internal medical knowledge…"): |
|
resp = requests.post(API_URL, json={"question": query}) |
|
if resp.status_code == 200: |
|
data = resp.json() |
|
|
|
st.subheader("Answer") |
|
st.write(data["answer"]) |
|
|
|
st.subheader("UMLS Concepts") |
|
if data["umls"]: |
|
st.dataframe(pd.DataFrame(data["umls"])) |
|
else: |
|
st.info("No UMLS concepts detected.") |
|
|
|
st.subheader("Simulated Search Documents") |
|
for i, doc in enumerate(data["docs"], 1): |
|
with st.expander(f"Document {i}"): |
|
st.write(doc) |
|
else: |
|
st.error(f"API error: {resp.status_code} – {resp.text}") |
|
|