Skip to main content
All docs
V24.2

ItemInfo(String, String, String) Constructor

Initializes a new instance of the SmartSearchRequest.ItemInfo class with specified settings.

Namespace: DevExpress.AIIntegration.Extensions

Assembly: DevExpress.AIIntegration.v24.2.dll

NuGet Package: DevExpress.AIIntegration

Declaration

public ItemInfo(
    string Id,
    string Value,
    string Description = null
)

Parameters

Name Type Description
Id String

The item’s unique identifier. This value is assigned to the Id property.

Value String

The value or content associated with the item. This value is assigned to the Value property.

Optional Parameters

Name Type Default Description
Description String null

A string that describes the expected content and/or data format for the item. This value is assigned to the Description property.

Remarks

The following example registers an Azure OpenAI client and uses the Smart Search AI-powered extension to filter items based on the searchQuery:

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 searchQuery = "furniture";
var response = await defaultAIExtensionsContainer.SmartSearchAsync(
    new SmartSearchRequest(searchQuery, new List<SmartSearchRequest.ItemInfo>() {
        new SmartSearchRequest.ItemInfo("item1", "chair"),
        new SmartSearchRequest.ItemInfo("item2", "sofa"),
        new SmartSearchRequest.ItemInfo("item3", "knife"),
        new SmartSearchRequest.ItemInfo("item4", "clock"),
        new SmartSearchRequest.ItemInfo("item5", "bed"),
    })
);

foreach (SmartSearchResponse.ItemInfo info in response.Values)
    Console.WriteLine(string.Format("{0}: {1}", info.Id, info.Value));

/* Output:
 * item1: chair
 * item2: sofa
 * item5: bed
 */

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