SemanticRoutingChatClient Constructor
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Initializes a new instance of the SemanticRoutingChatClient class.
public SemanticRoutingChatClient(Microsoft.Extensions.AI.IEmbeddingGenerator<string,Microsoft.Extensions.AI.Embedding<float>> embeddingGenerator, System.Collections.Generic.IReadOnlyDictionary<Microsoft.Extensions.AI.IChatClient,System.Collections.Generic.IReadOnlyList<string>> clientProfiles, Microsoft.Extensions.AI.IChatClient defaultClient, float scoreThreshold = 0.3, int topK = 1, Microsoft.Extensions.AI.SemanticRoutingChatClient.ScoreAggregation scoreAggregation = Microsoft.Extensions.AI.SemanticRoutingChatClient+ScoreAggregation.Mean, bool leaveOpen = false);
new Microsoft.Extensions.AI.SemanticRoutingChatClient : Microsoft.Extensions.AI.IEmbeddingGenerator<string, Microsoft.Extensions.AI.Embedding<single>> * System.Collections.Generic.IReadOnlyDictionary<Microsoft.Extensions.AI.IChatClient, System.Collections.Generic.IReadOnlyList<string>> * Microsoft.Extensions.AI.IChatClient * single * int * Microsoft.Extensions.AI.SemanticRoutingChatClient.ScoreAggregation * bool -> Microsoft.Extensions.AI.SemanticRoutingChatClient
Public Sub New (embeddingGenerator As IEmbeddingGenerator(Of String, Embedding(Of Single)), clientProfiles As IReadOnlyDictionary(Of IChatClient, IReadOnlyList(Of String)), defaultClient As IChatClient, Optional scoreThreshold As Single = 0.3, Optional topK As Integer = 1, Optional scoreAggregation As SemanticRoutingChatClient.ScoreAggregation = Microsoft.Extensions.AI.SemanticRoutingChatClient+ScoreAggregation.Mean, Optional leaveOpen As Boolean = false)
Parameters
- embeddingGenerator
- IEmbeddingGenerator<String,Embedding<Single>>
The generator used to embed profile utterances and request text.
- clientProfiles
- IReadOnlyDictionary<IChatClient,IReadOnlyList<String>>
The example utterances associated with each client.
- defaultClient
- IChatClient
The client selected when no profile satisfies scoreThreshold.
- scoreThreshold
- Single
The minimum aggregated score required to select a profiled client.
- topK
- Int32
The number of highest-scoring profile utterances, across all clients, whose scores are aggregated.
The default is 1.
- scoreAggregation
- SemanticRoutingChatClient.ScoreAggregation
The method used to aggregate matching profile scores for each client.
- leaveOpen
- Boolean
true to leave the configured clients and embedding generator open when this instance is
disposed; otherwise, false. The default is false.
Exceptions
embeddingGenerator, clientProfiles, or
defaultClient is null.
clientProfiles is empty or contains a null client, an empty utterance list, or a blank
utterance.
topK is not positive, scoreAggregation is invalid, or
scoreThreshold is outside the possible range for the configured aggregation.