WEBVTT

00:00.160 --> 00:01.600
So much as we started week two.

00:01.640 --> 00:08.480
We're now going to go through the core concepts of crew I, the sort of building blocks to understand

00:08.480 --> 00:11.320
how it works, and there's some similarities.

00:11.440 --> 00:13.560
First of all, there is an agent.

00:13.720 --> 00:21.800
An agent is basically the smallest the unit of work, an autonomous unit, which is related to an LM.

00:21.800 --> 00:27.520
It has an LM underneath it, and it has something called a role, a description of what it does, a

00:27.600 --> 00:30.040
goal and a backstory.

00:30.240 --> 00:33.040
And it can also have memory and it can have tools.

00:33.320 --> 00:36.520
And that is how an agent is defined.

00:36.520 --> 00:41.160
And you can remember back to OpenAI agents SDK definition.

00:41.880 --> 00:43.080
There is something new here.

00:43.080 --> 00:44.840
A task is another thing.

00:44.880 --> 00:48.000
And there wasn't an analog in the last framework.

00:48.160 --> 00:52.600
A task is a specific assignment that is going to be carried out.

00:52.600 --> 00:57.320
It has a description, it has an expected output, and it has an agent.

00:57.320 --> 01:00.240
So a task is assigned to an agent.

01:00.640 --> 01:02.880
So that is the distinction agents.

01:02.880 --> 01:04.400
And then tasks.

01:04.560 --> 01:14.170
And there can be multiple tasks for an agent, and then a crew is a team of agents and tasks, and that

01:14.170 --> 01:15.130
is simply so.

01:15.130 --> 01:21.810
A crew is the aggregate of the of the other two, and a crew can be can be has two different process

01:21.810 --> 01:22.650
modes.

01:22.650 --> 01:28.050
One of them is called sequential, and that is where it will simply execute each task in turn as it's

01:28.050 --> 01:28.690
laid out.

01:28.890 --> 01:31.250
And the other is called hierarchical.

01:31.250 --> 01:38.370
And that is where an LM will be used a manager LM in order to assign tasks to agents.

01:38.650 --> 01:42.410
So those are the two different modes that you can operate in.

01:43.010 --> 01:47.410
So that gives you these are the three core concepts to keep in mind.

01:47.970 --> 01:49.130
So how do we think about this.

01:49.130 --> 01:52.250
So so it's it's this these are lightweight concepts.

01:52.290 --> 01:58.730
And they're certainly reminiscent of last week I would say that it is a bit more opinionated than the

01:58.730 --> 02:00.210
OpenAI agents SDK.

02:00.250 --> 02:02.290
There's a bit more terminology.

02:02.290 --> 02:03.810
It's a bit more prescriptive.

02:03.810 --> 02:09.610
So as a clear example, if you look at the agent there, if you remember last week, agents just had

02:09.610 --> 02:10.570
instruction.

02:10.610 --> 02:12.850
An instruction was basically the system prompt.

02:12.850 --> 02:14.890
And you provided the instruction.

02:14.890 --> 02:17.570
And that's very unopinionated.

02:17.610 --> 02:21.410
You can choose to think about instructions however you want.

02:21.610 --> 02:26.810
Now with crew, an agent has a role, a goal, and a back story.

02:27.170 --> 02:29.130
So it's a bit more you can see immediately.

02:29.130 --> 02:36.450
It's more prescriptive in terms of how one is supposed to to prime the this, this, this LM, and how

02:36.450 --> 02:41.890
that is constituted into a system prompt is something that's, that's not immediately available.

02:41.890 --> 02:46.810
There are, in fact, ways that you can choose to set that you can sort of put in templates, but that's

02:46.810 --> 02:51.930
somewhat hidden from you at the, at the certainly at the beginner level, if you just use it out of

02:51.970 --> 02:54.930
the box, you have to provide the role, the goal, the backstory.

02:55.050 --> 03:00.250
And I think this is a really good example of the trade offs between these different frameworks, because

03:00.290 --> 03:05.770
obviously forcing us to think in terms of a role and a goal and a backstory is good, because these

03:05.770 --> 03:11.930
are all sort of good prompting practices to think about the context, to give the backstory this this

03:11.930 --> 03:14.890
is a a good, best practice at the same time.

03:14.930 --> 03:16.050
So so that's the benefit.

03:16.050 --> 03:20.340
The trade off is that we might not we might have a specific situation where we don't want to give a

03:20.340 --> 03:21.740
backstory that's not relevant.

03:21.740 --> 03:23.460
We want to think about it differently.

03:23.460 --> 03:26.260
And that is completely possible with AI.

03:26.300 --> 03:27.340
But it's going to be harder.

03:27.340 --> 03:30.260
We're going to have to then dig in and find out what's going on.

03:30.500 --> 03:34.700
And also if we're trying to debug a problem and we're not sure what's what's happening, we don't we

03:34.740 --> 03:37.300
don't have the same control over the system prompt.

03:37.340 --> 03:41.740
We just know that it's being constituted based on these various building blocks.

03:41.940 --> 03:47.340
So hopefully I give you this color because I want you to have a good sense of what are the trade offs

