Spaces:
Build error
Build error
File size: 1,010 Bytes
2304b58 |
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 |
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}")
|