Skip to main content
All docs
V26.1
  • 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.v26.1.dll

    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, save an audit trail, or trigger business logic.

    The event timing depends on the UseStreaming property:

    • When UseStreaming is false, the event fires before the response appears in the chat.
    • When UseStreaming is true, the event fires after the full response appears in the chat.

    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