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

Hierarchy (view full)

Constructors

Properties

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

Type declaration

    • (query, doc): Record<string, unknown>
    • Parameters

      • query: string
      • doc: DocumentInterface<Record<string, any>>

      Returns Record<string, unknown>

llmChain: LLMChain<string, LLMType>

Methods

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

    Parameters

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

      The list of documents to be compressed.

    • query: string

      The query to be used for document compression.

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

    A list of compressed documents.

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

    Parameters

    • llm: BaseLanguageModelInterface<any, BaseLanguageModelCallOptions>

      The BaseLanguageModel instance used for document extraction.

    • Optional prompt: PromptTemplate<any, any>

      The PromptTemplate instance used for document extraction.

    • Optional getInput: ((query, doc) => Record<string, unknown>)

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

        • (query, doc): Record<string, unknown>
        • Parameters

          • query: string
          • doc: DocumentInterface<Record<string, any>>

          Returns Record<string, unknown>

    Returns LLMChainExtractor

    A new instance of LLMChainExtractor.

Generated using TypeDoc