Share via


SummarizingChatReducer Class

Definition

Provides functionality to reduce a collection of chat messages into a summarized form.

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

Remarks

This reducer is useful for scenarios where it is necessary to constrain the size of a chat history, such as when preparing input for models with context length limits. The reducer automatically summarizes older messages when the conversation exceeds a specified length, preserving context while reducing message count. The reducer maintains system messages and excludes messages containing function call or function result content from summarization.

Constructors

Name Description
SummarizingChatReducer(IChatClient, Int32, Nullable<Int32>)

Initializes a new instance of the SummarizingChatReducer class with the specified chat client, target count, and optional threshold count.

Properties

Name Description
SummarizationPrompt

Gets or sets the prompt text used for summarization.

Methods

Name Description
ReduceAsync(IEnumerable<ChatMessage>, CancellationToken)

Reduces the size of a list of chat messages.

Applies to