Spaces:
Sleeping
Sleeping
Divyansh12
commited on
Commit
•
da6c0eb
1
Parent(s):
b1f46eb
Update app.py
Browse files
app.py
CHANGED
@@ -45,12 +45,13 @@ st.title("Simple Chatbot")
|
|
45 |
st.write("### Interact with the chatbot!")
|
46 |
|
47 |
# User input field
|
48 |
-
user_message = st.text_area("Your Message:")
|
49 |
|
50 |
# Chat history
|
51 |
if 'history' not in st.session_state:
|
52 |
st.session_state.history = []
|
53 |
|
|
|
54 |
if st.button("Send"):
|
55 |
if user_message: # Check if user has entered a message
|
56 |
# Get the response from the model
|
@@ -60,12 +61,10 @@ if st.button("Send"):
|
|
60 |
st.session_state.history.append((user_message, response))
|
61 |
|
62 |
# Clear the input field after sending
|
63 |
-
|
64 |
|
65 |
# Display the chat history
|
66 |
st.write("### Chat History")
|
67 |
for user_msg, assistant_msg in st.session_state.history:
|
68 |
st.write(f"**User:** {user_msg}")
|
69 |
st.write(f"**Assistant:** {assistant_msg}")
|
70 |
-
|
71 |
-
|
|
|
45 |
st.write("### Interact with the chatbot!")
|
46 |
|
47 |
# User input field
|
48 |
+
user_message = st.text_area("Your Message:", "")
|
49 |
|
50 |
# Chat history
|
51 |
if 'history' not in st.session_state:
|
52 |
st.session_state.history = []
|
53 |
|
54 |
+
# Button to send the message
|
55 |
if st.button("Send"):
|
56 |
if user_message: # Check if user has entered a message
|
57 |
# Get the response from the model
|
|
|
61 |
st.session_state.history.append((user_message, response))
|
62 |
|
63 |
# Clear the input field after sending
|
64 |
+
user_message = "" # Reset user_message to clear input
|
65 |
|
66 |
# Display the chat history
|
67 |
st.write("### Chat History")
|
68 |
for user_msg, assistant_msg in st.session_state.history:
|
69 |
st.write(f"**User:** {user_msg}")
|
70 |
st.write(f"**Assistant:** {assistant_msg}")
|
|
|
|