Github Copilot is even better with Copilot Labs!

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey welcome back a lot of you showed interest in the co-pilot video that I made a few weeks ago and today I want to show you an extension to copilot called co-pilot Labs it allows for quick translation of code brushing documenting test creation and a variety of other things and it does it in a way that makes the process much easier than if you had to query co-pilot to do it yourself so let's take a quick look foreign so there's a couple things that you need to do before you can get started with GitHub co-pilot Labs first of all you've got to use vs code for this so if you're using a different IDE that co-pilot supports unfortunately right now co-pilot Labs only supports vs code so that's the first thing second thing you gotta have an active copilot subscription if you don't have that it's I think 10 or 12 dollars a month it's really affordable so you'll need to get one of those you can also do a free trial and I mentioned that in my other video about copilot which I'll link to above and lastly you have to agree to the terms that GitHub next puts out in order to use copilot labs this is an additional piece of software so there's some additional terms involved with uh using that so uh this is uh next website and this tells you some of the things that co-pilot Labs can do so code explanation co-translation IDE brushes and test generation so very cool it shows you a little video here some clips of stuff that it's uh it's doing and it's very very cool we're going to look at that first hand so if you want to start using copilot Labs if you have all of those prerequisites met you can come and sign up for copilot Labs here on the GitHub next website so if I click that I'll have to sign into GitHub and it will add you to a waitlist in my experience I didn't have to wait at all it just immediately put me through and I was able to get it but your mileage may vary on that download copilot Labs you need to scroll down until you find a link here you can click on this so you'll see this sign up for copilot Labs button just down here below there is a a link to GitHub well it's actually Visual Studio Marketplace where you can install copilot labs and again this is an extension for vs code once you install that you will have to go over to vs code get the extension installed there which this will link to when you click this install button and then you'll have to sign in and authenticate with your copilot subscription that you already have which will be Associated to your GitHub account or a GitHub account that you're using so once you have all of that done you can start using the tool and so what I'm going to do now is switch over to vs code and show you a couple of the ways that you can use this tool really quickly and how it can make your co-pilot usage much more efficient all right so here we are vs code and once you get the copilot Labs extension installed you're going to see that pop up on your navigation blade over here um or app blade I don't know what they call this thing anyway you're going to see this little icon pop up and when you click it you get four different sections here so you got the explain language translation brushes and test generation and we're going to go through and look at each of those my experience so far is that they've been decent the idea here being that it's basically just a presentation layer for copilot so it does your querying for you in some circumstances but depending on what you're trying to achieve it also has the ability to quickly explain code and translate code for you without you having to query co-pilot to do that yourself with inline comments and things like that so it's pretty cool um now I will say you know copilot is still here it's working as expected so like here I have a uh you know new python file that I just started and so if I were to start writing a script it's copilot is going to work the same way it always did so maybe I do I don't know L1 is equal to an empty list L2 is equal to an empty list maybe we're gonna do like an algorithm for happy numbers or something right so let's say 4i in range and I'll do one two three let's do zero three hundred so again you can kind of see that you know co-pilot is still doing its thing it's giving me suggestions and I maybe I want to use those maybe I don't none of that has really changed uh we're gonna talk about when to use labs and when to just stick with co-pilot all right so again it's not like copilot Labs replaces copilot it just enhances it and it makes some functions of copilot easier to use so if I were to start to write this algorithm out um let's say we're searching for happy numbers between 0 and 300 for example so I can do e or a is equal to I divided by a hundred and B is equal to I divided by 10 minus a times 10 uh and then yeah that's correct copilot working the way that we want to do there let's do s n is equal to zero well that's true a is equal to a the second power B is equal to B to the second power C is uh equal to C to the second power n is equal to n plus one that's true T is equal to a plus b plus c uh and a of T is equal to one then yeah pin and then break if it's n is greater than or equal to I don't know 50. uh the pendulus two um we don't want to pin in though I want to pin I and a is equal to T divided by 100 B is equal to T divided by ten minus eight times yeah one card yeah I mean you know co-pilot again really awesome if you're not using uh copilot you've got to start it's uh it's really great and maybe we do a print of L1 okay so I don't know you know this this is just a basic uh start to an algorithm to calculate happy numbers in a range or to find Happy numbers in a range and write them to the list um this works the same way it always would with copilot so if I do a control enter it's going to come up with additional things that I might want to do um and so that hasn't changed right that hasn't changed at all but we do have the co-pilot Labs extension installed so we can do some other stuff so if I want to go over here and click on copilot labs I can now ask it to explain things so maybe if I highlighted these two list blank list definitions and I go to explain it's going to show me that code that I have highlighted I have some options here right code does the following show example code custom I'm not sure what that does but if I just say explain code oh you can use stops in here too this is an interesting idea right so you can tell it to stop at a certain thing uh and in this case it would be another code comment right in line code comment uh we're not going to go into that right now let's just see what it does with uh L1 equals blank list L2 equals blank list okay so there's the explanation for the code that I highlighted right L1 is the list of the first line of the input which is the number of elements on the list L2 is a list the second line of the input which is the elements of the list L1 and L2 are initialized as empty lists at first that is true right so it was able to then it's not like this is very difficult code to understand but you know for those two things it was able to explain what was happening so why don't we try the same thing with this section okay so the first line is an example of how to print out the integer value of a variable which is zero the second line is an example how to print out the integer value variable which is one so this is not uh accurate all right so this is not what is happening in here we are just defining um some rules in terms of what's Happening inside this Loop um so again your mileage may vary with some of these things let's see if we change this to say code does the following in English what does it do there okay so this one's a little bit closer to what we would expect to see so we say um you know what is this section of our code doing it says it sets the variables TABC and N to zero technically I guess that's true uh it sets the variable I to zero and then to one it adds one to the variable I and then two and so on until it reaches 300 it says the variable T the value of I divides I by 100 and sets the variable a to the result and so on and so forth so this is a little bit closer to what we would expect to see in an accurate explanation of the code if we ask it again does it give us a different result it does so you can see here how there's some variability in the results that you get back and that's kind of the same experience that you're going to get with copilot itself right or any of these other GPT products you you don't get the same answer even with the same query parameters every time because the the algorithm is running a little bit differently each time right the model is processing your query input a little bit differently and so you're going to have to still kind of understand what is going on if you want to you know really feel confident and say turning these into code comments or explanations for a particular part of your script be careful with that you can't just trust that everything it gives you is accurate just the same way as any of the other GPT products as I mentioned but this can be helpful in a situation like this where the developer didn't give you any insight as to what's going on right like say you got handed this this python script you didn't have a clue what it was doing this could give you some idea as to what you may be trying to achieve if I were to highlight the entire thing here and ask copilot what it does it gives you some more context right and it actually goes through and explains all of the section that's happening under the wild true area right so um this can be really really helpful if you don't understand what a piece of code is doing don't rely on it to be 100 accurate but again this is just to give you some context and maybe get you started down the right path this is exactly like what I discussed in my previous co-pilot video where I compared chat GPT and copilot which you know when should you use which in which cases and so forth and again you know the kind of the summation of that video is that you know these things aren't perfect but they get you going in a Direction they can help you with a starting point that maybe you didn't have before so that's how it does explaining code in copilot Labs let's look at language translation so I could take this same code and I can highlight this whole thing and then I can tell it to translate the code so this is really useful because it's just a much faster way of translating code than trying to query co-pilot or chat GPT or something else to do it yourself using inline code comments or of course in chat GPT you know the chat bot interface um so you've got a whole list of different languages here that you can translate to and I found it to be fairly accurate now I'm not a you know real programmer per se um so you know I have to kind of hunt and pack if you will to kind of figure out if these translations are accurate and if you know the output actually works the same way that you know the good code going in does but if we take a look at this as like let's say translate it to C sharp okay and so it took us it took a stab at translating this to c sharp and I mean again I don't know C sharp so I don't know how to know whether this is accurate or not but looking at it the logic that's happening in the code here looks to be similar to the logic that I have in my source python so if you had a need to quickly translate a piece of code and again you don't want to try to throw an entire script in here probably or an entire algorithm or something it's just it's not going to work with a huge volume of information the idea here is if you have bits and pieces of code that you want to use somewhere else maybe you're coding something in a different language and you want to just grab this one piece of logic out of some other source and translate it into the language that you're coding in then this could be a really helpful tool to do that so I could then just you know copy this paste it into another file or into this file or whatever I wanted to do so very cool feature translating code on the fly into different languages and again you know you could do this in copilot you could say Hey you know inline code or inline comment translate this code to C sharp and then it would give you synthesize some solutions for you that may or may not be accurate this kind of does that work for you which is another Time Saver all right so next up on the list is brushes now I'm not going to go through each of these uh because it would just take too long and I don't see a point in fact my code here is not going to be conducive to some of these tools like adding types or chunking for example uh but we can talk about each of them what they do so readable right make this code more readable if you high highlight something and you click readable then if that code was really complex or you know just tough to understand or not formatted correctly then it might be able to help you make it more readable it might put in inline code comments for you to help you understand what's happening add types okay so it looks like it added list in so in this case types must mean like schema types almost like data types in my case uh this is a list of integers L1 so you know maybe that's helpful if you need to know what types of data you're working with in your code I'm going to undo that fix bug does exactly what you would think it would do which would be to find bugs inside of your code so if I had a bug in here somewhere I could highlight the code that I wanted to check I could hit fix bug and it would probably point out any bugs that I had and or just correct them and let me know which ones it corrected debug uh would be you know if the code is very difficult to debug for some reason then it could potentially make changes to your existing code to make it easier to debug I don't know exactly how it does that or what it does in that process but I think that's the idea behind debug clean would be to clean the code up so if you had really messy code maybe you inherited a really messy script or messy algorithm this might be able to help you clean that up list steps is going to be more of like a documenting type function so um if I went ahead and highlighted let's just highlight the whole thing if I hit list steps you can see this little guy spinning up here this is how you know it's working um so list steps it took that entire code block and it gave me an inline comment for every applicable section that if I needed one and so um this is pretty useful right like it just explained the entire algorithm the entire part of this algorithm for me uh create two empty list to store numbers that are and aren't happy interestingly enough it knew that I was looking for happy numbers which I think is very very clever that it figured that out um Loop through all the numbers from zero to 300 store the number in a temporary variable extract hundreds tens and ones place of the number create a counter for the number of steps and then Loop until the number is one or the counter each is 50. that's exactly what is happening right so um very very handy now again make sure you're checking its work don't just assume that it's going to get everything right in your code when you're using this to document or create code comments but you can use it as a starting point nobody likes documenting it takes forever it's it's really kind of frustrating work um and it can add a lot of time to your development process so uh you know I recommend using this it's a lot faster than throwing this over into chat GPT for example and asking it to put in inline code comments and you know it also understands the context of the language that you're in in vs code so if you're in Python and you have your file set to python for example you're writing in Python it's going to know that and it's going to pass that context off to codex when it asks codex to you know put in these inline code comments so um very very cool stuff make robust so the idea there would be to if you had maybe some really condenser like difficult to understand code or sections of code if you make them more robust maybe they would be easier for you to kind of understand what they're doing I think that's the idea behind this one I've not used this one myself but um typically I'm trying to go the other direction and make code uh more efficient and less robust but you know to each their own it's there if you want to use it chunk so if I had a you know really dense code block I could use this chunk function to break the code apart into smaller chunks to make them a little bit easier to digest a little bit easier to read and understand and then document is kind of similar to list steps but I think for document it's going to spit out like uh potentially a one big code comment that kind of explains the entirety of the code let's just undo those previous code comments and let's try document and see what it does here on this huh interesting I don't know exactly what just happened there but uh yeah I I don't have an explanation for that I don't know what this is it looks like it's importing some libraries and things um but if somebody knows put it down in the comments because I'm curious what that is I so I thought document would actually document the code it actually spit out an entire uh set of additional code definitions it looks like so I'm a bit confused by that let me know if you know what just happened there but I think the intent here is the document brush should do something sort of similar to what this steps does and then finally we have custom so custom is the ability to Define your own custom brushes so if you have you know some way of doing something with Brushing in your in your IDE or in vs code in this case uh that this does not handle you can potentially create your own kind of brush definitions here I I haven't played with this I don't know how it works but it's there again let me know in the in the comments if you're using the custom brushes in copilot Labs how you're doing them and um you know what you're using them for I'd be very interested to hear that okay so the last thing that copilot Labs can offer is a test generation function so this is only supported for JavaScript and typescript I actually do have um some other code open over here so that we could test this I have a piece of HTML here with an embedded uh some embedded JavaScript code that creates a spinning Cube let me show you what that looks like it looks like that um so I've got a function in here but my script starts here so what I will do is just highlight this entire script section and I'll copy this out and let's go over and create a new file which is Javascript and I'll paste that in and I'll go ahead and format that and let's see okay so then I've highlighted the entire thing here we're in a JavaScript file now and it says please select a function in order to generate tests so it wants to do a function by function analysis here to create tests which I think makes total sense so if I come here and I highlight uh I can just highlight actually just the word function for this time now Loop it detects the entire function which is very cool and then I can hit suggest new test and then it's going to spit out a test for me a way for me to try out that function now I don't know if this is going to work or not I don't know exactly what the use case for this particular test is going to be but we could try to run it and see what happens could not find in closing package okay yeah that's fair enough um I don't know what it means by that I didn't really expect that to work I have a feeling that you Pro devs out there are going to find a lot more value in the test generation than I do um but you know I can definitely see it being a requirement to have some sort of test cases against your code when you're writing it so this might be able to assist you in creating those and if so uh I would say that's a fairly powerful tool the other thing I want to point out is that each of these sections have a feedback area so you can say you know hey this test is incorrect it's unhelpful or it's great I I recommend using that you're helping them train the models you're helping them improve the features of this product when you give them feedback and so I try to always give feedback when I know what the answer is right in this case I don't know if this is a valid test or not so I don't want to give any feedback because I don't really know if it's it might be good and I just don't know it it might be wrong I don't know so you know when you know use it give the developers something to work with help them train their models and get better so that these tools can make us more efficient so now let's take a second and talk about when to use copilot labs and when to just use straight up copilot first and foremost co-pilot Labs remember it's an extension to co-pilot it is a presentation layer it is a sort of a a set of shortcuts if you will to quickly query codex and use copilot in a more efficient way some things that it uh can do right we looked at how it can explain code translate code kind of clean up some of your code or document your code those are the situations where you want to use copilot Labs because it's just going to be faster than trying to query co-pilot directly to do those things for you so in those situations when there is a piece of functionality in copilot Labs that lets you very quickly do something that copilot could also do that's when you want to use copile Labs if you're looking for an entirely new piece of code for example like if you need a new script to calculate happy numbers between 0 and 300 or whatever the case may be like we just did that's when you would rely really heavily on straight up copilot you would create a new python file put a code comment in there and say I need a script for finding happy numbers in this range for example you could grab those Solutions use them accept them bring them into your file and then you could use copilot labs to document those if they weren't already fully code commented for example you could clean them up because there is some sloppy code out there you know that co-pilot could potentially return to you if you use these things in combination with one another I think that's where you're going to see the best results rely on copilot for what it's best at which is generating new code based on input queries or helping you with particular sections of your code if you have some math or something you don't know how to do allow co-pilot to do that work and then use copilot labs to kind of put the finishing touches put the Polish on the the product that you're outputting so I hope this video was helpful for you I really highly recommend using copilot Labs if you're already using copilot and if you're using vs code as your IDE to me it's a no-brainer to have these things working together and I think you're going to really see some awesome results with that let me know what you think down in the comments let me know about other topics related to co-pilot that you would like to hear about or like to see a video about or maybe an instructional video I'm open to suggestions and uh thank you for taking the time to watch this video uh this is doing it with AI I'm Daniel Lemay and I will see you in the next one cheers [Music]
Info
Channel: Doing It With A.I.
Views: 7,468
Rating: undefined out of 5
Keywords: copilot, github, ai, gpt-3, gpt-4, chatgpt, ide, development, machine learning, ml, javascript, python, artificial intelligence, vscode, visual studio, efficiency, code, software development, software
Id: SObHvP_8qRo
Channel Id: undefined
Length: 27min 2sec (1622 seconds)
Published: Mon Mar 13 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.