So far, AI has been struggling with AppleScript, but ChatGPT now has a dedicated AppleScript GPT, which may generate more reliable AppleScripts (and may not).
I will point the AppleScript GPT here for ChatGPT users’s questions.
If you are opposed to AI or don’t want to see that traffic, please ignore!
It will do. There’s relatively little by way of AppleScript code available on the internet, and the majority of what is available averages poor quality.
This is to be expected. New AppleScripts appear on the internet almost exclusively in the context of someone asking for assistance on how to get their non-working code to work.
By contrast, other scripting or programming languages (e.g. shell script, Python, C, JavaScript, … heck, even Brainfuck) not only have orders of magnitude more users—and, thus, much more code available online—but they’re also incredibly well-established in both professional and learner spheres, the former having had plenty of time to contribute language libraries, in-depth tutorials, and high-quality, workable samples of code.
For this reason, I think the only way to have an LLM capable of producing reliable AppleScript code is to specifically train a custom model.
I have set up a GPT in ChatGPT designed to write appleScripts. That means I give it a set of instructions/rules to follow and update them as I notice patterns in the errors it makes.
For example it seems to prefer records to lists when gathering and moving data, but it consistently mishandles nested records. So I added a rule to avoid using nested records. So far that seems to have helped.
I’ve also added rules to use handlers when appropriate, rather than one large block of script, and that seems to help.
Generally I’ll give it instructions on what I want done, then get an output and then go back and forth a few times until it gets it right. I’m hoping to get it to generate more complex scripts that work correctly on the first try.
Oh OK, so you’re basically fine-tuning a model. That’s going to come with some inherent limitations on what will ultimately be achievable in the best case scenario. But it will no doubt be a good learning exercise.