Partager via


ChatHistorySummarizationReducer Class

Definition

Reduce the chat history by summarizing message past the target message count.

public class ChatHistorySummarizationReducer : Microsoft.SemanticKernel.Agents.History.IChatHistoryReducer
type ChatHistorySummarizationReducer = class
    interface IChatHistoryReducer
Public Class ChatHistorySummarizationReducer
Implements IChatHistoryReducer
Inheritance
ChatHistorySummarizationReducer
Implements

Remarks

Summarization will always avoid orphaning function-content as the presence of a function-call _must_ be followed by a function-result. When a threshold count is is provided (recommended), reduction will scan within the threshold window in an attempt to avoid orphaning a user message from an assistant response.

Constructors

ChatHistorySummarizationReducer(IChatCompletionService, Int32, Nullable<Int32>)

Initializes a new instance of the ChatHistorySummarizationReducer class.

Fields

DefaultSummarizationPrompt

The default summarization system instructions.

SummaryMetadataKey

Metadata key to indicate a summary message.

Properties

FailOnError

Flag to indicate if an exception should be thrown if summarization fails.

SummarizationInstructions

System instructions for summarization. Defaults to DefaultSummarizationPrompt.

UseSingleSummary

Flag to indicate summarization is maintained in a single message, or if a series of summations are generated over time.

Methods

Equals(Object)

Each reducer shall override equality evaluation so that different reducers of the same configuration can be evaluated for equivalency.

GetHashCode()

Each reducer shall implement custom hash-code generation so that different reducers of the same configuration can be evaluated for equivalency.

ReduceAsync(IReadOnlyList<ChatMessageContent>, CancellationToken)

Optionally reduces the chat history.

Applies to