WEBVTT

00:00.440 --> 00:02.640
And a very warm welcome to cursor.

00:02.680 --> 00:03.320
Here we are.

00:03.360 --> 00:05.040
We are in week four.

00:05.080 --> 00:09.480
Landgraf, we're going to lab two, which is the lab for day three.

00:09.520 --> 00:10.280
It's confusing.

00:10.520 --> 00:14.080
Uh, so we're going to start with some imports as we do.

00:14.120 --> 00:18.280
And we are also going to do the low dot env that always needs to be done.

00:18.560 --> 00:21.200
And we are now going to go and set up Lang Smith.

00:21.200 --> 00:22.880
So there's a link to Lang Smith here.

00:22.880 --> 00:25.000
When you follow this link you'll get to their website.

00:25.000 --> 00:27.560
And the first thing you'll need to do is create an account.

00:27.800 --> 00:29.520
Uh, and it's free.

00:29.560 --> 00:33.440
It's free as long as you stay within some very high number, which we definitely will.

00:33.720 --> 00:35.400
Uh, so you can set that up.

00:35.400 --> 00:38.840
And when you come in, you're going to get this sort of dashboard a bit like this, except it will be

00:38.840 --> 00:39.360
empty.

00:39.520 --> 00:43.880
And the first thing to do is to press the setup tracing button right here.

00:43.880 --> 00:45.200
And this is going to fly up.

00:45.360 --> 00:48.880
You have to generate an API key so that you've got an API key.

00:49.000 --> 00:53.160
And as soon as you press that it will then fill this in down here.

00:53.440 --> 00:59.040
And you just simply then want to copy that to your clipboard, all of your, uh, fields, all of the

00:59.080 --> 01:01.320
key variables that you'll see here.

01:01.560 --> 01:04.720
Um, but just don't obviously don't take the OpenAI API key as well.

01:04.720 --> 01:06.840
You don't need that, But you need this.

01:07.080 --> 01:12.240
And then you will it will actually populate that API key with whatever you generate right here, which

01:12.240 --> 01:13.000
is great.

01:13.240 --> 01:21.280
And then you will go into, uh, back back here into your EMV file, which is just there, and you will

01:21.280 --> 01:26.560
add this in to your EMV file so that we have these variables set.

01:26.600 --> 01:31.240
And then once you've done that come back and run load dot env again so that they load in.

01:31.280 --> 01:32.800
Maybe I should have done that in the other order.

01:33.440 --> 01:34.280
So that's great.

01:34.280 --> 01:37.880
Then you have langsamt configured and you'll be able to see things.

01:38.080 --> 01:42.960
Now before we, uh, go further, I will just just talk through a few of the things we can expect to

01:42.960 --> 01:43.360
see.

01:43.640 --> 01:48.000
Um, so I called the project mastering agents, but you can call it whatever you want.

01:48.040 --> 01:48.560
Of course.

01:48.880 --> 01:52.480
Um, and you can see in here there's there's lots of stuff that I've been doing.

01:52.600 --> 01:58.200
You'll see that it for every time that I've invoked Landgraf, I get some sort of a of an entry here.

01:58.200 --> 02:00.480
I get the input and the output.

02:00.520 --> 02:03.480
If there's an error, which I had a couple of errors, then we will see them.

02:03.680 --> 02:05.520
It tells you when it happened.

02:05.560 --> 02:08.040
It tells you the latency, which is very helpful.

02:08.040 --> 02:11.530
And there's a bunch of other useful stuff here too, which we don't often get to see.

02:11.770 --> 02:17.010
The cost in this column is telling us how much this cost us to make this call to OpenAI.

02:17.290 --> 02:23.570
And for those people that are concerned about about API costs, do have a look at how insanely small

02:23.570 --> 02:24.330
these numbers are.

02:24.370 --> 02:25.930
It just really brings it to life.

02:26.090 --> 02:31.450
I realize that the main problem people have is with the upfront $5 you have to put in at the beginning,

02:31.450 --> 02:36.850
but I hope that you see that that until you get to such point as you are scaling, we are talking about

02:36.890 --> 02:42.570
not just fractions of a cent, but fractions of fractions of a cent for most of these.

02:42.850 --> 02:46.210
Um, it also tells you the number of tokens, which is helpful to know.

02:46.570 --> 02:51.490
I'm not sure the zeros were because I had some bug that I luckily then fixed.

02:51.650 --> 02:55.890
Uh, so you get to see a bunch of stuff in here and this is going to be useful.

02:55.890 --> 03:00.650
And when we actually have things to to look at, we will come back and take a look at that.

03:00.930 --> 03:01.490
Okay.

03:01.770 --> 03:02.570
Onwards.

03:02.810 --> 03:03.570
All right.

