AIPrompt Events
This article explains the events available in the Telerik AIPrompt for Blazor:
OnOutputActionClick
The OnOutputActionClick event fires when the user clicks an output action button in the output view of the AIPrompt component. Use this event to handle custom actions such as copying, retrying, or providing feedback on the generated output.
To define the available output actions, set the OutputActions parameter to a list of AIPromptOutputActionDescriptor objects. Each action descriptor configures the appearance and behavior of an action button.
The event handler receives an argument of type AIPromptOutputActionClickEventArgs, which provides details about the clicked action, the prompt, the output, and the related command (if any). For a full list of available properties, refer to the AIPromptOutputActionClickEventArgs API reference.
See the example below.
OnPromptRequest
The OnPromptRequest event fires when the user clicks on the Generate button within the Prompt view or retries a prompt from the Output view.
The event handler receives an argument of type AIPromptPromptRequestEventArgs. See the example below.
| Property | Type | Description |
|---|---|---|
Prompt | string | The prompt text of the request. |
Output | string | The output of the request. The output is based on the prompt text. |
IsCancelled | bool | Whether the event is cancelled and the built-in action is prevented. |
OutputItem | AIPromptOutputItemDescriptor | The output item. This property will be populated only when the user retries an existing output. See AIPromptOutputItemDescriptor. |
Do not use the
OnPromptRequestevent when integrating the AIPrompt component withMicrosoft.Extensions.AI. TheOnPromptRequestevent disables such integration.
OnPromptRequestStop
The OnPromptRequestStop event fires when the user stops a prompt request by clicking the stop floating action button in the output view. This event allows you to handle the cancellation of an ongoing prompt request.
The event handler receives an EventCallback with no arguments.
OnCommandExecute
The OnCommandExecute event fires when the user clicks on a command within the Commands view.
The event handler receives an argument of type AIPromptCommandExecuteEventArgs. See the example below.
| Property | Type | Description |
|---|---|---|
Command | AIPromptCommandDescriptor | The executed command. |
Output | string | The output based on the executed command. |
IsCancelled | bool | Whether the event is cancelled and the built-in action is prevented. |
OutputItem | AIPromptOutputItemDescriptor | The output item. This property will be populated only when the user retries an existing output. See AIPromptOutputItemDescriptor. |
PromptChanged
The PromptChanged event fires when the user changes the prompt text. Use the event to update the AIPrompt's prompt when the Prompt parameter is set with one-way binding, otherwise, the user action will be ignored.
Example
Using AIPrompt events