langchain.js
    Preparing search index...

    A class that uses an LLM chain to extract relevant parts of documents. It extends the BaseDocumentCompressor class.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    getInput: (query: string, doc: DocumentInterface) => Record<string, unknown> = defaultGetInput
    llmChain: LLMChain

    Methods

    • Compresses a list of documents based on the output of an LLM chain.

      Parameters

      • documents: DocumentInterface[]

        The list of documents to be compressed.

      • query: string

        The query to be used for document compression.

      Returns Promise<DocumentInterface[]>

      A list of compressed documents.

    • Creates a new instance of LLMChainExtractor from a given LLM, prompt template, and getInput function.

      Parameters

      • llm: BaseLanguageModelInterface

        The BaseLanguageModel instance used for document extraction.

      • Optionalprompt: any

        The PromptTemplate instance used for document extraction.

      • OptionalgetInput: (query: string, doc: DocumentInterface) => Record<string, unknown>

        A function used for constructing the chain input from the query and a Document.

      Returns LLMChainExtractor

      A new instance of LLMChainExtractor.