WEBVTT

1
00:00:00.970 --> 00:00:03.970
So far, we have only asked our agents

2
00:00:03.970 --> 00:00:09.430
about generic things, historic things, like what is

3
00:00:09.430 --> 00:00:12.230
the capital of France, and so on.

4
00:00:12.650 --> 00:00:15.170
But what if we need up-to-date

5
00:00:15.170 --> 00:00:15.650
news?

6
00:00:15.830 --> 00:00:18.390
What if we need today's date, and such

7
00:00:18.390 --> 00:00:18.770
things?

8
00:00:21.050 --> 00:00:24.390
Well, without doing anything, we can't really do

9
00:00:24.390 --> 00:00:25.070
such things.

10
00:00:25.790 --> 00:00:27.890
So we can, for example, say, what is

11
00:00:27.890 --> 00:00:28.610
today's date?

12
00:00:35.630 --> 00:00:37.690
It will come back and say it's October

13
00:00:37.690 --> 00:00:39.330
4th, 2023.

14
00:00:39.950 --> 00:00:43.750
Sometimes it will say different things, depending on

15
00:00:43.750 --> 00:00:46.230
what we do, but it will roughly be,

16
00:00:46.350 --> 00:00:50.330
in this case, it's at some completely other

17
00:00:50.330 --> 00:00:53.750
date, but it will roughly be around its

18
00:00:53.750 --> 00:00:56.370
cut-off date, meaning when it was finished

19
00:00:56.370 --> 00:00:59.590
training, and in this case, OpenAI put it

20
00:00:59.590 --> 00:01:00.310
into production.

21
00:01:02.970 --> 00:01:05.750
But without anything like this, we can't really

22
00:01:05.750 --> 00:01:06.250
do anything.

23
00:01:06.390 --> 00:01:08.150
And in the same manner, if I say,

24
00:01:08.670 --> 00:01:12.610
what is the latest space news?

25
00:01:16.870 --> 00:01:20.990
I do that, it will come back about

26
00:01:20.990 --> 00:01:28.010
something about Artemis 3 returning humans next year,

27
00:01:28.770 --> 00:01:33.070
which is apparently 2025, which we are already

28
00:01:33.070 --> 00:01:35.890
past, and not even Artemis 2 have been

29
00:01:35.890 --> 00:01:36.630
launched yet.

30
00:01:37.690 --> 00:01:41.170
So this has absolutely nothing to do with

31
00:01:41.170 --> 00:01:43.850
reality, and that's because it doesn't know it.

32
00:01:44.110 --> 00:01:46.730
It cannot predict the future, like you and

33
00:01:46.730 --> 00:01:51.650
me can't predict the future, and its current

34
00:01:51.650 --> 00:01:53.390
date is in the past.

35
00:01:54.510 --> 00:01:56.710
So what we need to do is we

36
00:01:56.710 --> 00:02:00.250
need to fix this with a few things.

37
00:02:02.390 --> 00:02:04.010
The first thing we can do is we

38
00:02:04.010 --> 00:02:06.330
can easily fix today's date.

39
00:02:06.850 --> 00:02:08.570
That's just to give it a couple of

40
00:02:08.570 --> 00:02:08.970
tools.

41
00:02:11.370 --> 00:02:13.950
So let's give it a function factory of

42
00:02:13.950 --> 00:02:17.470
two small tools I put down here, which

43
00:02:17.470 --> 00:02:21.490
is just today's date in UTC and my

44
00:02:21.490 --> 00:02:26.250
time zone, so it knows how to convert

45
00:02:26.250 --> 00:02:26.810
in UTC.

46
00:02:27.300 --> 00:02:32.770
So we can say get UTC here, and

47
00:02:32.770 --> 00:02:42.830
we can put in one more tool, function

48
00:02:42.830 --> 00:02:50.450
factory.create.getTimeZoneInfo. We do that.

49
00:02:52.950 --> 00:02:55.990
We will see now that if we ask

50
00:02:55.990 --> 00:03:05.190
what is today's date, it is now able

51
00:03:05.190 --> 00:03:09.010
to come back, and as you can see,

52
00:03:09.190 --> 00:03:12.170
AI is always eager, so it tells, oh,

53
00:03:12.270 --> 00:03:14.530
look how much I know about today's date

54
00:03:14.530 --> 00:03:16.650
is, but that's okay.

55
00:03:16.650 --> 00:03:20.230
We can always prompt the engineer to only

56
00:03:20.230 --> 00:03:22.410
just give the date if we wanted to,

57
00:03:22.910 --> 00:03:27.750
but we still can't say what is the

