Interface MemoryStore
-
public interface MemoryStoreAn interface for storing and retrieving indexedMemoryRecordobjects in a data store.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceMemoryStore.Builder
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description reactor.core.publisher.Mono<Void>createCollectionAsync(String collectionName)Creates a new collection in the data store.reactor.core.publisher.Mono<Void>deleteCollectionAsync(String collectionName)Deletes a collection from the data store.reactor.core.publisher.Mono<Boolean>doesCollectionExistAsync(String collectionName)Determines if a collection exists in the data store.reactor.core.publisher.Mono<MemoryRecord>getAsync(String collectionName, String key, boolean withEmbedding)Gets a memory record from the data store.reactor.core.publisher.Mono<Collection<MemoryRecord>>getBatchAsync(String collectionName, Collection<String> keys, boolean withEmbeddings)Gets a batch of memory records from the data store.reactor.core.publisher.Mono<List<String>>getCollectionsAsync()Gets all collection names in the data store.reactor.core.publisher.Mono<reactor.util.function.Tuple2<MemoryRecord,? extends Number>>getNearestMatchAsync(String collectionName, Embedding<? extends Number> embedding, double minRelevanceScore, boolean withEmbedding)Gets the nearest match to theEmbeddingof typeFloat.reactor.core.publisher.Mono<Collection<reactor.util.function.Tuple2<MemoryRecord,Number>>>getNearestMatchesAsync(String collectionName, Embedding<? extends Number> embedding, int limit, double minRelevanceScore, boolean withEmbeddings)Gets the nearest matches to theEmbeddingof typeFloat.reactor.core.publisher.Mono<Void>removeAsync(String collectionName, String key)Removes a memory record from the data store.reactor.core.publisher.Mono<Void>removeBatchAsync(String collectionName, Collection<String> keys)Removes a batch of memory records from the data store.reactor.core.publisher.Mono<String>upsertAsync(String collectionName, MemoryRecord record)Upserts a memory record into the data store.reactor.core.publisher.Mono<Collection<String>>upsertBatchAsync(String collectionName, Collection<MemoryRecord> records)Upserts a group of memory records into the data store.
-
-
-
Method Detail
-
createCollectionAsync
reactor.core.publisher.Mono<Void> createCollectionAsync(@Nonnull String collectionName)
Creates a new collection in the data store.- Parameters:
collectionName- The name associated with a collection of embeddings- Returns:
- A future that completes when the collection is created.
-
getCollectionsAsync
reactor.core.publisher.Mono<List<String>> getCollectionsAsync()
Gets all collection names in the data store.- Returns:
- An unmodifiable group of collection names.
-
doesCollectionExistAsync
reactor.core.publisher.Mono<Boolean> doesCollectionExistAsync(@Nonnull String collectionName)
Determines if a collection exists in the data store.- Parameters:
collectionName- The name associated with a collection of embeddings.- Returns:
- A future that completes with a boolean indicating whether the collection exists.
-
deleteCollectionAsync
reactor.core.publisher.Mono<Void> deleteCollectionAsync(@Nonnull String collectionName)
Deletes a collection from the data store.- Parameters:
collectionName- The name associated with a collection of embeddings.- Returns:
- A future that completes when the collection is deleted.
-
upsertAsync
reactor.core.publisher.Mono<String> upsertAsync(@Nonnull String collectionName, @Nonnull MemoryRecord record)
Upserts a memory record into the data store. Does not guarantee that the collection exists. If the record already exists, it will be updated. If the record does not exist, it will be created.- Parameters:
collectionName- The name associated with a collection of embeddings.record- The memory record to upsert.- Returns:
- The unique identifier for the memory record.
-
upsertBatchAsync
reactor.core.publisher.Mono<Collection<String>> upsertBatchAsync(@Nonnull String collectionName, @Nonnull Collection<MemoryRecord> records)
Upserts a group of memory records into the data store. Does not guarantee that the collection exists. If the record already exists, it will be updated. If the record does not exist, it will be created.- Parameters:
collectionName- The name associated with a collection of vectors.records- The memory records to upsert.- Returns:
- The unique identifiers for the memory records.
-
getAsync
reactor.core.publisher.Mono<MemoryRecord> getAsync(@Nonnull String collectionName, @Nonnull String key, boolean withEmbedding)
Gets a memory record from the data store. Does not guarantee that the collection exists.- Parameters:
collectionName- The name associated with a collection of embeddings.key- The unique id associated with the memory record to get.withEmbedding- If true, the embedding will be returned in the memory record.- Returns:
- The memory record if found, otherwise null.
-
getBatchAsync
reactor.core.publisher.Mono<Collection<MemoryRecord>> getBatchAsync(@Nonnull String collectionName, @Nonnull Collection<String> keys, boolean withEmbeddings)
Gets a batch of memory records from the data store. Does not guarantee that the collection exists.- Parameters:
collectionName- The name associated with a collection of embedding.keys- The unique ids associated with the memory record to get.withEmbeddings- If true, the embeddings will be returned in the memory records.- Returns:
- The memory records associated with the unique keys provided.
-
removeAsync
reactor.core.publisher.Mono<Void> removeAsync(@Nonnull String collectionName, @Nonnull String key)
Removes a memory record from the data store. Does not guarantee that the collection exists.- Parameters:
collectionName- The name associated with a collection of embeddings.key- The unique id associated with the memory record to remove.- Returns:
- A
Monothat completes when the operation is done.
-
removeBatchAsync
reactor.core.publisher.Mono<Void> removeBatchAsync(@Nonnull String collectionName, @Nonnull Collection<String> keys)
Removes a batch of memory records from the data store. Does not guarantee that the collection exists.- Parameters:
collectionName- The name associated with a collection of embeddings.keys- The unique ids associated with the memory record to remove.- Returns:
- A
Monothat completes when the operation is done.
-
getNearestMatchesAsync
reactor.core.publisher.Mono<Collection<reactor.util.function.Tuple2<MemoryRecord,Number>>> getNearestMatchesAsync(@Nonnull String collectionName, @Nonnull Embedding<? extends Number> embedding, int limit, double minRelevanceScore, boolean withEmbeddings)
Gets the nearest matches to theEmbeddingof typeFloat. Does not guarantee that the collection exists.- Parameters:
collectionName- The name associated with a collection of embeddings.embedding- TheEmbeddingto compare the collection's embeddings with.limit- The maximum number of similarity results to return.minRelevanceScore- The minimum relevance threshold for returned results.withEmbeddings- If true, the embeddings will be returned in the memory records.- Returns:
- A collection of tuples where item1 is a
MemoryRecordand item2 is its similarity score as adouble.
-
getNearestMatchAsync
reactor.core.publisher.Mono<reactor.util.function.Tuple2<MemoryRecord,? extends Number>> getNearestMatchAsync(@Nonnull String collectionName, @Nonnull Embedding<? extends Number> embedding, double minRelevanceScore, boolean withEmbedding)
Gets the nearest match to theEmbeddingof typeFloat. Does not guarantee that the collection exists.- Parameters:
collectionName- The name associated with a collection of embeddings.embedding- TheEmbeddingto compare the collection's embeddings with.minRelevanceScore- The minimum relevance threshold for returned results.withEmbedding- If true, the embedding will be returned in the memory record.- Returns:
- A tuple consisting of the
MemoryRecordand item2 is its similarity score as adouble. Null if no nearest match found.
-
-