How to get 100% valid JSON answers?

Over time, I have faced some common issues with the JSON responses from OpenAI. Though they are not very frequent, they can still occur. Often, the responses can be malformed with missing brackets, extra words like json, or using single quotes instead of double quotes.

I have written this small utility which tries to address these discrepancies with post-processing.

You can find the project on GitHub:

:link: GPT JSON Sanitizer

Feel free to check it out, and let me know of more cases, as I know there will be more, and we can together extend it further.