58
00:03:27.750 --> 00:03:34.820
latest space news because it still doesn't know,

59
00:03:35.620 --> 00:03:39.960
and sometimes it actually realises I don't have

60
00:03:39.960 --> 00:03:40.960
access.

61
00:03:41.240 --> 00:03:44.140
Sometimes it will give some values back from

62
00:03:44.140 --> 00:03:45.240
October 23.

63
00:03:45.240 --> 00:03:48.100
Sometimes it will just make stuff up because

64
00:03:48.100 --> 00:03:48.680
it doesn't know.

65
00:03:50.000 --> 00:03:53.480
In this case, it was honest in saying

66
00:03:53.480 --> 00:03:54.180
I don't know.

67
00:03:55.800 --> 00:04:00.080
So what we have available is a tool

68
00:04:00.080 --> 00:04:05.680
that Microsoft Agent Framework passes along.

69
00:04:06.560 --> 00:04:08.900
It's called Web Search, and you know it

70
00:04:08.900 --> 00:04:10.100
from ChatGPT.

71
00:04:11.420 --> 00:04:15.000
If we give it as a tool, so

72
00:04:15.000 --> 00:04:17.760
it's a tool we don't need to create

73
00:04:17.760 --> 00:04:20.120
ourselves behind the scenes if we look at

74
00:04:20.120 --> 00:04:24.440
it, it's just web underscore search as a

75
00:04:24.440 --> 00:04:27.940
name, which is the common name for it.

76
00:04:30.000 --> 00:04:32.040
It will, however, not help.

77
00:04:34.680 --> 00:04:40.140
What is today's new space news?

78
00:04:46.520 --> 00:04:48.000
So it comes back.

79
00:04:48.200 --> 00:04:53.880
It still talks about things that happened right

80
00:04:53.880 --> 00:04:54.180
now.

81
00:04:54.560 --> 00:04:59.160
It is like two, three years ago.

82
00:05:02.760 --> 00:05:06.000
So the reason why this doesn't work is

83
00:05:06.000 --> 00:05:08.260
because we're using a chat client.

84
00:05:09.120 --> 00:05:11.860
Back in the hello world, I talked about

85
00:05:11.860 --> 00:05:14.480
there was two different clients we could use,

86
00:05:15.240 --> 00:05:17.500
and we wanted to use chat client because

87
00:05:17.500 --> 00:05:18.520
it's most compatible.

88
00:05:19.780 --> 00:05:23.460
But if we want to use special tools

89
00:05:23.460 --> 00:05:27.760
like web search here and also a tool

90
00:05:27.760 --> 00:05:30.780
called Code Interpreter, which we'll cover in the

91
00:05:30.780 --> 00:05:35.160
next lecture, we need to have the responses

92
00:05:35.160 --> 00:05:35.660
client.

93
00:05:35.660 --> 00:05:39.660
The responses client is a more modern thing

94
00:05:39.660 --> 00:05:45.040
from OpenAI, but it is sort of finished,

95
00:05:45.180 --> 00:05:46.440
sort of not finished.

96
00:05:47.460 --> 00:05:50.520
According to the NuGet package, it's still in

97
00:05:50.520 --> 00:05:55.340
preview while OpenAI claims that it's finished.

98
00:05:57.440 --> 00:05:59.560
The reason I don't use it day to

99
00:05:59.560 --> 00:06:03.420
day is I find it more buggy.

100
00:06:03.420 --> 00:06:08.420
It sometimes can answer back without any content

101
00:06:08.420 --> 00:06:13.720
I've seen, so it's more experimental in my

102
00:06:13.720 --> 00:06:14.420
book.

103
00:06:14.820 --> 00:06:18.240
But if we need these more fancy tools

104
00:06:18.240 --> 00:06:20.240
and stuff, we need to use it.

105
00:06:21.560 --> 00:06:24.180
And we need to put these pragmas around

106
00:06:24.180 --> 00:06:27.760
them, so we are telling the system we

107
00:06:27.760 --> 00:06:30.220
are okay with using experimental features.

108
00:06:30.220 --> 00:06:35.820
But if we do this, we actually get

109
00:06:35.820 --> 00:06:38.640
news.

110
00:06:40.200 --> 00:06:49.950
List the top one space news item.

111
00:06:53.490 --> 00:06:57.790
And I know that, yeah, it's the medical

112
00:06:57.790 --> 00:07:02.010
emergency that's happening today on January 8th, 2026,

113
00:07:02.510 --> 00:07:04.770
where one of the crew members that were

114
00:07:04.770 --> 00:07:08.010
about to do a spacewalk has become ill.

