Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| # Session state for messages | |
| if "messages" not in st.session_state: | |
| st.session_state.messages = [] | |
| st.title("🤖 Simple Mock Chatbot") | |
| # Display chat history | |
| for msg in st.session_state.messages: | |
| with st.chat_message(msg["role"]): | |
| st.write(msg["content"]) | |
| # User input | |
| if prompt := st.chat_input("Ask me anything"): | |
| # Add user message | |
| st.session_state.messages.append({"role": "user", "content": prompt}) | |
| with st.chat_message("user"): | |
| st.write(prompt) | |
| # Mock assistant response | |
| reply = f"You said: {prompt}" | |
| st.session_state.messages.append({"role": "assistant", "content": reply}) | |
| with st.chat_message("assistant"): | |
| st.write(reply) |