Summary
I want to add a like
and
option for each answer in a chatbot (like ChatGPT) to collect feedback and use that for fine tuning. I need ideas for how I can do this?
Expected behavior:
When user clicks
, it should highlight
and vice versa, just like radio buttons! I should also be able to receive input in variables so that I can use that to store feedback to a CSV.
What I have tried:
I tried using button group component - New Component: Button Group
As soon as it reaches the code block for st_btn_group, the app reruns MULTIPLE times, that makes it very glitchy. Is there any possible solution for this?
Here I am attaching the code Iβm using -
buttons = [
{"label": "π",
"value": "like",
"style": {"border-radius": "22px", "padding": "1px"}
},
{"label": "π",
"value": "dislike",
"style": {"border-radius": "22px", "padding": "1px"}
}
]
col = st.columns([92, 8])
with col[1]:
returned = st_btn_group(buttons=buttons, key=message["query_id"], mode='radio',
return_value=True)
Here if you try to store βreturnedβ into a list, it will return βlikeβ or βdislikeβ multiple times for 1 question.
So this is a no-go.
Iβm looking for any creative ideas! Thanks in advance! 
1 Like
Hello @Manas_Swami! 
Thank you for your question!
I would recommend using the ace Feedback component from Trubrics for this!
Trubrics Feedback Blog Post
Trubrics Demo App
I have some experience using it myself, so feel free to reach out if you have any questions. Iβll do my best to assist you! 
Best,
Charly
Hi, thanks for the reply! Actually, I donβt want to use a third-party app for this. Instead, I am saving everything to a seaprate database including user information and feedback.
Although, I stumbled upon this - GitHub - trubrics/streamlit-feedback: Collect user feedback from within your Streamlit app
Here the issue is
user_input = st.chat_input("Type your question here or type an SQL query to run...")
if user_input:
logging.info(f"Received new user input - {user_input}")
# Processing the user input here ---
# After processing -
with st.chat_message("assistant"):
st.markdown("answer from LLM")
# Feedback code
feedback = streamlit_feedback(feedback_type="thumbs", key=query_id_key)
print(feedback)
Sorry this is a very small part of the code because the code is v large. Now here if I click on either like or dislike, the app reruns without storing the feedback and goes to my history display loop. How do I store this feedback? Any ideas?
if βbtn_valueβ not in st.session_state:
st.session_state.btn_value = None
Try to define st.session_state for button group and can be used elsewhere in the app without triggering unnecessary reruns. Let me know if it works.