Try chatgpt 4 premium. I have heard it automatically auto correct itself with code.
I regularly use gpt-4 for coding since it's the backend behind github copilot, and my company has approved use of copilot (and I have copilot plugins installed for vscode and vs2022). It's useful for autocompleting boilerplate code, but gets things wrong all the time about anything more complicated.