Exception loading st.image as avatar

Exception has occurred: StreamlitAPIException
Failed to load the provided avatar value as an image.
TypeError: a bytes-like object is required, not ‘DeltaGenerator’

The above exception was the direct cause of the following exception:

  File "<absolute_path_folder>/strimlit.py", line 33, in <module>
    with st.chat_message(name='assistant', avatar=st.image(logo_path)):
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
streamlit.errors.StreamlitAPIException: Failed to load the provided avatar value as an image.

below my code:

from PIL import Image
logo_path = "../../images/logo.png"
image = Image.open(logo_path)

...

if st.session_state.messages[-1]["role"] != "assistant":
    with st.chat_message(name='assistant', avatar=st.image(image=image)):

No need use st.image there. Passing the path (avatar = logo_path ) or the PIL.Image (avatar = image) should be enough.

I tried:

with st.chat_message(name=‘assistant’, avatar=logo_path):

and it works thanks a lot!