Checkbox not returning the correct response


I have created a feedback button in the chatbot-like interface built using the chat elements.
But the checkboxes are not holding the values so that I can store them in the database.

Steps to reproduce

import streamlit as st
from streamlit_extras.add_vertical_space import add_vertical_space
import random
from PIL import Image
from streamlit_chat import message

random_resp_optns = [‘Hello’, ‘How are you’, ‘What are you doing’, ‘I hope you are doing well’, ‘Hi’, ‘Hye’]

def streamlit_asthetics():

with st.sidebar:
      1. Ask your question in the 
          chat box & press Enter.
      2. Please wait a minute for 
          the models to run and 
          generate insights.
      3. Please review the answer 
          and provide the feedback 
          by clicking Thumbs-up or 
      4. Place your next query once 
          the previous query has run 
      5. The results are AI generated 
          and should be consumed with 
          human oversight.

intro = """
if "chat" not in st.session_state:
    st.session_state["chat"] = [{"role": "assistant",
                                     "content": intro}]
for qst in
if prompt := st.chat_input(key="input",
                           placeholder="AI assistant here! Ask me anything from the provided documents ...",):{"role": "user", "content": prompt})
    resp = random_resp_optns[random.choice(range(0,6))]{"role": "assistant", "content":resp})
    if 'a' not in st.session_state:
        st.session_state.a = 0
        st.session_state.b = 0
    def ChangeA():
        st.session_state.a, st.session_state.b = 1,0
    def ChangeB():
        st.session_state.a, st.session_state.b = 0,1
    col1, col2, _ = st.columns([1,1,10])
    with col1:
        like = st.checkbox('👍', value = st.session_state.a, on_change = ChangeA)
    with col2:
        dislike = st.checkbox('👎', value = st.session_state.b, on_change = ChangeB)

    if like or dislike:
        st.write('You selected',st.session_state.a*'👍',st.session_state.b*'👎')
        st.write('No selection')

        #st.session_state.a = 0
        #st.session_state.b = 0

if name == “main”:
# app run------
st. set_page_config(layout=“wide”)
st.session_state.a = 0
st.session_state.b = 0

If applicable, please provide the steps we should take to reproduce the error or specified behavior.

Expected behavior:

When I click on the like or dislike button, it should hold that value.

Actual behavior:

feedback buttons are not holding the value

Hi @Prahlad,

Thanks for posting!

Please check out the recent component shared here that might be just what you’re looking for