Spaces:
Sleeping
Sleeping
| 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}" | |
| ) |