Skip to content

Images pass to the avatar won't appear on streamlit share #57

@le-baronysard

Description

@le-baronysard

The avatar argument in st.chat_message doesnt work with custom images.
When putting the streamlit in streamlit share instead of the custom image this is what is shown :

Capture d’écran 2023-07-06 à 23 47 05

I'm passing the custom image like that

avatar = Pil.Image.open("static/avatar.jpg")
with` st.chat_message("assistant",avatar=avatar):   
        with st.spinner("Thinking..."):
            response = "Something the bot say"
            st.write(response)  

I have also tried to read the images differently :
avatar = open("static/avatar.jpg", "rb").read()
avatar = np.array(Image.open("data/avatar.jpg"))

All the methods works fine when running streamlit in local but fails in streamlit share

Edit :
I have noticed that the little image of my bot is served this way in htmle
<img src="/media/121f19f90f4c90cef78b3269ceb860024967c4a93b3e1ceee23993e3.jpg" <-- my image was named avatar.jpg
If i remove the "/" in the beginning in the html code of the page it works
<img src="media/121f19f90f4c90cef78b3269ceb860024967c4a93b3e1ceee23993e3.jpg"
Maybe it could be a clue

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions