corelibraries-devexpress-dot-aiintegration-dot-aiintegration-dot-changestyleasync-x28-iaiextensionscontainer-changestylerequest-cancellationtoken-x29.md
Rephrases or paraphrases the text while retaining its original meaning.
Namespace : DevExpress.AIIntegration
Assembly : DevExpress.AIIntegration.v25.2.dll
NuGet Package : DevExpress.AIIntegration
public static Task<TextResponse> ChangeStyleAsync(
this IAIExtensionsContainer container,
ChangeStyleRequest request,
CancellationToken cancellationToken = default(CancellationToken)
)
<ExtensionAttribute>
Public Shared Function ChangeStyleAsync(
container As IAIExtensionsContainer,
request As ChangeStyleRequest,
cancellationToken As CancellationToken = Nothing
) As Task(Of TextResponse)
| Name | Type | Description |
|---|---|---|
| container | IAIExtensionsContainer |
The AI extensions container.
| | request | ChangeStyleRequest |
The request to rephrase or paraphrase the text while retaining its original meaning.
|
| Name | Type | Default | Description |
|---|---|---|---|
| cancellationToken | CancellationToken | null |
The token that cancels the task.
|
| Type | Description |
|---|---|
| Task<TextResponse> |
The response that contains AI-generated text.
|
The following example registers an Azure OpenAI client and uses the AI-powered extension to change the writing style of originalText:
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 = "DevExpress released Universal v24.2 - the award-winning software development platform for .NET and Visual Studio developers.";
var response = await defaultAIExtensionsContainer.ChangeStyleAsync(
new ChangeStyleRequest(originalText, WritingStyle.Academic)
);
Console.WriteLine(response);
/* Output:
* DevExpress has announced the release of Universal v24.2, an acclaimed software development platform
* designed specifically for .NET and Visual Studio developers.
*/
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