Hi!
I’m using the API with gpt-4 mini to generate a json based on certain conditions.
One of these conditions is the number of records the JSON must have, f.i 10 dicts in a list of dicts.
I’m passing the requirements in the assistant promt: “The JSON must have ‘n’ records”
The output will randomly generate either 10 or any other number of dicts. It works better for smaller numbers.
Is there any better approach to this?
Thank you!
Hi @Popeyee and welcome back to the forums!
Short answer is: not as yet.
PEP593 introduced Annotated types, where you can annotate for example min and max items in the array. But according to OpenAI docs, minItems
and maxItems
are not yet supported.
So your current approach is the best you can get as of now (this may change!)
Thank you for the quick reply! Yeah, I was hoping there was another way around… I’ll wait then til those parameters are supported!
Ty again
1 Like