Anne31415 commited on
Commit
8a475f2
·
verified ·
1 Parent(s): 365e9a6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -8
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
- # Diagnostic print: Display each chat entry
292
- st.text(f"Chat entry: {chat}")
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
- background_color = "#ffeecf" if chat[2] == "new" else "#ffeecf" if speaker == "User" else "#ffeecf"
 
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}")