Back to Devexpress

MessageSentEventArgs.Chat Property

blazor-devexpress-dot-aiintegration-dot-blazor-dot-chat-dot-messagesenteventargs-8d7374c6.md

latest2.0 KB
Original Source

MessageSentEventArgs.Chat Property

Returns an object that allows you to send messages to the chat.

Namespace : DevExpress.AIIntegration.Blazor.Chat

Assembly : DevExpress.AIIntegration.Blazor.Chat.v25.2.dll

NuGet Package : DevExpress.AIIntegration.Blazor.Chat

Declaration

csharp
public IAIChat Chat { get; }

Property Value

TypeDescription
IAIChat

An object that implements the IAIChat interface.

|

Remarks

Use the Chat property to access methods available for the DxAIChat component. Call the Chat.SendMessage method to send a message to the chat.

razor
<DxAIChat MessageSent="MessageSent"
          FileUploadEnabled="true" />

@code {
    async Task MessageSent(MessageSentEventArgs args) {
        if(args.Files != null && args.Files.Count > 0) {
            var fileNames = args.Files.Select(x => x.Name);
            var response = $"Processed message content: {args.Content}.{System.Environment.NewLine}";
            response += $"The message contains {args.Files.Count} attached file(s):{System.Environment.NewLine}";
            response += string.Join(System.Environment.NewLine, fileNames);
            await args.Chat.SendMessage(response, ChatRole.Assistant);
        }
    }
}

Run Demo: AI Chat - Manual Message Processing

See Also

MessageSentEventArgs Class

MessageSentEventArgs Members

DevExpress.AIIntegration.Blazor.Chat Namespace