1
00:00:00,200 --> 00:00:02,480
And now we move on to tasks.

2
00:00:02,480 --> 00:00:07,440
And here you'll see that there is a research task and a reporting task.

3
00:00:07,760 --> 00:00:08,560
By default.

4
00:00:08,560 --> 00:00:11,800
But we're going to change this and we're going to have a few different tasks.

5
00:00:11,800 --> 00:00:13,760
We're going to have a task called propose.

6
00:00:14,320 --> 00:00:19,160
This is of course going to be the task which is about proposing a motion.

7
00:00:19,400 --> 00:00:22,280
And so the description what is this task.

8
00:00:22,720 --> 00:00:27,560
It's going to be your proposing the motion and then the motion that gets passed in when we do that part.

9
00:00:27,840 --> 00:00:30,440
Come up with a clear argument in favor of the motion.

10
00:00:30,480 --> 00:00:31,760
Be very convincing.

11
00:00:32,320 --> 00:00:36,640
Then we're going to have an expected output, which is going to be quite simple.

12
00:00:36,680 --> 00:00:43,560
The expected output is going to be your clear argument in favor of the motion in a concise manner.

13
00:00:44,080 --> 00:00:44,960
The agent.

14
00:00:44,960 --> 00:00:48,320
So this is where you associate a task with an agent.

15
00:00:48,320 --> 00:00:51,760
And obviously this is going to be associated with the debater agent.

16
00:00:52,200 --> 00:00:55,720
And then there's one other thing we can do here which is an output file.

17
00:00:55,840 --> 00:01:02,120
We want to put this in a subdirectory output and we will call it propose.md.

18
00:01:02,120 --> 00:01:06,310
And so there you have our proposal task.

19
00:01:06,310 --> 00:01:11,510
So now we're going to have another task which I'm going to copy and paste.

20
00:01:11,510 --> 00:01:14,750
And this one is going to be oppose.

21
00:01:15,150 --> 00:01:18,470
This is the debater that's saying no description.

22
00:01:18,710 --> 00:01:27,470
Instead of proposing you are in opposition to the motion, come up with a clear argument against the

23
00:01:27,470 --> 00:01:28,390
motion.

24
00:01:28,510 --> 00:01:29,910
Looks like Kostas can help there.

25
00:01:29,910 --> 00:01:30,910
It does help.

26
00:01:30,950 --> 00:01:32,150
Be very convincing.

27
00:01:32,190 --> 00:01:34,430
Your clear argument against the motion.

28
00:01:34,670 --> 00:01:37,510
And that should be oppose.

29
00:01:37,550 --> 00:01:38,590
It's amazing, isn't it?

30
00:01:38,590 --> 00:01:40,630
So cursive does all the work for us.

31
00:01:40,830 --> 00:01:45,710
And now we have our final task, which is going to be called decide.

32
00:01:46,350 --> 00:01:53,070
And uh, the as a little tip here, something which is worth knowing is that you cannot call your tasks

33
00:01:53,070 --> 00:01:58,550
the same thing as you call your agents, or you will have a problem with conflicting names.

34
00:01:58,550 --> 00:02:02,110
So sometimes it's better to call this like proposed task, opposed task.

35
00:02:02,430 --> 00:02:03,270
But I've kept it short.

36
00:02:03,270 --> 00:02:06,790
But we couldn't, for example, call this task judge.

37
00:02:06,830 --> 00:02:09,950
Otherwise that would conflict with the agent that we called judge.

38
00:02:10,430 --> 00:02:11,070
All right.

39
00:02:11,310 --> 00:02:14,550
So description we will say review.

40
00:02:14,870 --> 00:02:15,310
Let me see.

41
00:02:15,350 --> 00:02:18,310
Now review the arguments.

42
00:02:18,910 --> 00:02:19,710
Here we go.

43
00:02:20,990 --> 00:02:25,710
Review the arguments presented by the debaters and decide which side is more convincing.

44
00:02:26,110 --> 00:02:29,950
And we'll just change this to delete all of this.

