Update app.py
Browse files2 unmodified lines34567897 unmodified lines1718192021222324252627282930313233343536372 unmodified lines404142434445462 unmodified lines# Streamlit Page Configurationst.set_page_config(page_title="College Chatbot", layout="centered")st.title("🎓 CBIT Engineering College (Pallavolu) Chatbot")# Sidebar for User Type Selectionuser_type = st.sidebar.selectbox(7 unmodified linesif "user_query" not in st.session_state:st.session_state.user_query = ""# User Inputuser_query = st.text_input("Ask me anything about the CBIT college...", value=st.session_state.user_query, key="user_query")if st.button("Send"):if user_query:# Generate Responsebot_response = generate_response(user_query, user_type.lower())# Store chat historyst.session_state.chat_history.append(("You", user_query))st.session_state.chat_history.append(("Chatbot", bot_response))# Clear input fieldst.session_state.user_query = ""st.rerun() # Refresh the app to reflect the cleared input field# Display Chat History in Reverse Orderst.subheader("Chat History")2 unmodified linesst.markdown(message)# import streamlit as st# from backend import generate_response2 unmodified lines34567897 unmodified lines171819202122232425262728293031323334353637382 unmodified lines4142434445462 unmodified lines# Streamlit Page Configurationst.set_page_config(page_title="College Chatbot", layout="centered")st.title("🎓 CBIT Engineering College(Pallavolu) Chatbot")# Sidebar for User Type Selectionuser_type = st.sidebar.selectbox(7 unmodified linesif "user_query" not in st.session_state:st.session_state.user_query = ""# Form for user input (helps in resetting input properly)with st.form(key="chat_form"):user_query = st.text_input("Ask me anything about the college...", key="user_query")submit_button = st.form_submit_button("Send")if submit_button and user_query:# Generate Responsebot_response = generate_response(user_query, user_type.lower())# Store chat historyst.session_state.chat_history.append(("You", user_query))st.session_state.chat_history.append(("Chatbot", bot_response))# Clear input field after submissionst.session_state.user_query = ""st.experimental_rerun() # Forces UI to refresh and clear input# Display Chat History in Reverse Orderst.subheader("Chat History")2 unmodified linesst.markdown(message)# import streamlit as st# from backend import generate_response
app.py+14-14