Basic Concepts
Action
Actions are a way to send clickable buttons to the user interface. Each action is attached to a Message and can be used to trigger a python function when the user clicks on it.
Create an action
Actions are sent to the UI through messages:
Define a Python Callback
To handle the user’s click on the action button, you need to define a callback function with the @cl.action_callback
decorator:
Action API
Learn how more about Actions.
Toaster
While an action is being processed, a toaster is displayed to the user. The toaster is a small notification that appears at the top right of the screen and indicates that the action is being processed.
If the action callback returns a string, the toaster will display it to the user once the action is processed.
Output of the code above