CompactionProvider class

A AIContextProvider that applies a CompactionStrategy to compact the message list before each agent invocation.

Inheritance

Constructors

CompactionProvider(CompactionStrategy compactionStrategy, {String? stateKey, LoggerFactory? loggerFactory})

Properties

hashCode int
The hash code for this object.
no setterinherited
provideInputMessageFilter Iterable<ChatMessage> Function(Iterable<ChatMessage>)
Filter applied to input messages before providing context.
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
stateKeys List<String>
The keys used to store provider state in the StateBag.
no setteroverride
storeInputRequestMessageFilter Iterable<ChatMessage> Function(Iterable<ChatMessage>)
Filter applied to request messages before storing context.
finalinherited
storeInputResponseMessageFilter Iterable<ChatMessage> Function(Iterable<ChatMessage>)
Filter applied to response messages before storing context.
finalinherited

Methods

getLoggerFactory(AIAgent agent) → LoggerFactory
getService(Type serviceType, {Object? serviceKey}) Object?
Returns a service of the specified serviceType, or null.
inherited
getServiceOf<T extends Object>({Object? serviceKey}) → T?
Returns a service of type T, or null.
inherited
invoked(InvokedContext context, {CancellationToken? cancellationToken}) Future<void>
Called at the end of the agent invocation to process results.
inherited
invokedCore(InvokedContext context, {CancellationToken? cancellationToken}) Future<void>
Core implementation of invoked. Skips processing on failure, applies message filters, then calls storeAIContext.
inherited
invoking(InvokingContext context, {CancellationToken? cancellationToken}) Future<AIContext>
Called at the start of agent invocation to provide additional context.
inherited
invokingCore(InvokingContext context, {CancellationToken? cancellationToken}) Future<AIContext>
Core implementation of invoking. Filters messages, calls provideAIContext, and merges the returned context with the input.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
provideAIContext(InvokingContext context, {CancellationToken? cancellationToken}) Future<AIContext>
When overridden in a derived class, provides additional AI context to be merged with the input context for the current invocation.
inherited
storeAIContext(InvokedContext context, {CancellationToken? cancellationToken}) Future<void>
When overridden in a derived class, processes invocation results.
inherited
toString() String
A string representation of this object.
inherited

Operators

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

Static Methods

compact(CompactionStrategy compactionStrategy, Iterable<ChatMessage> messages, {Logger? logger, CancellationToken? cancellationToken}) Future<Iterable<ChatMessage>>