Skip to main content
You are viewing help content for pre-release software. This document and the features it describes are subject to change.
All docs
V26.2
  • AI Reasoning Visualization

    • 3 minutes to read

    Reasoning models generate intermediate “thinking” content before they produce a final answer. The DevExpress AI Chat component can display this reasoning content alongside the final response. Such content helps users understand how the assistant produced a result and allows developers to test and troubleshoot model behavior.

    Display Reasoning Content

    Set the DxAIChat.VisibleContentType property to Reasoning to display the model’s reasoning content in a built-in collapsible section above the final answer:

    <DxAIChat VisibleContentType="AIChatVisibleContentTypes.Reasoning" />
    

    Add the FunctionCallInfo flag to display reasoning content together with tool call details in the same response. Alternatively, you may set the VisibleContentType property to All:

    <DxAIChat VisibleContentType="AIChatVisibleContentTypes.Reasoning | AIChatVisibleContentTypes.All" />
    

    Alternatively, set the VisibleContentType property to FunctionCallInfo

    <DxAIChat VisibleContentType="AIChatVisibleContentTypes.FunctionCallInfo" />
    

    Customize the Reasoning Section

    Use the DxAIChat.ReasoningContentTemplate property to define custom markup for the reasoning text, while keeping the built-in collapsible header and expand/collapse behavior. This template affects only the reasoning content area:

    @using Markdig
    @using Ganss.Xss
    
    <DxAIChat VisibleContentType="AIChatVisibleContentTypes.Reasoning">
        <ReasoningContentTemplate>
            @ToHtml(context.ReasoningText)
        </ReasoningContentTemplate>
    </DxAIChat>
    
    @code {
        // Enable tables, task lists, and other Markdown extensions.
        private readonly MarkdownPipeline pipeline = new MarkdownPipelineBuilder()
            .UseAdvancedExtensions()
            .Build();
        private readonly HtmlSanitizer sanitizer = new HtmlSanitizer();
    
        MarkupString ToHtml(string markdown) {
            if(string.IsNullOrEmpty(markdown))
                return new MarkupString(string.Empty);
            string html = Markdown.ToHtml(markdown, pipeline);
            // Sanitize the HTML to prevent XSS attacks
            html = sanitizer.Sanitize(html);
            return new MarkupString(html);
        }
    }
    

    Render Reasoning Content Manually

    The built-in reasoning section appears as a collapsible block above the final answer. If you need a different layout (for example, custom markup or a different position of reasoning content within the message), render message content manually in the DxAIChat.MessageContentTemplate.

    The template’s context parameter returns a BlazorChatMessage object. Its Contents collection stores information about individual message parts. When the chat uses a reasoning model, this collection can contain the following items:

    TextReasoningContent
    An object that stores the model’s reasoning text.
    TextContent
    An object that stores the final answer.

    Use the Contents collection to control how the AI Chat renders each content type.

    The following example displays reasoning content in an expandable Model Thoughts block that the AI Chat component displays before the final answer:

    @using Markdig
    @using Ganss.Xss
    @using Microsoft.Extensions.AI
    
    <DxAIChat ResponseContentFormat="ResponseContentFormat.Markdown">
        <MessageContentTemplate>
            @foreach(var item in context.Contents) {
                if(item is TextReasoningContent reasoning) {
                    <details>
                        <summary>Model Thoughts</summary>
                        <p>@ToHtml(reasoning.Text)</p>
                    </details>
                }
                else if(item is TextContent text) {
                    <p>@ToHtml(text.Text)</p>
                }
            }
        </MessageContentTemplate>
    </DxAIChat>
    
    @code {
        // Enable tables, task lists, and other Markdown extensions.
        private readonly MarkdownPipeline pipeline = new MarkdownPipelineBuilder()
            .UseAdvancedExtensions()
            .Build();
        private readonly HtmlSanitizer sanitizer = new HtmlSanitizer();
    
        MarkupString ToHtml(string markdown) {
            string html = Markdown.ToHtml(markdown, pipeline);
            html = sanitizer.Sanitize(html);
            return new MarkupString(html);
        }
    }
    

    AI Chat Model Thoughts

    Run Demo: Reasoning Visualization