YAML’ing at speed with Duet AI
Hey Google, write my cloudbuild YAML for me because I have better things to do.
Anyone who’s ever had to write any YAML before when trying to get CI to work will know what a pain it is. You’ll have a million commits that say “Fix CI” or similar and you might get it right after a few hours. Especially if it's your first time doing it, or working with that type of file. Lately there’s been a plethora of news around AI and helping developers write code faster by providing contextual hints, and using this generative AI can be extremely helpful in many situations but of the ones I’ve tried so far they seemed to be too generalistic in their help. Eg, Bard or OpenAI or even CoPilot. The latter of the three was definitely better (in general) but still was way broader because it was trying to solve too much. DuetAI has entered the chat.
What is DuetAI?
AI-powered assistance in Google Cloud
Duet AI is your AI-powered collaborator available across Google Cloud and IDEs to help you get more done, faster.
This is what developers need. Hyper-focused AI on solving the task at hand with specific context on a few domains to help developers get what they need to do but in a (likely) more accurate way. But let’s see what it can do.
Before we continue, it’s probably worth mentioning that DuetAI can do a whole lot that I’m not going to be covering in this post, specifically, on the Google Cloud website, some of the features include:
Conversational assistance in natural language
AI-powered code assistance
Designed to respect intellectual property
Fully managed, ready to use
Safe and responsible AI
It’s focus areas:
Assisted data analysis
Assisted data science
Assisted database management
Assisted security management
In this post, we’re going to be specifically focusing on the assisted development focus. However, worth calling out, is that I particularly loved the assisted operations demo from the Cloud Next keynote this year from Priyanka (the link is skipped to the start of the demo).
What are we building?
You might have guessed it from the title and intro but if not, we’re going to be building a cloudbuild.yaml file with all the steps needed to build our code, test the change and then deploy it to cloud run.
Now this is kind of one of those things that really needs to be seen to be believed, but in short, I wrote a small comment about what I wanted in a cloudbuild.yaml file which has no project context at all, since it was in isolation. And with a bit of massaging of formatting and a small correction of args I was able to get a working app deployed in literal minutes.
Let's get into it!
From the video you can see the duet ai suggesting changes and additions to the code. Note that it’s not perfect, and neither am I! I removed a suggested change which turns out is actually required and fixed it in the second video.
Now let’s add the remainder of the project files and run the execution of the Duet AI assisted cloudbuild file.
Like most other AI tools they aren’t perfect, but from this example it will get us a really long way by not asking much. Perhaps I picked a rather lofty example by asking a lot of it from a simple query, but also, I think it shows significant capability here.
In less than 10 minutes, I was able to get a cloudbuild file created which builds, tests and deploys our app without needing working knowledge of the tools but looking at the prompt it picked up on all the terms I threw at it.
And no this wasn’t a pre-scripted prompt, what you’re seeing in the recording is the very first time I wrote that prompt.
That is pretty good. Especially for a product that is in preview (and not GA). The amount of hours I’ve wasted writing YAML only to get the syntax indenting wrong or the specific terms wrong or something like that is countless. This tool is something that will help reduce waste and toil working on problems that don’t solve problems and bring business value.
And I am all for it.
P.S. Here’s the last line of the build output with the running cloud run service that you can click on and see it working if you want:
Step #3 - "deploy": Service URL: https://go-3qqsqbdsuq-ts.a.run.app