• 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[]

      The list of documents to be collapsed.

    • combineDocumentFunc: ((docs: Document[]) => 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[]

          Returns Promise<string>

    Returns Promise<Toolkit>

    • A promise that resolves to a single document with combined content and merged metadata.
    • Throws an error if the combineDocumentFunc does not return a promise or if the promise does not resolve to a string.
""