1
00:00:00,120 --> 00:00:02,040
While they say time flies when you're having fun.

2
00:00:02,040 --> 00:00:07,960
And that seems to be happening because we already have reached the last, last of the days of the first

3
00:00:07,960 --> 00:00:14,600
week, day five and it's time to unveil our big project, which, as you know, is your own personal

4
00:00:14,600 --> 00:00:16,720
career alter ego for your website.

5
00:00:16,760 --> 00:00:19,360
Answering questions about your professional history.

6
00:00:19,800 --> 00:00:24,760
And I want to say one more time that last time we talked about the different Agentic frameworks and

7
00:00:24,760 --> 00:00:27,400
how there are simple ones and complex ones.

8
00:00:27,440 --> 00:00:30,360
Everything we're doing this week is with no framework at all.

9
00:00:30,360 --> 00:00:36,080
We are interacting directly with models, which is incredibly important because it gives you that foundational

10
00:00:36,080 --> 00:00:40,520
knowledge about what's actually going on under the hood, so that when we start to build on all sorts

11
00:00:40,520 --> 00:00:46,480
of clever frameworks that abstract us away, you have good insight into what's really going on behind

12
00:00:46,480 --> 00:00:47,320
the scenes.

13
00:00:48,040 --> 00:00:49,560
But that's the end of the intro.

14
00:00:49,600 --> 00: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.

15
00:00:54,800 --> 00:00:55,920
Let's get to it.

16
00:00:56,480 --> 00:00:58,720
And here we are back in cursor.

17
00:00:58,720 --> 00:01:02,880
And we go back into the first week foundations.

18
00:01:02,880 --> 00:01:06,980
And now we're on lab for the first big project.

19
00:01:06,980 --> 00:01:07,900
Professionally.

20
00:01:07,900 --> 00:01:08,260
You.

21
00:01:08,300 --> 00:01:09,180
I'm calling it.

22
00:01:09,220 --> 00:01:13,780
It's going to be your personal career alter ego, and it's going to include tool use.

23
00:01:13,820 --> 00:01:14,700
As promised.

24
00:01:14,700 --> 00:01:19,060
I know we covered it in the last lecture, but it's going to now make its appearance.

25
00:01:19,620 --> 00:01:25,820
First, I want to introduce you to a nifty little tool called pushover, which people from my last course

26
00:01:25,820 --> 00:01:27,340
will remember fondly.

27
00:01:27,380 --> 00:01:30,780
It is a nice little tool, and I've had to.

28
00:01:30,780 --> 00:01:34,380
I have to have my phone off silent because we're going to be using it.

29
00:01:34,380 --> 00:01:39,300
So I do apologize if I get things like text messages and stuff, but but it's important, as you will

30
00:01:39,300 --> 00:01:39,700
see.

31
00:01:40,060 --> 00:01:44,700
Pushover is a cute tool that lets you send push notifications to your phone.

32
00:01:44,700 --> 00:01:48,180
If you're used to using something like Twilio that lets you send text messages.

33
00:01:48,220 --> 00:01:53,180
Twilio used to be very easy to use, but now there's so much regulation around SMS that it's actually

34
00:01:53,180 --> 00:01:57,260
quite hard to get things together to send even yourself a text message.

35
00:01:57,300 --> 00:02:00,180
Pushover is super simple, and it's free.

36
00:02:00,220 --> 00: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,

37
00:02:04,580 --> 00:02:05,960
so you've got plenty of time.

38
00:02:06,080 --> 00:02:09,360
You simply go to pushover and it's super clear.

39
00:02:09,360 --> 00:02:14,680
You set up an account on the top right, you get an API key and you actually get two.

40
00:02:14,680 --> 00: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

41
00:02:21,920 --> 00:02:22,440
here.

42
00:02:22,840 --> 00:02:29,960
And you also install an app on your phone called pushover, which I have sitting right there.

43
00:02:30,360 --> 00: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

44
00:02:37,720 --> 00:02:43,680
load EMV, which is going to include my pushover user and token now, and I'm going to create the OpenAI

45
00:02:43,720 --> 00:02:44,360
library.

46
00:02:44,720 --> 00:02:45,080
All right.

47
00:02:45,080 --> 00:02:48,000
So my pushover user is in that field.

