Then we still must reflect on and ask - why you are using functions.
A strict schema can be given to the AI for JSON as instruction, with examples of what is acceptable.
gpt-4o-2024-08-06 supports json_object as a response format, enforcing production of only that JSON format by the AI model.
The AI will have significant coloration of the language when the training of how to write tools/functions is activated, then placing the output in a special container after producing a special “send-to-tool” sequence.
If you proceed with your current course: Since the AI is forced to use the function by API parameter, the overall description of the tool can focus on convincing the AI that it is sending its output to be interpreted by an external API, and where that information actually goes, and is displayed, and what the AI’s job is in general.
Then of course the property descriptions and their naming reflect clearly what is required.
Summary:
To maximize success:
-
Option 3 (Parameter Descriptions): This is where you should place the most detailed instructions. The assistant uses these descriptions to understand exactly what is required for each field.
-
Option 2 (Function Description): Provide a concise summary to guide the assistant on the function’s purpose.
-
Option 1 (Messages): Reinforce key instructions in the message to provide context and ensure the assistant is fully aware of your expectations.
By combining all three options, you provide comprehensive guidance to the assistant, increasing the likelihood of generating the desired complex JSON output.