How to build interactive Generative UI applications
onAction
callback with 2 arguments: llmFriendlyMessage
and humanFriendlyMessage
.
llmFriendlyMessage
is the text that will be sent to the backend to fetch the products.humanFriendlyMessage
is the text that will can be shown to the user if needed.llmFriendlyMessage
and previousMessages
that contains the current state of the UI. apple.com
and clicked on the Products
button. Given this context,
the LLM can use this information to fetch Products for apple.com
.Add buttons to the Generated UI
Add a button handler
onAction
callback to the C1Component
. This callback will be called when the user clicks on the button.
The argument to the callback is an object with two properties: llmFriendlyMessage
and humanFriendlyMessage
wherellmFriendlyMessage
is the text that will be sent to the backend to fetch the productshumanFriendlyMessage
is the text that will can be shown to the user (if needed, for example in chatbots)Call the backend endpoint and update the UI with the response