collapse_docs#

langchain.chains.combine_documents.reduce.collapse_docs(docs: List[Document], combine_document_func: CombineDocsProtocol, **kwargs: Any) β†’ Document[source]#

Execute a collapse function on a set of documents and merge their metadatas.

Parameters:
  • docs (List[Document]) – A list of Documents to combine.

  • combine_document_func (CombineDocsProtocol) – A function that takes in a list of Documents and optionally addition keyword parameters and combines them into a single string.

  • **kwargs (Any) – Arbitrary additional keyword params to pass to the combine_document_func.

Returns:

A single Document with the output of combine_document_func for the page content

and the combined metadata’s of all the input documents. All metadata values are strings, and where there are overlapping keys across documents the values are joined by β€œ, β€œ.

Return type:

Document