java.lang.Object
org.nasdanika.ai.CachingEmbeddingGenerator<S,E,K>
org.nasdanika.ai.MapCachingEmbeddingGenerator<S,E,K>
- All Implemented Interfaces:
EmbeddingGenerator<S,,E> Composable<EmbeddingGenerator<S,E>>
- Direct Known Subclasses:
CachingImageEmbeddingGenerator,CachingTextEmbeddingGenerator
Caches image embeddings in a map which can be loaded and saved between runs
Uses image digest as caching key
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.nasdanika.ai.EmbeddingGenerator
EmbeddingGenerator.Requirement -
Field Summary
FieldsFields inherited from class org.nasdanika.ai.CachingEmbeddingGenerator
target -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedMapCachingEmbeddingGenerator(EmbeddingGenerator<S, E> target, Map<K, E> cache) -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract KcomputeKey(S source) Computes caching key from source.static <S,E, K> MapCachingEmbeddingGenerator <S, E, K> create(EmbeddingGenerator<S, E> target, Map<K, E> cache, Function<S, K> keyComputer) Creates an instance which uses the provided key computer.protected Eprotected voidMethods inherited from class org.nasdanika.ai.CachingEmbeddingGenerator
generateAsyncMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.nasdanika.ai.EmbeddingGenerator
adapt, compose, compose, composeAsync, generate, generateAsync, then
-
Field Details
-
cache
-
-
Constructor Details
-
MapCachingEmbeddingGenerator
-
-
Method Details
-
computeKey
Computes caching key from source.- Specified by:
computeKeyin classCachingEmbeddingGenerator<S,E, K> - Parameters:
source-- Returns:
-
create
public static <S,E, MapCachingEmbeddingGenerator<S,K> E, createK> (EmbeddingGenerator<S, E> target, Map<K, E> cache, Function<S, K> keyComputer) Creates an instance which uses the provided key computer.- Type Parameters:
S-E-K-- Parameters:
target-cache-keyComputer-- Returns:
-
get
- Specified by:
getin classCachingEmbeddingGenerator<S,E, K>
-
put
- Specified by:
putin classCachingEmbeddingGenerator<S,E, K>
-
generate
-