LitReviewAI / src /chat.py
bano1's picture
Update src/chat.py
cc9478a verified
Raw
History Blame Contribute Delete
1.24 kB
import streamlit as st
from src.rag_pipeline import ask_rag
def chat_section():
st.header("πŸ’¬ Chat With Your Research Papers")
# Check if papers exist
if not st.session_state.get("papers"):
st.info(
"πŸ“€ Upload one or more research papers first."
)
return
st.write(
"""
Ask questions about your uploaded papers.
"""
)
question = st.text_area(
"Enter your question",
height=120,
placeholder="Example: What are the main findings of this paper?"
)
col1, col2 = st.columns([1, 5])
with col1:
ask = st.button(
"πŸ” Ask",
use_container_width=True
)
if ask:
if not question.strip():
st.warning(
"Please enter a question."
)
return
with st.spinner(
"Searching relevant sections..."
):
try:
answer = ask_rag(question)
st.success("Answer Generated")
st.markdown("## 🧠 Answer")
st.write(answer)
except Exception as e:
st.error(
f"Error: {e}"
)