Interface for a retriever that uses a vector store to store and retrieve document embeddings. This retriever interface allows for adding documents to the underlying vector store and conducting retrieval operations.

VectorStoreRetrieverInterface extends BaseRetrieverInterface to provide document retrieval capabilities based on vector similarity.

VectorStoreRetrieverInterface

interface VectorStoreRetrieverInterface<V> {
    vectorStore: V;
    addDocuments(documents: DocumentInterface<Record<string, any>>[], options?: AddDocumentOptions): Promise<void | string[]>;
    batch(inputs: string[], options?: Partial<RunnableConfig<Record<string, any>>> | Partial<RunnableConfig<Record<string, any>>>[], batchOptions?: RunnableBatchOptions & {
        returnExceptions?: false;
    }): Promise<DocumentInterface<Record<string, any>>[][]>;
    batch(inputs: string[], options?: Partial<RunnableConfig<Record<string, any>>> | Partial<RunnableConfig<Record<string, any>>>[], batchOptions?: RunnableBatchOptions & {
        returnExceptions: true;
    }): Promise<(Error | DocumentInterface<Record<string, any>>[])[]>;
    batch(inputs: string[], options?: Partial<RunnableConfig<Record<string, any>>> | Partial<RunnableConfig<Record<string, any>>>[], batchOptions?: RunnableBatchOptions): Promise<(Error | DocumentInterface<Record<string, any>>[])[]>;
    getName(suffix?: string): string;
    getRelevantDocuments(query: string, config?: Callbacks | BaseCallbackConfig): Promise<DocumentInterface<Record<string, any>>[]>;
    invoke(input: string, options?: Partial<RunnableConfig<Record<string, any>>>): Promise<DocumentInterface<Record<string, any>>[]>;
    stream(input: string, options?: Partial<RunnableConfig<Record<string, any>>>): Promise<IterableReadableStreamInterface<DocumentInterface<Record<string, any>>[]>>;
    transform(generator: AsyncGenerator<string, any, unknown>, options: Partial<RunnableConfig<Record<string, any>>>): AsyncGenerator<DocumentInterface<Record<string, any>>[], any, unknown>;
}

Type Parameters

Hierarchy (view full)

Implemented by

Properties

vectorStore: V

Methods

  • Adds an array of documents to the vector store.

    This method embeds the provided documents and stores them within the vector store. Additional options can be specified for custom behavior during the addition process.

    Parameters

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

      An array of documents to embed and add to the vector store.

    • Optionaloptions: AddDocumentOptions

      Optional settings to customize document addition.

    Returns Promise<void | string[]>

    A promise that resolves to an array of document IDs or void, depending on the implementation.

  • Retrieves documents relevant to a given query, allowing optional configurations for customization.

    Parameters

    • query: string

      A string representing the query to search for relevant documents.

    • Optionalconfig: Callbacks | BaseCallbackConfig

      (optional) Configuration options for the retrieval process, which may include callbacks and additional context settings.

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

    A promise that resolves to an array of DocumentInterface instances, each containing metadata specified by the Metadata type parameter.