langchain.js
    Preparing search index...

    A vector store that uses the Momento Vector Index.

    To sign up for a free Momento account, visit https://console.gomomento.com.

    Hierarchy (View Summary)

    Index

    Constructors

    • Creates a new MomentoVectorIndex instance.

      Parameters

      • embeddings: EmbeddingsInterface

        The embeddings instance to use to generate embeddings from documents.

      • args: MomentoVectorIndexLibArgs

        The arguments to use to configure the vector store.

      Returns MomentoVectorIndex

    Methods

    • Returns string

    • Adds vectors to the index. Generates embeddings from the documents using the Embeddings instance passed to the constructor.

      Parameters

      • documents: Document[]

        Array of Document instances to be added to the index.

      • OptionaldocumentProps: DocumentProps

      Returns Promise<void>

      Promise that resolves when the documents have been added to the index.

    • Adds vectors to the index.

      Parameters

      • vectors: number[][]

        The vectors to add to the index.

      • documents: Document<Record<string, any>>[]

        The documents to add to the index.

      • OptionaldocumentProps: DocumentProps

        The properties of the documents to add to the index, specifically the ids.

      Returns Promise<void | string[]>

      Promise that resolves when the vectors have been added to the index. Also returns the ids of the documents that were added.

      If the index does not already exist, it will be created if ensureIndexExists is true.

    • Deletes vectors from the index by id.

      Parameters

      • params: DeleteProps

        The parameters to use to delete the vectors, specifically the ids.

      Returns Promise<void>

    • Returns the Momento Vector Index client.

      Returns IVectorIndexClient

      The Momento Vector Index client.

    • Return documents selected using the maximal marginal relevance. Maximal marginal relevance optimizes for similarity to the query AND diversity among selected documents.

      Parameters

      • query: string

        Text to look up documents similar to.

      • options: MaxMarginalRelevanceSearchOptions<this["FilterType"]>
        • k

          Number of documents to return.

        • fetchK

          Number of documents to fetch before passing to the MMR algorithm.

        • lambda

          Number between 0 and 1 that determines the degree of diversity among the results, where 0 corresponds to maximum diversity and 1 to minimum diversity.

        • filter

          Optional filter

      Returns Promise<Document[]>

      • List of documents selected by maximal marginal relevance.
    • Searches the index for the most similar vectors to the query vector.

      Parameters

      • query: number[]

        The query vector.

      • k: number

        The number of results to return.

      Returns Promise<[Document<Record<string, any>>, number][]>

      Promise that resolves to the documents of the most similar vectors to the query vector.

    • Stores the documents in the index.

      Parameters

      • docs: Document[]

        The documents to store in the index.

      • embeddings: EmbeddingsInterface

        The embeddings instance to use to generate embeddings from the documents.

      • dbConfig: MomentoVectorIndexLibArgs

        The configuration to use to instantiate the vector store.

      • OptionaldocumentProps: DocumentProps

        The properties of the documents to add to the index, specifically the ids.

      Returns Promise<MomentoVectorIndex>

      Promise that resolves to the vector store.

    • Stores the documents in the index.

      Converts the documents to vectors using the Embeddings instance passed.

      Parameters

      • texts: string[]

        The texts to store in the index.

      • metadatas: object | object[]

        The metadata to store in the index.

      • embeddings: EmbeddingsInterface

        The embeddings instance to use to generate embeddings from the documents.

      • dbConfig: MomentoVectorIndexLibArgs

        The configuration to use to instantiate the vector store.

      • OptionaldocumentProps: DocumentProps

        The properties of the documents to add to the index, specifically the ids.

      Returns Promise<MomentoVectorIndex>

      Promise that resolves to the vector store.