WEBVTT

00:00.120 --> 00:02.040
While they say time flies when you're having fun.

00:02.040 --> 00:07.960
And that seems to be happening because we already have reached the last, last of the days of the first

00:07.960 --> 00:14.600
week, day five and it's time to unveil our big project, which, as you know, is your own personal

00:14.600 --> 00:16.720
career alter ego for your website.

00:16.760 --> 00:19.360
Answering questions about your professional history.

00:19.800 --> 00:24.760
And I want to say one more time that last time we talked about the different Agentic frameworks and

00:24.760 --> 00:27.400
how there are simple ones and complex ones.

00:27.440 --> 00:30.360
Everything we're doing this week is with no framework at all.

00:30.360 --> 00:36.080
We are interacting directly with models, which is incredibly important because it gives you that foundational

00:36.080 --> 00:40.520
knowledge about what's actually going on under the hood, so that when we start to build on all sorts

00:40.520 --> 00:46.480
of clever frameworks that abstract us away, you have good insight into what's really going on behind

00:46.480 --> 00:47.320
the scenes.

00:48.040 --> 00:49.560
But that's the end of the intro.

00:49.600 --> 00:54.760
It's now time to go straight to the lab, because for today, it's going to be a ton of coding.

00:54.800 --> 00:55.920
Let's get to it.

00:56.480 --> 00:58.720
And here we are back in cursor.

00:58.720 --> 01:02.880
And we go back into the first week foundations.

01:02.880 --> 01:06.980
And now we're on lab for the first big project.

01:06.980 --> 01:07.900
Professionally.

01:07.900 --> 01:08.260
You.

01:08.300 --> 01:09.180
I'm calling it.

01:09.220 --> 01:13.780
It's going to be your personal career alter ego, and it's going to include tool use.

01:13.820 --> 01:14.700
As promised.

01:14.700 --> 01:19.060
I know we covered it in the last lecture, but it's going to now make its appearance.

01:19.620 --> 01:25.820
First, I want to introduce you to a nifty little tool called pushover, which people from my last course

01:25.820 --> 01:27.340
will remember fondly.

01:27.380 --> 01:30.780
It is a nice little tool, and I've had to.

01:30.780 --> 01:34.380
I have to have my phone off silent because we're going to be using it.

01:34.380 --> 01:39.300
So I do apologize if I get things like text messages and stuff, but but it's important, as you will

01:39.300 --> 01:39.700
see.

01:40.060 --> 01:44.700
Pushover is a cute tool that lets you send push notifications to your phone.

01:44.700 --> 01:48.180
If you're used to using something like Twilio that lets you send text messages.

01:48.220 --> 01:53.180
Twilio used to be very easy to use, but now there's so much regulation around SMS that it's actually

01:53.180 --> 01:57.260
quite hard to get things together to send even yourself a text message.

01:57.300 --> 02:00.180
Pushover is super simple, and it's free.

02:00.220 --> 02:04.580
At least I think for the first month I'm now paying some tiny amount, but it's free for the first month,

02:04.580 --> 02:05.960
so you've got plenty of time.

02:06.080 --> 02:09.360
You simply go to pushover and it's super clear.

02:09.360 --> 02:14.680
You set up an account on the top right, you get an API key and you actually get two.

02:14.680 --> 02:21.880
You get like a user and a token, and you have to put that in your file so that it's going to be available

02:21.920 --> 02:22.440
here.

02:22.840 --> 02:29.960
And you also install an app on your phone called pushover, which I have sitting right there.

02:30.360 --> 02:37.680
And the reason you do that, if I do run a few imports right here and now, I'm going to do the usual

02:37.720 --> 02:43.680
load EMV, which is going to include my pushover user and token now, and I'm going to create the OpenAI

02:43.720 --> 02:44.360
library.

02:44.720 --> 02:45.080
All right.

02:45.080 --> 02:48.000
So my pushover user is in that field.

02:48.000 --> 02:49.600
My token is in that.

02:49.600 --> 02:55.560
And this is the URL of the endpoint for sending push notification messages.

02:55.760 --> 02:59.680
And so this function here push is all it takes.

02:59.680 --> 03:05.400
Basically you're just you just do a request stop post to that URL to that endpoint.

03:05.400 --> 03:07.160
And you pass in some data.

03:07.160 --> 03:09.820
And that data has the user token.

03:09.860 --> 03:15.060
The token token and the message itself that you want to push to your phone.

03:15.340 --> 03:16.900
It's just the end of it.

03:16.900 --> 03:17.260
Nothing.

03:17.300 --> 03:20.180
I mean, this is this is how all things should be just super simple.

03:20.340 --> 03:22.980
So I should be able to run this function here.

03:23.020 --> 03:23.380
Hey.

03:23.420 --> 03:25.340
And it should come up on my phone right now.

03:27.740 --> 03:28.140
There you go.

03:28.180 --> 03:29.940
I hope you heard that loud and clear.

03:30.180 --> 03:31.100
I'll do it again.

03:32.620 --> 03:33.140
There we go.

03:33.180 --> 03:33.740
And I see.

03:33.740 --> 03:34.820
Hey, twice.

03:35.020 --> 03:41.300
And that is a cool way to be able to notify yourself of things through code without having to worry

03:41.300 --> 03:43.740
about SMS regulations and things like that.

03:44.420 --> 03:46.340
Okay, that's push over.

03:46.380 --> 03:50.380
Please install it when when you have a moment because we're going to use it not just this time, but

03:50.380 --> 03:52.220
we're going to use it in other projects as well.

03:52.300 --> 03:54.020
It's a useful thing to be able to do.

03:55.180 --> 03:55.820
Okay.

