DxAIChat.ResponseContentFormat Property
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
Declaration
[Parameter]
public ResponseContentFormat ResponseContentFormat { get; set; }
Property Value
| 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. |
Remarks
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);
}
}
