WEBVTT

00:00.440 --> 00:06.920
Okay, now there's something a bit confusing now, which I'll have to get your head around, which is

00:06.920 --> 00:12.240
that you can, as we've just done, turn a function into a tool.

00:12.640 --> 00:15.280
There's something else you can turn into a tool as well.

00:15.480 --> 00:18.680
You can turn a whole agent into a tool.

00:18.920 --> 00:24.880
You can say, we've got this sales agent, something that can write a sales email.

00:25.080 --> 00:30.440
Well, that whole thing, that whole process of calling that LM with that prompt, that can just be

00:30.440 --> 00:32.560
considered itself to be a tool.

00:32.560 --> 00:35.720
We can think of it as a sales agent tool.

00:36.240 --> 00:42.040
And doing that might sound like there's a fair amount of work to be done to package an LM call into

00:42.040 --> 00:42.640
a tool.

00:43.000 --> 00:51.200
But no, all you have to do is call as tool on the agent, and you will convert the agent into a tool.

00:51.680 --> 00:54.600
What does it mean to convert an agent into a tool?

00:54.840 --> 00:58.200
All it means is it's going to create a new tool.

00:58.200 --> 01:02.080
It's going to have all of the JSON gunk that describes what that tool can do.

01:02.280 --> 01:07.560
And if that tool is called it's going to actually call the agent and make the agent make the call to

01:07.560 --> 01:08.160
the LM.

01:08.320 --> 01:13.920
So it's a wrapper, a wrapper around the agent that turns the agent into a tool.

01:14.160 --> 01:15.360
That's all it is.

01:15.360 --> 01:16.640
So let's look at this.

01:16.680 --> 01:18.640
Sales agent one as tool.

01:18.640 --> 01:25.320
We're going to give it a tool name sales agent one still and write a cold sales email is our description

01:25.320 --> 01:26.600
of what that tool can do.

01:26.720 --> 01:30.560
And now if we look at tool one you can see it's a function tool just like this one.

01:30.560 --> 01:31.760
Just like send email.

01:32.040 --> 01:33.080
It's got a different name.

01:33.120 --> 01:35.160
Its description is this description here.

01:35.200 --> 01:40.200
Now it's got the same like parameters, the JSON blob that we would expect.

01:40.560 --> 01:46.240
And it's got a special function to tell it what to do when the tool is actually called.

01:46.240 --> 01:49.200
And that of course is actually going to call our agent.

01:49.640 --> 01:51.760
So hopefully that makes sense.

01:51.760 --> 01:55.440
We're now going to package our agents into tools and use them.

01:56.120 --> 01:58.040
All right here we go.

01:58.360 --> 02:04.320
So this I could have done this with a fancy loop, but I thought, you know what, I'll just spell it

02:04.320 --> 02:07.320
out so that you're crystal clear on what's happening here.

02:07.960 --> 02:09.690
We're going to have three tools.

02:09.730 --> 02:10.530
Tool one.

02:10.570 --> 02:12.250
Tool two and tool three.

02:12.490 --> 02:14.970
And it is just taking the three agents.

02:15.050 --> 02:17.690
Sales agent one, two and three.

02:17.850 --> 02:20.490
And calling as tool on each of them.

02:20.810 --> 02:26.970
And for each one we just give it a tool name and a tool description which is the same tool description.

02:27.570 --> 02:28.850
That is it.

02:28.890 --> 02:34.170
Now if you if you feel up to it, just rewrite that as a nice little loop so that we don't have a silliness

02:34.410 --> 02:36.290
with the repetition like this.

02:36.290 --> 02:38.210
But but I wanted to spell it out.

02:38.250 --> 02:45.450
And now I'm giving myself a list called tools and tools has tool one, tool two, tool three.

02:45.450 --> 02:48.490
And these are like the agents wrapped as tools.

02:48.490 --> 02:54.810
They're tools that would simply call the agents and then send email is the real tool that is just a

02:54.810 --> 02:55.450
function.

02:55.490 --> 02:58.810
Send email that calls SendGrid the email program.

02:59.130 --> 03:01.530
And let's have a look at what we get if we run this.

03:01.530 --> 03:03.250
So now this is our list of tools.

03:03.250 --> 03:09.210
And it is indeed four function tools sales agent one, sales agent two, sales agent three and send

03:09.250 --> 03:12.170
email all in a list of tools.

03:12.850 --> 03:18.650
Okay, now it's time to put all of that into a sales manager.

03:18.970 --> 03:20.530
Our planning agent.

