def merge()

in aidial_sdk/utils/merge_chunks.py [0:0]


def merge(*chunks: T) -> T:
    """
    Merge a list of chunks into one.
    The very first chunk is modified in-place by accumulating the content of the subsequent chunks.
    The subsequent chunks aren't modified.
    The new content added to the first chunk is deeply copied from a source chunk.
    """

    assert len(chunks) > 0, "At least one chunk must be provided"
    ret: T = chunks[0]
    for chunk in chunks[1:]:
        ret = merge_recursive(ret, chunk, path=[])
    return ret