IAIChat.LoadMessages(IEnumerable<BlazorChatMessage>) Method
Loads messages to the chat history.
Namespace: DevExpress.AIIntegration.Blazor.Chat
Assembly: DevExpress.AIIntegration.Blazor.Chat.v24.2.dll
NuGet Package: DevExpress.AIIntegration.Blazor.Chat
Declaration
void LoadMessages(
IEnumerable<BlazorChatMessage> messages
)
Parameters
Name | Type | Description |
---|---|---|
messages | IEnumerable<BlazorChatMessage> | A collection of messages. |
Remarks
Use SaveMessages() and LoadMessages(IEnumerable<BlazorChatMessage>)
methods to manage chat history.
<div class="chat-demo-container">
<DxAIChat CssClass="demo-chat"
Initialized="ChatInitialized"
ResponseContentFormat="ResponseContentFormat.Markdown">
<MessageContentTemplate>
<div class="demo-chat-content">
@(new MarkupString(Markdig.Markdown.ToHtml(context.Content)))
</div>
</MessageContentTemplate>
</DxAIChat>
</div>
@code {
void ChatInitialized(IAIChat chat) {
chat.LoadMessages(new[] {
new BlazorChatMessage(Microsoft.Extensions.AI.ChatRole.User, "Hello, AI!"),
new BlazorChatMessage(Microsoft.Extensions.AI.ChatRole.Assistant, "Hey there, human! What's on your mind? 😊")
});
}
}
See Also