Update app.py
Browse files
app.py
CHANGED
|
@@ -18,7 +18,7 @@ def main():
|
|
| 18 |
if 'history' not in st.session_state:
|
| 19 |
st.session_state.history = []
|
| 20 |
|
| 21 |
-
# User input
|
| 22 |
user_input = st.text_input("Tell us what's happening:", key="user_input")
|
| 23 |
|
| 24 |
# Submit button
|
|
@@ -28,13 +28,14 @@ def main():
|
|
| 28 |
display_conversation(user_input, response)
|
| 29 |
st.session_state.user_input = "" # Clear the input after submission
|
| 30 |
|
| 31 |
-
#
|
| 32 |
-
|
| 33 |
-
st.session_state.history = []
|
| 34 |
|
| 35 |
def display_conversation(user_input, response):
|
| 36 |
-
|
| 37 |
-
|
|
|
|
|
|
|
| 38 |
for i, message in enumerate(st.session_state.history[-10:]): # Display last 10 messages
|
| 39 |
if i % 2 == 0:
|
| 40 |
st.markdown(f"<div style='background-color:#e1f5fe;padding:10px;border-radius:10px;'>{message}</div> ", unsafe_allow_html=True)
|
|
|
|
| 18 |
if 'history' not in st.session_state:
|
| 19 |
st.session_state.history = []
|
| 20 |
|
| 21 |
+
# User input with a unique key that gets reset
|
| 22 |
user_input = st.text_input("Tell us what's happening:", key="user_input")
|
| 23 |
|
| 24 |
# Submit button
|
|
|
|
| 28 |
display_conversation(user_input, response)
|
| 29 |
st.session_state.user_input = "" # Clear the input after submission
|
| 30 |
|
| 31 |
+
# Display the conversation history
|
| 32 |
+
display_conversation(None, None)
|
|
|
|
| 33 |
|
| 34 |
def display_conversation(user_input, response):
|
| 35 |
+
if user_input and response:
|
| 36 |
+
st.session_state.history.append(f"User: {user_input}")
|
| 37 |
+
st.session_state.history.append(f"IT Support: {response}")
|
| 38 |
+
|
| 39 |
for i, message in enumerate(st.session_state.history[-10:]): # Display last 10 messages
|
| 40 |
if i % 2 == 0:
|
| 41 |
st.markdown(f"<div style='background-color:#e1f5fe;padding:10px;border-radius:10px;'>{message}</div> ", unsafe_allow_html=True)
|