Checkbox inside with statement not working

Dears …anybody there to correct this code. checkbox click not working. is it bug ?thanks

import streamlit as st
from streamlit_chat import message

if user_input := st.chat_input("You:"):

    with st.chat_message("user"):
    bot_reply = st.write(user_input)
    assistant_responses = "" 
    if bot_reply:
        assistant_responses = 'test'
        button_info_list = ""
        assistant_responses = "I'm sorry, but I don't understand that input. Please provide a valid request.."
    with st.chat_message("assistant"):

        button_info_list = [{"title": "Title", "payload": "Foo"}, {"title": "Another title", "payload": "Payload"}]
        for button_info in button_info_list:
            button_title = button_info.get("title", "")
            payload = button_info.get("payload", "").lstrip("/")

            checked = st.checkbox(label=button_title, key=payload)

            if checked:
               st.write("after click")