How to shift elements in JSON?

Hi,
I make history of chat for ChatGPT. So I send to GPT JSON with dialogue. I can’t figure out better way to remove top 2 values (user, assistant) from JSON and add to bottom new 2. It should happen when we have more than N messages in dialogue.
At the top must always be message with role system.

Can you help?

You can use the built-in function slice to remove the first two items of an array:

e.g.:

{{ slice(1.array; 2) }}

For more information, see the function documentation in the Help Center.

Here are some useful links and guides you can use to learn more on how to use the Make platform, apps, and app modules. I found these useful when I was learning Make, and hope they might benefit you too —

General

Help Center Basics

Articles & Videos

samliewrequest private consultation

Join the unofficial Make Discord server to chat with other makers!

1 Like