I haven't really used ChatGPT but I do think it's quite inaccurate. I remember seeing some articles about lawyers using it to find cases and they made up cases that did not exist.
I am wondering if the reason why it could not find the correct code and used depreciated code is because the training data was a few years back. I don't know if it can even access the new libraries to make the correct code.