1
00:00:00,160 --> 00:00:01,600
So much as we started week two.

2
00:00:01,640 --> 00:00:08,480
We're now going to go through the core concepts of crew I, the sort of building blocks to understand

3
00:00:08,480 --> 00:00:11,320
how it works, and there's some similarities.

4
00:00:11,440 --> 00:00:13,560
First of all, there is an agent.

5
00:00:13,720 --> 00:00:21,800
An agent is basically the smallest the unit of work, an autonomous unit, which is related to an LM.

6
00:00:21,800 --> 00:00:27,520
It has an LM underneath it, and it has something called a role, a description of what it does, a

7
00:00:27,600 --> 00:00:30,040
goal and a backstory.

8
00:00:30,240 --> 00:00:33,040
And it can also have memory and it can have tools.

9
00:00:33,320 --> 00:00:36,520
And that is how an agent is defined.

10
00:00:36,520 --> 00:00:41,160
And you can remember back to OpenAI agents SDK definition.

11
00:00:41,880 --> 00:00:43,080
There is something new here.

12
00:00:43,080 --> 00:00:44,840
A task is another thing.

13
00:00:44,880 --> 00:00:48,000
And there wasn't an analog in the last framework.

14
00:00:48,160 --> 00:00:52,600
A task is a specific assignment that is going to be carried out.

15
00:00:52,600 --> 00:00:57,320
It has a description, it has an expected output, and it has an agent.

16
00:00:57,320 --> 00:01:00,240
So a task is assigned to an agent.

17
00:01:00,640 --> 00:01:02,880
So that is the distinction agents.

18
00:01:02,880 --> 00:01:04,400
And then tasks.

19
00:01:04,560 --> 00: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

20
00:01:14,170 --> 00:01:15,130
is simply so.

21
00:01:15,130 --> 00: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

22
00:01:21,810 --> 00:01:22,650
modes.

23
00:01:22,650 --> 00:01:28,050
One of them is called sequential, and that is where it will simply execute each task in turn as it's

24
00:01:28,050 --> 00:01:28,690
laid out.

25
00:01:28,890 --> 00:01:31,250
And the other is called hierarchical.

26
00:01:31,250 --> 00:01:38,370
And that is where an LM will be used a manager LM in order to assign tasks to agents.

27
00:01:38,650 --> 00:01:42,410
So those are the two different modes that you can operate in.

28
00:01:43,010 --> 00:01:47,410
So that gives you these are the three core concepts to keep in mind.

29
00:01:47,970 --> 00:01:49,130
So how do we think about this.

30
00:01:49,130 --> 00:01:52,250
So so it's it's this these are lightweight concepts.

31
00:01:52,290 --> 00:01:58,730
And they're certainly reminiscent of last week I would say that it is a bit more opinionated than the

32
00:01:58,730 --> 00:02:00,210
OpenAI agents SDK.

33
00:02:00,250 --> 00:02:02,290
There's a bit more terminology.

34
00:02:02,290 --> 00:02:03,810
It's a bit more prescriptive.

35
00:02:03,810 --> 00:02:09,610
So as a clear example, if you look at the agent there, if you remember last week, agents just had

36
00:02:09,610 --> 00:02:10,570
instruction.

37
00:02:10,610 --> 00:02:12,850
An instruction was basically the system prompt.

38
00:02:12,850 --> 00:02:14,850
And you provided the instruction.

39
00:02:14,850 --> 00:02:17,570
And that's very unopinionated.

40
00:02:17,610 --> 00:02:21,410
You can choose to think about instructions however you want.

41
00:02:21,610 --> 00:02:26,850
Now with crew, an agent has a role, a goal, and a back story.

42
00:02:27,170 --> 00:02:29,130
So it's a bit more you can see immediately.

43
00:02:29,130 --> 00:02:36,450
It's more prescriptive in terms of how one is supposed to to prime the this, this, this LM, and how

44
00:02:36,450 --> 00:02:41,890
that is constituted into a system prompt is something that's, that's not immediately available.

45
00:02:41,890 --> 00: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

46
00:02:46,810 --> 00:02:51,930
somewhat hidden from you at the, at the certainly at the beginner level, if you just use it out of

47
00:02:51,970 --> 00:02:54,930
the box, you have to provide the role, the goal, the backstory.

48
00:02:55,050 --> 00:03:00,250
And I think this is a really good example of the trade offs between these different frameworks, because

49
00:03:00,290 --> 00:03:05,770
obviously forcing us to think in terms of a role and a goal and a backstory is good, because these

50
00:03:05,770 --> 00:03:11,930
are all sort of good prompting practices to think about the context, to give the backstory this this

51
00:03:11,930 --> 00:03:14,890
is a a good, best practice at the same time.

52
00:03:14,930 --> 00:03:16,050
So so that's the benefit.

53
00:03:16,050 --> 00: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

54
00:03:20,340 --> 00:03:21,740
backstory that's not relevant.

55
00:03:21,740 --> 00:03:23,460
We want to think about it differently.

56
00:03:23,460 --> 00:03:26,220
And that is completely possible with AI.

57
00:03:26,260 --> 00:03:27,340
But it's going to be harder.

58
00:03:27,340 --> 00:03:30,260
We're going to have to then dig in and find out what's going on.

59
00:03:30,500 --> 00: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

60
00:03:34,740 --> 00:03:37,300
don't have the same control over the system prompt.

61
00:03:37,340 --> 00:03:41,740
We just know that it's being constituted based on these various building blocks.

62
00:03:41,940 --> 00: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

63
00:03:47,340 --> 00:03:49,220
in adopting these different platforms.

