Spaces:
Runtime error
Runtime error
| import streamlit as st | |
| from agent_backend import process_message | |
| import logging | |
| logging.basicConfig(level=logging.DEBUG) | |
| print("π₯ APP.PY STARTED") | |
| st.set_page_config(page_title="FoodHub Chatbot", layout="centered") | |
| st.title("π FoodHub Customer Support Chatbot") | |
| # ------------------------------------------------------- | |
| # Chat history | |
| # ------------------------------------------------------- | |
| if "history" not in st.session_state: | |
| st.session_state.history = [] | |
| st.markdown("Chat with the FoodHub Assistant below:") | |
| # User input box | |
| user_input = st.text_input("You:", "", key="user_text") | |
| # When Send button is clicked | |
| if st.button("Send"): | |
| if user_input.strip(): | |
| response = process_message(user_input) | |
| st.session_state.history.append(("You", user_input)) | |
| st.session_state.history.append(("Bot", response)) | |
| # Clear input box | |
| st.session_state.user_text = "" | |
| # ------------------------------------------------------- | |
| # Display chat | |
| # ------------------------------------------------------- | |
| chat_container = st.container() | |
| with chat_container: | |
| for sender, msg in st.session_state.history: | |
| if sender == "You": | |
| st.markdown(f"**π§ You:** {msg}") | |
| else: | |
| st.markdown(f"**π€ Bot:** {msg}") | |
| # Auto-scroll | |
| st.write("") | |