Here is the code for which shows LLMs output on buttons which is generated in json format and I want to click on one button and send its response to save_option function but without clicking it is sending all button data to that function.
result = json.loads(result)
for sen in result[‘ad_options’]:
st.button(sen[‘scenario’], key=None, on_click=save_option(sen[‘scenario’]))
print(‘------------------------’)
result value:
def save_option(option_label):
print(“‘Here it should print’”, option_label)
output :

