Skip to main content
All docs
V25.2
  • IAIChatMessageContextItem Interface

    Defines the programmatic interface for the AIChatResource component.

    Namespace: DevExpress.AIIntegration.Blazor.Chat

    Assembly: DevExpress.AIIntegration.Blazor.Chat.v25.2.dll

    NuGet Package: DevExpress.AIIntegration.Blazor.Chat

    Declaration

    public interface IAIChatMessageContextItem

    Remarks

    Use the IAIChatMessageContextItem interface to read AIChatResource properties at runtime. Get an instance from a message context or from MessageSent event arguments.

    The following code snippet gets an IAIChatMessageContextItem reference and uses it to build a custom message template:

    <DxAIChat Resources="Resources">
        <MessageContentTemplate>
            <div class="ai-resources-wrapper">
                @foreach(var resource in context.Contexts) {
                    <span class="ai-resource">@resource.Name</span>
                }
            </div>
            <div class="ai-chat-message">@context.Content</div>
        </MessageContentTemplate>
    </DxAIChat>
    
    @code {
        List<AIChatResource> Resources { get; set; } = [];
    
        protected override async Task OnInitializedAsync() {
            AIChatResource instructions = await FileResourceProvider.GetTextResourceAsync("instructions",
                "Technical Support",
                "An assistant that helps troubleshoot technical issues and provides step-by-step solutions.");
            AIChatResource documentation = await FileResourceProvider.GetTextResourceAsync("api-reference.md",
                "API Reference",
                "DevExpress Blazor AI Chat API Reference.");
            AIChatResource screenshot = await FileResourceProvider.GetBinaryResourceAsync("ai-chat-image.png",
                "AI Chat Screenshot",
                "An annotated screenshot of the AI Chat component.",
                "image/png");
            Resources.Add(instructions);
            Resources.Add(documentation);
            Resources.Add(screenshot);
            await base.OnInitializedAsync();
        }
    }
    

    Add AI Resource Names to Chat Message

    See Also