File size: 1,150 Bytes
6349b6e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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

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}")