CachingEmbeddingGenerator class abstract

An abstract DelegatingEmbeddingGenerator that caches embeddings for individual input values.

Each input value is cached separately, so a request is forwarded to the inner generator only for the values that are not already cached. Subclasses provide the actual caching mechanism by implementing getCachedEmbedding and setCachedEmbedding.

Inheritance
Implementers
Available extensions

Constructors

CachingEmbeddingGenerator(EmbeddingGenerator innerGenerator)
Creates a new CachingEmbeddingGenerator.

Properties

hashCode int
The hash code for this object.
no setterinherited
innerGenerator EmbeddingGenerator
The inner generator to delegate to.
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

asBuilder() EmbeddingGeneratorBuilder

Available on EmbeddingGenerator, provided by the EmbeddingGeneratorBuilderEmbeddingGeneratorExtensions extension

Creates a new EmbeddingGeneratorBuilder using this generator as its inner generator.
dispose() → void
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
inherited
generateEmbeddings({required Iterable<String> values, EmbeddingGenerationOptions? options, CancellationToken? cancellationToken}) Future<GeneratedEmbeddings>
Generates embeddings for the given values.
override
getCachedEmbedding(String key) Future<Embedding?>
Retrieves a cached embedding for the given key, or null if not found.
getCacheKey(String value, EmbeddingGenerationOptions? options) String
Gets a cache key for a single input value and options.
getService<T>({Object? key}) → T?
Gets a service of the specified type.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
setCachedEmbedding(String key, Embedding embedding) Future<void>
Stores an embedding in the cache with the given key.
toString() String
A string representation of this object.
inherited

Operators

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