Button created within st.chat_message disappears after it's clicked

It’s a chat application, few buttons gets created when the LLM model gives out a response.
there are few functions these buttons execute when clicked on.
the problem is when any of these buttons are clicked all created buttons disappear.

with st.chat_message(“assistant”, avatar=ast):
for idx, doc in enumerate(result[“source_documents”]):
pagenum = result[“source_documents”][idx].metadata[“page”] + 1
searchterm = result[“source_documents”][idx].page_content
newsearchterm = " “.join(searchterm.split(”\n"))
str(idx + 1),
args=(pdf_path, pagenum, newsearchterm),

1,2,3,4 are the buttons it populates, and based on the button click, there is a function that runs at the backend to write certain content on the screen.

when one of these buttons are clicked, the content gets written on the screen but the buttons disappear. it is not allowing me to click on a different button to see the contents of other buttons.

Hi @Swaroop_Mg,

Thank you for sharing your question with the community!

Your post is missing a code snippet and a link to your app’s GitHub repo. Please check out our guidelines on how to post an effective question here and update your post to help the community answer your question.

thank you for pointing that out, i have added some screenshots

See also this answer to Why should I not upload images of code/data/errors?, which for the most part applies here too.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.