45
00:02:30,790 --> 00:02:31,870
We don't need any of that.

46
00:02:31,910 --> 00:02:38,150
We just need to say the expected output is your decision on which side is more convincing.

47
00:02:38,550 --> 00:02:41,550
And let's say and why.

48
00:02:42,230 --> 00:02:42,870
All right.

49
00:02:42,870 --> 00:02:52,950
And then the this should go please to a folder outputs and decide folder output.

50
00:02:52,990 --> 00:02:53,350
All right.

51
00:02:53,350 --> 00:02:54,110
That seems good.

52
00:02:54,150 --> 00:02:56,150
So there are our tasks.

53
00:02:56,830 --> 00:02:57,510
Okay.

54
00:02:57,870 --> 00:03:04,430
So the final step really is is the final steps is setting up pi and Main.py.

55
00:03:04,710 --> 00:03:06,180
And then we'll be ready to go.

56
00:03:06,900 --> 00:03:09,820
So this is the default module crew dot pi.

57
00:03:09,820 --> 00:03:13,980
And you can see it's got some stuff in here based on the standard scaffolding.

58
00:03:14,100 --> 00:03:16,140
It has created a class.

59
00:03:16,340 --> 00:03:19,660
And it's got this crew base decorator around it.

60
00:03:19,700 --> 00:03:23,780
And this class is named the same as the name of our project debate.

61
00:03:23,780 --> 00:03:27,540
So it's set that for us and it called it Debate Crew, which is exactly right.

62
00:03:27,780 --> 00:03:33,460
Now one of the things I dislike a bit is that it does generate all of this scaffolding code, all this

63
00:03:33,460 --> 00:03:37,660
standard code with lots of comments, and you can read some of the comments and follow the links.

64
00:03:37,660 --> 00:03:41,740
And it's got stuff like there's, there's ways that you can add in functions that get called at the

65
00:03:41,740 --> 00:03:43,740
beginning and end and stuff like that.

66
00:03:43,740 --> 00:03:49,180
But I do find that these comments are get in the way a bit, and I usually start by coming through and

67
00:03:49,180 --> 00:03:52,340
deleting everything in these just to keep it nice and clean.

68
00:03:52,340 --> 00:03:58,140
But what you'll see that it's done that is nice is that it brings in the agent's config and the tasks

69
00:03:58,140 --> 00:03:58,820
config.

70
00:03:58,980 --> 00:04:02,980
It just brings them in from the config folder right here.

71
00:04:02,980 --> 00:04:06,380
So those are set as variables for this class.

72
00:04:06,380 --> 00:04:09,460
And you can see how it refers directly to our configuration.

73
00:04:09,460 --> 00:04:13,740
And of course, that means that if you had different configuration files, then you could bring them

74
00:04:13,740 --> 00:04:15,020
in just like that.

75
00:04:15,060 --> 00:04:17,780
Then this is stuff about how you can bring in your own tools.

76
00:04:17,980 --> 00:04:21,740
And then this is where we set up our agents.

77
00:04:21,820 --> 00:04:24,060
So obviously we don't have an agent called researcher.

78
00:04:24,060 --> 00:04:26,140
We have an agent called debater.

79
00:04:26,500 --> 00:04:31,740
And the agent decorator is telling crew that this is an agent.

80
00:04:31,980 --> 00:04:34,900
It's going to return an agent, the config.

81
00:04:34,900 --> 00:04:38,820
We're going to want to change that to debater and we'll leave it verbose.

82
00:04:38,940 --> 00:04:39,220
True.

83
00:04:39,260 --> 00:04:42,740
Which means that we'll get a nice sort of print as it's running with what's going on.

84
00:04:43,260 --> 00:04:46,820
And then we'll have another agent and remember the name of this guy.

85
00:04:47,060 --> 00:04:52,220
Well, even if you don't, luckily cursor does and it's filled it in in both places.

86
00:04:52,220 --> 00:04:52,980
There we go.

87
00:04:53,020 --> 00:04:55,180
The judge is our other agent.

88
00:04:55,740 --> 00:04:56,500
All right.