03:20.810 --> 03:27.810
So now it's a bit like we did before, except we're giving an agent the ability to choose what to run

03:27.810 --> 03:28.290
when.

03:28.330 --> 03:33.450
It's not like we're just writing Python code to say, do this, this, this, and then send email.

03:33.450 --> 03:40.770
But rather we're letting the agent decide you are a sales manager working for comply.

03:41.130 --> 03:45.370
You use the tools given to you to generate cold sales emails.

03:45.570 --> 03:47.490
You never generate sales emails yourself.

03:47.530 --> 03:49.010
You always use the tools.

03:49.290 --> 03:52.930
You try all three tools once before choosing the best.

03:52.970 --> 04:00.810
You pick the single best email and use the Send Email tool to send the best email and only the best

04:00.810 --> 04:02.250
email to the user.

04:02.290 --> 04:04.450
Now, I'm probably over spelling it out here.

04:04.450 --> 04:05.330
You can experiment.

04:05.330 --> 04:10.290
It's not always required to be so pedantic, but I'm also doing it to show you what's going on.

04:10.610 --> 04:14.810
And it's never a bad thing to be very precise and instructive with your prompts.

04:15.530 --> 04:20.890
Okay, so with that, we want to create a new sales manager agent.

04:20.970 --> 04:21.810
There it is.

04:21.850 --> 04:24.130
We want to give it these instructions.

04:24.170 --> 04:25.290
It's system prompt.

04:25.330 --> 04:27.530
We want to pass in all four tools.

04:27.530 --> 04:28.930
All these tools right here.

04:29.290 --> 04:30.890
And we give it a model.

04:31.730 --> 04:36.250
And then we say send a cold sales email addressed to dear CEO.

04:36.770 --> 04:42.170
And we start this going and off it runs.

04:42.370 --> 04:44.730
And this will take about 30s.

04:44.730 --> 04:46.410
So I will see you in a seconds.

04:46.930 --> 04:48.330
Well actually it didn't take 30s.

04:48.330 --> 04:49.370
It took 18 seconds.

04:49.370 --> 04:50.290
So it's quite quick.

04:50.490 --> 04:51.530
And it finished.

04:51.810 --> 04:57.810
And we can first let's look look in my email I did in fact just receive an email and here it is.

04:58.210 --> 04:59.610
And very good.

04:59.810 --> 05:03.010
It does indeed do things quite nicely.

05:03.010 --> 05:03.370
You'll see.

05:03.370 --> 05:09.290
It's put like like a template CEO's name not dear CEO you can improve the prompting to stop it doing

05:09.290 --> 05:13.370
that if you wish, but there's an exercise at the end to incorporate mail merge.

05:13.370 --> 05:16.410
So it actually would put in real people's names here.

05:16.690 --> 05:17.850
But but very nice.

05:17.850 --> 05:24.340
We got the email, it came through to me and it came from the verified email sender as expected.

05:24.700 --> 05:27.540
The other thing to do, of course, is to go and have a look at the trace.

05:27.540 --> 05:28.860
Let's go and do that now.

05:29.140 --> 05:29.820
So here it is.

05:29.820 --> 05:31.980
Sales manager is what we called it for.

05:31.980 --> 05:33.220
Tools were used.

05:33.220 --> 05:34.300
It took 18 seconds.

05:34.300 --> 05:35.460
Let's go in and have a look.

05:35.740 --> 05:37.260
So it called Sales Agent one.

05:37.300 --> 05:38.620
It called sales agent two.

05:38.780 --> 05:39.980
Sales agent three.

05:39.980 --> 05:42.460
And then it called Send Email.

05:42.460 --> 05:45.340
That's the the the tool that is just a tool.

05:45.660 --> 05:51.660
If you look at each of these sales agents tools representing by this this sort of green thing, you'll

05:51.660 --> 05:54.140
see that underneath that was an agent.

05:54.140 --> 05:59.340
So this hopefully makes it crystal clear for you that we had an agent, the professional sales agent

05:59.340 --> 06:02.740
that was wrapped in the tool, sales agent one.

06:02.740 --> 06:04.980
And you can see that again for this one and for this one.

06:04.980 --> 06:10.940
But in the case of send email, it was simply a function that was called with a body.

06:10.940 --> 06:16.180
But you can look through the trace and you should look through the trace and understand the interactions

06:16.180 --> 06:24.020
between tools and agents to allow the sales manager to carry out its full activity, allowing itself

06:24.020 --> 06:26.940
to make its decisions about what it does, in what order.
