AI Engineer Summit 2023
Move Fast Break Nothing
About this talk
Dedy Kredo presents CodiumAI's GAN-inspired vision of pairing AI code generation with a critic that checks developer intent, code behavior and edge cases. In a VS Code demonstration using the untested AutoScraper project, he generates and iteratively repairs tests, applies code-quality and performance suggestions including BLAKE3, and uses pull-request tooling for commit messages, review and security fixes. He concludes with personal remarks concerning violence and the Gaza Strip.
Chapters
- 0:00Why generated code needs a GAN-like critic
- 2:13IDE integrations and AutoScraper test-generation demo
- 6:54Code enhancements and BLAKE3 performance recommendation
- 8:54Pull-request assistant, automated review and security fixes
- 12:04Closing personal remarks
Talk transcript
- 0:00
[upbeat music] Hey, good morning, everyone.
- 0:18
Let's take a step... Let's start by taking a step back. Uh, remember GANs, generative adversarial networks. They represented a very compelling architecture, in my opinion. Two neural networks working hand-in-hand, one generating and one is the critic, in order to generate high-quality outcomes.
- 0:41
Then came transformers that changed everything. We dropped the adversarial and the focus became solely on the generative,
- 0:51
and they became the state-of-the-art for a variety of use cases.
- 0:57
But code is very, very nuanced. We believe that in order to generate code that actually works as intended, the right architecture is actually GAN-like architecture.
- 1:11
And what I mean by is that... by that is not the actual neural network, it's the system. It's the concept of having two different components, one focused on the code generation piece and one that serves as the critic.
- 1:26
We call it the code integrity component. It actually analyzes the, the outcomes, the generation of the code gen, uh, component, and it reviews it, it analyzes it. It tries to figure out all the different edge cases in order to generate high-quality code that works as intended based on the developer's actual intent.
- 1:50
This is our focus at CodiumAI, on the critic piece. We help developers understand the behaviors of their code.
- 2:00
We believe that behavior coverage is a more useful metric than actual code coverage. We help them generate tests for these behaviors, enhance their code, and review their code,
- 2:13
and we do that throughout the developer life cycle, leveraging our IDE extensions for both JetBrains and VS Code
- 2:21
and our Git plugin. And then soon in the future, in the near future, we will also offer APIs for this to be able to be embedded in various agents.
- 2:36
So we're gonna focus the majority of the time in a live demo,
- 2:41
which is a risky thing to do in this, uh, situation here, but, uh, let's go for it.
- 3:00
Okay, I'm here in my VS Code. I have the CodiumAI extension installed. Uh, we now have, uh, around two hundred thousand, uh, installs across both JetBrains and VS Code.
- 3:10
I have here an open source project that's called AutoScraper. Um, it's basically a scraping class that automates the process of generating the rules for scraping information from websites. It's a very cool project.
- 3:25
It has more than five thousand, uh, GitHub stars. But the problem is that it doesn't have any tests, so it's very hard to make changes to a project where it doesn't have any, any tests because there's nothing that protects you from making changes.
- 3:42
So I'm gonna go ahead here and trigger CodiumAI on this class. This is a six hundred-line class, complex code, and you can see that I can trigger CodiumAI either on the class level or at the method level.
- 3:56
So I'm starting on the class. I'm actually gonna re-trigger it.
- 4:00
Um, the first thing that happens is that Codium analyzes the class.
- 4:06
It basically maps out different behaviors, and it starts generating tests. You can see it starts, uh, streaming the test. I already have one, one, two. I'm getting more tests.
- 4:16
You can see some of them are quite complex.
- 4:20
It also generate the code explanation, detailed code explanation that shows me how this class actually works, the example usage, the different components, the methods. Uh, very detailed.
- 4:33
And then I have all the... all my tests.
- 4:40
As you can see, we look at different, uh, examples, both happy path, edge cases, variety of cases.
- 4:56
Okay, so here I have the different behaviors
- 4:59
that were generated. Now, this is crucial. We're basically mapping the different behaviors of this class, doing both happy path, edge cases, and for each one of them, we can drill deeper down and see the sub-behaviors below them.
- 5:13
And we can generate tests for any one that is important for us. So let's pick a few and add additional tests.
- 5:19
Let's pick some, uh, uh, edge cases as well. Let's generate test here. Maybe here we'll generate another one for an edge case.
- 5:30
And you can see it's very simple. A few clicks and I'm having a... and I have a test suite that is built out. I already have nine tests here.
- 5:38
The next step will be to run these tests, so let's go ahead and do that.
- 5:47
So I'm hitting Run & Autofix. You can see some of these very complex tests are actually passing.
- 5:54
And here I have a test that actually failed. What happens in a failure is that the model actually analyzes, reflects on the failure, and then it tries to generate a fix in an automated manner.
- 6:07
So we have a fix, uh, generated. And now it's gonna be run.
- 6:15
And it passed on the second try. So this is a, this, this chain of thought, this reflection process in order to get to a high-quality test suite.
- 6:26
Okay. So I'm gonna start with these eight tests. Let's open them as a file.
- 6:34
I'm gonna save them in my project. And done.
- 6:51
I have a test suite that now protects me.
- 6:54
So now I'm gonna go ahead and take the next step. Let's use CodiumAI to actually enhance this code
- 7:02
now that I have a test suite that protects me. So I'm gonna choose a method here, the build method, that has a lot of the main functionality of the class.
- 7:13
I'm gonna trigger CodiumAI on that. And now let's focus on the code suggestions component of CodiumAI.
- 7:24
So Codium analyzes this code, and it basically recommends different improvements, enhancements. And these are deep enhancements. We're not talking about linting or, or things like that. We're talking about things related to performance, security, best practices, readability.
- 7:45
So I'm gonna look at these. Let's, uh, choose one that, uh, makes sense. Maybe the first one that looks quite important for performance. Basically, it recommends to replace, um, the hash leave with, uh, BLAKE3.
- 8:01
I'm gonna prepare the code changes and apply it to my code.
- 8:09
And now I can save this. But remember, now I have a test suite. So now actually, I can actually go to my test suite
- 8:19
and run it. And of course, it broke on me for some reason, as things happen in a demo. But,
- 8:31
uh, let's see this again. Okay. I have one test that failed.
- 8:42
I'm gonna ignore that for now. [laughs] Okay. So let's continue.
- 8:54
I created my test suite. I, I enhanced my code. The next step would be to prepare for my PR. So I'm gonna go ahead here and commit these changes.
- 9:09
And I'm gonna go to the CodiumAI PR Assistant, and I'm gonna do a /commit to get a commit message.
- 9:19
And now I have a commit message, so I can commit.
- 9:27
And now that I committed my changes, I can then go ahead to the last step
- 9:32
and prepare for the PR. So I'm gonna do a /review.
- 9:37
Um, and that's basically a review process that CodiumAI would do, and it will try to see if there's any issues, anything I may have missed. It will summarize the PR.
- 9:47
It will give it a score. And then we can see, um, if there's anything that I maybe I have missed here. Let's take a look.
- 9:55
So this is the main theme of the PR. We can see that it's tests. You can see that it's, it's basically telling me that it's pretty well-structured.
- 10:06
Let's let it continue. But it says that it does introduce a, a potential security vulnerability. So I'm gonna do /improve to try to fix that.
- 10:20
And it looks like I forgot an API key in my code.
- 10:27
So CodiumAI will then, uh, suggest a fix for this, and I can actually see the API in my code.
- 10:39
Let's give it a second. Looks like... I'm gonna do it again.
- 10:54
And this is where I actually have the API in my code.
- 10:59
The network is bad in this room.
- 11:01
Yeah. No, here we go. So basically, it's saying, uh, here's the API key. I'm gonna click on this, and it will launch me to where I actually forgot the API key.
- 11:11
Forgot the API key. Um, and this is the actual fix.
- 11:16
So, uh, with that, uh, I'm gonna conclude the demo so we can go back to the slides.
- 11:23
So we're able to see how we were able to, uh, use CodiumAI to map our behaviors, to generate tests, to review our code, and to do it throughout the entire life cycle.
- 11:32
We also have, as I mentioned, a Git plugin that enables us to do that inside of GitHub as well. I'm going to end, um, with a personal note.
- 11:45
So we're a company that is based in Israel. While we were on the plane on the way here, the Hamas terrorist organization launched a vicious attack on Israel.
- 11:57
The Hamas terrorists are not humans. They, they are animals.
- 12:04
Maybe not even animals. They entered into towns. They slaughtered men, women, and children. Innocent people in their home. And abducted many
- 12:20
into the Gaza Strip. This is a picture that my co-founder and CEO, Itamar, sent me.
- 12:29
He left his eight-month-pregnant wife at home and is now in military reserve duty. In the screen,
- 12:37
you can see a chart that shows the CodiumAI usage constantly increasing.
- 12:43
Behind it is his rifle. We will prevail.
- 12:49
Thank you. [audience applauding] [upbeat music]