From 364c3c8da95671b3ce0ea9a6606e221c62dc0933 Mon Sep 17 00:00:00 2001 From: odrec Date: Thu, 20 Jun 2024 05:47:02 +0200 Subject: [PATCH] Simplify image displaying code --- src/chat_manager.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/chat_manager.py b/src/chat_manager.py index 070622a..f70ddb1 100644 --- a/src/chat_manager.py +++ b/src/chat_manager.py @@ -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. @@ -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) @@ -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,