Share via


EmbeddingToolReductionStrategy Class

Definition

A tool reduction strategy that ranks tools by embedding similarity to the current conversation context.

public ref class EmbeddingToolReductionStrategy sealed : Microsoft::Extensions::AI::IToolReductionStrategy
[System.Diagnostics.CodeAnalysis.Experimental("MEAI001")]
public sealed class EmbeddingToolReductionStrategy : Microsoft.Extensions.AI.IToolReductionStrategy
public sealed class EmbeddingToolReductionStrategy : Microsoft.Extensions.AI.IToolReductionStrategy
[<System.Diagnostics.CodeAnalysis.Experimental("MEAI001")>]
type EmbeddingToolReductionStrategy = class
    interface IToolReductionStrategy
type EmbeddingToolReductionStrategy = class
    interface IToolReductionStrategy
Public NotInheritable Class EmbeddingToolReductionStrategy
Implements IToolReductionStrategy
Inheritance
EmbeddingToolReductionStrategy
Attributes
Implements

Remarks

The strategy embeds each tool (name + description by default) once (cached) and embeds the current conversation content each request. It then selects the top toolLimit tools by similarity.

Constructors

Name Description
EmbeddingToolReductionStrategy(IEmbeddingGenerator<String,Embedding<Single>>, Int32)

Initializes a new instance of the EmbeddingToolReductionStrategy class.

Properties

Name Description
IsRequiredTool

Gets or sets a function that determines whether a tool is required (always included).

MessagesEmbeddingTextSelector

Gets or sets the selector used to generate a single text string from a collection of chat messages for embedding purposes.

PreserveOriginalOrdering

Gets or sets a value indicating whether to preserve original ordering of selected tools. If false (default), tools are ordered by descending similarity. If true, the top-N tools by similarity are re-emitted in their original order.

Similarity

Gets or sets a similarity function applied to (query, tool) embedding vectors.

ToolEmbeddingTextSelector

Gets or sets the selector used to generate a single text string from a tool.

Methods

Name Description
SelectToolsForRequestAsync(IEnumerable<ChatMessage>, ChatOptions, CancellationToken)

Selects the tools that should be included for a specific request.

Applies to