If you release it as GPL or AGPL, it should be pretty difficult to obey those terms while using the code for AI training. Of course, they'll probably scoop it up anyway, regardless of license.
If the courts decide it’s not fair use then OpenAI et al. are going to have some issues.