Interface MemoryStore

  • All Superinterfaces:
    Buildable

    public interface MemoryStore
    extends Buildable
    An interface for storing and retrieving indexed MemoryRecord objects in a 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 Mono that 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 Mono that completes when the operation is done.
      • getNearestMatchesAsync

        reactor.core.publisher.Mono<Collection<reactor.util.function.Tuple2<MemoryRecord,​Float>>> getNearestMatchesAsync​(@Nonnull
                                                                                                                               String collectionName,
                                                                                                                               @Nonnull
                                                                                                                               Embedding embedding,
                                                                                                                               int limit,
                                                                                                                               float minRelevanceScore,
                                                                                                                               boolean withEmbeddings)
        Gets the nearest matches to the Embedding of type Float. Does not guarantee that the collection exists.
        Parameters:
        collectionName - The name associated with a collection of embeddings.
        embedding - The Embedding to 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 MemoryRecord and item2 is its similarity score as a Float.
      • getNearestMatchAsync

        reactor.core.publisher.Mono<reactor.util.function.Tuple2<MemoryRecord,​Float>> getNearestMatchAsync​(@Nonnull
                                                                                                                 String collectionName,
                                                                                                                 @Nonnull
                                                                                                                 Embedding embedding,
                                                                                                                 float minRelevanceScore,
                                                                                                                 boolean withEmbedding)
        Gets the nearest match to the Embedding of type Float. Does not guarantee that the collection exists.
        Parameters:
        collectionName - The name associated with a collection of embeddings.
        embedding - The Embedding to 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 MemoryRecord and item2 is its similarity score as a float. Null if no nearest match found.