corelibraries-devexpress-dot-aiintegration-dot-extensions-f0593bf4.md
An AI-powered extension that offers a more powerful and user-friendly search experience.
Namespace : DevExpress.AIIntegration.Extensions
Assembly : DevExpress.AIIntegration.v25.2.dll
NuGet Package : DevExpress.AIIntegration
public class SmartSearchAIExtension :
ChatAIExtensionBase<SmartSearchRequest, SmartSearchResponse>
Public Class SmartSearchAIExtension
Inherits ChatAIExtensionBase(Of SmartSearchRequest, SmartSearchResponse)
“Smart Search” works alongside traditional search algorithms to offer a more powerful and user-friendly search experience. It filters Items to offer results that are more aligned with what the user is seeking, even if the search query (SearchText) contains misspellings.
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 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});
}
Read the following help topics for additional information:
Tip
Smart Search AI-poweredExtension for WinForms Ribbon and Accordion Controls
Object DevExpress.AIIntegration.Extensions.AIExtensionBase<SmartSearchRequest, SmartSearchResponse> DevExpress.AIIntegration.Extensions.ChatAIExtensionBase<SmartSearchRequest, SmartSearchResponse> SmartSearchAIExtension
See Also