WEBVTT

1
00:00:00.390 --> 00:00:02.250
In this lecture, I'm going to show you

2
00:00:02.250 --> 00:00:04.170
a neat trick you can do with agents

3
00:00:04.170 --> 00:00:04.930
and tools.

4
00:00:05.730 --> 00:00:07.990
So right now, I'm just running an agent.

5
00:00:08.350 --> 00:00:10.670
I haven't showed the code on purpose, and

6
00:00:10.670 --> 00:00:12.910
if I say hello to it, you'll see

7
00:00:12.910 --> 00:00:16.370
it's a rather slow system to talk.

8
00:00:17.330 --> 00:00:18.770
How are you?

9
00:00:21.150 --> 00:00:25.050
So it's thinking a lot, and the reason

10
00:00:25.050 --> 00:00:28.450
for that is that this agent I'm running

11
00:00:28.450 --> 00:00:32.110
right now is running chatgpt 5.2, so

12
00:00:32.110 --> 00:00:35.410
one of the bigger models, and we have

13
00:00:35.410 --> 00:00:37.570
run in the past with a smaller model.

14
00:00:39.110 --> 00:00:41.270
So here's the agent, and we can of

15
00:00:41.270 --> 00:00:45.970
course switch it to run 4.1 nano

16
00:00:45.970 --> 00:00:46.450
again.

17
00:00:48.850 --> 00:00:50.050
Run it.

18
00:00:52.770 --> 00:00:56.270
Say hello to it, and we get a

19
00:00:56.270 --> 00:00:58.090
faster answer.

20
00:01:00.450 --> 00:01:02.010
How are you?

21
00:01:04.500 --> 00:01:09.840
Again, almost instant, but what if we want

22
00:01:09.840 --> 00:01:13.700
that certain things should be just handled by

23
00:01:13.700 --> 00:01:16.560
a small agent, and other things should be

24
00:01:16.560 --> 00:01:18.540
handled by a bigger agent?

25
00:01:19.000 --> 00:01:21.760
For example, that could be that we want

26
00:01:21.760 --> 00:01:25.520
to have it really good at astronomy, like

27
00:01:25.520 --> 00:01:27.520
for example, explain the lights.

28
00:01:28.700 --> 00:01:31.200
Yes, the agent here can talk about what

29
00:01:31.200 --> 00:01:35.120
it is, but it's not as good a

30
00:01:35.120 --> 00:01:37.540
way of doing it as a bigger model

31
00:01:37.540 --> 00:01:40.000
that can really think about some more hard

32
00:01:40.000 --> 00:01:40.400
questions.

33
00:01:42.080 --> 00:01:44.340
So what I have here is I have

34
00:01:44.340 --> 00:01:49.060
an agent that we just run with no

35
00:01:49.060 --> 00:01:52.240
specific instructions or tools or anything, but then

36
00:01:52.240 --> 00:01:55.820
I also have an astronomy agent up here,

37
00:01:55.880 --> 00:01:58.460
which we're not using at the moment, and

38
00:01:58.460 --> 00:02:01.680
that is using chatgpt 5.2, because we

39
00:02:01.680 --> 00:02:03.780
want to be really, really good at astronomy,

40
00:02:04.300 --> 00:02:07.080
and the rest someone else can take care

41
00:02:07.080 --> 00:02:07.280
of.

42
00:02:08.560 --> 00:02:10.080
It could also be that we want to

43
00:02:10.080 --> 00:02:12.100
make an agent that was really good at

44
00:02:12.100 --> 00:02:16.280
your data and had some tools in order

45
00:02:16.280 --> 00:02:16.960
to do that.

46
00:02:18.140 --> 00:02:21.140
But let's step within astronomy for this time,

47
00:02:21.940 --> 00:02:25.080
and say we want to have this main

48
00:02:25.080 --> 00:02:30.980
agent refer all astronomy questions to the astronomy

49
00:02:30.980 --> 00:02:34.860
agent, and then we take the agent itself

50
00:02:34.860 --> 00:02:37.740
and just say, treat it as a tool,

