WEBVTT

00:02.060 --> 00:11.750
So we did use the suggestions and completion functionality quite a bit and as you can tell, it works

00:11.750 --> 00:12.770
pretty well.

00:13.370 --> 00:16.970
Now GitHub Copilot is more than just that though.

00:17.000 --> 00:19.400
It also gives you a chat.

00:19.430 --> 00:27.200
You can use a chat integrated into your IDE, though it's not a chat like the one you have in ChatGPT.

00:27.230 --> 00:31.580
Instead, it's really optimized for coding related tasks.

00:32.420 --> 00:38.120
You could try asking some other questions as well, but it's really optimized to help you with coding,

00:38.150 --> 00:43.490
to understand the surrounding context and take it into account, and so on.

00:44.420 --> 00:50.780
And we could use this chat to change this code here a little bit, because one thing we don't have in

00:50.780 --> 00:53.480
here is error handling.

00:54.020 --> 01:01.160
And for example, at the moment when I delete both the backup and the restore database files, if I

01:01.180 --> 01:08.800
run my script here and I try to back up the database, I'm getting an error because there is no database

01:08.800 --> 01:09.550
file.

01:10.330 --> 01:12.820
So we might want to have some error handling in there.

01:12.820 --> 01:18.370
And of course we could add it manually and or in combination with suggestions.

01:18.370 --> 01:21.280
But we can also take advantage of the chat.

01:22.270 --> 01:24.460
Now there are different ways of using the chat.

01:24.490 --> 01:31.000
There is a separate chat panel you can open up in the sidebar.

01:31.030 --> 01:36.550
You can also do that through the command palette here in Visual Studio Code.

01:36.790 --> 01:45.280
Simply type chat in there and choose the open chat command to open this, but we'll not use that sidebar

01:45.310 --> 01:51.970
chat right now, because often the inline chat is much quicker, and you can open that by hitting command

01:51.970 --> 01:57.130
or control I by default, depending on which operating system you are.

01:57.130 --> 02:04.740
And this chat box here should open up now depending on the point of time where you're viewing this,

02:04.740 --> 02:13.650
you might be able to choose which AI model should be used behind the scenes to fulfill your request.

02:13.680 --> 02:20.910
To answer your question and you can experiment with the different options you might have here, which

02:20.910 --> 02:25.860
may change over time to find the one that best suits your needs.

02:26.070 --> 02:31.650
For this course, it doesn't matter which one you choose, because as mentioned earlier, you'll very

02:31.650 --> 02:36.450
likely not get the exact same results as I do anyways.

02:37.890 --> 02:41.550
Now, when I recorded this course, this feature simply didn't exist yet.

02:41.550 --> 02:47.730
But of course this does not impact the other things I show you here, because the way you use the chat

02:47.730 --> 02:51.600
and the tips and tricks I want to share with you haven't changed.

02:52.080 --> 02:59.040
It's also worth noting that you can also attach files or use voice chat here if you wanted to.

02:59.070 --> 03:07.460
You could, for example, attach a screenshot that maybe contains a UI mockup you want to use for your

03:07.460 --> 03:13.910
chat query, but here, to get started, we'll simply use some plain text which you can enter here.

03:14.930 --> 03:20.000
Now you can also open this inline chat here in a couple of other ways.

03:20.030 --> 03:26.810
For example, you can also use the command palette and type inline chat in there and then choose this

03:26.840 --> 03:29.540
editor inline chat option to open it.

03:30.710 --> 03:38.240
You can also right click in the place in your code where you want to use the chat, and go to Copilot

03:38.240 --> 03:40.700
Editor Inline Chat to open it.

03:41.510 --> 03:45.860
Here you also see the shortcut, which depends on the operating system you're on.

03:45.890 --> 03:53.450
You can use to open this chat, and you see a bunch of other options you can use to quickly explain

03:53.450 --> 03:57.260
a part of your code, fix an error in a part of your code, and so on.

03:57.260 --> 03:59.540
But for now, we'll focus on this chat.

04:01.220 --> 04:04.160
Now you can ask any questions in here.

04:04.160 --> 04:09.020
But of course, just as before with the suggestions, it will also take into account the surrounding

04:09.020 --> 04:09.500
code.

04:09.530 --> 04:14.660
To answer this question, or to be precise here with the inline chat.

04:14.690 --> 04:20.090
It's really not about answering the question, but instead about generating code.

04:20.900 --> 04:27.290
You can also use a voice command, or even attach a file like an image, which might contain, um,

04:27.290 --> 04:35.150
a little picture of the UI you want to build or something like that to control which code gets generated.

04:36.410 --> 04:44.030
It's also helpful if you select the code you want to tweak with chat, like here where I am selecting

04:44.030 --> 04:50.180
this backup db function to then tell copilot to add error handling.

04:50.180 --> 04:51.140
Like this.

04:52.340 --> 04:57.680
Now you can add more details, but for a basic start this should be enough.

04:57.680 --> 05:02.810
And if I hit enter, you see it goes ahead and it generates some code.

05:04.480 --> 05:07.690
And it also shows you what it changed.

05:07.720 --> 05:14.680
Now it might be a bit hard to see, but you can maybe see that there are some parts which have a darker

05:14.710 --> 05:16.420
green and a lighter green.

05:17.080 --> 05:19.060
Here, for example, I have a lighter green.

05:19.060 --> 05:21.850
That's the part that did not change.

05:21.850 --> 05:23.080
That's my original code.

05:23.080 --> 05:27.940
The other green parts are the code parts that did change that were added.

05:28.630 --> 05:32.950
You sometimes also have read parts code that's highlighted in red.

05:32.980 --> 05:37.810
That would be code that's removed due to this command you ran.

05:38.980 --> 05:42.700
Now you can then accept those changes or discard them.

05:42.700 --> 05:43.990
You can regenerate it.

05:43.990 --> 05:48.490
Rerun the command to maybe get a different suggestion, different code generation.

05:49.360 --> 05:54.220
And you can also go through various options here.

05:55.300 --> 06:00.310
Toggle changes for example, shows you in greater detail that it's actually going to remove the code

06:00.310 --> 06:03.010
we had and then re-add it down there.

06:03.010 --> 06:05.040
So it's a bit more detailed.

06:06.210 --> 06:10.770
You can also configure the inline chat and that opens up the settings.

06:10.770 --> 06:16.410
And then here you get various settings you can tweak regarding that chat, but we'll take a look at

06:16.440 --> 06:17.310
that later.

06:18.390 --> 06:21.840
So for the moment I'll just hit accept.

06:22.380 --> 06:24.870
And you see it changed the code now.

06:24.870 --> 06:28.020
And it tries to run the code we had before.

06:28.020 --> 06:34.560
But if it fails, it checks which kind of error it is and then outputs a more user friendly error message.

06:36.180 --> 06:43.170
So with that, if I save that code and I again try to run it and back up my database without having

06:43.200 --> 06:44.340
a database file.

06:44.340 --> 06:50.880
You see, now I got this more user friendly error message here instead of that huge error block we had

06:50.880 --> 06:51.690
before.

06:52.920 --> 07:01.050
And that's how we can use this inline chat functionality to tell GitHub Copilot to generate some code

07:01.080 --> 07:03.660
or to tweak some code as we're doing it here.