langchain.js
    Preparing search index...

    Prefer the @langchain/weaviate package.

    Class that extends the VectorStore base class. It provides methods to interact with a Weaviate index, including adding vectors and documents, deleting data, and performing similarity searches.

    Hierarchy (View Summary)

    Index

    Constructors

    • Parameters

      • embeddings: EmbeddingsInterface
      • args: WeaviateLibArgs

      Returns WeaviateStore

    Properties

    embeddings: EmbeddingsInterface
    FilterType: FilterValue

    Methods

    • Returns string

    • Method to add documents to the Weaviate index. It first generates vectors for the documents using the embeddings, then adds the vectors and documents to the index.

      Parameters

      • documents: Document[]

        Array of documents to be added.

      • Optionaloptions: { ids?: string[] }

        Optional parameter that can include specific IDs for the documents.

      Returns Promise<string[]>

      An array of document IDs.

    • Method to add vectors and corresponding documents to the Weaviate index.

      Parameters

      • vectors: number[][]

        Array of vectors to be added.

      • documents: Document[]

        Array of documents corresponding to the vectors.

      • Optionaloptions: { ids?: string[] }

        Optional parameter that can include specific IDs for the documents.

      Returns Promise<string[]>

      An array of document IDs.

    • Method to delete data from the Weaviate index. It can delete data based on specific IDs or a filter.

      Parameters

      • params: { filter?: FilterValue; ids?: string[] }

        Object that includes either an array of IDs or a filter for the data to be deleted.

      Returns Promise<void>

      Promise that resolves when the deletion is complete.

    • 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

      • Optional_callbacks: undefined

      Returns Promise<Document[]>

      • List of documents selected by maximal marginal relevance.
    • Method to perform a similarity search on the stored vectors in the Weaviate index. It returns the top k most similar documents and their similarity scores.

      Parameters

      • query: number[]

        The query vector.

      • k: number

        The number of most similar documents to return.

      • Optionalfilter: FilterValue

        Optional filter to apply to the search.

      Returns Promise<[Document, number][]>

      An array of tuples, where each tuple contains a document and its similarity score.

    • Method to perform a similarity search on the stored vectors in the Weaviate index. It returns the top k most similar documents, their similarity scores and embedding vectors.

      Parameters

      • query: number[]

        The query vector.

      • k: number

        The number of most similar documents to return.

      • Optionalfilter: FilterValue

        Optional filter to apply to the search.

      Returns Promise<[Document, number, number, number[]][]>

      An array of tuples, where each tuple contains a document, its similarity score and its embedding vector.

    • Static method to create a new WeaviateStore instance from a list of documents. It adds the documents to the Weaviate index.

      Parameters

      • docs: Document[]

        Array of documents.

      • embeddings: EmbeddingsInterface

        Embeddings to be used for the documents.

      • args: WeaviateLibArgs

        Arguments required to create a new WeaviateStore instance.

      Returns Promise<WeaviateStore>

      A new WeaviateStore instance.

    • Static method to create a new WeaviateStore instance from an existing Weaviate index.

      Parameters

      • embeddings: EmbeddingsInterface

        Embeddings to be used for the Weaviate index.

      • args: WeaviateLibArgs

        Arguments required to create a new WeaviateStore instance.

      Returns Promise<WeaviateStore>

      A new WeaviateStore instance.

    • Static method to create a new WeaviateStore instance from a list of texts. It first creates documents from the texts and metadata, then adds the documents to the Weaviate index.

      Parameters

      • texts: string[]

        Array of texts.

      • metadatas: object | object[]

        Metadata for the texts. Can be a single object or an array of objects.

      • embeddings: EmbeddingsInterface

        Embeddings to be used for the texts.

      • args: WeaviateLibArgs

        Arguments required to create a new WeaviateStore instance.

      Returns Promise<WeaviateStore>

      A new WeaviateStore instance.

    • Parameters

      • embeddings: EmbeddingsInterface
      • config: WeaviateLibArgs & { dimensions?: number }

      Returns Promise<WeaviateStore>