Partager via


ChatHistoryTruncationReducer Class

Definition

Truncate the chat history to the target message count.

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

Remarks

Truncation 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

ChatHistoryTruncationReducer(Int32, Nullable<Int32>)

Initializes a new instance of the ChatHistoryTruncationReducer class.

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