langchain.js
    Preparing search index...

    A retriever that wraps a base retriever and compresses the results. It retrieves relevant documents based on a given query and then compresses these documents using a specified document compressor.

    const retriever = new ContextualCompressionRetriever({
    baseCompressor: new LLMChainExtractor(),
    baseRetriever: new HNSWLib().asRetriever(),
    });
    const retrievedDocs = await retriever.getRelevantDocuments(
    "What did the speaker say about Justice Breyer?",
    );

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    baseCompressor: BaseDocumentCompressor
    baseRetriever: BaseRetrieverInterface
    lc_namespace: string[] = ...

    Methods

    • Parameters

      • query: string
      • OptionalrunManager: any

      Returns Promise<DocumentInterface[]>

    • Returns string