48
00:02:48,000 --> 00:02:49,600
My token is in that.

49
00:02:49,600 --> 00:02:55,560
And this is the URL of the endpoint for sending push notification messages.

50
00:02:55,760 --> 00:02:59,680
And so this function here push is all it takes.

51
00:02:59,680 --> 00:03:05,400
Basically you're just you just do a request stop post to that URL to that endpoint.

52
00:03:05,400 --> 00:03:07,160
And you pass in some data.

53
00:03:07,160 --> 00:03:09,820
And that data has the user token.

54
00:03:09,860 --> 00:03:15,060
The token token and the message itself that you want to push to your phone.

55
00:03:15,340 --> 00:03:16,900
It's just the end of it.

56
00:03:16,900 --> 00:03:17,260
Nothing.

57
00:03:17,300 --> 00:03:20,180
I mean, this is this is how all things should be just super simple.

58
00:03:20,340 --> 00:03:22,980
So I should be able to run this function here.

59
00:03:23,020 --> 00:03:23,380
Hey.

60
00:03:23,420 --> 00:03:25,340
And it should come up on my phone right now.

61
00:03:27,740 --> 00:03:28,140
There you go.

62
00:03:28,180 --> 00:03:29,940
I hope you heard that loud and clear.

63
00:03:30,180 --> 00:03:31,100
I'll do it again.

64
00:03:32,620 --> 00:03:33,140
There we go.

65
00:03:33,180 --> 00:03:33,740
And I see.

66
00:03:33,740 --> 00:03:34,820
Hey, twice.

67
00:03:35,020 --> 00:03:41,300
And that is a cool way to be able to notify yourself of things through code without having to worry

68
00:03:41,300 --> 00:03:43,740
about SMS regulations and things like that.

69
00:03:44,420 --> 00:03:46,340
Okay, that's push over.

70
00:03:46,380 --> 00:03:50,380
Please install it when when you have a moment because we're going to use it not just this time, but

71
00:03:50,380 --> 00:03:52,220
we're going to use it in other projects as well.

72
00:03:52,300 --> 00:03:54,020
It's a useful thing to be able to do.

73
00:03:55,180 --> 00:03:55,820
Okay.

74
00:03:55,860 --> 00:03:59,380
Now I'm going to introduce you to two innocent looking functions.

75
00:03:59,380 --> 00:04:04,140
One of them is called record user details and the other is called record.

76
00:04:04,180 --> 00:04:05,500
Unknown question.

77
00:04:05,980 --> 00: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.

78
00:04:13,240 --> 00: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

79
00:04:18,320 --> 00:04:21,280
record if a user asks a question that it doesn't know how to answer.

80
00:04:21,280 --> 00: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

81
00:04:27,400 --> 00:04:28,680
if someone does that.

82
00:04:29,160 --> 00: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

83
00:04:37,320 --> 00:04:39,560
and it's going to return that the recorded.

84
00:04:39,560 --> 00:04:41,200
So that's a useful thing to be able to do.

85
00:04:41,720 --> 00:04:47,360
And if it gets a question it doesn't know it's going to push recording that a question was asked.

86
00:04:48,080 --> 00:04:52,080
Why don't we make this a bit more descriptive that I couldn't answer.

87
00:04:52,360 --> 00:04:52,840
Answer.

88
00:04:52,840 --> 00:04:53,640
There we go.

89
00:04:53,760 --> 00:04:57,200
So now it's nice and clear recording interest.

90
00:04:57,200 --> 00:04:58,960
From there we go.

91
00:04:59,120 --> 00:05:05,760
Okay, so the idea is we want to turn these into tools that are LM can use.

92
00:05:06,040 --> 00: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

93
00:05:12,040 --> 00:05:13,950
is what you're going to see right now.

94
00:05:14,430 --> 00:05:15,830
Here is some JSON.

95
00:05:15,830 --> 00:05:17,070
There's quite long JSON.

96
00:05:17,070 --> 00:05:19,070
It's quite there's quite verbose.

97
00:05:19,230 --> 00:05:24,030
And one of the things that the agent frameworks do is they sort of do all of this for you automatically.

98
00:05:24,030 --> 00:05:29,150
So you won't have to worry about this again, because a lot of this stuff is very boilerplate, a lot

