So im using Functions in chatgpt API, and its generating invalid/malformed json. Its not useable. I cant even parse it.
Anyone face these issues?
So im using Functions in chatgpt API, and its generating invalid/malformed json. Its not useable. I cant even parse it.
Anyone face these issues?
People do face issues, because it is a AI language model replicating its training and trying to figure out what you want, not a logical computer program.
JSON is very hard for the model. It’s much better at Markdown. If you have the ability to parse Markdown, try making it generate that.
well i assumed when openAI released functions this type of basic JSON formatting will be more reliable, seems like this feature is far from ready to be used.
It works for the cases it works for. If it doesn’t solve your particular use case, you either find a work-around, or you use some other tool for the use case. That’s what the whole “bleeding edge of research/engineering” is all about.
If you want something that’s guaranteed to work every time, buy a Lego kit.
I’ve been using a few-shot sample technique to generate my output and parse that data and it has been pretty consistent but this is gpt-4 and not the functions, functionality.
As an added check, I use a try and catch to see whether the JSON is formatted correctly or not and if not so, send it back to GPT with the error I got from JSONDecoder to “fix” it. Though this assume only the formatting is wrong and the data generated is correct