Spaces:
Sleeping
Sleeping
File size: 721 Bytes
ed893bc | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | 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) |