Feedback and Download Button Conflict in Streamlit App

Hello Streamlit community,

I’m encountering an issue in my Streamlit app where the feedback buttons (thumbs up and thumbs down) conflict with the download button. Here’s a brief overview of the problem:

Description:
I have implemented feedback buttons (thumbs up and thumbs down) for each chat answer in my Streamlit app, along with a download button for downloading extracted text from the answer. However, when I give feedback (click on a thumbs up or thumbs down button), the download button disappears, and vice versa.

heres a sample snippet

col1, col2, col3, col4 = st.columns([3, 3, 0.5, 0.5])
with col3:
    if st.button(":thumbsup:", on_click = like_button_clicked):
        pass
with col4:
    if st.button(":thumbsdown:", on_click = unlike_button_clicked):
        pass

if '<NONE>' not in res.split("[/INST]")[-1].strip().split(':')[-1].strip():
    with open('exec.txt') as f:
        st.download_button('Download script', f, 'exec.txt')

Hello,

It tries to ensure that the elements are always present in the design, but are conditionally enabled or disabled depending on the state of the application. Perhaps by using the session state

import streamlit as st

# Define feedback button click handlers
def like_button_clicked():
    st.write("Like button clicked")

def unlike_button_clicked():
    st.write("Unlike button clicked")

# Define a sample value for res (replace this with your actual value)
res = "Sample text"

# Display feedback buttons
if st.button(":thumbsup:", on_click=like_button_clicked):
    pass

if st.button(":thumbsdown:", on_click=unlike_button_clicked):
    pass

# Conditionally display download button based on certain conditions
try:
    with open('exec.txt') as f:
        # Provide a placeholder file object for download_button, since you're using a file object
        placeholder = st.empty()
        # Display the download button
        placeholder.download_button('Download script', f, 'exec.txt')
except FileNotFoundError:
    st.error("The file 'exec.txt' does not exist. Please make sure the file exists in the correct location.")