OpenAI node returning multiple arrays instead of 1

Hi, new user so still learning my way around the UI but finding it quite good so far. Having some trouble though with asking the OpenAI node to return a single JSON string of 8 objects. The premise being I have had some educational content created, and I have asked it to create 8 flashcards for me based on the content.

I’ve tried being as specific as possible with requests like this:

Generate exactly 8 flashcards covering {{ $json.fields[‘Content Description’] }}.
Output one JSON object with key “flashcards” whose value is an array of 8 objects:
{“Title”:“…”,“Summary”:“…”}
No extra text or repeats.

END

or this:
Create exactly 8 flashcards based on {{ $(‘Create Content Record’).item.json.fields[‘Content Description’] }}.
Output one JSON object with key “flashcards” whose value is an array of 8 objects:
{“Title”:“…”,“Summary”:“…”}

But no matter what happens it’s always returning 8 arrays x 8 records. I’ve asked GPT for suggestions and it hasn’t helped.

For some final context the plan was to get it to spit out the 8 flashcards, then use the Split node so I can upload each flashcard onto airtable. The chatgpt model I’m using is o4mini.

Any help would be appreciated!

1 Like

Hi @chef ,

Welcome to the community.
Replace your prompt with below one and check if it is working as expected:

"Create exactly 8 flashcards based on {{ $(‘Create Content Record’).item.json.fields[‘Content Description’] }}.

Output one JSON object with the key “flashcards” whose value is an array of 8 objects. Each object should have the following structure:
{ “Title”: “…”, “Summary”: “…” }

Format:
{
“flashcards”: [
{ “Title”: “…”, “Summary”: “…” },
{ “Title”: “…”, “Summary”: “…” },

]
}
"

Hi,

Thanks for your help but unfortunately I’m getting the same result. The Scheme output is correct and showing 8 records but the JSON is still giving me 64. Even in the Split function it is looking ok but when I update the records in airtable it is loading all 64 cards up.

The only workaround I’ve found is to go into Settings and change the tab to Execute Once which then works fine. But then I can only do one topic at a time and cannot load multiple subjects, it’s quite manual

Hi @chef ,
Coud you please share the input and the expected output here?
So we can truble shoot it and fix the issues in the prompt.

Best Regards,
Msquare Automation and Solutions

@chef you could add a Structured Output parser in the OpenAI node

Hi,

Here is the screenshot, as you can see the output goes to over 600 lines and takes time to process. If I switch it to execute once though, I have no issues