89
00:04:56,940 --> 00:05:00,340
And now I'm getting rid of the comments about tasks.

90
00:05:00,340 --> 00:05:04,940
But it tells you about how you can do things like track outputs and dependencies and the like.

91
00:05:04,940 --> 00:05:07,580
But we're going to go on and define our, our tasks.

92
00:05:07,620 --> 00:05:10,410
They have a again the decorator task.

93
00:05:10,650 --> 00:05:13,450
And now we're going to have a task called propose.

94
00:05:14,250 --> 00:05:15,530
And there we go.

95
00:05:15,570 --> 00:05:16,770
Cursor fills it in.

96
00:05:16,810 --> 00:05:19,250
Now it has an output file listed there.

97
00:05:19,250 --> 00:05:23,650
But we don't need that because it's already specified in our config file.

98
00:05:23,650 --> 00:05:25,130
So that's not actually needed.

99
00:05:25,450 --> 00:05:29,890
And you know now that I look at this I do I have to say I think this would be cleaner if we have this

100
00:05:29,890 --> 00:05:32,890
all on one line like this, we don't need to be on multiple lines.

101
00:05:33,010 --> 00:05:37,690
And now you can see how very simple this whole function is going to look.

102
00:05:37,730 --> 00:05:39,290
And look cursor is going to do it for us.

103
00:05:39,330 --> 00:05:40,810
And then we can just delete that.

104
00:05:41,250 --> 00:05:45,490
Sorry I'm tidying this all up when you see how much better it is when this is in JupyterLab.

105
00:05:45,490 --> 00:05:47,290
And you don't have to watch me doing all this.

106
00:05:47,650 --> 00:05:48,690
So don't hate me.

107
00:05:48,690 --> 00:05:52,850
I'll be quick, but I think it's nicer if we have it looking nice and sharp like that.

108
00:05:52,850 --> 00:05:55,290
You see how nice and simple and clean this is?

109
00:05:55,450 --> 00:06:01,090
And that's the benefit of using the the config that we don't need to, to have too much here.

110
00:06:01,090 --> 00:06:03,490
And then the other task is oppose.

111
00:06:04,250 --> 00:06:07,010
And obviously it brings in the config for oppose.

112
00:06:07,010 --> 00:06:09,650
And then the final one is decide.

113
00:06:09,930 --> 00:06:11,120
And there we go.

114
00:06:11,160 --> 00:06:13,520
Thank you cursor for filling that in for us.

115
00:06:13,920 --> 00:06:18,080
So those are our two agents and three tasks.

116
00:06:18,080 --> 00:06:20,640
And we are down to the final section here.

117
00:06:21,280 --> 00:06:21,920
Okay.

118
00:06:22,160 --> 00:06:25,920
So now we now create this the crew.

119
00:06:26,360 --> 00:06:29,040
And this is, this is in the the function crew.

120
00:06:29,040 --> 00:06:30,640
And it has the decorator crew.

121
00:06:31,000 --> 00:06:36,120
And I'm going to take out the, the piece there which we will be coming to later.

122
00:06:36,160 --> 00:06:39,520
So we just simply have to create an instance of crew.

123
00:06:39,760 --> 00:06:48,120
We populate the agents with agents and as cry helpfully tells us, this is automatically created by

124
00:06:48,160 --> 00:06:49,880
the agent decorator.

125
00:06:50,440 --> 00:06:53,440
We populate it with the tasks that are similarly created.

126
00:06:53,640 --> 00:06:59,560
This is where we choose to be sequential rather than hierarchical in our process, and that we want

127
00:06:59,560 --> 00:07:00,920
to be verbose.

128
00:07:00,960 --> 00:07:04,880
And then there's some stuff about being hierarchical if you want to.

129
00:07:05,160 --> 00:07:10,600
And uh, look, if you want to use that nice little comment from the crew team in there.

130
00:07:11,040 --> 00:07:11,640
Okay.

131
00:07:11,760 --> 00:07:14,000
that's it for our crew object.

