Grouping paragraphs by ChatGPT token problems


I have a problem with sending data to ChatGPT by token number.

I have to summarize a few paragraphs returned by an API.

1 - I make the API call and it returns x number of paragraphs (In the example 64).

2 - I need to group these paragraphs in groups of 20. In the example it would be, 4 groups of 20, 20, 20 and 4 paragraphs.

3 - I send these 4 grouped fields to Airtable.

4 - From Airtable I send them to ChatGPT to summarize each group.

5 - Then I send the 5 reduced groups to ChatGPT to get the final summary.

My question is:

How can I tell Make to group the paragraphs 20 by 20 and that the last one is the remaining number of paragraphs?


I have found a solution, I share it in case it helps anyone:

Hi @Ramagu ,

To group the paragraphs into batches of 20 and send the last batch with the remaining paragraphs, you can use a repeater and the slice function in Make. Here’s an overview of the process:

  1. Add a repeater before the iterator and divide the total number of paragraphs by the number you want to group them by (20 in your case). This will give you the total number of times you need to process the batches of 20.
  2. Use the slice function in the iterator to process the groups of 20 paragraphs. If the last batch has fewer than 20 paragraphs, the slice function will automatically stop at the end of the array, and it won’t fill it with empty elements.

Here’s an example of how to do this in Make:

  1. Total overview

  2. Add a repeater before the iterator and divide the total number of paragraphs by your batch size (In my example my array had a length of 5 and I repeated by 2)

3. Use the slice function in the iterator to process each batch of paragraphs.

If you want to learn more about the slice function, I recommend checking out this article: Mastering the slice function in Make: Understanding zero-based and one-based indexing

I hope this helps! Let me know if you have any further questions.

Best regards,
Glenn - Callinetic


This can be tricky, Please do let me know if you think this makes sense, as there might be a better solution to this.

What you want to do After HTTP Module, Use an array aggregator that will grab all the data that you have. Based on your scenario though, the HTTP module is returning an array so we don’t need to use the array aggregator. So, Remove the iterator from there.

  1. Add a Repeater after the HTTP module that will have a repeat parameter set to,

    • Initial Value: 1
    • Repeats: {{ceil(length(1.array) / 20)}}, whereby array is the data that is obtained from the HTTP response. So, for eg., if the total length is 64 then the iterator will run from 1 to 4.
  2. After the Repeater is set, what you want to do now is split the array and then join the relevant data from the incoming array.

    • For testing, Put a Set a Variable Module that will have the following logic.
    • Slice array, {{slice(1.array; ((2.i - 1) * 20 + 1); 2.i * 20 + 1)}}. What this does is based on the iterator value, it will split the array into each element of 20.

After which you can manipulate the sliced/chunked array to pass it to Airtable or Chatpgpt. Either by performing a join or map function.

You can try this blueprint and see if it make sense :
blueprint (31).json (6.6 KB)


Incredible help and quick response.

I will try the options you recommend to see if it is better than the one I suggest.

Thank you very much!

I have done several tests and I don’t know where I am going wrong that it is not working properly.

The problem is that it “eats” the first paragraph. It does the whole process fine, but it starts grouping the paragraphs from the 2nd paragraph. I attach screenshots:

@Ramagu ,

Change the initial value of your repeater to 0. You don’t need to use the ceil() function in the repeater (See my first post)
In the iterator, change you slice function parameters to the screenshot I shared you. I still recommend you to check out this article when it comes to the slice function parameters: Mastering the slice function in Make: Understanding zero-based and one-based indexing

Glenn - Callinetic


Sorry, My bad, I didn’t throughly checked it,

Just replace this function with this one,

{{slice(1.array; ((2.i - 1) * 20); 2.i * 20)}}

1 Like

Incredible! It works perfectly! Thank you both so much for the help! @Callinetic y @Runcorn !!