DxAIChat.ResponseReceived Event
Fires after the AI provider returns a response, before the message is displayed in the chat.
Namespace: DevExpress.AIIntegration.Blazor.Chat
Assembly: DevExpress.AIIntegration.Blazor.Chat.v25.2.dll
NuGet Package: DevExpress.AIIntegration.Blazor.Chat
Declaration
[Parameter]
public EventCallback<ResponseReceivedEventArgs> ResponseReceived { get; set; }
Parameters
| Type | Description |
|---|---|
| ResponseReceivedEventArgs | An object that contains event data. |
Remarks
Handle the ResponseReceived event to process the AI provider’s response immediately before it is rendered. Use this event to analyze content, save an audit trail, or trigger business logic.
The following code snippet handles the ResponseReceived event to remove specific tool call details from the response:
@using DevExpress.AIIntegration.Blazor.Chat
@using DevExpress.AIIntegration.Tools
@inject AIToolsContextContainer aiToolsContextContainer
<DxAIChat IncludeFunctionCallInfo="true"
ResponseReceived="OnResponseReceived">
</DxAIChat>
@code {
private void OnResponseReceived(ResponseReceivedEventArgs args) {
args.Message.FunctionCalls.RemoveAll(
fc => fc?.Request?.Name != null &&
fc.Request.Name == "Generic_Greeting");
}
protected override void OnAfterRender(bool firstRender) {
if(firstRender) {
var context = new AIToolsContextBuilder()
.WithToolMethods(MyAITools.Greet, MyAITools.AddNumbers)
.Build();
aiToolsContextContainer.Add(context);
}
}
}
See Also