Skip to main content
All docs
V24.2

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

AI Assistant Extensions

  • 10 minutes to read

AI Assistant extensions allow you to enhance the way your users interact with and manage text content. These extensions leverage advanced natural language processing (NLP) technologies to offer automated, intelligent text manipulation capabilities directly within your Windows Forms applications.

Run Demo

#Applies To

#Activate AI Assistant

#Install DevExpress NuGet Packages

  1. DevExpress.AIIntegration.WinForms
  2. DevExpress.Win.Design (enables design-time features for DevExpress UI controls)

Read the following help topics for information on how to obtain the DevExpress NuGet Feed and install DevExpress NuGet packages:

#Register AI Client

The following code snippet registers the Azure OpenAI client:

using Microsoft.Extensions.AI;
using DevExpress.AIIntegration;

internal static class Program {
    [STAThread]
    static void Main() {
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        IChatClient asChatClient = new Azure.AI.OpenAI.AzureOpenAIClient(new Uri(AzureOpenAIEndpoint),
            new System.ClientModel.ApiKeyCredential(AzureOpenAIKey))
            .AsChatClient(ModelId);
        AIExtensionsContainerDesktop.Default.RegisterChatClient(asChatClient);
        // Uncomment the following line if your project targets the .NET Framework and
        // you create AI-powered behaviors in code.
        // DevExpress.AIIntegration.WinForms.BehaviorInitializer.Initialize();
        Application.Run(new Form1());
    }
    static string AzureOpenAIEndpoint { get { return Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT"); } }
    static string AzureOpenAIKey { get { return Environment.GetEnvironmentVariable("AZURE_OPENAI_APIKEY"); } }
    static string ModelId { get { return "gpt-4o-mini"; } }
}

Tip

Read the following help topic for additional information: How to Register an AI Client.

#Create and Configure AI Assistant Behaviors

Follow the steps below to apply a behavior to a control at design time:

  1. Drop the BehaviorManager component from the Toolbox onto a Form.
  2. Use the BehaviorManager’s smart tag menu to edit behaviors.
  3. Add required AI-powered text transform behaviors and configure their settings as needed.

    Add AI-powered Text Transform Behaviors at Design Time, DevExpress

  4. Run the application. Select the text in the MemoEdit and invoke the context menu. The context menu displays the AI Assistant submenu with AI-powered commands:

    WinForms MemoEdit with AI-powered Options, DevExpress

  5. Click the required command. The AI processes the command and generates an answer. The AI-generated answer is displayed in a dialog. A user can easily insert the answer directly into a document or text field with a single click.

    The user can insert the AI’s answer above/below the cursor, replace all content or selected text, or copy the answer to the clipboard.

    AI Response - WinForms MemoEdit with AI-powered Options, DevExpress

Note

Call the BehaviorInitializer.Initialize() method at application startup if your project targets the .NET Framework and you create AI-powered behaviors in code. Otherwise, an exception is thrown.

C#
internal static class Program {
    [STAThread]
    static void Main() {
        //...
        // The Initialize() method forcibly initializes the behavior manager in .NET Framework apps.
        DevExpress.AIIntegration.WinForms.BehaviorInitializer.Initialize();
        Application.Run(new Form1());
    }
}

#Change Style

ChangeStyleBehavior rephrases or paraphrases the selected text while retaining its original meaning. This behavior allows you to generate alternative versions of the same content to match a specific genre or format. You can choose from 12 predefined styles (see WritingStyle).

The following code snippet registers a ChangeStyleBehavior and assigns it to a MemoEdit control:

using DevExpress.AIIntegration.WinForms;

//...
public partial class Forms : DevExpress.XtraEditors.XtraForm {
    public MemoEdit() {
        InitializeComponent();
        behaviorManager1.Attach<ChangeStyleBehavior>(memoEdit1, behavior => {
            //behavior.Properties.Temperature = 0.6f;
        });
    }
}

Tip

Use ChangeStyleRequest to manually initiate a request to change the style of the original text:

C#
var response = await defaultAIExtensionsContainer.ChangeStyleAsync(
    new ChangeStyleRequest(originalText, WritingStyle.Academic)
);

#Change Tone

ChangeToneBehavior adjusts the tone of the text to meet audience or context requirements. This option helps tailor the voice of your content.

Tone styles include:

  • Casual
  • Confident
  • Friendly
  • Professional
  • Straightforward

The following code snippet registers a ChangeToneBehavior and assigns it to a MemoEdit control:

using DevExpress.AIIntegration.WinForms;

//...
public partial class Forms : DevExpress.XtraEditors.XtraForm {
    public MemoEdit() {
        InitializeComponent();
        behaviorManager1.Attach<ChangeToneBehavior>(memoEdit1, behavior => {
            //behavior.Properties.Temperature = 0.6f;
        });
    }
}

Tip

Use ChangeToneRequest to manually initiate a request to adjust the tone of the original text:

C#
var response = await defaultAIExtensionsContainer.ChangeToneAsync(
    new ChangeToneRequest(originalText, ToneStyle.Casual)
);

#Expand

ExpandBehavior enriches your text with additional information or in-depth explanations.

The following code snippet registers an ExpandBehavior and assigns it to a MemoEdit control:

using DevExpress.AIIntegration.WinForms;

//...
public partial class Forms : DevExpress.XtraEditors.XtraForm {
    public MemoEdit() {
        InitializeComponent();
        behaviorManager1.Attach<ExpandBehavior>(memoEdit1, behavior => {
            //behavior.Properties.Temperature = 0.6f;
        });
    }
}

Tip

Use ExpandRequest to manually initiate a request to enrich the original text with additional information:

C#
var response = await defaultAIExtensionsContainer.ExpandAsync(
    new ExpandRequest(originalText)
);

#Explain

ExplainBehavior transforms text into more understandable terms that make complex content more accessible and understandable.

The following code snippet registers an ExplainBehavior and assigns it to a MemoEdit control:

using DevExpress.AIIntegration.WinForms;

//...
public partial class Forms : DevExpress.XtraEditors.XtraForm {
    public MemoEdit() {
        InitializeComponent();
        behaviorManager1.Attach<ExplainBehavior>(memoEdit1, behavior => {
            //behavior.Properties.Temperature = 0.6f;
        });
    }
}

Tip

Use ExplainRequest to manually initiate a request to explain the original text:

C#
var response = await defaultAIExtensionsContainer.ExplainAsync(
    new ExplainRequest(originalText)
);

#Proofread

ProofreadBehavior reviews the text for spelling, grammar, punctuation, and style errors.

The following code snippet registers a ProofreadBehavior and assigns it to a MemoEdit control:

using DevExpress.AIIntegration.WinForms;

//...
public partial class Forms : DevExpress.XtraEditors.XtraForm {
    public MemoEdit() {
        InitializeComponent();
        behaviorManager1.Attach<ProofreadBehavior>(memoEdit1, behavior => {
            //behavior.Properties.Temperature = 0.6f;
        });
    }
}

Tip

Use ProofreadRequest to manually initiate a request to proofread the original text:

C#
var response = await defaultAIExtensionsContainer.ProofreadAsync(
    new ProofreadRequest(originalText)
);

#Shorten

ShortenBehavior removes unnecessary details and makes content more concise.

The following code snippet registers a ShortenBehavior and assigns it to a MemoEdit control:

using DevExpress.AIIntegration.WinForms;

//...
public partial class Forms : DevExpress.XtraEditors.XtraForm {
    public MemoEdit() {
        InitializeComponent();
        behaviorManager1.Attach<ShortenBehavior>(memoEdit1, behavior => {
            //behavior.Properties.Temperature = 0.6f;
        });
    }
}

Tip

Use ShortenRequest to manually initiate a request to shorten the original text:

C#
var response = await defaultAIExtensionsContainer.ShortenAsync(
    new ShortenRequest(originalText)
);

#Summarize

SummarizeBehavior generates a brief summary of long text.

SummarizeBehavior supports the following summarization modes:

  1. Abstractive Summarization

    Generates a summary by understanding the context of the original text and rephrasing it in a new, concise form. The AI essentially “writes” a new summary based on its understanding, which may include new sentences that were not present in the original text.

  2. Extractive Summarization

    Selects and extracts key sentences or phrases from the original text. The AI identifies the most important parts of the content and combines them into a summary without altering the original wording.

The following code snippet registers a SummarizeBehavior and assigns it to a MemoEdit control:

using DevExpress.AIIntegration;
using DevExpress.AIIntegration.WinForms;

//...
public partial class MemoEdit : DevExpress.XtraEditors.XtraForm {
    public MemoEdit() {
        InitializeComponent();
        behaviorManager1.Attach<SummarizeBehavior>(memoEdit1, behavior => {
            behavior.Properties.SummarizationMode = SummarizationMode.Extractive;
        });
    }
}

Tip

Use AbstractiveSummaryRequest and/or ExtractiveSummaryRequest to manually initiate a request to generate a summary for the original text:

C#
var response1 = await defaultAIExtensionsContainer.AbstractiveSummaryAsync(
    new AbstractiveSummaryRequest(originalText)
);

var response2 = await defaultAIExtensionsContainer.ExtractiveSummaryAsync(
    new ExtractiveSummaryRequest(originalText)
);

#Translate

TranslateBehavior converts the text from one language to another while maintaining the original meaning and context. Use the Languages parameter to specify target languages/cultures for text translation.

The following code snippet registers a TranslateBehavior and assigns it to a MemoEdit control:

using DevExpress.AIIntegration;
using DevExpress.AIIntegration.WinForms;
using DevExpress.AIIntegration.Desktop;

//...
public partial class MemoEdit : DevExpress.XtraEditors.XtraForm {
    public MemoEdit() {
        InitializeComponent();
            behaviorManager1.Attach<TranslateBehavior>(memoEdit1, behavior => {
                behavior.Properties.Languages = new LanguageInfo[] {
                    new LanguageInfo("de-DE"),
                    new LanguageInfo("es-ES")
                };
            });
    }
}

Tip

Use TranslateRequest to manually initiate a request to translate the original text:

C#
var response = await defaultAIExtensionsContainer.TranslateAsync(
    new TranslateRequest(textToTranslate, "Italian")
);

#Ask AI Assistant (Custom Prompt)

CustomRequestBehavior displays the “Ask AI Assistant” item in the context menu. The “Ask AI Assistant” item invokes a dialog that allows users to interact with an AI-powered assistant directly within your application. A user can enter a question or prompt. The AI assistant will process the query and generate an answer.

The user can easily insert the answer directly into a document or text field with a single click. The user can insert the answer above/below the cursor, replace all content or selected text, or copy the answer to the clipboard.

Tip

Use CustomPromptRequest to manually initiate a request to transform the original text based on a custom request:

C#
var response = await defaultAIExtensionsContainer.CustomPromptAsync(
    new CustomPromptRequest("Specify a prompt...", originalText)
);

#Temperature

The Temperature parameter controls the balance between creativity and consistency in AI responses. Lower temperatures yield more predictable and focused outputs, while higher temperatures produce more diverse and creative responses.

The Temperature parameter is predefined for DevExpress AI-powered behaviors.

AI-powered Behavior Temperature (Default)
Summarize Behavior 1
Change Style Behavior 0.6
Change Tone Behavior 0.5
Translate Behavior 0.5
Proofread Behavior 0.2
Expand Behavior
Explain Behavior
Shorten Behavior

#Chunking (Processing Long Input Text)

If input text is too long, the DevExpress control displays a dialog that informs a user that the input text must be divided into manageable chunks to ensure accurate processing.

Warning

The user can process chunks one by one by pressing the “Proceed” button, or enable the “I consent to process all remaining chunks” option to process all chunks automatically.

After processing, chunks are reassembled into a single output.

Tip

Use the ChunkMaxLength property to specify how much text can be processed simultaneously. The chunk length is limited by 6,000 symbols. The TextBufferMaxSize property specifies the maximum size of the input text, in bytes.

See Also