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.

  • docs – A list of Documents to combine.

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

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


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 “, “.