Github Copilot vs. ChatGPT: Which one should you use, and when?

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey everybody Daniela May here with another episode of doing it with AI we've all heard of chat GPT by now it's been all over the news I've made a couple videos on it it's been all over LinkedIn and other socials but let me ask you how much do you know about GitHub co-pilot it works in the same technology slightly different model but it is a must-have tool even for entry-level developers so if you haven't heard of it sit back prepare to have your mind blown because this is some pretty amazing stuff stay tuned so like most of you the more I dig into this technology the more it just amazes me and just captivates me and I started looking into other AI Technologies because this channel is all about using whatever AI Technologies are available to make life easier more efficient and just more productive and so I stumbled across co-pilot which has actually been around longer than chat GPT has but I don't see nearly enough people talking about this amazing tool so co-pilot is a tool that you can get from github.com and it is a augmentation to your favorite IDE an IDE would be like vs code neovim visual studio if you're a full-blown developer and it gives you some additional features so think about intellisense intellisense will tell you if you are missing a character like a comma or a bracket it will tell you if you have modules missing or libraries missing it will tell you if you're using a function that doesn't exist and it'll show you it'll kind of highlight all the different areas within your code where you have issues and it does have a suggestion tool as well to kind of say hey here's some possible ways you can fix this problem well think about copilot as that only more right so what it does is it actually based on what you're putting in gives you suggestions on how to complete the code so think about like when you're on Google and you're typing something in you say how do I and then Google shows you a bunch of suggestions well this does that but for code and that's a really really powerful idea now I'm not suggesting that you use this instead of chat GPT they each have their own use cases but this is a video about using the right tool for the job and that's why we're going to do a comparison between chat GPT and copilot I'm going to ask chat GPT to write me some Powershell and then I'm going to go over to vs code and I'm going to have copilot help me with the same Powershell script and we're going to see which one is quicker at that and more efficient and then we're going to just talk about what the implications of what we find are first thing I want to show you though really quickly is co-pilot's website to give you a better idea of how to get the tool how to install it and what it'll work with so let's take a quick look over at github.com feature slash copilot you can see here it says it's your AI pair programmer copilot uses the openai codecs to suggest code and entire functions in real time right from your editor so that's kind of exactly what I was describing they show you some very cool examples here we have something in typescript we have something in Python and what looks like Ruby or something and so it kind of tells you a little bit about it trained on billions of lines of code it turns natural language prompts into coding suggestions across dozens of languages indeed it does I have been blown away by this tool and the things that it can do so again it's it's very similar right it can handle natural language inputs and it does that by looking at your inline code comments so you can write a code comment and then hit shift enter and go to the next line and it'll give you suggestions if it can for the things that you've typed so you can literally describe some code hit shift enter and go to the next line and it'll give you some suggestion suggestions for that code so if you want to get this you can do a trial for 60 days with no charge and after that you can do 10 bucks a month or 100 a year which I think frankly is an amazing deal you know again this is a video for people that are dealing with scripting or development if if you're just a regular business user you may not get as much value out of this but if you are a tech viewer and you're somebody who works in you know infrastructure maybe you're a CIS admin you're dealing with Powershell on a regular basis or you're a you know full stack developer and you're dealing with all kinds of different languages this is going to be an amazing tool for you so with that said why don't we hop over here to chat GPT and start asking it some questions write me a Powershell script that connects to SharePoint online grabs a list of site collections and then for each site collection creates a list of the document libraries within that site collection okay so GPT doing its thing as usual it's probably going to give me some really decent advice here um okay well I say that it's wanting to put my password as plain text that's hmm questionable okay get a list of site collections iterate through each list of site collections get a list of document libraries print the name the document Library okay so from there what I'm going to do is say instead of printing the name of the document library in the console export the list to an xlsx file okay so now it's going to modify the script and hopefully give us something that we can use to export this to xlsx okay iterating through the site collections adding the document Library information to the array and now we get to the export piece okay so see one thing that it did wrong there is it says that it wanted to export to an xlsx but the path that it gave was in the root of the C drive and actually is a CSV so it says you can open the file using Excel and save it as xlsx format that's true I guess you could do that I mean that's one way to do it what's a way to save the document libraries output as xlsx without having to open the file okay so I may have violated their content policy they probably think I'm trying to uh create some malware or something like that which is not the case of course okay so this time it did it did what we wanted and it's telling us that we have to have the import Excel module installed and uh you know have the necessary permissions to write to the root of the C uh Drive so um yeah that's that's kind of interesting right so let's talk about this for a second so some of the things that it did well that I that I like about doing using chat GPT for this purpose it told us reasoning behind what it did right not only did it code comment each of the sections of the Powershell script but it followed that up with an explanation saying Hey listen the way that I wrote this requires that you have additional modules and uh if you're running Powershell version less than 5.1 then you're going to have a slightly different module that you're going to have to use that's helpful information right so that's one thing about chat GPT that I really like one thing that I don't necessarily like is the length of time that it took to actually do that and I know that may seem kind of petty considering that if I had wrote this script myself it would have taken much much longer I also don't really like kind of how it did some of these things uh converting this uh the password you know plain text in the script I'm not thrilled with that but you know it's not the end of the world it did what I asked it to do so uh you know all in all pretty impressive really impressive I mean let's be honest so here's the thing if you're a developer you are going to spend a lot of time in chat GPT asking it to iterate on scripts and give you different options on how to do things and such and so forth and that can really add up in time you have to sit there and wait for chat gbt to do its dialogue thing or it's typing everything out and so in my opinion co-pilot is actually a little bit better equipped to handle this so why don't we go over to co-pilot and take a look at how it would do the same script first I'm going to try to get it to generate the script just by typing in the uh code comment and seeing what it comes up with maybe it'll write the whole script for me that'd be pretty cool if that doesn't work what I'm going to do instead is I'm going to look at the script that chat GPT gave me as the source of information and then I'm going to tab through in copilot and show you just how rapidly you can actually spit out code with copilot and the Assumption here is that if you're a developer and you're somebody who's really comfortable in Powershell you're going to be able to kind of crank through this because you're going to know what's coming you're going to know what needs to come next in your script but you can't type as fast as you can tab through things and tab is the way that you complete a line or complete a suggestion that's coming from a copile so let's head over to vs code and let's take another look at this okay so now we're on vs code and one thing I want to mention right away is you are probably sitting at your desk going but Daniel you didn't check if the code works or not you're right I didn't the code may not work that chat GPT wrote for us pretty good chance there's an error in it and I did that on purpose I did that so that when we come over to vs code if we end up bringing some of that code that uh Chad gbt wrote for us over here it'd be kind of neat if intellisense would tell us hey actually you know this is where your error is or maybe co-pilot would say yeah this doesn't really work this is a wrong function or something here's a different one here's an expression that will actually work for you so I'm going to open up a new file I'm going to pick Powershell as my language so that it knows what we're working with and I'm just going to start with a comment so in Powershell you can use the pound time for comments so I'm going to put a comment in here and then what I think I'll do is just paste in the same uh the same original query that I put into chat GPT and we'll see what it does with that all right so I put that in as you can see it's just all one big line I think I'll just go up to view and turn on word wrap so we can see it so write me a Powershell script that connects to SharePoint online grabs a list of site Collections and then for each site collection creates a list of document libraries within that site collection okay I'm just going to hit shift enter okay so the first thing that it's suggesting for me is another comment the script should then output the site collection URL the document Library name and the number of items in that document Library yeah okay I mean that's not really what I'm hoping to do but it's interesting that that's sort of the next logical step that it thinks I might want to take and it's giving us some suggestions here that I really want to point out to you so the alt uh brackets if you press alt and then the close bracket it'll go to the next suggestion that it has queued up for you or alt an Open Bracket will go to the previous suggestion if you like a suggestion that it's giving you you can hit tab which accepts that and then writes it out or you can hit Ctrl enter which opens GitHub copilot so if you open up GitHub copilot you can see it says synthesizing zero of 10 Solutions now here's what's really interesting if I open this up and I start to scroll down I can see that it's coming up with solutions for me to look look at and I'm going to expand this out a little bit for you so what it's done here is it has gone through and it's read my natural language and it said hey based on all of the experience that I have for lack of a better word based on all the knowledge that I've gathered in in building this model out here are the possible acceptable solutions that I'm going to give to you and if we start to look through this this is actually really really close to what chat GPT wrote for us as well so in chat GPT it uh it wanted to import a module for SharePoint uh for Powershell which this one does it then connects to the SPO service which this one does it uh has a list of site collections it has a variable for that which it calls the get SPO site commandlet to populate and then it creates an empty array and that is another variable an array variable and then it Loops through each site collection in the site collection list and it starts doing some stuff with it right and then down here it gives us some information scraped from either GitHub or from some other repositories online that they use to train the model and what's really cool about this I think is that it gives you some context as to how the AI model actually works it's able to process the natural language that I gave it and then go out there and find examples of things that are similar it's even pulling in the comments from that repository uh like maybe it's in the readme or something like that most likely it's just inline in the script in this case but I just found that fascinating the first time I saw it I can actually see you know the creator of the script I can see what they wrote and what their intention was and again right it says seven of ten Solutions and so if you scroll down through here um you can see a whole bunch of other possible solutions and a lot of these things here are just comments which um I guess the intention here is to be able to grab these and then do some additional work with them but in any event this is very interesting here's some more comments down here if you want to include the site collection URL you know someone named Chris put this together so anyway pretty fascinating stuff and if I wanted to accept one of these I can just go up here and hit accept solution and boom it's going to bring it in so pretty powerful right I can then kind of cut this stuff out obviously I don't need all of that in there so I can cut this out and then this could be a Powershell script I could go ahead and save this as a PS1 or whatever the case may be and you know test it out and see if it works um really really powerful stuff now that's pretty cool but what if you don't have that information available right uh like what if um there are no Solutions it doesn't know what to suggest for you because no one has queried it in that way before well I'm going to show you kind of what the natural kind of flow of things would be most likely if you were a developer and you were just kind of trying to hammer some stuff out so over here on the right side of my screen I'm looking at the code that uh chat GPT wrote for us and so what I'm going to do is just start typing things and I'm going to show you how quickly it's going to suggest new lines to those things so the first thing I'm going to type in is the username variable so username equals and then if I stop it's going to give me a suggestion so it's a username equals well what maybe it equals a username well in our case it's you know username at domain.com all right and then I'm going to go to the next one and look before I can even finish typing it knows that okay you've got a username you're probably going to want a password right so I'll just hit Tab and that's going to auto complete that line for me now if I go back a little bit anytime you can see just a piece of the suggestion left remember you can hold alt and you can start hitting the left and right bracket keys and that's going to iterate through the different suggestions that it has for you in this case this is the only one that it has but in a second we will see uh something different so in our case we don't want to use just the password string right we want to use that convert to and in this case what's really interesting is that now we have vs code kicking in so you can see how these are really companions to each other right intellisense and the suggestion functionality in vs code is a really great companion to what's happening with copilot so where this leaves off copilot kind of picks up so I'm going to say convert to and then yeah down there is secure string so I'll do secure string and then again now copilot is kicking in and it's saying oh well maybe you want to do Dash string password as plain text Dash force and that is what I want to do but even more interesting is that I'm looking over here at the chat GPT version of this script and it doesn't have Dash string in there so that might be the very first place where chat GPT kind of falls short in writing the script it may have been missing that that string parameter string flag and I'm probably getting these names wrong right like the noun the the noun because Powershell is like nounvertebrate so the the string noun may have been missing so that may not have worked so I'm just going to hit Tab and finish that line and I'm going to go to the next line and look it's already suggesting that I'm going to need a credential variable and it's actually it's right because if I'm looking at the chat GPT version of this um it doesn't say dollar sign credential it says dollar sign cred but everything that comes after that is pretty similar it's pretty similar but I'm going to try iterating through some things so here I go I'm pressing alt and right and left brackets and you can see that it's offering me different suggestions so if I'm a developer and I know that there's a specific command LED or specific function or something I'm trying to use in whatever language I'm coding in that first suggestion may not be what I want but if I want to start you know just alt bracketing through these things I may be able to find the thing that I actually do want and that's pretty cool so in our case we're going to go with this one uh system.management.automation.ps credential I'm going to tab that out I'm going to hit enter and then um it's it's saying I need a session variable uh this actually is pretty common uh you'll see a lot of session variables in connecting the SharePoint online or any of these exchange online or any of those apis for office 365. so um you know this is pretty cool what other suggestions does it have okay none now if I'm looking back over at uh the chat GPT version of this script it doesn't do that it stops at cred and then it just goes down to site collection so let's just do shift enter a couple times and I'll do site collections and I'm going to hit equals and then again here it goes it starts suggesting things again so what I'm going to do now is I'm just going to show you kind of the rapid rate that you can tab through these things and just imagine that you're a developer you may not have to imagine you may be a developer just imagine how fast your workflow becomes if you do it this way so check this out and I'm not going to speed this up this will just be in real time all right so you kind of get the idea right it's it's pretty fast um I'm not going to embarrass myself by uh showing how bad I am at power show um but you get the idea it's it's gonna be if you know what you're doing or kind of know what you're doing this is gonna just really speed up the process of scripting for you and what I want you to remember is that you know the first example we showed we commented and we put in some natural language text of what we wanted you can do that at any point in here so you know it's probably the case that I know certainly in my work I don't necessarily know every single function or you know every single possible thing that could come next in my in my code or in my script so if I don't know what's going to happen next then I can simply put another code comment in and describe just the very next thing that I need to have happen and it's going to go back out there to all of its information that it has stored in the model and it's going to try to find the closest match and suggest it to you I guess the point that I'm really trying to drive home to you is that if you're a developer or Junior developer or senior developer it doesn't really matter this is going to speed up your development process 100 guaranteed it's going to speed it up it's going to get you over those hurdles it's going to get you to your goals faster and it's going to probably teach you some things I know that just kind of playing around with the tool I've learned some things about Powershell I've learned some things about JavaScript and python because you know just seeing things in action is helpful and if you were to have to go out to stack Overflow or to GitHub and do Google searching or Bing searching and try to find all these different scripts that do different things I mean it's going to take you forever right even just as a tool that's going to go out and do that searching for you and make all of that available and quickly import that script if you find one that works that matches what you're trying to do you can import it super quickly as we just saw I mean that alone would make this tool awesome but the fact of the matter is that it's doing that on a line by line basis or even an inline basis right where you're in the same line you're typing things out it's going out and saying okay what references do I have for this specific function or expression that's being put in and so it can do it on like a micro or a macro scale right you want the whole script great it might be able to find you an exam you just want one little section it can find you an example of that too and it's predicting what you're going to do next so when we started the video we talked about right tool for the job if you are writing scripts if you are writing code co-pilot is going to be the right tool for that job if you are a business user and you don't have scripting a scripting background or a coding background then you can start with chat GPT see what it suggests and then do some iterating there if you want to take what chat GPT gives you and then throw it into a tool like vs code and if you have you know if you don't have copilot that's okay you have intellisense it might be able to help you solve some things that chat GPT did wrong but if you do have co-pilot then I mean you've got an amazing set of tools in your tool belt to get you to where you need to be without having all that prerequisite knowledge that a developer a true developer is going to have so with that said thank you for joining me on another episode of doing it with AI and we will see you next time where we're going to talk about custom connectors and how we can use some of these tools that we looked at today to build custom connectors to the open AI Services how we can make Power Platform a little bit more integrated with some of these things like DaVinci and the different models that are available out there through the open AI apis so looking forward to that video hope to see you there take care [Music]
Info
Channel: Doing It With A.I.
Views: 16,521
Rating: undefined out of 5
Keywords: ChatGPT, Github Copilot, AI, language model, OpenAI, machine learning, natural language processing, code generation, coding assistance, developer tools, programming, software development
Id: ORZZbxKNeUI
Channel Id: undefined
Length: 26min 33sec (1593 seconds)
Published: Tue Jan 31 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.