03:04.050 --> 03:09.210
So I found a useful function that's in the long chain community folder.

03:09.490 --> 03:16.090
Uh and it's called Google Sherpa API wrapper, which means that it's a nice little convenient wrapper

03:16.130 --> 03:22.450
around the same thing that we set up before the Sherpa API, where we already have the API key in our

03:22.450 --> 03:24.970
env file, which is convenient to use.

03:25.290 --> 03:29.210
And so we can create an instance of this thing Google soap API wrapper.

03:29.210 --> 03:33.610
And we can call Sherpa with something like what's the capital of France?

03:33.650 --> 03:36.050
And if we do this, then it will think for a moment.

03:36.050 --> 03:41.850
And indeed we get Paris is the capital and largest city of France, and with some stuff about it, from

03:41.850 --> 03:44.810
doing an internet search on this, which is great.

03:44.810 --> 03:50.530
And again, this is something that's part of what's free and included in the plan up until some several

03:50.570 --> 03:51.490
thousand calls.

03:51.490 --> 03:55.530
I think unlike OpenAI, which is charging us two and a half cents for each one.

03:56.410 --> 03:59.170
So that is, uh, that is good.

03:59.650 --> 04:06.090
Now, this is showing you some of the nice stuff that's actually in Long Chain rather than Landgraf,

04:06.090 --> 04:07.530
but Landgraf uses it to.

04:07.570 --> 04:11.650
I mentioned to you that Long chain already does sort of simple agent interactions.

04:11.650 --> 04:15.050
It already gives some some wrapper code, some abstraction code.

04:15.090 --> 04:16.690
And here is here is one of them.

04:16.690 --> 04:19.890
I kept the import here so we could see that it's from, from long chains.

04:20.050 --> 04:20.810
Long chain.

04:21.130 --> 04:21.570
So?

04:21.570 --> 04:27.850
So you can say that, uh, you can wrap a function like this with a tool object.

04:27.850 --> 04:32.330
You give it a name like search a function serpent run.

04:32.330 --> 04:35.730
That's what it will actually do when it needs to call this tool.

04:35.770 --> 04:43.770
And a description is what will be will be called in order to, um, when, when building the JSON around

04:43.770 --> 04:44.410
this tool.

04:44.770 --> 04:50.690
Uh, so that's wrapped it in a tool object, a long chain tool object.

04:50.690 --> 04:55.970
And as you can probably guess, this is going to take away all of the gumph about building that JSON

04:55.970 --> 04:59.130
object with all the stuff and the properties and everything else.

04:59.130 --> 05:04.010
It's going to take care of all of that for us, so we can now try out the same, the same question,

05:04.010 --> 05:10.410
what's the capital of France which we can do using tool search dot invoke the long chain way we are

05:10.410 --> 05:12.290
calling this tool and there we go.

05:12.330 --> 05:15.770
We get an answer of the capital of France, same thing.

05:15.770 --> 05:18.610
But now we're doing it by calling invoke.

05:18.850 --> 05:19.370
Okay.

05:19.410 --> 05:23.530
And now let's just show you what it's like to build a tool from scratch ourselves.

05:23.530 --> 05:24.610
It's super easy.

05:24.930 --> 05:28.660
Uh, so we'll use the same old thing that we like to do because it's nice.

05:28.700 --> 05:30.180
It's so tangible.

05:30.420 --> 05:36.420
Uh, using pushover, this is the same kind of function that is able to send a push notification to

05:36.460 --> 05:36.940
me.

05:36.940 --> 05:42.620
So we give it the usual docstring, we give it, uh, the information about it.

05:42.860 --> 05:45.100
Um, and, uh, here we go.

05:45.140 --> 05:45.980
That's that.

05:46.260 --> 05:51.700
I put that into a tool again, the same construct, the long chain construct.

05:51.740 --> 05:53.820
The name is send push notification.

05:53.820 --> 05:56.260
The function is push and that's a description.

05:56.460 --> 06:01.460
And now I can then call tool push invoke with me.

06:04.740 --> 06:05.300
There we go.

06:05.340 --> 06:05.700
Oh, yeah.

06:05.740 --> 06:06.020
Hello.

06:06.060 --> 06:06.340
Me.

06:06.700 --> 06:10.340
Uh, so now we have made, uh, a tool ourselves.

06:10.380 --> 06:11.540
A custom tool.

06:11.540 --> 06:16.980
So now we have an off the shelf tool for searching using the same API.

06:17.220 --> 06:22.220
And we have a custom tool for sending a push notification using the nifty pushover package.

06:22.540 --> 06:22.980
Okay.

06:23.020 --> 06:27.220
And we can put both of these tools in a list of tools.

06:27.900 --> 06:28.500
All right.

06:29.140 --> 06:30.860
Then we actually get to use it.
