Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -288,15 +288,13 @@ def page1():
|
|
288 |
new_messages = st.session_state['chat_history_page1'][-2:]
|
289 |
for chat in new_messages:
|
290 |
try:
|
291 |
-
#
|
292 |
-
|
293 |
-
|
294 |
-
# Ensure tuple has two elements
|
295 |
-
if len(chat) != 2:
|
296 |
raise ValueError(f"Invalid chat tuple: {chat}")
|
297 |
-
|
298 |
-
speaker, message = chat
|
299 |
-
|
|
|
300 |
new_messages_placeholder.markdown(f"<div style='background-color: {background_color}; padding: 10px; border-radius: 10px; margin: 10px;'>{speaker}: {message}</div>", unsafe_allow_html=True)
|
301 |
except IndexError as e:
|
302 |
st.error(f"Error processing chat entry: {e}")
|
|
|
288 |
new_messages = st.session_state['chat_history_page1'][-2:]
|
289 |
for chat in new_messages:
|
290 |
try:
|
291 |
+
# Ensure the tuple has at least two elements
|
292 |
+
if len(chat) < 2:
|
|
|
|
|
|
|
293 |
raise ValueError(f"Invalid chat tuple: {chat}")
|
294 |
+
|
295 |
+
speaker, message = chat[:2]
|
296 |
+
status = chat[2] if len(chat) > 2 else "old" # Default to "old" if the third element is missing
|
297 |
+
background_color = "#ffeecf" if status == "new" else "#ffeecf" if speaker == "User" else "#ffeecf"
|
298 |
new_messages_placeholder.markdown(f"<div style='background-color: {background_color}; padding: 10px; border-radius: 10px; margin: 10px;'>{speaker}: {message}</div>", unsafe_allow_html=True)
|
299 |
except IndexError as e:
|
300 |
st.error(f"Error processing chat entry: {e}")
|