99
00:05:29,150 --> 00:05:31,310
of lot of standard JSON.

100
00:05:31,750 --> 00:05:35,190
But this JSON right here record user details.

101
00:05:35,190 --> 00:05:40,190
JSON is a blob of JSON that refers to this function.

102
00:05:40,190 --> 00:05:43,950
It describes the capability of being able to call that function.

103
00:05:43,950 --> 00:05:46,270
It gives it a name record user details.

104
00:05:46,270 --> 00:05:48,630
It says why might you want to do that?

105
00:05:48,670 --> 00:05:54,310
Use this tool to record that a user is interested in being in touch and provided an email address.

106
00:05:54,750 --> 00:05:56,910
And then we specify the parameters.

107
00:05:57,110 --> 00:06:00,550
There's one called email, one called name, one called notes.

108
00:06:00,710 --> 00:06:03,790
Look here it is email name and notes.

109
00:06:04,150 --> 00:06:06,230
And we give each one a description.

110
00:06:06,510 --> 00:06:11,870
And we say that email is required and that there aren't additional properties.

111
00:06:12,590 --> 00:06:17,090
So you may be wondering what this is about.

112
00:06:17,090 --> 00:06:22,930
The thing to keep in mind is that this is the information that's going to be sent to OpenAI.

113
00:06:23,210 --> 00:06:26,450
We're going to say to it, you have the ability to do this.

114
00:06:26,450 --> 00:06:29,610
Tell me if you want me to run it for you, and I'll tell you the answer.

115
00:06:29,890 --> 00:06:31,450
So that's that's what's going on here.

116
00:06:31,450 --> 00:06:39,090
It's like a packaged way of describing what this function does in JSON format, so that the LLM can

117
00:06:39,090 --> 00:06:44,730
decide in its response whether or not it wants to actually call this tool.

118
00:06:45,410 --> 00:06:51,810
And then very similar for record unknown user question, we give it a name, the name of the function,

119
00:06:51,970 --> 00:06:53,610
we give it a description.

120
00:06:53,610 --> 00:06:58,570
And this is what the LLM will use to decide whether or not it's appropriate to use this tool.

121
00:06:58,930 --> 00:07:06,130
And then we say that it has one property question which is a string, the question that couldn't be

122
00:07:06,130 --> 00:07:06,970
answered.

123
00:07:07,370 --> 00:07:09,890
And that is the end of that.

124
00:07:09,930 --> 00:07:15,050
Let's run this and run this okay.

125
00:07:15,330 --> 00:07:18,190
If I run everything, I didn't run the functions themselves.

126
00:07:18,190 --> 00:07:21,470
It's always if you fail to run things, then you're going to get a name error later.

127
00:07:21,470 --> 00:07:22,990
It's something to watch out for.

128
00:07:22,990 --> 00:07:26,590
So always come back and make sure that you've run all of your cells.

129
00:07:27,350 --> 00:07:28,070
Okay.

130
00:07:28,390 --> 00: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.

131
00:07:35,990 --> 00:07:39,870
Type is function and the function is that function.

132
00:07:40,030 --> 00:07:44,590
So now this blob of JSON is a big blob of JSON.

133
00:07:44,590 --> 00:07:45,670
Let's have a look at it.

134
00:07:46,030 --> 00:07:47,710
Print tools.

135
00:07:48,670 --> 00:07:52,150
And you're going to see it's actually what happens if I just do it like this.

136
00:07:52,150 --> 00:07:53,310
That might look better.

137
00:07:53,310 --> 00:07:53,790
There we go.

138
00:07:53,790 --> 00:07:54,910
It does look better.

139
00:07:55,190 --> 00:08:03,790
This is what tools now is it is this big chunk of JSON boilerplate JSON, which describes the two functions

140
00:08:03,790 --> 00:08:08,310
that we're providing with a name, a description, the parameters, and so on.

141
00:08:08,310 --> 00:08:13,550
And this putting things in JSON is a language that llms are good at understanding because it's in lots

142
00:08:13,550 --> 00:08:14,750
of their training data.

143
00:08:14,750 --> 00:08:19,510
And so that's going to help us to be able to interact with OpenAI.