Referring to the function-call JSON Schema in a follow-up Completion's message thread

What is the correct (or, best) way to refer to the JSON Schema provided as part of the tool or function call part of a Completion?

E.g. Sometimes, GPT doesn’t return JSON that conforms to the JSON Schema provided for the function call. To fix this, I retry the Completion with a updated message thread that includes the first completion’s incorrect JSON output and ask GPT to fix it.

In the message thread — how can I best refer to the JSON Schema provided for the function call? The JSON Schema isn’t a part of my message thread, so it’s unclear how GPT identifies with it.

What I currently do is:

[
*<previous message thread here>,

AI message:
<the JSON output from the first function-call Completion>,

Human message:
The Completion in the function call above did not exactly satisfy all of the constraints required by the function-call JSON schema.

Please correct the output, making sure to fix the following validation errors:

{"location": "/columns/0/bullet_points", "error": "The array has too few elements (minimum 3)"}
{"location": "/columns/1/bullet_points", "error": "The array has too few elements (minimum 3)"}


]

In that thread, I refer to the JSON Schema with “function-call JSON schema”. But I’m unsure if the model understands what I’m talking about.

fwiw, the above message thread does mostly work, though it can take 2-3 retries before the result fully conforms to the schema.

Is there a better way to do this? A better or correct way to refer to the function-call’s JSON Schema?

1 Like