1
00:00:00,440 --> 00:00:02,640
And a very warm welcome to cursor.

2
00:00:02,680 --> 00:00:03,320
Here we are.

3
00:00:03,360 --> 00:00:05,040
We are in week four.

4
00:00:05,080 --> 00:00:09,480
Landgraf, we're going to lab two, which is the lab for day three.

5
00:00:09,520 --> 00:00:10,280
It's confusing.

6
00:00:10,520 --> 00:00:14,080
Uh, so we're going to start with some imports as we do.

7
00:00:14,120 --> 00:00:18,280
And we are also going to do the low dot env that always needs to be done.

8
00:00:18,560 --> 00:00:21,200
And we are now going to go and set up Lang Smith.

9
00:00:21,200 --> 00:00:22,880
So there's a link to Lang Smith here.

10
00:00:22,880 --> 00:00:25,000
When you follow this link you'll get to their website.

11
00:00:25,000 --> 00:00:27,560
And the first thing you'll need to do is create an account.

12
00:00:27,800 --> 00:00:29,520
Uh, and it's free.

13
00:00:29,560 --> 00:00:33,440
It's free as long as you stay within some very high number, which we definitely will.

14
00:00:33,720 --> 00:00:35,400
Uh, so you can set that up.

15
00:00:35,400 --> 00: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

16
00:00:38,840 --> 00:00:39,360
empty.

17
00:00:39,520 --> 00:00:43,880
And the first thing to do is to press the setup tracing button right here.

18
00:00:43,880 --> 00:00:45,200
And this is going to fly up.

19
00:00:45,360 --> 00:00:48,880
You have to generate an API key so that you've got an API key.

20
00:00:49,000 --> 00:00:53,160
And as soon as you press that it will then fill this in down here.

21
00:00:53,440 --> 00:00:59,040
And you just simply then want to copy that to your clipboard, all of your, uh, fields, all of the

22
00:00:59,080 --> 00:01:01,320
key variables that you'll see here.

23
00:01:01,560 --> 00:01:04,720
Um, but just don't obviously don't take the OpenAI API key as well.

24
00:01:04,720 --> 00:01:06,840
You don't need that, But you need this.

25
00:01:07,080 --> 00:01:12,240
And then you will it will actually populate that API key with whatever you generate right here, which

26
00:01:12,240 --> 00:01:13,000
is great.

27
00:01:13,240 --> 00:01:21,280
And then you will go into, uh, back back here into your EMV file, which is just there, and you will

28
00:01:21,280 --> 00:01:26,560
add this in to your EMV file so that we have these variables set.

29
00:01:26,600 --> 00:01:31,240
And then once you've done that come back and run load dot env again so that they load in.

30
00:01:31,280 --> 00:01:32,800
Maybe I should have done that in the other order.

31
00:01:33,440 --> 00:01:34,280
So that's great.

32
00:01:34,280 --> 00:01:37,880
Then you have langsamt configured and you'll be able to see things.

33
00:01:38,080 --> 00:01:42,960
Now before we, uh, go further, I will just just talk through a few of the things we can expect to

34
00:01:42,960 --> 00:01:43,360
see.

35
00:01:43,640 --> 00:01:48,000
Um, so I called the project mastering agents, but you can call it whatever you want.

36
00:01:48,040 --> 00:01:48,560
Of course.

37
00:01:48,880 --> 00:01:52,480
Um, and you can see in here there's there's lots of stuff that I've been doing.

38
00:01:52,600 --> 00: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.

39
00:01:58,200 --> 00:02:00,480
I get the input and the output.

40
00:02:00,520 --> 00:02:03,480
If there's an error, which I had a couple of errors, then we will see them.

41
00:02:03,680 --> 00:02:05,520
It tells you when it happened.

42
00:02:05,560 --> 00:02:08,040
It tells you the latency, which is very helpful.

43
00:02:08,040 --> 00:02:11,530
And there's a bunch of other useful stuff here too, which we don't often get to see.

44
00:02:11,770 --> 00:02:17,010
The cost in this column is telling us how much this cost us to make this call to OpenAI.

45
00:02:17,290 --> 00:02:23,570
And for those people that are concerned about about API costs, do have a look at how insanely small

46
00:02:23,570 --> 00:02:24,330
these numbers are.

47
00:02:24,370 --> 00:02:25,930
It just really brings it to life.

48
00:02:26,090 --> 00:02:31,450
I realize that the main problem people have is with the upfront $5 you have to put in at the beginning,

49
00:02:31,450 --> 00: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

50
00:02:36,890 --> 00:02:42,570
not just fractions of a cent, but fractions of fractions of a cent for most of these.

51
00:02:42,850 --> 00:02:46,210
Um, it also tells you the number of tokens, which is helpful to know.

52
00:02:46,570 --> 00:02:51,490
I'm not sure the zeros were because I had some bug that I luckily then fixed.

53
00:02:51,650 --> 00:02:55,890
Uh, so you get to see a bunch of stuff in here and this is going to be useful.

54
00:02:55,890 --> 00:03:00,650
And when we actually have things to to look at, we will come back and take a look at that.

55
00:03:00,930 --> 00:03:01,490
Okay.

56
00:03:01,770 --> 00:03:02,570
Onwards.

57
00:03:02,810 --> 00:03:03,570
All right.

58
00:03:04,050 --> 00:03:09,210
So I found a useful function that's in the long chain community folder.

