drAIML / app /app.py
Gregory-L's picture
evidence index loads in the background, in parallel, with retry
19ba89e verified
Raw History Blame Contribute Delete
1.82 kB
"""drAIML 2.0.0 — open healthcare consultation. Runs in the browser via stlite on huggingface.co/spaces/PYTHAI/drAIML."""
import os
import streamlit as st
from draiml import __version__, state
st.set_page_config(page_title="drAIML — open healthcare consultation", page_icon="⚕️", layout="wide")
if "hf_token" not in st.session_state: # token handed over by the page's "Sign in with Hugging Face"
st.session_state.hf_token = os.environ.get("HF_TOKEN") or ""
st.session_state.hf_user = os.environ.get("HF_USER") or ""
st.session_state.hf_oauth = bool(st.session_state.hf_token)
state.start_loading() # fetch the evidence index in the background while the visitor reads/types
pages = [
st.Page("views/consult.py", title="Consultation", icon="🩺", default=True),
st.Page("views/evidence.py", title="Evidence search", icon="🔎"),
st.Page("views/models.py", title="Models", icon="🧠"),
st.Page("views/datasets.py", title="Datasets", icon="📚"),
st.Page("views/about.py", title="About · Oath", icon="⚕️"),
]
nav = st.navigation(pages)
with st.sidebar:
st.markdown(f"### ⚕️ drAIML `{__version__}`")
if st.session_state.hf_oauth:
st.caption(f"Signed in as **{st.session_state.hf_user or 'Hugging Face user'}** — hosted models bill your HF account.")
else:
st.caption("Not signed in. Browse freely; to consult a hosted model, sign in with Hugging Face "
"(top bar) or bring a key.")
nav.run()
st.markdown(
"<div style='margin-top:2rem;font-size:0.8rem;opacity:0.7'>drAIML provides information, not diagnosis. "
"It does not replace a clinician. In an emergency call your local emergency number. · "
"MIT · <a href='https://github.com/AIMLdr/drAIML'>v1 on GitHub</a></div>", unsafe_allow_html=True)