64
00:03:49,260 --> 00:03:51,060
And and that's a pretty important one.

65
00:03:51,780 --> 00: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

66
00:03:58,620 --> 00:04:04,500
using configuration, which allows you to sort of nicely separate some of the text rather than having

67
00:04:04,500 --> 00:04:06,220
it embedded all over your code.

68
00:04:06,580 --> 00:04:12,060
So when you think about agents and tasks, those those are the two things that make up a crew.

69
00:04:12,220 --> 00:04:14,500
Agents and tasks can be created by code.

70
00:04:14,500 --> 00:04:18,940
You can say agent equals my agent, my agent equals agent.

71
00:04:18,940 --> 00: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

72
00:04:24,990 --> 00:04:25,510
so on.

73
00:04:26,110 --> 00:04:31,590
Or instead of that, you can write a YAML file that looks a bit like this.

74
00:04:31,830 --> 00:04:35,030
We'll look at many of them in the course of this week, but it's a YAML file.

75
00:04:35,030 --> 00:04:41,550
If you're not familiar with YAML, it's a very simple, easy for humans to read kind of markup file.

76
00:04:41,670 --> 00:04:43,310
And it and it looks a bit like this.

77
00:04:43,350 --> 00: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

78
00:04:50,910 --> 00:04:53,830
an agent called researcher in this example.

79
00:04:54,070 --> 00:04:59,470
And that will allow us to separate out the configuration from the code.

80
00:04:59,750 --> 00:05:03,870
And whilst that is in some ways, as always there's some pros and cons.

81
00:05:03,910 --> 00:05:06,910
The, the con is that it's a bit of something to get used to.

82
00:05:06,950 --> 00:05:09,790
It's some scaffolding, it's specific to crew.

83
00:05:10,030 --> 00:05:16,390
There's definitely a great benefit that this means that you don't have your your various prompts buried

84
00:05:16,390 --> 00:05:18,310
within your code all over the place.

85
00:05:18,310 --> 00:05:22,550
You've got it nicely separated out and you can work on that somewhat independently.

86
00:05:22,550 --> 00:05:22,790
So.

87
00:05:22,790 --> 00:05:26,590
So I think it's a nice a nice touch in your code.

88
00:05:26,590 --> 00:05:32,080
You can then create something like an agent and instead of specifying all of the fields of an agent.

89
00:05:32,080 --> 00:05:34,160
Like the role of gold backstory.

90
00:05:34,160 --> 00:05:40,160
You can just simply select the configuration as as it shows in this code right here, and they will

91
00:05:40,160 --> 00:05:41,520
all be populated for you.

92
00:05:41,840 --> 00:05:43,840
So it's I like it because it's lightweight.

93
00:05:43,840 --> 00:05:46,000
It's not like there's magic happening behind the scenes.

94
00:05:46,000 --> 00:05:48,320
You clearly refer to the config right there.

95
00:05:48,320 --> 00:05:49,560
It's clear what's going on.

96
00:05:49,600 --> 00:05:55,520
And it has this nice separation of concerns, allowing us to work on our prompts separately from our

97
00:05:55,520 --> 00:05:56,000
code.

98
00:05:57,280 --> 00:06:02,240
And then in addition to the YAML files, there are a couple of Python files.

99
00:06:02,240 --> 00:06:05,640
And the most important one is called crew.py.

100
00:06:06,000 --> 00:06:07,960
And it's where everything comes together.

101
00:06:07,960 --> 00:06:11,640
It defines your crew and it's going to look a bit like this.

102
00:06:11,640 --> 00: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

103
00:06:16,280 --> 00:06:20,440
over it and you're now you've got a bit of experience with decorators from, from last week.

104
00:06:20,640 --> 00:06:23,760
And uh, sure enough, crew has decorators as well.

105
00:06:23,960 --> 00:06:26,480
And you can see that they there is a few of them.

106
00:06:26,480 --> 00:06:31,840
It has crew base as the decorator you put around the whole class that's going to manage your crew.

107
00:06:32,160 --> 00:06:38,160
And then there's a decorator agent for each of your functions which creates an agent, and there's a

108
00:06:38,160 --> 00:06:42,080
decorator task for each of your functions which creates a task.

109
00:06:42,280 --> 00:06:47,320
And then there's decorator crew for your final function that generates your crew.

110
00:06:47,560 --> 00:06:54,600
And you can see that it creates an instance of crew and it returns and it passes in the agents, the

111
00:06:54,600 --> 00:06:55,120
tasks.

112
00:06:55,120 --> 00:06:59,680
And this thing that's telling it that it is sequential, not hierarchical.

113
00:06:59,720 --> 00:07:03,920
It's where you set that important different mode of processing.

114
00:07:04,320 --> 00:07:05,560
And you can see that there.

115
00:07:05,560 --> 00:07:08,600
It says agents is self dot agents.

116
00:07:08,760 --> 00:07:11,600
And you might wonder where is that coming from.

117
00:07:11,640 --> 00:07:18,800
Well that's really one of the roles of this decorator at agent that that is making sure that any function

118
00:07:18,800 --> 00:07:25,320
that has that decorator automatically, the agent that comes from that will be associated with the instance

119
00:07:25,320 --> 00:07:27,920
variable agents will be added to that list.

120
00:07:28,080 --> 00:07:30,840
So that's why you can just simply refer to it at the bottom.

121
00:07:31,080 --> 00:07:35,600
So anyway, this this will be more concrete when we look at a proper coding example.

122
00:07:35,640 --> 00:07:41,080
My main point is that there is this very important module crew, and it's where you define your agents,

123
00:07:41,080 --> 00:07:43,440
tasks and crew, and it uses decorators.