Sourcegraph Cody: your AI coding assistant - Use Cases

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey I'm Alex from sourcegraph and today I'm going to be showing off some new features from our product Kodi Kodi is an AI coding assistant that can help you find write and explain code it uses a combination of llms source Graph Search and the code graph from sourcegraph in order to provide you with context aware answers as you're querying the llm I want to show us a few of the main ways that you can use Kodi today in this video and those are onboarding decode writing code testing code and fixing bugs and code so let's jump in here I've got vs code open and look at how you can onboard the code with Kodi imagine that you're just jumping into a project that maybe is new to you or maybe you're providing a code review for a really large pull request and you're not familiar with that code first thing you're going to want to do is get a basic understanding of what you're looking at before you can really jump in and Cody can speed up this process so I've got this file open and imagine I'm not familiar with what's going on in this code I'm going to highlight the entire contents of this file and I'm just going to hit here explain selected code at a high level and this is a pre-written Cody recipe so I can simply click this button and it's going to ask Cody to explain the selected code for me let's open up this sidebar a little bit and you can see Cody actually read four files in order to gather the necessary context on this file and answer my question and then it's going line by line and actually explaining to me what exactly is happening in this code awesome all right let's move on to writing code so Cody can also write boilerplate code or generic code for example I can say the uh give me some code for a bubble sort algorithm in a certain language for example but I can more importantly ask Cody to give up any specific code based on my repositories contents so in this case I'm going to ask Cody to write an API request that retrieves a user's repository permissions I'm working in the source graph repository and this is important to us with the source graph application because we always have to respect permissions that any given user has for what repositories they can and can't see uh so here we go Cody is responding now can go up here here is a graphql API request to retrieve a user's repository permissions and here I can actually see the code for a query to the graphql API and then Cody also unpacks what's happening in this code underneath here so very quickly Cody can provide me with actual code that I can then copy and bring right into my file and it also gives me the context in it and this code is relevant to the actual context of my code base so it's actually looking at how our API is written in order to provide me with this all right so next up is testing code and this is a simple one I'm actually going to hop over here to a go file rather than that typescript file and this is simple I can ask Cody to generate a unit test with a simple recipe here so I'm going to highlight a bit of code ask Cody hey generate me a unit test for this code it's going to once again fetch contacts it's going to look at the code surrounding this read some files understand what's Happening Here and then it's going to write me my unit test so I have the code right here that I can copy and then it's actually telling me what this test checks for too so I've got my unit test right here awesome all right so last but not least let's move on to fixing bugs I'm going to clear my Kodi history here so to make it super clear what Cody's doing here I'm going to jump into this file it's actually outside the source graph a code base but this is just some example python code it's not really doing anything particularly important but I just wanted to provide some example code so that's really obvious what Cody's doing here and the first thing I'm going to show you is not actually fixing a specific bug but asking Cody to provide me code smells so I can see what's going on with this code I'm going to highlight all of this go into recipes and ask Cody to smell code here it's going to think a little bit and give me top five code smells all right so Cody says I have a broad accept Clause I'm missing type hints I have an unused import I have magic numbers and I'm missing a doc string so all things that conveniently Cody can also help me fix so let's see I'm going to say Cody fix the code smells above Cody should rewrite that code awesome that I can copy and drop in and place that fixes for those code smells and I can also use our newest functionality here that we call fix up where I actually write a command in line with my code and then I highlight it and Cody will make the fix in line so let me grab that same thing I said here fix the code smells above but in this case imagine I'm just writing it right under my code that I want updated highlighting all this and then I'm going to hit Ctrl option slash which is my hotkey for fix up Cody is going to pass that in and it's going to make changes directly in line so here you go it's telling me the four changes that it's made and I can see now I have type pins now I have a doc string now I have a less broad accept Clause Cody has actually gone in and Rewritten my code for me for fixes for that and you can do that for very specific things so you can write hey Cody fix X bug we've also seen this work for very general things so you can say Kodi handle errors better in this code factor out helper functions extract a specific item into a dedicated react component you can use this fix up functionality write that in line highlight it hit the hotkey and Cody will go in and rewrite your code all right so those are the four key ways that you can use Kodi onboarding to code writing code testing code and fixing code and give it a try it's available today both as a vs code extension and right in the interface at sourcegraph.com so give it a try we'd love your feedback and if you'd like to jump into it you can head to docs.sourcegraph.com Cody to get started thank you foreign
Info
Channel: Sourcegraph
Views: 18,293
Rating: undefined out of 5
Keywords: copilot x, github copilot, sourcegraph, codebase, code search, code intelligence, source graph, ai coding, frontend, backend, devops, software engineering
Id: fmir_bUyygw
Channel Id: undefined
Length: 6min 17sec (377 seconds)
Published: Fri Apr 28 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.