Comment after like is pressed

Summary

After like button is pressed st.text_input should appear where user can type comment and it will be saved after enter is pressed to .txt file. The problem is after like is pressed, nothing happens, there is no text box, the streamlit just shows running for half sec and nothing else happens.

Steps to reproduce

Code snippet:


def save_likes_to_txt(answer,comment):
    with open("likes.txt", 'a') as f:
        f.write("Bot: " +  answer + "\n")
        f.write("Comment: " + comment + "\n\n")
        f.write("\n" + "*" * 80 + "\n\n") 

def likes(full_response):
    user_comment = st.text_input("Add comment here: ")
    if user_comment:
     save_likes_to_txt(full_response,user_comment)

with st.chat_message("assistant"):
   full_response = result["answer"]
   st.markdown(full_response)
   if st.button(":thumbsup:"):
       likes(full_response)

Clicking the like button makes the text box appear when I run your code. Note that result is undefined and I had to make it up.

1 Like

Sorry my bad for implementation we can close this/

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