private boolean isIndexedArray(ArrayNode array) {
        if (array.isEmpty()) {
            return false;
        }
        boolean allIndexed = true;
        boolean anyIndexed = false;

        for (JsonNode node : array) {
            if (node.isObject() && node.has("index")) {
                anyIndexed = true;
            } else {
                allIndexed = false;
            }
        }

        if (anyIndexed && !allIndexed) {
            throw new IllegalArgumentException(INCONSISTENT_INDEXED_LIST_ERROR_MESSAGE);
        }
        return allIndexed;
    }
The utility merges chunks received from a streaming response. The original reference implementation is provided
<a href="https://github.com/epam/ai-dial-sdk/blob/0.10.1/aidial_sdk/utils/merge_chunks.py">here</a>.
server/src/main/java/com/epam/aidial/core/server/util/MergeChunks.java