Chainlit / chainlit

Build Conversational AI in minutes ⚡️
https://docs.chainlit.io
Apache License 2.0
6.74k stars 873 forks source link

Button callbacks: Redundant functions due to name-based assignment #1251

Open khadar1020 opened 3 weeks ago

khadar1020 commented 3 weeks ago

Describe the bug I will explain a scenario in the present functionality of the buttons, where the name of the buttons will be given as the callback function, and also for the callback function the name is displayed on the webpage so we have to create separate functions for every button. now let's think there 6 buttons they are having the same functionality but the only change is we use the text inside the button for it.

for example: There are 6 buttons of song names inside it when we click on any one song we will get the midi file of the song all buttons behave the same but the only change is taking the name of the song by action.value method but for this in the current implementation of chainlit we have to create separate functions for all

Expected behavior Instead of giving the name as the callback function we can give separate id for all buttons because the name is displayed on the webpage.

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context Add any other context about the problem here.

khadar1020 commented 3 weeks ago

Hi @dokterbob I think you got my issue