如何实现对 Array<File> 类型的数据进行 chunk 切分

My scenario is that in a flow, I use a set of images for the model to understand, but the model’s provider has a limit on the number of images per request—say, 5. So I want to chunk this set of images into groups of 5 and call the model in parallel for each group.

I’d like to ask the community if anyone has any ideas for this scenario.

  • The List Operator doesn’t support chunk operations.

  • The Code node can operate on arrays, but the output type of the node cannot be set to File, so the type mismatch prevents its use in subsequent nodes.

Just had a sudden idea to implement it using a Loop nested within an Iteration:

Manually calculate the number of chunks, start a Loop, inside the Loop use an index variable to compute a range, then perform an iteration over the original list, but with an if condition currentIndex in range to filter. (This effectively acts like list.filter((_, idx) => idx in range).)

But didn’t expect that a Loop can’t contain an Iteration inside it :joy:

Well, although Loop can’t wrap Iteration, it can wrap a workflow, and the workflow can then use iteration.