Trying to understand the trade offs between when to use JSON mode instead of Function Calling?
The documentation says JSON mode will always produce valid JSON. And at the same time it says Function Calling is “more likely” to return the right function parameters than in the previous models.
Previously I was using function calling to get JSON from the GPT models (using the function_call parameter) and occasionally it would give me invalid JSON. If I require valid JSON should I swap out my current function calling approach for the JSON mode in order to get 100% valid JSON then?
JSON mode is always enabled for the generation of function arguments, so those are guaranteed to parse.
JSON mode is opt in for regular messages.
Note that JSON mode sadly doesn’t guarantee that the output will match your schema (though the model tries to do this and is continually getting better at it), only that it is JSON that will parse.
So TL;DR is that you can use either functions or messages, and in both cases know you will get parseable JSON back