SemanticSearchBehavior Class
Enables AI-driven semantic search in GridControl, GridLookUpEdit, and SearchLookUpEdit controls.
Namespace: DevExpress.AIIntegration.WinForms
Assembly: DevExpress.AIIntegration.WinForms.SemanticSearch.v25.1.dll
NuGet Package: DevExpress.AIIntegration.WinForms.SemanticSearch
Declaration
public sealed class SemanticSearchBehavior :
BehaviorWithEvents<ISemanticSearchBehaviorSource>,
ISemanticSearchCaller
Remarks
Warning
This help topic describes v25.1.3
(RTM), which includes the updated and improved semantic search API. If you are using the BETA version (v25.1.2
), the API differs. See our demo project for details on how to activate and configure semantic search in BETA.
- Drop the
BehaviorManager
component from the Toolbox onto a Form. - Add a
SemanticSearchBehavior
and attach it to a DevExpress UI control (GridControl, GridLookUpEdit, or SearchLookUpEdit). Configure behavior settings:
Property Name Description DataSourceKeyField Gets or sets the key field in the data source that uniquely identifies records. VectorCollectionName Gets or sets the name of the collection with embeddings in the vector store. ScoreThreshold Gets or sets the similarity score threshold at which search results are considered relevant. ScoreThresholdFilter Controls how the ScoreThreshold is applied during filtering. SearchMode Gets or sets a control’s search mode. SearchResultCount Gets or sets the maximum number of semantic search results returned by a vector store for a query. EmbeddingGeneratorName Gets or sets the embedding generator name. Set this property if you registered multiple embedding generators in the AI container.
The following code snippet activates semantic search for a GridLookUpEdit
:
public Form1() {
InitializeComponent();
gridLookUpEdit1.Properties.DataSource = DataHelper.Items;
gridLookUpEdit1.Properties.DisplayMember = "Model";
gridLookUpEdit1.Properties.ValueMember = "Id";
behaviorManager1.Attach<SemanticSearchBehavior>(gridLookUpEdit1.Properties.View, behavior => {
behavior.Properties.VectorCollectionName = "Cars";
behavior.Properties.DataSourceKeyField = "Id";
behavior.Properties.SearchResultCount = 10;
behavior.Properties.SearchMode = ControlSearchMode.Semantic;
// It is implied, that Cosine Distance filtering is used for the vector store.
// Lower = more similar
behavior.Properties.ScoreThreshold = 0.5D;
behavior.Properties.ScoreThresholdFilter = ScoreThresholdFilter.LessOrEqual;
});
}
Note
Call the BehaviorInitializer.Initialize()
method at application startup if your project targets the .NET Framework and you create AI-powered behaviors in code. Otherwise, an exception is thrown.
internal static class Program {
[STAThread]
static void Main() {
//...
// The Initialize() method forcibly initializes the behavior manager in .NET Framework apps.
DevExpress.AIIntegration.WinForms.BehaviorInitializer.Initialize();
Application.Run(new Form1());
}
}
See the following help topic for additional information: Semantic Search.