Skip to main content
All docs
V25.1
  • SmartPasteRequest Class

    A Smart Paste request.

    Namespace: DevExpress.AIIntegration.Extensions

    Assembly: DevExpress.AIIntegration.v25.1.dll

    NuGet Package: DevExpress.AIIntegration

    Declaration

    public class SmartPasteRequest :
        BaseRequest

    Remarks

    “Smart Paste” is an AI-powered feature that analyzes the source content (Data) and intelligently assigns the right values to the appropriate items in Items based on their Value and Description.

    The following example registers an Azure OpenAI client to use the AI-powered Smart Paste extension to analyze the rawData and intelligently assign the right values to the appropriate items:

    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 rawData = "The 42 DevAV LED TV is changing the way people watch TV. It delivers crystal-clear images with mind-blowing video. Product Dimensions 42x28x10, Product Weight 70 lbs";
    var response = await defaultAIExtensionsContainer.SmartPasteAsync(
        new SmartPasteRequest(rawData, new List<SmartPasteRequest.ItemInfo>() {
            new SmartPasteRequest.ItemInfo("product", "Product Name"),
            new SmartPasteRequest.ItemInfo("weight", "Weight")
        })
    );
    
    foreach (SmartPasteResponse.ItemInfo info in response.Values)
        Console.WriteLine(string.Format("{0}: {1}", info.Id, info.Value));
    
    /* Output:
     * product: 42 DevAV LED TV
     * weight: 70 lbs
     */
    
    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});
    }
    

    Smart Paste from Image

    The following example registers an Azure OpenAI client to use the AI-powered Smart Paste extension to analyze an image (dataContent) and intelligently assign the right values to the appropriate items:

    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 filePath = @"C:\Media\example.png";
    
    byte[] dataContent = File.ReadAllBytes(filePath);
    
    var response = await defaultAIExtensionsContainer.SmartPasteAsync(
        new SmartPasteRequest(string.Empty, new List<SmartPasteRequest.ItemInfo>() {
            new SmartPasteRequest.ItemInfo("product", "Product Name"),
            new SmartPasteRequest.ItemInfo("price", "Price")
        }, dataContent, "image/png")
    );
    
    foreach (SmartPasteResponse.ItemInfo info in response.Values)
        Console.WriteLine(string.Format("{0}: {1}", info.Id, info.Value));
    
    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}");
    }
    

    Inheritance

    Object
    DevExpress.AIIntegration.Extensions.BaseRequest
    SmartPasteRequest
    See Also