03:55.860 --> 03:59.380
Now I'm going to introduce you to two innocent looking functions.

03:59.380 --> 04:04.140
One of them is called record user details and the other is called record.

04:04.180 --> 04:05.500
Unknown question.

04:05.980 --> 04:13.240
And these are two tools that I'm going to want to equip our LM with so that it can do these things.

04:13.240 --> 04:18.320
It's going to be able to record if a user wants to be in touch with us, and it's going to be able to

04:18.320 --> 04:21.280
record if a user asks a question that it doesn't know how to answer.

04:21.280 --> 04:27.400
And by record, what I mean is it's going to send a push notification to my phone so I know immediately

04:27.400 --> 04:28.680
if someone does that.

04:29.160 --> 04:37.160
And so it's going to say the that it's recording that someone, a person with this email and these notes

04:37.320 --> 04:39.560
and it's going to return that the recorded.

04:39.560 --> 04:41.200
So that's a useful thing to be able to do.

04:41.720 --> 04:47.360
And if it gets a question it doesn't know it's going to push recording that a question was asked.

04:48.080 --> 04:52.080
Why don't we make this a bit more descriptive that I couldn't answer.

04:52.360 --> 04:52.840
Answer.

04:52.840 --> 04:53.640
There we go.

04:53.760 --> 04:57.200
So now it's nice and clear recording interest.

04:57.200 --> 04:58.960
From there we go.

04:59.120 --> 05:05.760
Okay, so the idea is we want to turn these into tools that are LM can use.

05:06.040 --> 05:12.040
Now remember I told you that at the end of the day tool use is just JSON and if statements and that

05:12.040 --> 05:13.950
is what you're going to see right now.

05:14.430 --> 05:15.830
Here is some JSON.

05:15.830 --> 05:17.070
There's quite long JSON.

05:17.070 --> 05:19.070
It's quite there's quite verbose.

05:19.230 --> 05:24.030
And one of the things that the agent frameworks do is they sort of do all of this for you automatically.

05:24.030 --> 05:29.150
So you won't have to worry about this again, because a lot of this stuff is very boilerplate, a lot

05:29.150 --> 05:31.310
of lot of standard JSON.

05:31.750 --> 05:35.190
But this JSON right here record user details.

05:35.190 --> 05:40.190
JSON is a blob of JSON that refers to this function.

05:40.190 --> 05:43.950
It describes the capability of being able to call that function.

05:43.950 --> 05:46.270
It gives it a name record user details.

05:46.270 --> 05:48.630
It says why might you want to do that?

05:48.670 --> 05:54.310
Use this tool to record that a user is interested in being in touch and provided an email address.

05:54.750 --> 05:56.910
And then we specify the parameters.

05:57.110 --> 06:00.550
There's one called email, one called name, one called notes.

06:00.710 --> 06:03.790
Look here it is email name and notes.

06:04.150 --> 06:06.230
And we give each one a description.

06:06.510 --> 06:11.870
And we say that email is required and that there aren't additional properties.

06:12.590 --> 06:17.090
So you may be wondering what this is about.

06:17.090 --> 06:22.930
The thing to keep in mind is that this is the information that's going to be sent to OpenAI.

06:23.210 --> 06:26.450
We're going to say to it, you have the ability to do this.

06:26.450 --> 06:29.610
Tell me if you want me to run it for you, and I'll tell you the answer.

06:29.890 --> 06:31.450
So that's that's what's going on here.

06:31.450 --> 06:39.090
It's like a packaged way of describing what this function does in JSON format, so that the LLM can

06:39.090 --> 06:44.730
decide in its response whether or not it wants to actually call this tool.

06:45.410 --> 06:51.810
And then very similar for record unknown user question, we give it a name, the name of the function,

06:51.970 --> 06:53.610
we give it a description.

06:53.610 --> 06:58.570
And this is what the LLM will use to decide whether or not it's appropriate to use this tool.

06:58.930 --> 07:06.130
And then we say that it has one property question which is a string, the question that couldn't be

07:06.130 --> 07:06.970
answered.

07:07.370 --> 07:09.890
And that is the end of that.

07:09.930 --> 07:15.050
Let's run this and run this okay.

07:15.330 --> 07:18.190
If I run everything, I didn't run the functions themselves.

07:18.190 --> 07:21.470
It's always if you fail to run things, then you're going to get a name error later.

07:21.470 --> 07:22.990
It's something to watch out for.

07:22.990 --> 07:26.590
So always come back and make sure that you've run all of your cells.

07:27.350 --> 07:28.070
Okay.

07:28.390 --> 07:35.630
Final step for this is that we're going to put both of these blobs of JSON into a list of tools.

07:35.990 --> 07:39.870
Type is function and the function is that function.

07:40.030 --> 07:44.590
So now this blob of JSON is a big blob of JSON.

07:44.590 --> 07:45.670
Let's have a look at it.

07:46.030 --> 07:47.710
Print tools.

07:48.670 --> 07:52.150
And you're going to see it's actually what happens if I just do it like this.

07:52.150 --> 07:53.310
That might look better.

07:53.310 --> 07:53.790
There we go.

07:53.790 --> 07:54.910
It does look better.

07:55.190 --> 08:03.790
This is what tools now is it is this big chunk of JSON boilerplate JSON, which describes the two functions

08:03.790 --> 08:08.310
that we're providing with a name, a description, the parameters, and so on.

08:08.310 --> 08:13.550
And this putting things in JSON is a language that llms are good at understanding because it's in lots

08:13.550 --> 08:14.750
of their training data.

08:14.750 --> 08:19.510
And so that's going to help us to be able to interact with OpenAI.
