SummarizingChatReducer class

A ChatReducer that summarizes older messages using a ChatClient.

When the message count exceeds maxMessageCount, older messages are summarized into a single system message while preserving the most recent messages.

This is an experimental feature.

Inheritance

Constructors

SummarizingChatReducer({required ChatClient chatClient, int maxMessageCount = 20, String summarizationPrompt = 'Summarize the conversation so far in a concise paragraph.'})
Creates a new SummarizingChatReducer.

Properties

chatClient ChatClient
The chat client used to generate summaries.
final
hashCode int
The hash code for this object.
no setterinherited
maxMessageCount int
The maximum number of messages before summarization is triggered.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
summarizationPrompt String
The prompt used to request a summary from the model.
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
reduce(List<ChatMessage> messages, {CancellationToken? cancellationToken}) Future<List<ChatMessage>>
Reduces the given messages.
override
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited