SQL injections are preventable by either 1) escaping input (so that your query and the input continue to come in a single stream), or 2) sending the query out-of-band, using prepared statements with placeholders
Converting this situation to AI, perhaps 2) can be done with https://github.com/openai/openai-python/blob/main/chatml.md, but if you were stuck with an unstructured text input and had to do 1), how would you escape the untrusted user input?