Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions docs/ai/microsoft-extensions-ai.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ The following subsections show specific [`IChatClient`](#the-ichatclient-interfa
- [Custom `IChatClient` middleware](#custom-ichatclient-middleware)
- [Dependency injection](#dependency-injection)
- [Stateless vs. stateful clients](#stateless-vs-stateful-clients)
- [Chat reduction (experimental)](#chat-reduction-experimental)
- [Tool reduction (experimental)](#tool-reduction-experimental)

The following sections show specific [`IEmbeddingGenerator`](#the-iembeddinggenerator-interface) usage examples:

Expand Down Expand Up @@ -198,6 +200,20 @@ If you don't know ahead of time whether the service is stateless or stateful, yo

:::code language="csharp" source="snippets/microsoft-extensions-ai/ConsoleAI.StatelessStateful/Program.cs" id="Snippet4":::

#### Chat reduction (experimental)

> [!IMPORTANT]
> This feature is experimental and subject to change.

Chat reduction helps manage conversation history by limiting the number of messages or summarizing older messages when the conversation exceeds a specified length. The `Microsoft.Extensions.AI` library provides reducers like <xref:Microsoft.Extensions.AI.MessageCountingChatReducer> that limits the number of non-system messages, and <xref:Microsoft.Extensions.AI.SummarizingChatReducer> that automatically summarizes older messages while preserving context.

#### Tool reduction (experimental)

> [!IMPORTANT]
> This feature is experimental and subject to change.

Tool reduction helps manage large tool catalogs by trimming them based on relevance to the current conversation context. The <xref:Microsoft.Extensions.AI.IToolReductionStrategy> interface defines strategies for reducing the number of tools sent to the model. The library provides implementations like <xref:Microsoft.Extensions.AI.EmbeddingToolReductionStrategy> that ranks tools by embedding similarity to the conversation. Use the <xref:Microsoft.Extensions.AI.ChatClientBuilderToolReductionExtensions.UseToolReduction*> extension method to add tool reduction to your chat client pipeline.

### The `IEmbeddingGenerator` interface

The <xref:Microsoft.Extensions.AI.IEmbeddingGenerator`2> interface represents a generic generator of embeddings. For the generic type parameters, `TInput` is the type of input values being embedded, and `TEmbedding` is the type of generated embedding, which inherits from the <xref:Microsoft.Extensions.AI.Embedding> class.
Expand Down