blazor-devexpress-dot-aiintegration-dot-blazor-dot-chat-dot-dxaichat-7d24a3e3.md
Specifies the format of response content.
Namespace : DevExpress.AIIntegration.Blazor.Chat
Assembly : DevExpress.AIIntegration.Blazor.Chat.v25.2.dll
NuGet Package : DevExpress.AIIntegration.Blazor.Chat
[Parameter]
public ResponseContentFormat ResponseContentFormat { get; set; }
| Type | Description |
|---|---|
| ResponseContentFormat |
Content format.
|
Available values:
| Name | Description |
|---|---|
| Markdown |
An assistant sends the response as Markdown.
| | PlainText |
An assistant sends the response as plain text.
|
The AI service uses plain text as the default response format. To display rich formatted messages, set the ResponseContentFormat property to Markdown and use a markdown processor to convert the response content to HTML code.
Important
Always sanitize HTML generated from Markdown to prevent cross-site scripting (XSS). Use a trusted sanitizer (for example, the HtmlSanitizer package) to allow only safe tags and attributes before the browser renders content.
@using Markdig
@using Ganss.Xss
<DxAIChat ResponseContentFormat="ResponseContentFormat.Markdown">
<MessageContentTemplate>
@ToHtml(context.Content)
</MessageContentTemplate>
</DxAIChat>
@code {
private readonly HtmlSanitizer sanitizer = new HtmlSanitizer();
MarkupString ToHtml(string markdown) {
string html = Markdown.ToHtml(markdown);
// Sanitize the HTML to prevent XSS attacks
html = sanitizer.Sanitize(html);
return new MarkupString(html);
}
}
.demo-chat {
width: 100%;
height: 400px;
}
See Also