59
00:03:09,490 --> 00:03:16,090
Uh and it's called Google Sherpa API wrapper, which means that it's a nice little convenient wrapper

60
00:03:16,130 --> 00:03:22,450
around the same thing that we set up before the Sherpa API, where we already have the API key in our

61
00:03:22,450 --> 00:03:24,970
env file, which is convenient to use.

62
00:03:25,290 --> 00:03:29,210
And so we can create an instance of this thing Google soap API wrapper.

63
00:03:29,210 --> 00:03:33,610
And we can call Sherpa with something like what's the capital of France?

64
00:03:33,650 --> 00:03:36,050
And if we do this, then it will think for a moment.

65
00:03:36,050 --> 00:03:41,850
And indeed we get Paris is the capital and largest city of France, and with some stuff about it, from

66
00:03:41,850 --> 00:03:44,810
doing an internet search on this, which is great.

67
00:03:44,810 --> 00:03:50,530
And again, this is something that's part of what's free and included in the plan up until some several

68
00:03:50,570 --> 00:03:51,490
thousand calls.

69
00:03:51,490 --> 00:03:55,530
I think unlike OpenAI, which is charging us two and a half cents for each one.

70
00:03:56,410 --> 00:03:59,170
So that is, uh, that is good.

71
00:03:59,650 --> 00:04:06,090
Now, this is showing you some of the nice stuff that's actually in Long Chain rather than Landgraf,

72
00:04:06,090 --> 00:04:07,530
but Landgraf uses it to.

73
00:04:07,570 --> 00:04:11,650
I mentioned to you that Long chain already does sort of simple agent interactions.

74
00:04:11,650 --> 00:04:15,050
It already gives some some wrapper code, some abstraction code.

75
00:04:15,090 --> 00:04:16,690
And here is here is one of them.

76
00:04:16,690 --> 00:04:19,890
I kept the import here so we could see that it's from, from long chains.

77
00:04:20,050 --> 00:04:20,810
Long chain.

78
00:04:21,130 --> 00:04:21,570
So?

79
00:04:21,570 --> 00:04:27,850
So you can say that, uh, you can wrap a function like this with a tool object.

80
00:04:27,850 --> 00:04:32,330
You give it a name like search a function serpent run.

81
00:04:32,330 --> 00:04:35,730
That's what it will actually do when it needs to call this tool.

82
00:04:35,770 --> 00:04:43,770
And a description is what will be will be called in order to, um, when, when building the JSON around

83
00:04:43,770 --> 00:04:44,410
this tool.

84
00:04:44,770 --> 00:04:50,690
Uh, so that's wrapped it in a tool object, a long chain tool object.

85
00:04:50,690 --> 00:04:55,970
And as you can probably guess, this is going to take away all of the gumph about building that JSON

86
00:04:55,970 --> 00:04:59,130
object with all the stuff and the properties and everything else.

87
00:04:59,130 --> 00: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,

88
00:05:04,010 --> 00:05:10,410
what's the capital of France which we can do using tool search dot invoke the long chain way we are

89
00:05:10,410 --> 00:05:12,290
calling this tool and there we go.

90
00:05:12,330 --> 00:05:15,770
We get an answer of the capital of France, same thing.

91
00:05:15,770 --> 00:05:18,610
But now we're doing it by calling invoke.

92
00:05:18,850 --> 00:05:19,370
Okay.

93
00:05:19,410 --> 00:05:23,530
And now let's just show you what it's like to build a tool from scratch ourselves.

94
00:05:23,530 --> 00:05:24,610
It's super easy.

95
00:05:24,930 --> 00:05:28,660
Uh, so we'll use the same old thing that we like to do because it's nice.

96
00:05:28,700 --> 00:05:30,180
It's so tangible.

97
00:05:30,420 --> 00:05:36,420
Uh, using pushover, this is the same kind of function that is able to send a push notification to

98
00:05:36,460 --> 00:05:36,940
me.

99
00:05:36,940 --> 00:05:42,620
So we give it the usual docstring, we give it, uh, the information about it.

100
00:05:42,860 --> 00:05:45,100
Um, and, uh, here we go.

101
00:05:45,140 --> 00:05:45,980
That's that.

102
00:05:46,260 --> 00:05:51,700
I put that into a tool again, the same construct, the long chain construct.

103
00:05:51,740 --> 00:05:53,820
The name is send push notification.

104
00:05:53,820 --> 00:05:56,260
The function is push and that's a description.

105
00:05:56,460 --> 00:06:01,460
And now I can then call tool push invoke with me.

106
00:06:04,740 --> 00:06:05,300
There we go.

107
00:06:05,340 --> 00:06:05,700
Oh, yeah.

108
00:06:05,740 --> 00:06:06,020
Hello.

109
00:06:06,060 --> 00:06:06,340
Me.

110
00:06:06,700 --> 00:06:10,340
Uh, so now we have made, uh, a tool ourselves.

111
00:06:10,380 --> 00:06:11,540
A custom tool.

112
00:06:11,540 --> 00:06:16,980
So now we have an off the shelf tool for searching using the same API.

113
00:06:17,220 --> 00:06:22,220
And we have a custom tool for sending a push notification using the nifty pushover package.

114
00:06:22,540 --> 00:06:22,980
Okay.

115
00:06:23,020 --> 00:06:27,220
And we can put both of these tools in a list of tools.

116
00:06:27,900 --> 00:06:28,500
All right.

117
00:06:29,140 --> 00:06:30,860
Then we actually get to use it.