115
00:07:08.970 --> 00:07:12.350
We also see that it comes from Indian

116
00:07:12.350 --> 00:07:13.350
TV news.

117
00:07:13.890 --> 00:07:16.450
This is just random in this case.

118
00:07:17.630 --> 00:07:20.810
But the way web searches work is, of

119
00:07:20.810 --> 00:07:22.990
course, a little like you going to Google.

120
00:07:23.790 --> 00:07:28.150
But since Microsoft and OpenAI are working together,

121
00:07:28.530 --> 00:07:30.250
this actually comes from Bing.com.

122
00:07:31.050 --> 00:07:33.530
So it would be the same as if

123
00:07:33.530 --> 00:07:36.290
you put in this in Bing.com.

124
00:07:36.370 --> 00:07:39.010
It would give back a few answers, and

125
00:07:39.010 --> 00:07:43.550
it will go in and use that from

126
00:07:43.550 --> 00:07:47.750
the system, give it to you as input,

127
00:07:48.150 --> 00:07:53.050
and then summarise it like a normal AI

128
00:07:53.050 --> 00:07:53.630
would do.

129
00:07:54.370 --> 00:07:56.970
So I think it gets like 10 different

130
00:07:56.970 --> 00:07:59.890
things, but we just asked for the top

131
00:07:59.890 --> 00:08:01.470
one, and that's the reason why it only

132
00:08:01.470 --> 00:08:01.970
shows one.

133
00:08:05.210 --> 00:08:09.450
This, however, comes at some quite of cost.

134
00:08:10.890 --> 00:08:14.890
Not that up-to-date information is not

135
00:08:14.890 --> 00:08:18.090
valuable, but we need to pay a little

136
00:08:18.090 --> 00:08:18.950
extra for this.

137
00:08:20.290 --> 00:08:30.170
So list, top one, space, news in space.

138
00:08:33.570 --> 00:08:38.490
If we do this again, we will see

139
00:08:38.490 --> 00:08:47.530
that our response here is 7,102 input

140
00:08:47.530 --> 00:08:51.710
tokens, where a lot of them comes from.

141
00:08:51.950 --> 00:08:54.950
If we look inside these messages and content,

142
00:08:55.410 --> 00:08:59.450
we can see it came from a web

143
00:08:59.450 --> 00:09:01.610
search call response item.

144
00:09:05.350 --> 00:09:08.390
So the tool has been called.

145
00:09:08.570 --> 00:09:10.530
It was called up in the cloud and

146
00:09:10.530 --> 00:09:11.730
came back with the data.

147
00:09:12.480 --> 00:09:14.210
So we wouldn't be able to see it

148
00:09:14.210 --> 00:09:16.150
as a middleware tool.

149
00:09:17.390 --> 00:09:21.810
They don't work with that, but we are

150
00:09:21.810 --> 00:09:24.990
paying extra tokens because it made the web

151
00:09:24.990 --> 00:09:28.330
search, and it put all the search result

152
00:09:28.330 --> 00:09:30.290
into our input.

153
00:09:31.790 --> 00:09:34.950
Another thing as well is that we also

154
00:09:34.950 --> 00:09:36.550
pay for each call.

155
00:09:37.550 --> 00:09:40.870
So web searches are premium on top of

156
00:09:40.870 --> 00:09:44.950
tokens where you actually pay $10 per 1

157
00:09:44.950 --> 00:09:46.290
,000 of these calls.

158
00:09:48.070 --> 00:09:51.150
For this, calling one here and there right

159
00:09:51.150 --> 00:09:53.790
now doesn't cost a lot, but of course

160
00:09:53.790 --> 00:09:56.470
if you make a chatbot that can search

161
00:09:56.470 --> 00:09:59.650
the news and stuff, you might easily spend

162
00:09:59.650 --> 00:10:01.810
a lot of money on that.

163
00:10:02.630 --> 00:10:04.250
So just be aware of this.

164
00:10:04.250 --> 00:10:08.930
Of course, there are an extra cost involved,

165
00:10:09.550 --> 00:10:13.690
all depending on if you're using Azure OpenAI

166
00:10:13.690 --> 00:10:14.770
or OpenAI.

167
00:10:15.250 --> 00:10:17.110
These are the OpenAI costs.

168
00:10:19.010 --> 00:10:23.130
But we are not limited to just its

169
00:10:23.130 --> 00:10:25.930
cutoff date or anything, so we can make

170
00:10:25.930 --> 00:10:29.330
our own simple things to get the date

171
00:10:29.330 --> 00:10:33.050
right, and to get news items and stuff,

172
00:10:33.470 --> 00:10:35.470
we can get this as well.
