Class for interacting with the Vectara API. Extends the VectorStore class.

Hierarchy

  • VectorStore
    • VectaraStore

Constructors

Properties

FilterType: VectaraFilter
embeddings: EmbeddingsInterface

Embeddings interface for generating vector embeddings from text queries, enabling vector-based similarity searches.

Methods

  • Adds documents to the Vectara store.

    Parameters

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

      An array of Document objects to add to the Vectara store.

    Returns Promise<string[]>

    A Promise that resolves to an array of document IDs indexed in Vectara.

  • Vectara provides a way to add documents directly via their API. This API handles pre-processing and chunking internally in an optimal manner. This method is a wrapper to utilize that API within LangChain.

    Parameters

    • files: VectaraFile[]

      An array of VectaraFile objects representing the files and their respective file names to be uploaded to Vectara.

    • metadatas: undefined | Record<string, unknown> = undefined

    Returns Promise<string[]>

    A Promise that resolves to the number of successfully uploaded files.

  • Throws an error, as this method is not implemented. Use addDocuments instead.

    Parameters

    • _vectors: number[][]

      Not used.

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

      Not used.

    Returns Promise<void>

    Does not return a value.

  • Creates a VectorStoreRetriever instance with flexible configuration options.

    Parameters

    • OptionalkOrFields: number | Partial<VectorStoreRetrieverInput<VectaraStore>>

      If a number is provided, it sets the k parameter (number of items to retrieve).

      • If an object is provided, it should contain various configuration options.
    • Optionalfilter: VectaraFilter

      Optional filter criteria to limit the items retrieved based on the specified filter type.

    • Optionalcallbacks: Callbacks

      Optional callbacks that may be triggered at specific stages of the retrieval process.

    • Optionaltags: string[]

      Tags to categorize or label the VectorStoreRetriever. Defaults to an empty array if not provided.

    • Optionalmetadata: Record<string, unknown>

      Additional metadata as key-value pairs to add contextual information for the retrieval process.

    • Optionalverbose: boolean

      If true, enables detailed logging for the retrieval process. Defaults to false.

    Returns VectorStoreRetriever<VectaraStore>

    • A configured VectorStoreRetriever instance based on the provided parameters.

    Basic usage with a k value:

    const retriever = myVectorStore.asRetriever(5);
    

    Usage with a configuration object:

    const retriever = myVectorStore.asRetriever({
    k: 10,
    filter: myFilter,
    tags: ['example', 'test'],
    verbose: true,
    searchType: 'mmr',
    searchKwargs: { alpha: 0.5 },
    });
  • Deletes documents from the vector store based on the specified parameters.

    Parameters

    • Optional_params: Record<string, any>

      Flexible key-value pairs defining conditions for document deletion.

    Returns Promise<void>

    A promise that resolves once 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<VectaraFilter>
    • _callbacks: undefined | Callbacks

    Returns Promise<DocumentInterface<Record<string, any>>[]>

    • List of documents selected by maximal marginal relevance.
  • Performs a similarity search and returns documents.

    Parameters

    • query: string

      The query string for the similarity search.

    • Optionalk: number

      Optional. The number of results to return. Default is 10.

    • Optionalfilter: VectaraFilter

      Optional. A VectaraFilter object to refine the search results.

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

    A Promise that resolves to an array of Document objects.

  • Throws an error, as this method is not implemented. Use similaritySearch or similaritySearchWithScore instead.

    Parameters

    • _query: number[]

      Not used.

    • _k: number

      Not used.

    • Optional_filter: VectaraFilter

      Not used.

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

    Does not return a value.

  • Performs a similarity search and returns documents along with their scores.

    Parameters

    • query: string

      The query string for the similarity search.

    • Optionalk: number

      Optional. The number of results to return. Default is 10.

    • Optionalfilter: VectaraFilter

      Optional. A VectaraFilter object to refine the search results.

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

    A Promise that resolves to an array of tuples, each containing a Document and its score.

  • Returns Serialized

  • Performs a Vectara API call based on the arguments provided.

    Parameters

    • query: string

      The query string for the similarity search.

    • k: number

      Optional. The number of results to return. Default is 10.

    • vectaraFilterObject: VectaraFilter
    • summary: VectaraSummary = ...

    Returns Promise<SummaryResult>

    A Promise that resolves to an array of tuples, each containing a Document and its score.

  • Creates a VectaraStore instance from documents.

    Parameters

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

      An array of Document objects.

    • _embeddings: EmbeddingsInterface

      Not used.

    • args: VectaraLibArgs

      A VectaraLibArgs object for initializing the VectaraStore instance.

    Returns Promise<VectaraStore>

    A Promise that resolves to a VectaraStore instance.

  • Creates a VectaraStore instance from texts.

    Parameters

    • texts: string[]

      An array of text strings.

    • metadatas: object | object[]

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

    • _embeddings: EmbeddingsInterface

      Not used.

    • args: VectaraLibArgs

      A VectaraLibArgs object for initializing the VectaraStore instance.

    Returns Promise<VectaraStore>

    A Promise that resolves to a VectaraStore instance.