Back to Devexpress

DxAIChat.SendMessage(String, ChatRole, List<AIChatUploadFileInfo>) Method

blazor-devexpress-dot-aiintegration-dot-blazor-dot-chat-dot-dxaichat-dot-sendmessage-x28-string-chatrole-list-aichatuploadfileinfo-x29.md

latest2.6 KB
Original Source

DxAIChat.SendMessage(String, ChatRole, List<AIChatUploadFileInfo>) Method

Sends a message 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 Task SendMessage(
    string messageContent,
    ChatRole role,
    List<AIChatUploadFileInfo> files = null
)

Parameters

NameTypeDescription
messageContentString

The message text to be sent.

| | role | Microsoft.Extensions.AI.ChatRole |

The role of the message owner.

|

Optional Parameters

NameTypeDefaultDescription
filesList<AIChatUploadFileInfo>null

A collection of files to be uploaded.

|

Returns

TypeDescription
Task

A task that is completed when the message is sent.

|

Remarks

Call the SendMessage method to send a message to the chat.

razor
<DxAIChat @ref="Chat" CssClass="demo-chat" />
<DxButton Text="Start dialog" Click="StartDialog" />

@code {
    DxAIChat Chat { get; set; }

    void StartDialog(MouseEventArgs args) {
        var filePath = "C:\\Users\\Public\\images\\AlbertEinstein.jpg";

        var fileBytes = File.ReadAllBytes(filePath);

        var testFiles = new List<AIChatUploadFileInfo> {
            new AIChatUploadFileInfo(
                name: Path.GetFileName(filePath),
                type: "image/jpeg",
                size: fileBytes.Length,
                data: new ReadOnlyMemory<byte>(fileBytes)
            )
        };
        Chat.SendMessage("What is s on the image?", Microsoft.Extensions.AI.ChatRole.User, testFiles);
    }
}

Implements

SendMessage(String, ChatRole, List<AIChatUploadFileInfo>)

See Also

DxAIChat Class

DxAIChat Members

DevExpress.AIIntegration.Blazor.Chat Namespace