DocumentCompressorPipeline#

class langchain.retrievers.document_compressors.base.DocumentCompressorPipeline[source]#

Bases: BaseDocumentCompressor

Document compressor that uses a pipeline of Transformers.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

param transformers: List[BaseDocumentTransformer | BaseDocumentCompressor] [Required]#

List of document filters that are chained together and run in sequence.

async acompress_documents(documents: Sequence[Document], query: str, callbacks: list[BaseCallbackHandler] | BaseCallbackManager | None = None) Sequence[Document][source]#

Compress retrieved documents given the query context.

Parameters:
Return type:

Sequence[Document]

compress_documents(documents: Sequence[Document], query: str, callbacks: list[BaseCallbackHandler] | BaseCallbackManager | None = None) Sequence[Document][source]#

Transform a list of documents.

Parameters:
Return type:

Sequence[Document]

Examples using DocumentCompressorPipeline