Collapses a list of documents into a single document.
This function takes a list of documents and a function to combine the content of these documents.
It combines the content of the documents using the provided function and merges the metadata of all documents.
If a metadata key is present in multiple documents, the values are concatenated with a comma separator.
Parameters
docs: Document<Record<string, any>>[]
The list of documents to be collapsed.
combineDocumentFunc: ((docs) => Promise<string>)
A function that combines the content of a list of documents into a single string. This function should return a promise that resolves to the combined string.
(docs): Promise<string>
Parameters
docs: Document<Record<string, any>>[]
Returns Promise<string>
Returns Promise<Document>
A promise that resolves to a single document with combined content and merged metadata.
Throws
Throws an error if the combineDocumentFunc does not return a promise or if the promise does not resolve to a string.
Collapses a list of documents into a single document.
This function takes a list of documents and a function to combine the content of these documents. It combines the content of the documents using the provided function and merges the metadata of all documents. If a metadata key is present in multiple documents, the values are concatenated with a comma separator.