langchain.js
    Preparing search index...

    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 extends Record<string, any> = Record<string, any>,
    > {
        lc_serializable: boolean;
        get lc_id(): string[];
        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>,
            options: Partial<CallOptions>,
        ): AsyncGenerator<DocumentInterface<Metadata>[]>;
    }

    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 Summary)

    Implemented by

    Index

    Properties

    lc_serializable: boolean

    Accessors

    • get lc_id(): string[]

      Returns string[]

    Methods

    • Parameters

      • Optionalsuffix: string

      Returns string

    • 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.