Why can't I get variable batching for my Loop?

Hello,

So I need to send images to ChatGPT for analysis. Each item has a different number of images, so I have a segment that figures out how many images there are of every item. The problem is that my Loop Over Items node doesn’t loop when I use the variable batch size. When I use a static batch size, it works perfectly. What can I do so that my loop works and takes the specific number of images?



All the code node does is combine all of the images so that they can be uploaded to Chat.

Thank you all for your time!

There are nodes to reduce the number of items if needed and aggregate them. But the strategy depends on the data structure at hand.

Could you post your workflow with some data pinned in it?
See how: OleksiyRudenko’s gists · GitHub

The Loop node with a dynamic batch size works pretty well — but not exactly as expected. The batch size is updated in each loop cycle based on the result of the last node in the loop.

That’s not what you actually want.

I also noticed that your loop has two inputs (two paths going in). But the loop doesn’t automatically merge those inputs. Instead, it will first loop through the items from the first input, and only after that move on to the items from the second input.

To fix this, you can use something like a Merge node before the loop.

Code is easier to understand than words — so here’s an example to show you what I mean.
The first two code nodes are just used to generate some sample data.

Ok, after reading your response again. I duplicated the google sheets read node and put it in the loop, and it almost works, but it takes the first variable again instead of moving on to the second variable. Any Ideas?

Thank You very much for the help already though!

Show some code. There can be a lot of reasons. E.g. referring data using $(nodeNaame).first(). Actual workflow posted will help to avoid guesswork.