wop commited on
Commit
b9f1b65
1 Parent(s): 91c3eb6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -140,9 +140,13 @@ with col2:
140
 
141
  # Display chat messages from history on app rerun
142
  for message in st.session_state.messages:
143
- avatar = "🤖" if message["role"] == "assistant" else "🕺"
144
- with st.chat_message(message["role"], avatar=avatar):
145
- st.markdown(message["content"])
 
 
 
 
146
 
147
 
148
  def generate_chat_responses(chat_completion) -> Generator[str, None, None]:
 
140
 
141
  # Display chat messages from history on app rerun
142
  for message in st.session_state.messages:
143
+ if hasattr(message, "role"):
144
+ avatar = "🤖" if message.role == "assistant" else "🕺"
145
+ with st.chat_message(message.role, avatar=avatar):
146
+ st.markdown(message.content)
147
+ else:
148
+ st.warning("Message object does not have the 'role' attribute.")
149
+
150
 
151
 
152
  def generate_chat_responses(chat_completion) -> Generator[str, None, None]: