Skip to main content
All docs
V26.1
  • AIChatControl.SendMessageAsync(List<AIContent>) Method

    Sends a message to the AI service.

    Namespace: DevExpress.AIIntegration.WinForms.Chat

    Assembly: DevExpress.AIIntegration.WinForms.Chat.v26.1.dll

    NuGet Package: DevExpress.AIIntegration.WinForms.Chat

    Declaration

    public Task SendMessageAsync(
        List<AIContent> contents
    )

    Parameters

    Name Type Description
    contents List<Microsoft.Extensions.AI.AIContent>

    A list of content items that make up the message.

    Returns

    Type Description
    Task

    A task that completes when the message is sent.

    Remarks

    Call this overload to send a message that combines multiple content items (for example, text and an image).

    To manually process messages sent to an AI service, handle the MessageSending event.

    Note

    Set the e.Cancel event parameter to true to block automatic message delivery, and call the SendMessageAsync method to send the message to the AI service manually.

    Example

    The following example sends a message that contains text and an image:

    using Microsoft.Extensions.AI;
    
    async void ButtonSend_Click(object sender, EventArgs e) {
        await aiChatControl1.SendMessageAsync(new List<AIContent> {
            new TextContent("Describe this screenshot."),
            new DataContent(File.ReadAllBytes("dashboard.jpg"), "image/jpeg")
        });
    }
    

    Refer to the following help topic for additional information: AI Chat Control

    See Also