Some open source licenses are fine with AI training, eg. MIT No Attribution https://choosealicense.com/licenses/mit-0/ and BSD Zero Clause https://choosealicense.com/licenses/0bsd/
My view is that it's good to allow AI training to use your code. This democratises AI models, otherwise AI will be the exclusive preserve of wealthy corporations. So I say, let's license our code under permissive, no attribution licences!