blazor-devexpress-dot-aiintegration-dot-blazor-dot-chat-dot-dxaichat-dot-sendmessage-x28-string-chatrole-list-aichatuploadfileinfo-x29.md
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
public Task SendMessage(
string messageContent,
ChatRole role,
List<AIChatUploadFileInfo> files = null
)
| Name | Type | Description |
|---|---|---|
| messageContent | String |
The message text to be sent.
| | role | Microsoft.Extensions.AI.ChatRole |
The role of the message owner.
|
| Name | Type | Default | Description |
|---|---|---|---|
| files | List<AIChatUploadFileInfo> | null |
A collection of files to be uploaded.
|
| Type | Description |
|---|---|
| Task |
A task that is completed when the message is sent.
|
Call the SendMessage method to send a message to the chat.
<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);
}
}
SendMessage(String, ChatRole, List<AIChatUploadFileInfo>)
See Also