Pair Programming with GitHub Copilot | Learn to Use the GitHub AI

Nuno from DataCamp shows how to use GitHub Copilot and Copilot Chat for coding and data analysis. The tools generate code from comments, autocomplete functions, write tests, and debug errors. He covers best practices like concise prompts and reviewing suggestions, plus limitations like hallucinations that need human oversight.
Chapters
Welcome to this code along. My name is Nunu. I'm here to show you how you can pair program with GitHub Copilot. Maybe starting with the question why me? I have a set of slides that I will bother you with for the first minutes and basically a quick introduction on my end. I'm Portuguese, living in Belgium. I'm an engineer now at heart and like Richie mentioned, I've been building products for more than 15 years. So today, as director of engineering at Datacamp, my day to day involves overseeing the engineering team at datacamp that is responsible for the learning experience, but also support the whole organization by ensuring the engineering teams have access to the tools they need to do their job, ensure that the teams follow the best practices, ensure the teams are productive and efficient and here's the connection to GitHub Copilot. I believe that GitHub Copilot is a tool that can enhance the productivity and efficiency of the people who code. It can help you to follow best practices and basically can help you to do your job faster. So it shouldn't be surprising if I tell you that we use GitHub copilot@datacam to build products. And that's why I'm here to talk to you about GitHub Copilot by the end of this session. I hope I'm able enough to help you understand how and when AI pair programming can benefit your workflows. I hope you can learn about the features available in GitHub Copilot today, and I hope that also you can learn how to use GitHub Copilot for data analysis. I'm going to do one myself. There's a few caveats there. I'll cover that later. This session is beneficial for you if you are a software developer. Of course GitHub Copilot can speed up your workflow, can help you generate boilerplate code. You can get suggestions to complete lines or blocks of code as well. It's beneficial for data scientists. You can quickly generate code for data preprocessing, some visualization and also analysis, and obviously for students and learners. GitHub Copilot can be a learning tool. It can provide code examples and help you understand how to implement certain functions or algorithms, or even explain certain parts of the code. So basically it's beneficial for anyone in a role that requires you to code. Now, important before we start is to know how to get access to GitHub Copilot. As you heard, you need obviously a GitHub account, but you need more than that. You need to actually enroll on GitHub copilot. You can visit the page that I've linked here so githubcopilot.com settings copilot or you can click on your profile picture on the top right corner on any page on GitHub and then you should see on the menu a link called your copilot. If you don't find it, go to your settings on the left side menu. You should also see a link called copilot. Okay for individuals. Obviously there's a subscription, but there's also a one time free trial so it's ideal for today. If you never did the free trial with Copilot, you can enable this one. Also, if you're a verified student, teacher or maintainer on a popular open source project, you can also get Copilot for free. If you are in an organization, you should ask for a seat to your admin to the admin on your organization. I also recommend that you check if there are any policies around using GitHub Copilot. Some companies have them, so please do make sure you check before you start using GitHub Copilot. So I'll bother you for a few more minutes. I hope you can have time to set up this so you then can follow along. Now. What is GitHub Copilot? There's a quote from GitHub themselves. They say GitHub Copilot is your AI pair programmer that offers autocomplete style suggestions as you code. Let's decompose this. Let's start with AI pair programmer. What is pair programming? Well, pair programming is a very known technique where two people can be more but normally two people work side by side, can be physically or they can join on a video call and they jointly produce code, they review code together or they continuously exchange feedback about the code or the solution to solve the problem they're trying to solve. There are many benefits from doing pair programming. It can help you improve the code quality, it enhances learning and skill development, enables fast problem solving, so productivity and forces creativity as well. Besides that also has many team benefits, improves the team communication and so on. Because of all these reasons, pair programming is a best practice in the industry and it should happen often. Now GitHub is suggesting that you can always have by your side an AI pair programmer not to replace the pair programming that happens today between humans, but but rather to have this tool that is always available for developers. So you can always have by your side this virtual pair programmer and benefit from the same advantages that you have or some of the advantages that you have when you pair program with a human. Now, how does it work and what are these autocomplete suggestions that GitHub mentioned? Now let me start to explain you how GitHub Copilot integrates directly with your editor. It's available for these four major IDEs, Visual Studio Code, Visual Studio, the JetBrains, IDEs and Neovim. I'll show you later how to install these extensions on Visual Studio code, but it should be very similar on the other IDEs. How does it look? Let me cover two features, the two main features I want to cover or the two main extensions. While you're coding in your editor, GitHub Copilot will make suggestions to complete the code. As you can see here on this gif, it basically gets the context from the file, the comments around it, what you try, what you're typing, and automatically makes a suggestion to complete that piece of code, block of code. You can choose obviously from different suggestions and you can iterate. You can reject or discard suggestions as well. You can generate different bits of code, it can generate function full classes, boilerplate code, or can just help you to make an import or name a variable. Like I mentioned, it's very interesting also to generate to let GitHub copilot generate code from your comments. You can just add a comment and GitHub copilot will make a suggestion for a function or a piece of code that you're describing with that code. It can be very helpful to refactor code and fix code in line and also generate documentation and tests. These autocomplete suggestions are done directly in the code editor, but I wanted to show you another functionality which is called Copilot Shot. You can also have on the left hand side and this is an additional extension that integrates directly as well in your editor. It's the Copilot chat extension. This is a powerful chat. It's powered by GPT4, but it's trained to answer any questions related to code or related to GitHub itself or your IDE. For example, you can ask how to modify a certain setting and it will help you to do that. This is a very interesting feature that can give you suggestions about your code. You can use it to discover new packages, to learn about new programming language and frameworks, to talk about basically anything related to code. You can learn new techniques, explore best practices, basically have a discussion with these assistants, but only About Code or GitHub or IDES. If you ask the meaning of life, it won't help you there, this is pretty cool, but how does this magic happen? Another quote from GitHub themselves. They say trained on billions of lines of code, GitHub copilot turns natural language prompts into coding suggestions across dozens of languages. Okay, let me try explain this very high level. I'll try to do a quick explanation. Basically when you're coding and first step, when you're coding, when you're typing, GitHub is collecting all this information about your file. It analyzes what you're writing. It considers the name of the function, the language syntax, the code structure, the cursor position, the comments section string, literals, everything. Then it sends this information to GitHub copilot service and on this server, what we are calling here the AI prediction. This service uses OpenAI Codex model to predict what is going to be the next piece of code. This OpenAI codex is a powerful AI model that is developed by OpenAI and here note if you don't know. GitHub is owned by Microsoft and as you know, Microsoft has a close partnership with OpenAI and so GitHub is benefiting as well from that partnership. This model, this OpenAI codecs, it specializes in understanding and generating human like code. It's kind of an evolution of GPT3 model, but it's tailored specifically for programming so it can interpret instructions written in natural language and translate them into code. So this makes coding very accessible for people who are not expert coders or they might not know the language syntax. This model can then write a variety of programming languages, it can automate repetitive tasks, it can even write some complex algorithms. And it does this because it was trained on the vast array of code from publicly available sources, including code repositories on GitHub. And you can see how useful is for GitHub to feed all this data. And because of this, it has a broad understanding of coding patterns, practices and languages. So it can be very versatile handling a wide range of programming tasks, from small code snippets to more complex programming structures. Well, this is basically the meat, the core and the magic. The prediction is then sent back to your editor and you will receive maybe actually one or more suggestions for the next piece. And over time it can also adapt to your personal style, depending on your engagement with the suggestions. So if you always reject certain type of suggestions, over time it will adapt and stop giving such suggestions. So this is more or less the high level how GitHub Copilot is working under the hood. So you notice we talk about OpenAI codecs as being key for GitHub Copilot and how it works. So maybe you might have the question, why not ChatGPT instead? Well, we can compare GitHub Copilot with ChatGPT, but they are designed for very different purpose and they excel in their respective areas. ChatGPT was designed to provide information, answer questions and assist on a variety of tasks and engage in a dialogue across a wide range of topics. So it's kind of a generalist. GitHub Copilot, on the other hand, is specialized. It was specialized, designed for coding assistant. It helps to write and complete code. So it's specialized. And also GitHub Copilot is strategically integrated with the IDEs, right? So it can be easily part of your workflow. So when comparing ChatGPT with GitHub Copilot, you need to remember generalist versus specialized. Because I may not have time at the end of the code along, I want to highlight already the benefits. And here I want to highlight three points. Productivity, learning and quality. So the benefits around productivity is because you can code faster, can help you to code faster, you can spend less time on boilerplates and repetitive code, you can spend less time debugging, it can help you to fix code. And this gives you more time to solve with creativity, more significant tasks than the daily and or repetitive tasks. Now for learning, it can be helpful if you're learning a new language or framework. GitHub Copilot can provide real time examples, it can explain pieces of code and it can suggest in that language or framework pieces of code. So we could help you to learn as you code. Obviously it can help you to solve a problem if you're stuck, you can write a comment and describe what you're trying to do. And GitHub can help you to get unstuck and with time and because you can explore different approaches and it can give you different answers over time, you can learn from how to solve the same problem in different ways. And then quality, like I mentioned, because it's trained with millions of repositories, it looks into different coding patterns and practices, you definitely can benefit from that learning. You can benefit from introducing best practice in your code. It can improve your quality, it can help to reduce errors and look into security vulnerabilities. Here there's a note I want to give. There's a complimentary add on the GitHub Advanced Security. It's quite interesting because it can integrate directly with GitHub Copilot. It's a different product, but if you're interested in security vulnerabilities. I recommend you have a look into that one. And now some best practice and tips. Now promise this is the last slide that we going to code. I want to give a big reminder that GitHub copilot is this. It's an amazing tool, but it's a tool to assist you. It's not to replace you. It's not there to make your. It's not that. It's there to make your job easier, but not to do your job you right. You can for sure enjoy a cup of tea more frequently, but you still need to understand what you're doing right. It doesn't replace your peers as well. So keep work close to them and learn and mentor them as well. But it's important to understand as a best practice on using Copilot that there are limitations. GitHub Copilot is. It's based on patterns that it finds on the training data. So it's definitely more effective in common coding tasks. And it might not always provide a solution for unique or complex problems. So we might not provide a direct solution for your unique problem. So there are limitations and obviously because of these limitations and the way it's trained, make sure you always review your code. Review the code that GitHub Copilot gives you. It's an AI, but still can make mistakes, can hallucinate, can give you more code than you need as well ensure the code is actually correct. It works, it fits what you're trying to achieve. It fits your coding style as well. Like I mentioned, be aware of unnecessary code. There's I noticed that GitHub Copilot has this tendency on giving more code than you need. So pay attention to that. Always aim for simplicity and efficiency on your code. Obviously and because of this, because you need to review the code, you need to understand the limitations. GitHub Copilot is not the replacement for coding education. You can go quite far without knowing much, but definitely it does not replace the need of understanding the code that you are accepting from GitHub. It's important to understand the code you're writing. It's important to understand that it fits. It's actually working as it should work. It does not substitute learning how to code. And if you're looking for a place to learn how to code, datacamp provides very interesting programming courses. Make sure you have a look. I look very much into security, obviously and one tip that I give always when tools that send data to third parties is to make sure that you never input sensitive information such as passwords, API keys and so on. So when you're using GitHub Copilot, make sure you take a look into that. It's a good security practice and be a bit more practical. GitHub copilot works better with concise comments. So if you're stuck on a problem, write a comment, but describe it in a concise way so it can provide you a code snippet and then you can iterate from there. And this is actually another practical tip. Iterate. The first suggestion might not be what you're looking for. You can iterate and I'll show you how it is done. All right, enough. Enough with slides. Let's go. I'm going to move into my other desktop and let me start by actually giving you a couple of caveats here. I'm going to abuse on the usage of GitHub Copilot. Okay? To just to demonstrate the capabilities on a normal situation, you should program a bit more. You should code more. Okay? Also, don't pay much attention to the code that I'll be using. It's not the most beautiful code. Don't judge me with that. Also another notice what we're going to do today. I'm going to do a simple stock analysis. Do not use the content of this analysis to make decisions about investing in stocks. Make sure that you always do your own research or even consult a financial advisor before investing stocks. Remember, investing involves risks, including loss of capital. So be careful. Another caveat is that GitHub copality is changing rapidly. These features, especially if you're watching this record later, the way these features work, what I will show it today, it might change tomorrow, it might be outdated very fast. The landscape is moving very, very fast. And definitely GitHub is investing a lot on improving Copilot every day. I guess that's it. Let me show you how you can install the extensions. I'm using Visual Studio code to install the extensions. You can just look on the marketplace for copilot. There are two extensions that I recommend you install. I Recommend you install GitHub copilot. This one, you're gonna need this one. Look for the one that is verified by GitHub. The ownership was verified and also the GitHub copilot chat now. These two are the ones you're gonna need for today. Obviously you can see here that I already have them installed. Okay? But like any other extension, if you come to the extension here instead of saying uninstall, it's gonna stay install. Install both of them. Install first the GitHub Copilot and then install the GitHub Copilot chat. Go ahead, do this. Once you do this, you might be prompt to log into GitHub and this is why you need a GitHub account. This is why you need to have the subscription for GitHub Copilot. Okay? It will verify that, so make sure you log in. I already have done that, but it should be very simple. You should see a prompt on the bottom right corner to login into GitHub. Okay, do those steps. Meanwhile, I'll go around and show a bit more of the UI of this chat. So right now I have absolutely no files. And what I want to show you first is the GitHub copilot chat. So once you install it, you might find it here on the left menu. Like I mentioned, this is a chat just for coding or to ask questions about your editor. For example, if I ask how do I change the theme of my code editor, it should tell me how to change the theme of Visual Studio code. He understands the context. He knows we're using Visual Studio code. Another caveat that actually I didn't mention. This is a macOS version, so commands that I mentioned might be slightly different. Different. Okay, all right, let's start this analysis. I want to do a plot and I want to understand, I want to explore data, stock data. I don't know which library I might use. So let's. Let's ask Copilot what is the library we can use? So I'd like to do some stock analysis in Python. Let's win in Python. What package could I use to get the stock data right? So, All right. This already giving me an answer. It's telling me that it's common to use this package. Yahoo Finance. It matches, it makes sense. It's even telling me how I can install that package. This is great. I might have to have this package installed. It's also telling me, give me a small snippet, a small example and how can I do. How can I get that data? All right, I don't have a file yet. I think if I click here, yeah, it doesn't work. So let's copy. Let's create a new file. Let's call it stock. All right, we have our code. It seems that I'm having an error here. You will always have the possibility here to call as well some of the code copilot functionality. In this case, I can ask to explain me this piece of code or help me to fix this. This piece of code, if I ask to fix inline is Telling me to resolve the EC issue. It cannot find this, this package. I need to do PIP install. Yahoo. Finance. Let's do that. I'm gonna get my terminal here. PIP install should be fine. Okay, let me see if it works. Yeah, it works. All right, because I'm gonna hit Yahoo. Finance API. I don't want to call for like, wait for two minutes for this to return. So let's just ask data from the last month. So let's say until yesterday. Okay, 19. Okay, let's see. There you go. We have our data frame. You can see that each line has. It's. It's an entry, so it's a day. It shows me the open price, the high, the low, the close price and also some, some volume. Cool. I think we have the data. I think I want to make this dynamic, this, this, this, this state dynamic. So if I open tomorrow, I can see data of the last, let's say 30 days. Let's use command I to call the inline copilot suggestion and ask something to copilot. I'm going to ask it. Change the window, the time window to be last 30 days. Let's see. All right, let me close the chat so you can see the diff. This is how it's presented. A suggestion is telling me let's replace with this piece of code, as you can see, is importing a new library. It's going to need date, time, and it's creating the code that is needed to dynamically calculate or give a window for the last 30 days. This looks good. If I accept it immediately, it's part of my code base. All right, let's run this. All good. If we look into the data, it seems to be fine. It starts on the 22nd of January. Looks okay. Now this is actually using, I guess the Apple stock. Let's use the stock that makes more sense to us because we're talking about AI and Nvidia has been in the news. So let's replace with Nvidia. Replace with Nvidia. I don't know. What's the symbol? Nvidia symbol. Let's see if it knows. Okay, seems to be this one. Let's see if everything works. I'm going to accept it. And it seems we have data. Perfect. All right, now I want to see this obviously in a beautiful plot. I don't know what plot library I should use. What library should I use to generate a plot to display stock data? Let's see. What is the recommendation? GitHub Copilot is thinking. Okay. All right. We Already start seeing here some common libraries. Matplotlight Lib. It's already giving me as well a piece of code here I can use. This is one way to get it. Another way would be I can write a comment for example in my code that will say generate a plot that displays the stock price per day. Okay. Import. Great. This doesn't look right. So obviously the import should be at the top. But it's just. Let's see if we run this if we get anything at all. Well, this display on my second monitor, I'm going to push it here. Actually it's putting the price right. It's displaying a plot very simple. Just with the close price it's okay. But I would like to actually replace this with a candlestick. With a candlestick chart. Candlestick charts. In stock analysis it's very common to be used kind of to also to predict the future price movements. The concept is quite simple. If when the price at the end of the day it's lower than the price when it's open it will should show red. When the the opposite when it's higher than when it's open it shows green. So let's see if GitHub Copilot can give me can give me this. Replace this code with a candle stick chart that shows let's say just a candlestick sharp. Let's see if it's smart enough. Okay. It's replacing the my library with a different library actually with matplotlib Finance it's specific. I already know if I don't know. Let me accept this and let's asked to explain this. You can also right click and go to where do I have copilot explain this and opens the chat and will explain you. What is this? This library for example, it's explaining that is used specifically for financial data visualization. Okay, let's run this code and let's see what we get. All right. There we go. It's not necessarily what I wanted. I want colors, right. I want it to be kind of more pretty. I like plotly. Let's see if we can generate one with plotly. Let's use plotly to generate a candle stick chart. Let's see what this give us. All right. You can always like I mentioned this cart or ask for another suggestion. I just asked for another one. Let's try to use this this one again. Imports always put it here. I like imports at the top. Okay, let's go for it. And now let me go to my browser because this will be in the browser actually and it went to a different window. There you go. A candlestick graph is showing me red because the price was lower. Perfect. Last 30 days for NVV are here. Here I want to show you how GitHub Copilot can help you to fix errors. I'm going to remove this print and I'm going to on purpose, not show, not render, not call the action function. So if I run this code, nothing happened. If I ask now how to fix, fix. And there's. There are a few commands you can do, slash, flick, fix or explain. But also if you just use natural language, fix the code for me. It will use the same, actually the same. The same command. So you can see here that is actually it's doing something weird. It's fixing. It's calling the function, but seems that it's moving the. The. The import. I don't really like this. I'm gonna discard. Actually, I should have generate another one. Fix this for me. Let's see if it's. No, I don't like this one. Okay. I like this one. It's just fixing that. Perfect. And it should be working. There you go. It's working. All right. So what else I want to show you. Let's try the autocomplete, for example. If I want to create the function, you can see that it's automatically trying to autocomplete for me based on what I have already in my code base. And I replace basically this functionality with a function. Perfect. Love it. Now let's create another function that plots stock data. Perfect. Let's see if it can generate the rest of the code for me. Okay. And not really. Okay, never mind. I can also fix it myself. I should know how to code, right? All right, now we're putting this into functions. One thing I want to show is when you can also generate comments. So if you do docs, you can generate documentation for functions and for classes and so on. As you can see here, it's generating documentation for me right now. Perfect. Now this is a very simple data analysis. We can go on. Let me check on time. I think we don't have much more time, so I want to show you. For example, if we. If we try to do another analysis, I want to do a simple moving average. Simple moving average. It's kind of nice. It smooths the price data and helps you identify the trend of. Of the price of. Of the stock. For example, if. If the simple moving average is below the price on that day of the stock, the. The close price, it indicates upward trend and the. The inverse. So when the simple moving average is above the close price, it's actually signaling a downward trend. So let's try to maybe create a simple moving average function. It's kind of not giving me anything. So let's fix this by saying generate simple moving average for the stock price. Okay. You can see here that it changed the function. I should get data and a window and based on that window and it will calculate the simple moving average. All right, let's accept this one. And this is good. Now I want to generate a different. A different figure for this. So let's say that we want to plot the simple moving average so we get the data and. Okay, it's already giving me a suggestion. Let's follow. Let's see where it goes. Okay. Figure show. So we are adding a trace. It's showing the close price I do need here because it's only showing me the close price I need to add as well the single moving average. So let's get it. We with this. Let's say it's 50 days and let's add another trace so we can compare both. So add trace. Perfect. Let's see if it works. Let's use the same data. So we need to get the plot data. Let me check. Plot. Okay, perfect. No, that's not what I want. Get stock data. Exactly. Thank you. I don't want Apple. I want Nvidia. And I want a plot single moving average data. Okay, let's see. Oops. Error. There's an error in my code. I don't know where it is. Let's see if it fakes my code works. All right, where is it? Aha. Yes, I missed the comma. Accept. Let's run it. Okay. It opened on a different window. Sorry. Let me go back here and run it. And there we go. That's only the close. So I'm not seeing the 50 day. Why is that? So this. Let's try to debug this one. Why I'm not seeing the single. The simple moving average. Am I returning it? Yes. I want a 50 days. Yes. Huh. Why is not showing. Why is that data not showing? I don't know. Let's see. I'm having a bit of a trouble here. Right. It doesn't know the answer for this one. Okay, so if I look into the code. Let me see, what do I have here? So I'm getting that. Do I have data? Yes. Okay. Simple moving average data. Okay. Data, close figure. Ah. I may need to update the layout. No data index. Well, I really not see Enough. If you are, scream.
Why is that fig show?
Yes, let's run again. No, it didn't work. Okay, I'm not going to dwell much in this. I think we're also running out of time. I want to give you time for questions. It should help me to. Maybe I'm not getting any data here. I'm going to debug. We do have data. Okay, I think I need more than 20 minutes for this. Okay. No, I'm not getting any data here. Close data. Okay, there's a problem here that I'm not seeing it. Neither Me or GitHub Copilot. So you should learn how to code and not trust GitHub Copilot solely for the sake of time. I'm going to move on because for the functionalities I show you most of the things. I want to show you one thing at last, which is generating tests. So if you generate tests, it can generate tests for your code base. Let's see, it's actually creating a test underscore stock file. Let's create that file and see what it does create. See, let's go here. Generated a few asserts. Obviously this is not the right setup for running tests in Python. But as you can see, if you put the right setup here and then iterate here, you can definitely also generate tests for your code base. I think that's basically it what I wanted to show you within the experience. Obviously this is pretty nice, but you do need to install Visual Studio, you need to have all these dependencies on your machine and you also need to have a GitHub account and GitHub Copilot subscription. So I want to show you something else which is our own product data Camp workspace. If you never use data, if you never use workspace, you should. It's our own notebook to do any data analysis. You can do it here. And we also have AI functionalities and I have this workspace ready for me to play around. I'm just gonna hope that if I use AI now and I ask it to create the financial I tried before, that's why it's trying to recommend Candlestick. I want to do a financial Candlestick chart plot that shows the evolution of a given stock over five years. And what I want to show you here is with workspace, you actually don't need to have anything installed on your machine. You have your own space where you can install dependencies, actually just install the dependency. Let's try this again. Obviously, just like GitHub Copilot, AI sometimes plays some tricks with you. But as you can see, it's generating code that is very, very similar to the one that GitHub Copilot was generating. And let's see if when it runs, we can have a similar effect. There you go. In less than five minutes, I was able to do exactly the same, obviously on GitHub Copilot, I could also ask to generate the whole code. The point being here is that it's definitely convenient to use Workspace and you can have the benefits of using AI as well within the product with the similar functionalities as if I do a mistake and code, let's say I do like something like this, that it will run a code, it will run an error. It will also give you opportunity to help to explain what is the error that actually you have in your code and helps you to fix as well. I think that's it for me. I hope you, you were able to see the value of using GitHub code pilots and that you're excited to use it on your day to day to get all the benefits, more productivity, learn about the languages and the frameworks you're using, and also improve the quality of your code base. And I hope that as well, this short demo of Workspace can also show you the possibility of using Workspace and leveraging Workspace to do your data analysis with the benefits of pair programming with an AI assistant.
All right, super. Thank you, Nero. That was a very cool demo and I haven't really thought of using Copilot in a data context. So that was a nice, sort of a nice example because I sort of thought of it as being a separate software development tool. But yeah, you can do data science or data analysis with, with copilot. All right, we have 10 minutes and a ton of questions from the audience. I have many questions for you, but I'm gonna, I'm gonna skip those. Let's go straight to the audience questions. All right, so first question comes from Rich. I think you sort of talked about this briefly, but can you Summarize how is GitHub Copilot different from using ChatGPT when you're coding?
Yes. So it's different in the essence that first they were designed with different purpose. Right. ChatGPT is more generalist, so it's trained to answer questions and have a dialogue in the. A wide variety of topics, while GitHub Copilot was trained specifically and designed specifically for code and to write code and to talk and have a dialogue about code. So the difference is really the specialization a bit more than that. Also, GitHub Copilot, you can use it within your working environment already. Right. If you're using one of these four major ides, you have it right, right there. So you can make it easily part of your workflows. I hope this kind of quickly answers your question.
Absolutely. So I'm kind of curious because with ChatGPT, one of the stupid but fun features is that you can get it to write code in different styles. You can do write Python in the style of Dr. Seuss or whatever and then give you a nice rhyming code. Is that still possible with Copilot? I don't whether you've explored.
Yeah, I haven't explored it. We can definitely do some. Some funky. Obviously it's trained to be restricted to programming. If you go to too while like write me a function that gives recipes for banana bread. Well, it's going to be quite hard to achieve a good result right there.
Okay. Yeah, you're going to get some dodgy outputs there. All right, Next question comes from Max. So Max asked, which version of GPT is Copilot using?
Well, I don't know the latest, but it was built initially based on GPT 3.5. I don't know if GitHub copilot updated and I'm talking about the prediction of code the chat it's using GPT4. It's powered by GPT4 because you want basically you can have a dialogue, you can reason with it for the coding. It's not necessarily needed the GPT4 there they. Because they build their own. Their own model on top of GPT 3.5 and they got very good results. I actually don't know if meanwhile they. They updated to GPT4 and if they retrain the model, I guess it can be also a costly operation for. For that. Yeah.
So it's different models in different places because like you said, the code generation is. It's a very heavily customized version of GPT.
Right.
It's been trained on all the GitHub data. So yeah, different versions in different places. Next question comes from Devanshu. So Devanshu asked, can you talk a bit about how you think about writing prompts? So you gave some examples in there, but do you have any tips in general for writing prompts that helps Copilot give good results?
Well, I would say keep it concise, right. If you write a very long prompt that would definitely. You think you might be giving a lot of information, but GitHub Cobalt will already gather some information from the context that you have on your Code base, I think together with writing good prompts and iterates, I think you need to use these two techniques combined. Writing code is iteration already. And the same when you're using GitHub Copilot, you should iterate. So I would say try to be concise. Try to be to the point you want to plot, you want to refactor this line, or you want to find an error. Try to be specific to the point and then iterate over it. Discard the results that don't make sense. Ask for different suggestions as well.
That's interesting. So this is very different to ChatGPT where normally you do have to just provide sentences and sentences of context. But here it sounds like there's a lot of automatic prompt engineering being done to say, hey, these are the other variables there. This is the state of things. And so you don't need to write as much.
The context is everything, I would say. And that's why having the access to the file that you're, that you have open, it gives a huge advantage for them to get a good prediction of what should be the next piece.
Okay, and next question comes from Lucy. So Lucy asks, if you're cautious about confidential data, are there any guarantees from copilot about data safety?
Yes, it's a very good question. I think I need to rely on how GitHub mentions that they handle your data because it's important to know they go through. Basically they divide them in three the user engagement data and they have policies about these. They retain this data, the engagement. So did you accept or discard a suggestion? They retain this for 24 months. The prompt itself, they discard once the suggestion is returned, so the prompt doesn't get stored and the suggestion is not retained at all. Now, obviously there's a recommendation that we also do at datacamp is you can, when you have Enterprise set up policies for your GitHub copilot configuration and I recommend, for example, that you configure, do not use pieces of code that match public coding in GitHub repositories. Because it's known that GitHub copilot from time to time in the past, especially use code that it was open, was public, but actually it was proprietary. You couldn't use it on your code base. And that was a problem, a legal problem for GitHub Copilot. There are tools within GitHub Copilot and GitHub address that concern from enterprises by giving tools that allows you to manage these policies.
Okay, so you do have some control over what Gets used. Another question from Rich saying, how do I install Copilot in different edges? It gives Visual Studio as an example, but I think it works for quite a few editors.
Yes, it works for Neovim, JetBrains, IDES. It works for Visual Studio code and Visual Studio. I believe the GitHub copilot chat is yet not available on JetBrains. It's under a private beta, but from GitHub themselves they told me that it should be available soon. It should roll out soon to all users. The installation is quite simple. If you go to GitHub copilot, just follow the instructions. They made very good documentation about it. You just download your IDE of choice and then within you should go to the extension. Should be very similar to how I demonstrate on the Visual Studio.
All right, next question comes from Elvis. So Elvis asks, do you get different suggestions for different users? That's actually interesting because I know there's a certain amount of randomness in the answers. So I guess if you ask the same, give the same prompt a few times, you're going to get different responses. And is it customized depending on who you are?
Yeah, you definitely give. Even if the same user will get different. Will get different answers. I didn't know what I was going to get today. I've run a few trials before. Obviously this got long to test my script on the plot, the analysis I want to do. And I got very different things. There is of course information about the engagement that is sent back to GitHub copilot that helps to fine tune that. But you will get, there's a sense of randomness there and you will get different answers. You might not get the same answer even being the same user all the time.
Absolutely. And as you saw in the demo, it's very easy for like problems to happen and they work when you. Of course they work when you're practicing and fail live.
Yeah, this was not too bad though. Yeah, I've seen worse. Yeah.
Oh, actually just on that note, I think Steve spotted the problem. So we were calculating a 50 day moving average, but there was 30 days of data, which is why we got the. Not a number of values.
Great, thank you, Steve. That was, that was, that was the issue. Indeed.
All right, next question from Richard saying, does Copilot adapt to your coding style? So does it learn what sort of code you like and give answers that way?
Yeah, it does. It should it because you do send, especially for large files. For example, if you have multiple, multiple files open, it will embed. It will send that coding structure and definitely uses that to provide a suggestion that is similar to your coding style. However, for some cases, just like the imports, right. I keep putting the import on top, but it seems that for some reason it didn't capture that. I think that's one of the things that potentially at the moment it will continue to be like that. Perhaps if I have many files open with all the imports on top, it will start giving me more accurate changes on the imports. What I do, what I did notice is that in other examples when I when I'm missing an import and actually adds the import on top. So I guess it tried on those examples to put the import close to the the code it was changing. But definitely it should adapt a bit to your style. Not always accurate though.
Excellent. So we're kind of at time. There's one more interesting question I want to get to. Before we do that, I just want to say we've got some upcoming webinars that you might want to attend. So tomorrow me and my colleague Adele are going to be talking about the Data Camp roadmap. So if you want to find out what's coming next for datacamp, please do show up tomorrow. Then next Tuesday we've got a session on analyzing Google Sheets data in Python and next Wednesday there's a session on Scaling data quality. So if you're involved in data governance or you want to know how you get good quality data in order to feed into your AI, that's worth a visit. Next Wednesday and then next Thursday there is a session on building a Data Skills Academy. So lots of good sessions. To sign up for, click the or click Go on the QR code link at the top left of this screen and that'll help you sign up. All right, so last question I want to get to. Before we finish, there's another question from Elvis about when when should you use this to generate code? So it's like if you it's stuff you know already and you're like okay, this is easy peasy stuff, should you use it to generate that code? It's like, well I know how to do this. Or should it be more about like I don't know how to solve this and therefore I'm using AI to help me.
I think it's both right? Especially if you want to code faster for sure. Like you're doing some something task that is repetitive or writing a variable or the beginning of the function. And GitHub Copilot already gives you everything. Even if you knew how to do that, you're going to be fast. Right. And obviously when you don't know how to do certain things, you don't know the language syntax. You shouldn't be blocked by that. Right. And that's how GitHub Copilot helps you there too. So I do. I think it's in both, both situations that Copilot can be. Can be a valuable tool.
Absolutely. So don't just rely on AI as a crutch to help you solve everything and learn nothing, because that's not going to help you. But certainly it can be very powerful learning tool. All right. With that, I think we're. We're past time, so let's wrap up. Thank you, Nuno, once again, that was a really great session. Very interesting tool and, yeah, lovely demo. Thank you to Rhys for moderating. Thank you to everyone who asked questions. So excited. Lots of questions today. Well done for that. Thank you to everyone who showed up today. I hope to see you all again in future webinars. All right, bye bye.
More from Richie

#359 My Best Friend is AI with Valerie Tiberius, Professor of Philosophy at University of Minnesota

How AI Agents Will Work While You Sleep | Ruslan Salakhutdinov, Professor at Carnegie Mellon

#358 How AI Agents Will Work While You Sleep | Ruslan Salakhutdinov, Professor at Carnegie Mellon