51
00:02:38.280 --> 00:02:41.720
and when we do that, we will end

52
00:02:41.720 --> 00:02:46.020
up being able to say this agent can

53
00:02:46.020 --> 00:02:49.840
answer all the questions, but if it's astronomy

54
00:02:49.840 --> 00:02:52.440
questions, it needs to pass it on to

55
00:02:52.440 --> 00:02:55.820
this bigger agent, which has more capability of

56
00:02:55.820 --> 00:02:56.280
answering.

57
00:02:57.980 --> 00:03:00.380
We add middleware here so we can see

58
00:03:00.380 --> 00:03:03.180
that it's being called, so nothing special there.

59
00:03:05.720 --> 00:03:09.200
So, if we run it like this and

60
00:03:09.200 --> 00:03:14.480
say, hello, it will just answer quickly back,

61
00:03:15.540 --> 00:03:23.260
how are you, will answer quickly back, but

62
00:03:23.260 --> 00:03:26.360
what if we ask, explain northern lights, which

63
00:03:26.360 --> 00:03:29.840
is a astronomy question, it will now pass

64
00:03:29.840 --> 00:03:34.320
the question on to another agent, and you

65
00:03:34.320 --> 00:03:37.740
can see it's actually enhancing the query other

66
00:03:37.740 --> 00:03:41.900
than just what the user, me, answered, and

67
00:03:41.900 --> 00:03:43.460
we can see it takes a longer time

68
00:03:43.460 --> 00:03:46.200
now because now we are actually using a

69
00:03:46.200 --> 00:03:48.740
bigger model to answer this specific question.

70
00:03:49.600 --> 00:03:51.960
So, certain things are easy, certain things are

71
00:03:51.960 --> 00:03:56.320
harder, and hopefully this should be a better

72
00:03:56.320 --> 00:04:00.220
answer because it's a better model at answering

73
00:04:00.220 --> 00:04:00.860
questions.

74
00:04:03.160 --> 00:04:06.420
So, again, just for reference, I know I

75
00:04:06.420 --> 00:04:08.800
was a bit coy about showing the code,

76
00:04:09.680 --> 00:04:10.740
but let's go through it.

77
00:04:10.800 --> 00:04:13.300
We make our connections like normal, and then

78
00:04:13.300 --> 00:04:14.740
we just make two agents.

79
00:04:14.740 --> 00:04:17.440
There's no limits to how many agents you

80
00:04:17.440 --> 00:04:19.740
can have in an AI programme, of course,

81
00:04:20.519 --> 00:04:24.400
the one just being the default agent, and

82
00:04:24.400 --> 00:04:27.580
the other one being an agent that gets

83
00:04:28.080 --> 00:04:29.720
the first agent as a tool.

84
00:04:30.460 --> 00:04:32.600
You could give multiple agents tools, and you

85
00:04:32.600 --> 00:04:35.680
give other tools among these, so it will

86
00:04:35.680 --> 00:04:39.100
just be treated as a tool, and then

87
00:04:39.100 --> 00:04:41.100
we put in the middleware, which we saw

88
00:04:41.100 --> 00:04:43.400
in the lecture about that, so we can

89
00:04:43.400 --> 00:04:47.240
see that it's really actually passing on the

90
00:04:47.240 --> 00:04:49.780
question to the other agent, and then we

91
00:04:49.780 --> 00:04:50.900
have our normal chat loop.

92
00:04:52.340 --> 00:04:55.140
So, using it like this, where we have,

93
00:04:55.640 --> 00:04:57.580
you can almost see this as a kind

94
00:04:57.580 --> 00:05:00.960
of dispatcher that takes care of certain questions,

95
00:05:01.080 --> 00:05:04.100
but you can pass it on to other

96
00:05:04.100 --> 00:05:08.420
agents for certain areas, certain topics, and so

97
00:05:08.420 --> 00:05:08.640
on.

98
00:05:10.080 --> 00:05:12.920
So, that is how you use agents as

99
00:05:12.920 --> 00:05:13.320
tools.
