Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -171,18 +171,17 @@ def page1():
|
|
| 171 |
# Find the last assistant message
|
| 172 |
last_assistant_message = next((message for message in reversed(st.session_state.messages.data) if message.role == "assistant"), None)
|
| 173 |
if last_assistant_message:
|
| 174 |
-
with st.chat_message('assistant'):
|
| 175 |
-
for content_part in last_assistant_message.content:
|
| 176 |
-
if content_part.type == 'text':
|
| 177 |
-
st.markdown(content_part.text.value)
|
| 178 |
-
elif hasattr(content_part, 'image_file') and content_part.image_file:
|
| 179 |
-
image = handle_and_display_image(content_part.image_file.file_id)
|
| 180 |
-
if image:
|
| 181 |
-
st.image(image, caption="Generated Image")
|
| 182 |
-
|
| 183 |
# Add assistant's response to chat history
|
| 184 |
st.session_state.chat_history.append(("Assistant", last_assistant_message.content[0].text.value))
|
| 185 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 186 |
|
| 187 |
# Check if 'run' object has 'status' attribute
|
| 188 |
if hasattr(st.session_state.run, 'status'):
|
|
|
|
| 171 |
# Find the last assistant message
|
| 172 |
last_assistant_message = next((message for message in reversed(st.session_state.messages.data) if message.role == "assistant"), None)
|
| 173 |
if last_assistant_message:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 174 |
# Add assistant's response to chat history
|
| 175 |
st.session_state.chat_history.append(("Assistant", last_assistant_message.content[0].text.value))
|
| 176 |
|
| 177 |
+
# Display chat history in Streamlit chat format
|
| 178 |
+
for role, message in st.session_state.chat_history:
|
| 179 |
+
if role == "User":
|
| 180 |
+
with st.chat_message("User"):
|
| 181 |
+
st.markdown(message)
|
| 182 |
+
elif role == "Assistant":
|
| 183 |
+
with st.chat_message("Assistant"):
|
| 184 |
+
st.markdown(message)
|
| 185 |
|
| 186 |
# Check if 'run' object has 'status' attribute
|
| 187 |
if hasattr(st.session_state.run, 'status'):
|