Keep the display of files uploaded via chat_input after text submission

Hello everyone,

I’m working on a Streamlit application and I’m running into an issue with the st.chat_input component, specifically regarding the handling and display of uploaded files.

The Problem:

I’ve set up the chat_input component to allow users to upload files and submit a question simultaneously. The core issue is that when a user submits their input, the uploaded files are deleted from the UI.

What I’ve Tried:

  • I’ve successfully persisted the uploaded files in st.session_state. I can access the file data (like st.session_state.uploaded_file.name) in subsequent chat turns.

  • However, I can’t find a way to make the uploaded file visually persistent in the UI after the user hits “send”. The user has no visual confirmation that their question is grounded in the file they just uploaded.

My Goal:

I want the uploaded file’s name or a representation of it to remain visible in the chat UI, possibly alongside the user’s message, to provide clear feedback. This would ensure the user knows their question is being processed with the file they provided.

Has anyone faced this issue? How can I achieve this persistent visual feedback for uploaded files with st.chat_input? Any code examples or alternative approaches would be greatly appreciated.

Thank you!

I am running the app locally using streamlit 1.49.1 andpython 3.10.12

According to the docs, the uploaded files are available in the files item/attribure of the return value, so you can use that to provide feedback.