Spaces:
Build error
Build error
import streamlit as st | |
from rag_dspy import MedicalRAG | |
st.set_page_config(page_title="Medical QA Bot", page_icon="🩺") | |
st.title("🩺 Medical QA Bot") | |
st.write("Ask a medical question and get an answer based on retrieved medical literature.") | |
if "history" not in st.session_state: | |
st.session_state["history"] = [] | |
rag_chain = MedicalRAG() | |
with st.form("chat_form"): | |
user_question = st.text_input("Enter your medical question:", "") | |
submitted = st.form_submit_button("Get Answer") | |
if submitted and user_question.strip(): | |
with st.spinner("Retrieving answer..."): | |
result = rag_chain.forward(user_question) | |
answer = result.final_answer | |
st.session_state["history"].append((user_question, answer)) | |
st.markdown(f"**Answer:** {answer}") | |
if st.session_state["history"]: | |
st.markdown("---") | |
st.markdown("### Conversation History") | |
for q, a in reversed(st.session_state["history"]): | |
st.markdown(f"**Q:** {q}") | |
st.markdown(f"**A:** {a}") | |