import streamlit as st from rag_pipeline import get_qa_chain # ===================================================== # PAGE CONFIG # ===================================================== st.set_page_config( page_title="AlgoPilot", page_icon="🤖", layout="wide" ) # ===================================================== # CUSTOM CSS # ===================================================== st.markdown(""" """, unsafe_allow_html=True) # ===================================================== # LOAD QA CHAIN # ===================================================== @st.cache_resource def load_chain(): return get_qa_chain() qa_chain = load_chain() # ===================================================== # SESSION STATE # ===================================================== if "messages" not in st.session_state: st.session_state.messages = [] # ===================================================== # SIDEBAR # ===================================================== st.sidebar.title("🤖 AlgoPilot") st.sidebar.markdown(""" ### 📚 Features - Ask DSA Questions - Learn Algorithms - Understand Code - AI Tutor Assistance """) # ===================================================== # TITLE # ===================================================== st.markdown("""
🤖 AlgoPilot
Your AI DSA Tutor
""", unsafe_allow_html=True) # ===================================================== # CHAT HISTORY # ===================================================== for msg in st.session_state.messages: if msg["role"] == "user": st.markdown( f"""
👤 You

{msg['content']}
""", unsafe_allow_html=True ) else: st.markdown( f"""
🤖 Tutor

{msg['content']}
""", unsafe_allow_html=True ) # ===================================================== # INPUT # ===================================================== query = st.chat_input("Ask a DSA question...") # ===================================================== # RESPONSE # ===================================================== if query: st.session_state.messages.append( { "role": "user", "content": query } ) with st.spinner("Thinking..."): response = qa_chain.run(query) st.session_state.messages.append( { "role": "assistant", "content": response } ) st.rerun()