132
00:07:14,000 --> 00:07:15,280
We're almost finished.

133
00:07:15,560 --> 00:07:16,560
That was our crew module.

134
00:07:16,560 --> 00:07:20,520
We're now going to the main module where we finish things off.

135
00:07:21,040 --> 00:07:26,080
So this this is the again there's all of this stuff that you can read.

136
00:07:26,480 --> 00:07:29,840
This main file is intended to run your crew locally.

137
00:07:29,840 --> 00:07:32,920
So refrain from adding unnecessary logic.

138
00:07:33,240 --> 00:07:33,920
Gotcha.

139
00:07:34,320 --> 00:07:41,280
So inputs when we're running the crew, this is where we choose those template values that we put in

140
00:07:41,280 --> 00:07:42,320
our YAML file.

141
00:07:42,320 --> 00:07:44,400
This is where we choose what we want them to be.

142
00:07:44,440 --> 00:07:50,960
And so what we want them to be here is we want to have a motion and we want to give ourselves a nice

143
00:07:50,960 --> 00:07:51,320
motion.

144
00:07:51,320 --> 00:07:52,680
We don't we don't have this.

145
00:07:52,720 --> 00:07:54,840
We only have the one field motion.

146
00:07:55,160 --> 00:07:56,720
And what motion?

147
00:07:56,720 --> 00:07:59,520
What do we think that we would like them to debate?

148
00:07:59,600 --> 00:08:08,960
Let's have the motion is there should be a that was that was where I was heading with this uh, cursor.

149
00:08:09,240 --> 00:08:13,710
I must be super predictable, but it does seem like a good one to have our eyes A's debate.

150
00:08:13,750 --> 00:08:14,830
Let's not say there should be.

151
00:08:14,830 --> 00:08:22,030
Let's say there needs to be strict laws to regulate llms.

152
00:08:22,470 --> 00:08:22,990
There we go.

153
00:08:23,030 --> 00:08:25,870
That's a nice meaty topic for them to debate.

154
00:08:26,190 --> 00:08:29,230
And then we've got our stuff down here.

155
00:08:29,230 --> 00:08:30,310
We will come back to this stuff.

156
00:08:30,310 --> 00:08:31,950
We don't care about any of that.

157
00:08:32,030 --> 00:08:34,310
That is all it should take.

158
00:08:34,310 --> 00:08:39,550
We should now be ready to run our first crew just based on that.

159
00:08:40,190 --> 00:08:46,270
Actually, just before we run, let me make another little change that in this main module.

160
00:08:46,270 --> 00:08:51,710
I'm just going to make sure we print the result to the screen just to be satisfying.

161
00:08:51,750 --> 00:08:53,350
It will be saved to a file as well.

162
00:08:53,670 --> 00:08:55,590
Results equals debate.

163
00:08:55,710 --> 00:08:58,750
And then we will print result dot raw.

164
00:08:58,870 --> 00:09:05,030
That will print the raw output from the final task sent to the final agent.

165
00:09:05,630 --> 00:09:11,510
And then maybe one other little change I'll make is I realize we're right now sending both the debater

166
00:09:11,510 --> 00:09:15,950
and the judge to be OpenAI, but it would be more interesting to switch this one up.

167
00:09:15,990 --> 00:09:16,950
Let's let's flip it.

168
00:09:16,950 --> 00:09:18,030
As cursor suggests.

169
00:09:18,070 --> 00:09:21,310
Let's use Claude 37 sonnet latest.

170
00:09:21,310 --> 00:09:27,950
The latest Claude 3.7 model so that we have anthropic judging OpenAI's debates.

171
00:09:27,950 --> 00:09:34,110
And this also means that we'll be using anthropic this time, which was harder for us last time.

172
00:09:34,550 --> 00:09:37,670
Okay, so with that now I think we should be ready.

173
00:09:37,710 --> 00:09:39,790
We can bring up a terminal.

174
00:09:40,030 --> 00:09:40,830
Here it is.

175
00:09:41,070 --> 00:09:47,350
We will want to change into the directory for crew and then the directory for debate.

