Back to Devexpress

ChangeToneRequest.Tone Property

corelibraries-devexpress-dot-aiintegration-dot-extensions-dot-changetonerequest.md

latest3.1 KB
Original Source

ChangeToneRequest.Tone Property

Gets or sets a tone style.

Namespace : DevExpress.AIIntegration.Extensions

Assembly : DevExpress.AIIntegration.v25.2.dll

NuGet Package : DevExpress.AIIntegration

Declaration

csharp
public ToneStyle Tone { get; set; }
vb
Public Property Tone As ToneStyle

Property Value

TypeDescription
ToneStyle

The tone style.

|

Available values:

NameDescription
Professional

A formal and polished tone that is suitable for business or official communication.

| | Casual |

A relaxed and informal tone that is used in everyday conversation.

| | Straightforward |

A direct and clear tone for concise communication.

| | Confident |

A tone that exudes certainty and assurance.

| | Friendly |

A warm and pleasant tone. This tone is ideal for personal or customer-oriented communication.

|

Remarks

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

csharp
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 Azure.AI.OpenAI.AzureOpenAIClient(new Uri(azureOpenAIEndpoint),
        new System.ClientModel.ApiKeyCredential(azureOpenAIKey)).GetChatClient("gpt-4o-mini").AsIChatClient();

    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

ChangeToneRequest Class

ChangeToneRequest Members

DevExpress.AIIntegration.Extensions Namespace