Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,29 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
|
| 3 |
+
# Initialize session state for conversation history
|
| 4 |
+
if 'conversation' not in st.session_state:
|
| 5 |
+
st.session_state['conversation'] = []
|
| 6 |
+
|
| 7 |
+
# Function to update conversation
|
| 8 |
+
def update_conversation(message):
|
| 9 |
+
st.session_state['conversation'].append(message)
|
| 10 |
+
|
| 11 |
+
# Chat interface
|
| 12 |
+
st.title("Streamlit Chat Interface")
|
| 13 |
+
|
| 14 |
+
# Text input for user message
|
| 15 |
+
user_message = st.text_input("Type your message here:")
|
| 16 |
+
|
| 17 |
+
# On message send
|
| 18 |
+
if user_message:
|
| 19 |
+
update_conversation(f"You: {user_message}")
|
| 20 |
+
# Here you can add your processing (e.g., sending message to a chatbot)
|
| 21 |
+
# For demonstration, echoing the user message
|
| 22 |
+
bot_response = f"Bot: Echoing '{user_message}'"
|
| 23 |
+
update_conversation(bot_response)
|
| 24 |
+
# Clear the input box after sending the message
|
| 25 |
+
st.session_state['user_message'] = ''
|
| 26 |
+
|
| 27 |
+
# Display conversation history
|
| 28 |
+
for message in st.session_state['conversation']:
|
| 29 |
+
st.text(message)
|