Even in a simplified context like this you probably need another system to limit "the hallucination of facts". I asked some specific questions about Linux system APIs and ChatGPT "hallucinated" interfaces and generated code to interact with those interfaces (that do not exist)