While developing code, you sometimes get
stuck while coding, then, what do you do next? Do you Google it or go to Stack Overflow
to get your answers! You pick some solution from Stack Overflow, implement it, and again, you get
stuck somewhere else. Then, you want someone who could stay with you and answer all the questions.
You need some tool that can integrate with your favorite IDE, and you don't have to Google
each of your technical questions online. Enter GitHub Copilot Chat, a revolutionary tool
that can not only assist with coding but also comprehend natural language questions and provide
insightful answers. So, in simple language, you can ask any programmatic question from GitHub
Copilot Chat and get the solution in your IDE itself. Copilot will understand the context of the
code and give a relevant solution. In this video, we'll uncover all the features of GitHub
Copilot Chat and explain each of them in depth. Before we install GitHub Copilot, you'll need
an active subscription for GitHub Copilot. You can follow this video to get GitHub Copilot for
free; I have given the link in the description. Once we have got the subscription for Copilot,
let's install GitHub Copilot on IDE. I'm using VSCode right now. We'll go to the Marketplace
and search for GitHub Copilot and install it. Once you have installed GitHub Copilot, you
have to sign in with your GitHub account. I've already signed in. Let me introduce
you to Chat View. You can access Chat View via the activity bar. To further help
Copilot give you more relevant answers, you can indicate the scope and intent of a
question through agents and / commands. Agents are like experts who have a specialty that
they can help you with, and you can talk to them in chat by mentioning them with an '@'
symbol. Currently, there are three agents: @workspace has context about the code in
your workspace and can help you navigate it, finding relevant files and classes.
@VScode knows about the commands and features in the VS Code editor
itself and can help you use them. @terminal has answers to all the things
that can be executed on the terminal. So let's explore the working of agent @workspace.
Now, let's explore the `/explain` command. This command will be explaining a step by step of how
the selected code works. Let's select the code for which we want an explanation, and in the
Chat View, let's write down `/explain`. Now, GitHub Copilot is thinking and using `@workspace`
agent, and you can also see the reference that it is using as line numbers 5 to 10. It is giving
you the explanation for the code that you have selected. So, you can see the provided code finds
the factorial of a given number. It uses the recursive function, and it is telling you the exit
conditions that are used here, and each variable, what it does. In the end, it is also giving you,
"This code is quite efficient, but it works only for positive numbers. For negative numbers,
it could give a Stack Overflow exception." Now let's ask a very specific question for
this code: "Can you tell its time and space complexity?" Let's see whether it is able
to find its space and time complexity. So, it is writing down, "Yeah, the time
complexity is O(N), and space complexity is also O(N). Nice!" It is also telling how
the time and space complexity are measured; it's a very nice way of analyzing how your
code or algorithm would perform in production. Now, let's explore the `/fix` command. This
will propose a fix for the bugs in the selected code. As the code is already selected, we'll
just write down `/fix`, write down a prompt, and hit enter. Now it's analyzing the
code. The provided factorial code seems to be working only for positive numbers, and it
lacks error handling for negative numbers. So, we would have got a Stack Overflow exception if
we were using that code. We'll just use this code, copy it from here, and paste it. We have handled
the condition where the number is less than zero, so we'll not be getting Stack Overflow
from now. This is a very wonderful way of fixing the code or refactoring
the code that is already written. Now, let's explore the `/test` command. This
will be generating unit test cases for the selected code. As the code is already selected,
we'll just write down `/test` and just write down a prompt as "generate unit test case." It's
thinking. Yes, it has given junit test cases for this particular code. This could have taken a lot
of time to write down, but this is very nice and this could save a lot of time for developers for
writing those test cases. You could also give a prompt to test out some particular business use
cases also over here. I've given a very generic prompt over here. It is giving me the option to
copy; it is giving me the option to insert into this cursor here. Let's click on these three
dots and see. Yeah, insert into a new file. We'll just click on this; we'll create a new
file for this factorial test class, and you can save it at the relevant position. Okay. Now
let's check whether this code is working or not. Click on "Allow," and the test cases that it has
generated are working. Yes, all the test cases are working fine. This could save a hell lot of
time for developers writing down these test cases. Now, we'll explore the `/new` command. This
command will create a new project based on the natural language description that you'll write
down. To create a Spring Boot microservice, you have to go to Spring Initializer,
select all the jars that you want to add, and then click on generate to do it. I'll give
you a smarter way of doing it: just use `/new` command and write down a prompt to create a Spring
Boot microservice project. You can write down the Java version over here, write down it should have
Java 17, the latest version. Let's write down the name of the microservice that we want as, "Copilot
Microservice." Now, let's ask it to include all the necessary jars. We are not giving any specific
description; Copilot will itself think and add the relevant dependencies. Just need to tell it that
we want a restful application that can run all the test cases and restful APIs. Let's wait for a
few seconds before it generates. It is generating a Spring Boot microservice. So, this is the
preview of the microservice structure that we have got. It has pom.xml, application properties, the
microservice name that we have given. Let's click on pom.xml. Let's check out all the dependencies
that it has added. Yes, it's using Java 17 version that we have asked, has added all the dependencies
like starter web, JPA, it has an inbuilt database H2, Lombok, and the test dependency that we
have asked. The name of the project is Copilot Microservice, as we have asked. You can also give
better prompts to change the group ID over here. Now, let's check out this Application.java. Yes,
it is using Spring Boot microservice over here, and this Application Test is also created. Now,
If this project looks good to you, you can click on this create workspace and select a folder
where you want this to be there and set this as the parent folder. So it will be creating
files and all the relevant things over here and putting them in the folder that you have
asked. This is such an easy way of doing it, and this is just the example of Java that I have
given you. You can build projects in languages that you have never worked on. This is a very
smart way of developing a project from scratch. If you have worked with Jupyter before, here with
GitHub Copilot Chat, you don't have to write down all those codes now. You can just give a clear
prompt, and it will create a Jupyter notebook for you. The `/` command that does this part is
`/new notebook`. Just write down `/new notebook` and write down the kind of Jupyter notebook that
you want. What I'm trying to make is something complex, as to analyze the weather report and
predict the kind of weather that would happen. This will have year data of weather for a
particular city. After analyzing this data, you have to produce a trend for each month
and forecast the weather. Let's hit enter now, and GitHub Copilot is thinking. Now we'll just
close down the tabs that we don't want. So it has created a structure like to import required
libraries, load the data, data cleaning and pre-processing, explanatory data analysis, trend
analysis, and weather forecast. So it has given all the steps that you have to follow to make
this Jupyter notebook. We can just hit on this create notebook icon, and the whole project will
be ready. Let's hit on create notebook and let's wait for some time to create a fully developed
project for this one. This might take some time. I'll just fast forward it. So it is generating all
the sections: diagnosis, explanatory data analysis over here. Now it has developed everything. You'll
just scroll up and see it has done the importing of the required libraries over here. And if you
go down, weatherdata.csv, you have to provide it over here. So, Pandas DataFrame that it is using
right now and data cleaning and pre-processing that it is doing and trend analysis it is doing
and weather forecasting, all these steps it has done. You can see it has plotted all the predicted
values and into the graph format here. If you give a better prompt, you can develop a very complex
application over here without doing anything. Now let's explore `@terminal`. Right now, it
comes as a part of `/terminal`, but later on, this will be a part of `@terminal` and will not
be a part of `@workspace`. With this command, you just have to give this Copilot a command to
run something, and it will give you the exact terminal command. So no longer do you have
to remember those terminal commands. I'll ask it how to run `factorialTest.java`
using maven command. So it's analyzing the structure and is giving me an option to
run directly. I'll just click on this. Okay, it's scanning the project, and it has
started running the test cases. Yes, and the build is a success. Perfect! You
don't have to remember the command for Maven. So, let's ask it something different,
not using Maven. We'll ask it to run it using the `javac` command. Let's see
whether it is able to answer it. Yes, it has given me the command `javac
factorialTest.java`. Perfect! We'll explore the last part of this GitHub
Copilot Chat, that is `@VSCode`. With `@VSCode`, we have a command of `/api` where you
can ask questions related to VSCode, about its extension development, about
the search operations that we have, and multiple others. `/api` about how can I
develop an extension for a special setting for VSCode during screen cast, I'm not well
versed, about how to create extensions for VSCode. There are four steps that it has
given. Now let's ask it how can I publish this VSCode extension? Again, it has given me a
few commands that I have to run to publish this. That's it from my side. If you have
any questions about this process, then you can comment below. If you
want to know more about GitHub Copilot, then you can check out other videos on my
channel. Share this video with all your peers. Don't forget to hit that like button and
subscribe to my channel for more such content.