', unsafe_allow_html=True) st.title("🌐 Web RAG Assistant") st.markdown("### Ask questions about any webpage") st.divider() # Display chat messages for message in st.session_state.chat_history: if message["role"] == "user": st.markdown(f"""
{message["content"]}
""", unsafe_allow_html=True) else: st.markdown(f"""
{message["content"]}
""", unsafe_allow_html=True) # Chat Input if st.session_state.url_processed: question = st.chat_input("💬 Ask a question about the webpage...") if question: st.session_state.chat_history.append({"role": "user", "content": question}) with st.spinner("Thinking..."): try: answer = st.session_state.rag.ask_question( question, [(msg["content"], msg["content"]) for msg in st.session_state.chat_history if msg["role"] == "assistant"] ) st.session_state.chat_history.append({"role": "assistant", "content": answer}) st.rerun() except Exception as e: st.error(f"Error: {str(e)}") else: st.info("👈 Please process a URL first using the sidebar") st.markdown('