BlazorChatMessage Class
Defines an individual chat message.
Namespace: DevExpress.AIIntegration.Blazor.Chat
Assembly: DevExpress.AIIntegration.Blazor.Chat.v24.2.dll
NuGet Package: DevExpress.AIIntegration.Blazor.Chat
Declaration
public class BlazorChatMessage
Remarks
The BlazorChatMessage
class implements the functionality of an individual message displayed in the DxAIChat component. Use the class properties to get information about the message.
<DxAIChat CssClass="demo-chat">
<MessageTemplate>
<div class="@GetMessageClasses(context)">
@if(context.Typing) {
<span>Loading...</span>
} else {
<div class="demo-chat-content">
@context.Content
</div>
}
</div>
</MessageTemplate>
</DxAIChat>
@code {
string GetMessageClasses(BlazorChatMessage message) {
if(message.Role == ChatMessageRole.Assistant) {
return "demo-chat-message demo-assistant-message";
} else if(message.Role == ChatMessageRole.User) {
return "demo-chat-message demo-user-message";
} else if(message.Role == ChatMessageRole.Error) {
return "demo-chat-message demo-error-message";
}
return "demo-chat-message";
}
}
You can use the ToMessage(Object) method to convert BlazorChatMessage
objects to Microsoft.Extensions.AI.ChatMessage
objects compatible with AI services.
Inheritance
Object
BlazorChatMessage
See Also