Back to Devexpress

SmartPasteRequest.DataContent Property

corelibraries-devexpress-dot-aiintegration-dot-extensions-dot-smartpasterequest-7fad755d.md

latest3.2 KB
Original Source

SmartPasteRequest.DataContent Property

Gets or sets the binary content to analyze.

Namespace : DevExpress.AIIntegration.Extensions

Assembly : DevExpress.AIIntegration.v25.2.dll

NuGet Package : DevExpress.AIIntegration

Declaration

csharp
public byte[] DataContent { get; set; }
vb
Public Property DataContent As Byte()

Property Value

TypeDescription
Byte[]

The binary content to analyze.

|

Remarks

Use the DataContent property to pass binary data (for example, an image) to Smart Paste for analysis. The AI engine processes the content based on the format specified in the MediaType property.

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:

csharp
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}");
}

See Also

MediaType

SmartPasteRequest Class

SmartPasteRequest Members

DevExpress.AIIntegration.Extensions Namespace