Spaces:
Build error
Build error
File size: 921 Bytes
feb033c cc1f26a | 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 26 27 28 29 30 | import streamlit as st
# Initialize session state for conversation history
if 'conversation' not in st.session_state:
st.session_state['conversation'] = []
# Function to update conversation
def update_conversation(message):
st.session_state['conversation'].append(message)
# Chat interface
st.title("Streamlit Chat Interface")
# Text input for user message
user_message = st.text_input("Type your message here:")
# On message send
if user_message:
update_conversation(f"You: {user_message}")
# Here you can add your processing (e.g., sending message to a chatbot)
# For demonstration, echoing the user message
bot_response = f"Bot: Echoing '{user_message}'"
update_conversation(bot_response)
# Clear the input box after sending the message
st.session_state['user_message'] = ''
# Display conversation history
for message in st.session_state['conversation']:
st.text(message)
|