Interface BaseRetrieverInterface<Metadata>

Interface for a base retriever that defines core functionality for retrieving relevant documents from a source based on a query.

The BaseRetrieverInterface standardizes the getRelevantDocuments method, enabling retrieval of documents that match the query criteria.

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

Type Parameters

  • Metadata extends Record<string, any> = Record<string, any>

    The type of metadata associated with each document, defaulting to Record<string, any>.

Hierarchy (view full)

Implemented by

Methods

  • 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<Metadata>[]>

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