Atricle 3 and 4 of the EU 'Copyright in the Digital Single Market' give data miners quite extensive rights.
Move operation to the EU, train a foundational model, than train a constitutional model based on that.
As much as I hate the upcoming AI regulation, the CDSM is solid.
https://academic.oup.com/grurint/article/71/8/685/6650009 https://eur-lex.europa.eu/eli/dir/2019/790/oj
Update: Fixed wrong link
There are some things that would make for good faith displays by the players in the space. For example, Microsoft has been investing a lot and yet their code offering is not trained on their internal code base. Same for Google. Start by doing that and I'll entertain the argument that your tools are fair use or data mining.
Regarding the copyright of returned material here is a good discussion:
https://copyrightblog.kluweriplaw.com/2023/05/09/generative-...
That’s the author’s entire gripe. Brave reproduced a Wikipedia entry without attribution and then slapped a copyright on it to boot.
There are a lot of pretty complex prompts, where if you asked a group of reasonably skilled programmers to implement, they'd produce code that was "reformatted and changed variable names" but otherwise identical. Many of us learned from the same foundational materials, and there are only a handful of non-pathological ways to implement a linked list of integers, for example.
With code it may be more obvious, in that you can't as easily obfuscate things with synonyms and sentence structure changes. Even with prose, there is going to be a tendency to use "conventional" language choices, driving you back towards a familiar-looking mean.