Back to Devexpress

DxAIChat.ResponseContentFormat Property

blazor-devexpress-dot-aiintegration-dot-blazor-dot-chat-dot-dxaichat-7d24a3e3.md

latest2.4 KB
Original Source

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

csharp
[Parameter]
public ResponseContentFormat ResponseContentFormat { get; set; }

Property Value

TypeDescription
ResponseContentFormat

Content format.

|

Available values:

NameDescription
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.

razor
@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);
    }
}
css
.demo-chat {
    width: 100%;
    height: 400px;
}

See Also

DxAIChat Class

DxAIChat Members

DevExpress.AIIntegration.Blazor.Chat Namespace