Skip to content

Commit

Permalink
Simplify image displaying code
Browse files Browse the repository at this point in the history
  • Loading branch information
Odrec committed Jun 20, 2024
1 parent fd8880a commit 364c3c8
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/chat_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,10 @@ def _display_images_inside_message(images):
'src': image
})

streamlit_image_gallery(images_list, max_width='100%')
col1, _ = st.columns(2)
with col1:
with st.chat_message("user"):
streamlit_image_gallery(images_list, max_width='100%')

def _display_conversation(self, conversation_history):
"""Displays the conversation history between the user and the assistant within the given container or globally.
Expand All @@ -318,11 +321,7 @@ def _display_conversation(self, conversation_history):
"""
for speaker, message, _, images in conversation_history:
if speaker == session_state['USER']:
if images:
col1, _ = st.columns(2)
with col1:
with st.chat_message("user"):
self._display_images_inside_message(images)
self._display_images_inside_message(images)
with st.chat_message("user"):
st.write(message)

Expand Down Expand Up @@ -558,10 +557,7 @@ def display_chat_interface(self):
session_state['current_photo_to_use'])
# We want to display the images just once in the chat area
if session_state['images_state'] == 0:
col1, _ = st.columns(2)
with col1:
with st.chat_message("user"):
self._display_images_inside_message(images_dict)
self._display_images_inside_message(images_dict)

# Handles the user's input and interaction with the LLM
self._handle_user_input(description_to_use,
Expand Down

0 comments on commit 364c3c8

Please sign in to comment.