Spaces:
Sleeping
Sleeping
File size: 1,236 Bytes
d5f0cae 1e9ece1 d5f0cae 0ad523c d5f0cae 0ad523c d5f0cae 0ad523c d5f0cae 0ad523c d5f0cae 0ad523c d5f0cae 1e9ece1 0ad523c 1e9ece1 0ad523c 1e9ece1 0ad523c 1e9ece1 0ad523c d5f0cae 0ad523c | 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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | 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}"
) |