176
00:09:47,590 --> 00:09:49,590
And now we simply type crew.

177
00:09:49,590 --> 00:09:52,870
I run to kick off the run.

178
00:09:52,870 --> 00:09:56,630
And the first time you do this, it's going to do some UV stuff to build the environment.

179
00:09:56,630 --> 00:09:58,870
But I've already done it, so it's running right away.

180
00:09:59,030 --> 00:10:01,150
You can see it's executing tasks.

181
00:10:01,390 --> 00:10:05,430
The debater, each of the agents is running it's debate right now.

182
00:10:05,430 --> 00:10:10,630
It's the the debater for the proposer has already said the against is now debating.

183
00:10:10,950 --> 00:10:15,830
And now we're deciding on the winner of the debate based on the arguments.

184
00:10:15,830 --> 00:10:16,900
It is anthropic.

185
00:10:16,940 --> 00:10:17,860
That is thinking.

186
00:10:18,340 --> 00:10:24,860
And with any luck, we will soon see whether anthropic decides for or against the motion.

187
00:10:25,260 --> 00:10:25,900
Here we go.

188
00:10:25,940 --> 00:10:26,860
Let me see.

189
00:10:27,500 --> 00:10:33,220
In evaluating, I found the arguments in favor of the motion to be more convincing.

190
00:10:33,420 --> 00:10:39,100
So the view is that there should be strict laws to regulate large language models, such as the very

191
00:10:39,100 --> 00:10:41,420
one that is making the judgment here.

192
00:10:41,780 --> 00:10:42,380
Okay.

193
00:10:42,420 --> 00:10:43,020
So that ran.

194
00:10:43,020 --> 00:10:46,180
And look, that's quite a wordy response that came from anthropic.

195
00:10:46,220 --> 00:10:50,380
There you get to see in here the trace of the thinking that happened.

196
00:10:50,500 --> 00:10:53,700
And you'll see that an output directory has been created.

197
00:10:53,700 --> 00:10:59,220
And if we open this up and if I close this terminal so it's not in the way we can go into the output,

198
00:10:59,220 --> 00:11:05,580
and you'll see that there is weighty argument in favor of LM law regulation that you can read about

199
00:11:05,580 --> 00:11:11,740
about the ethical, safety and social challenges necessitating strict regulatory frameworks.

200
00:11:12,140 --> 00:11:15,300
And then the opposing thinking as well.

201
00:11:15,780 --> 00:11:19,020
It's no doubt going to be about hindering creativity.

202
00:11:19,260 --> 00:11:19,900
Yes.

203
00:11:19,940 --> 00:11:20,580
Very good.

204
00:11:20,620 --> 00:11:23,540
And I'm sure there's some compelling arguments there, too.

205
00:11:23,780 --> 00:11:28,900
And then the decision is the thing that we already saw printed a moment ago that came from anthropic.

206
00:11:29,100 --> 00:11:33,460
And so that is our first experiment into the world of crew.

207
00:11:33,500 --> 00:11:35,180
We set up our yamls.

208
00:11:35,180 --> 00:11:40,820
We set up our overall our our module for crew, the crew module.

209
00:11:40,980 --> 00:11:47,620
And then the main.py was where we set the motion, which was the thing that was templated in the various

210
00:11:47,620 --> 00:11:48,260
YAML documents.

211
00:11:48,260 --> 00:11:56,340
And we actually ran our debates with debates, crew kickoff passing in the inputs, this dictionary

212
00:11:56,500 --> 00:12:00,820
of the templated keys with their values.

213
00:12:01,300 --> 00:12:07,660
So I hope you enjoyed our first foray into crew AI, and I very much encourage you to do the same thing.

214
00:12:07,700 --> 00:12:12,740
Well, of course you will actually see this debates project in there, but you can go and make a second

215
00:12:12,740 --> 00:12:13,140
one.

216
00:12:13,140 --> 00:12:16,860
Or just run this by typing query run and get a handle.

217
00:12:16,900 --> 00:12:20,140
Get a good sense for how crew AI works.