forked from DevExpress-Examples/devexpress-ai-chat-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Chat-CustomMessage.razor
30 lines (28 loc) · 927 Bytes
/
Chat-CustomMessage.razor
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
@page "/custommessage"
@using DevExpress.AIIntegration.Blazor.Chat
@using AIIntegration.Services.Chat;
<DxAIChat CssClass="my-chat">
<MessageTemplate>
<div class="@GetMessageClasses(context)">
@if(context.Typing) {
<span>Loading...</span>
} else {
<div class="my-chat-content">
@context.Content
</div>
}
</div>
</MessageTemplate>
</DxAIChat>
@code {
string GetMessageClasses(ChatMessage message) {
if(message.Role == ChatMessageRole.Assistant) {
return "my-chat-message my-assistant-message";
} else if(message.Role == ChatMessageRole.User) {
return "my-chat-message my-user-message";
} else if(message.Role == ChatMessageRole.Error) {
return "my-chat-message my-error-message";
}
return "my-chat-message";
}
}