03:47.340 --> 03:49.220
in adopting these different platforms.

03:49.260 --> 03:51.060
And and that's a pretty important one.

03:51.780 --> 03:58.580
So a nice feature of crew is that you can do a lot of the definition of things like agents and tasks

03:58.620 --> 04:04.500
using configuration, which allows you to sort of nicely separate some of the text rather than having

04:04.500 --> 04:06.220
it embedded all over your code.

04:06.580 --> 04:12.580
So when you think about agents and tasks, those those, the two things that make up a crew, agents

04:12.580 --> 04:14.500
and tasks can be created by code.

04:14.500 --> 04:18.940
You can say agent equals my agent, my agent equals agent.

04:18.940 --> 04:24.900
Open brackets and then pass in a lot of things like the LLM to use and the role and the backstory and

04:24.990 --> 04:25.510
so on.

04:26.110 --> 04:31.590
Or instead of that, you can write a YAML file that looks a bit like this.

04:31.830 --> 04:35.030
We'll look at many of them in the course of this week, but it's a YAML file.

04:35.030 --> 04:41.550
If you're not familiar with YAML, it's a very simple, easy for humans to read kind of markup file.

04:41.670 --> 04:43.310
And and it looks a bit like this.

04:43.350 --> 04:50.910
And this is going to allow us to lay out a, a role, a goal, a backstory, and an LLM associated with

04:50.910 --> 04:53.830
an agent called researcher in this example.

04:54.070 --> 04:59.470
And that will allow us to separate out the configuration from the code.

04:59.750 --> 05:03.870
And whilst that is in some ways, as always there's some pros and cons.

05:03.910 --> 05:06.910
The the con is that it's a bit of something to get used to.

05:06.950 --> 05:09.790
It's some scaffolding, it's specific to crew.

05:10.030 --> 05:16.390
There's definitely a great benefit that this means that you don't have your your various prompts buried

05:16.390 --> 05:18.270
within your code all over the place.

05:18.310 --> 05:22.470
You've got it nicely separated out and you can work on that somewhat independently.

05:22.550 --> 05:26.590
So so I think it's a nice a nice touch in your code.

05:26.590 --> 05:32.080
You can then create something like an agent and instead of specifying all of the fields of an agent.

05:32.080 --> 05:34.160
Like the role of gold backstory.

05:34.160 --> 05:40.160
You can just simply select the configuration as as it shows in this code right here, and they will

05:40.160 --> 05:41.520
all be populated for you.

05:41.840 --> 05:43.840
So it's I like it because it's lightweight.

05:43.840 --> 05:46.000
It's not like there's magic happening behind the scenes.

05:46.000 --> 05:48.320
You clearly refer to the config right there.

05:48.320 --> 05:49.600
It's clear what's going on.

05:49.600 --> 05:55.520
And it has this nice separation of concerns, allowing us to work on our prompts separately from our

05:55.520 --> 05:56.000
code.

05:57.280 --> 06:02.240
And then in addition to the YAML files, there are a couple of Python files.

06:02.240 --> 06:05.640
And the most important one is called crew.py.

06:06.000 --> 06:07.960
And it's where everything comes together.

06:07.960 --> 06:11.640
It defines your crew and it's going to look a bit like this.

06:11.640 --> 06:16.280
And we're going to of course go and look at a proper example in a second, but it has some decorators

06:16.280 --> 06:20.440
over it and you're now you've got a bit of experience with decorators from, from last week.

06:20.640 --> 06:23.760
And uh, sure enough, crew has decorators as well.

06:23.960 --> 06:26.480
And you can see that they there is a few of them.

06:26.480 --> 06:31.840
It has crew base as the decorator you put around the whole class that's going to manage your crew.

06:32.160 --> 06:38.160
And then there's a decorator agent for each of your functions which creates an agent, and there's a

06:38.160 --> 06:42.080
decorator task for each of your functions which creates a task.

06:42.280 --> 06:47.320
And then there's a decorator crew for your final function that generates your crew.

06:47.560 --> 06:54.600
And you can see that it creates an instance of crew, and it returns and it passes in the agents, the

06:54.600 --> 06:55.120
tasks.

06:55.120 --> 06:59.680
And this thing that's telling it that it is sequential, not hierarchical.

06:59.720 --> 07:03.920
It's where you set that important different mode of processing.

07:04.320 --> 07:05.560
And you can see that there.

07:05.560 --> 07:08.600
It says agents is self dot agents.

07:08.760 --> 07:11.640
And you might wonder where is that coming from.

07:11.640 --> 07:18.800
Well that's really one of the roles of this decorator at agent that that is making sure that any function

07:18.800 --> 07:25.320
that has that decorator automatically, the agent that comes from that will be associated with the instance

07:25.320 --> 07:28.080
variable agents will be added to that list.

07:28.080 --> 07:30.840
So that's why you can just simply refer to it at the bottom.

07:31.080 --> 07:35.600
So anyway, this this will be more concrete when we look at a proper coding example.

07:35.640 --> 07:41.080
My main point is that there is this very important module crew, and it's where you define your agents,

07:41.080 --> 07:43.440
tasks and crew, and it uses decorators.
