Skip to main content
All docs
V24.2

ChangeToneRequest(String, ToneStyle) Constructor

Initializes a new instance of the ChangeToneRequest class with specified settings.

Namespace: DevExpress.AIIntegration.Extensions

Assembly: DevExpress.AIIntegration.v24.2.dll

NuGet Package: DevExpress.AIIntegration

#Declaration

public ChangeToneRequest(
    string text,
    ToneStyle tone
)

#Parameters

Name Type Description
text String

The text to be translated. This value is assigned to the Text property.

tone ToneStyle

The tone style. This value is assigned to the Tone property.

#Remarks

The following example registers an Azure OpenAI client and uses the AI-powered extension to adjust the tone of originalText:

C#
using Azure;
using Azure.AI.OpenAI;
using Microsoft.Extensions.AI;
using DevExpress.AIIntegration;
using DevExpress.AIIntegration.Extensions;

SetEnvironmentVariables();

// Register an Azure OpenAI client
AIExtensionsContainerDefault defaultAIExtensionsContainer = RegisterAzureOpenAIClient(
    Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT"),
    Environment.GetEnvironmentVariable("AZURE_OPENAI_APIKEY")
);

string originalText = "The Adjust Tone AI-powered extension adjusts the tone of the text to meet audience or context requirements.";
var response = await defaultAIExtensionsContainer.ChangeToneAsync(
    new ChangeToneRequest(originalText, ToneStyle.Casual)
);

Console.WriteLine(response);

/* Output:
 * Tone Tweaker is an AI tool that changes the vibe of your text to fit your crowd or situation.
 */

AIExtensionsContainerDefault RegisterAzureOpenAIClient(string azureOpenAIEndpoint, string azureOpenAIKey) {
    IChatClient client = new AzureOpenAIClient(
        new Uri(azureOpenAIEndpoint),
        new AzureKeyCredential(azureOpenAIKey))
            .AsChatClient("gpt-4o-mini");
    return AIExtensionsContainerConsole.CreateDefaultAIExtensionContainer(client);
}

void SetEnvironmentVariables() {
    Environment.SetEnvironmentVariable("AZURE_OPENAI_ENDPOINT", {SPECIFY_YOUR_AZURE_ENDPOINT});
    Environment.SetEnvironmentVariable("AZURE_OPENAI_APIKEY", {SPECIFY_YOU_AZURE_KEY});
}
See Also