Skip to main content
All docs
V25.1
  • ExplainRequest(String) Constructor

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

    Namespace: DevExpress.AIIntegration.Extensions

    Assembly: DevExpress.AIIntegration.v25.1.dll

    NuGet Package: DevExpress.AIIntegration

    Declaration

    public ExplainRequest(
        string text
    )

    Parameters

    Name Type Description
    text String

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

    Remarks

    The following example registers an Azure OpenAI client and uses the AI-powered extension to explain 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 = "Stochastic gradient descent, a variant of gradient descent, updates parameters based on individual training examples.";
    var response = await defaultAIExtensionsContainer.ExplainAsync(
        new ExplainRequest(originalText)
    );
    
    Console.WriteLine(response);
    
    /* Output:
     * Stochastic gradient descent is a method used in machine learning to adjust parameters of a model.
     * It's similar to another method called gradient descent. The main difference is that stochastic gradient
     * descent updates the parameters of the model after looking at each individual training example, one at a time,
     * instead of using the entire dataset at once.
     * 
     * For example, imagine you are trying to teach a robot to recognize apples. In stochastic gradient descent,
     * you would show the robot one apple picture at a time, update its understanding based on that single picture,
     * then move to the next one. In contrast, traditional gradient descent would look at all of the pictures of apples
     * together before making any updates.
     */
    
    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