Back to Devexpress

ChangeStyleRequest(String, WritingStyle) Constructor

corelibraries-devexpress-dot-aiintegration-dot-extensions-dot-changestylerequest-dot-ctor-x28-system-dot-string-devexpress-dot-aiintegration-dot-extensions-dot-writingstyle-x29.md

latest3.5 KB
Original Source

ChangeStyleRequest(String, WritingStyle) Constructor

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

Namespace : DevExpress.AIIntegration.Extensions

Assembly : DevExpress.AIIntegration.v25.2.dll

NuGet Package : DevExpress.AIIntegration

Declaration

csharp
public ChangeStyleRequest(
    string text,
    WritingStyle style
)
vb
Public Sub New(
    text As String,
    style As WritingStyle
)

Parameters

NameTypeDescription
textString

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

| | style | WritingStyle |

The writing style that determines the tone and structure of text. This value is assigned to the Style property.

|

Remarks

The following example registers an Azure OpenAI client and uses the AI-powered extension to change the writing style 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 = "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

ChangeStyleRequest Class

ChangeStyleRequest Members

DevExpress.AIIntegration.Extensions Namespace