AIIntegration.ExpandAsync(IAIExtensionsContainer, ExpandRequest, CancellationToken) Method
Enriches the text with additional information or in-depth explanations.
Namespace: DevExpress.AIIntegration
Assembly: DevExpress.AIIntegration.v24.2.dll
NuGet Package: DevExpress.AIIntegration
Declaration
public static Task<TextResponse> ExpandAsync(
this IAIExtensionsContainer container,
ExpandRequest request,
CancellationToken cancellationToken = default(CancellationToken)
)
Parameters
Name | Type | Description |
---|---|---|
container | IAIExtensionsContainer | The AI extensions container. |
request | ExpandRequest | The request to enrich the text with additional information or in-depth explanations. |
Optional Parameters
Name | Type | Default | Description |
---|---|---|---|
cancellationToken | CancellationToken | null | The token that cancels the task. |
Returns
Type | Description |
---|---|
Task<TextResponse> | The response that contains AI-generated text. |
Remarks
The following example registers an Azure OpenAI client and uses the AI-powered extension to enrich the originalText
with additional information:
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 AI-powered expand extension enriches your text with additional information or in-depth explanations.";
var response = await defaultAIExtensionsContainer.ExpandAsync(
new ExpandRequest(originalText)
);
Console.WriteLine(response);
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