And now we move on to tasks.
And here you'll see that there is a research task and a reporting task.
By default.
But we're going to change this and we're going to have a few different tasks.
We're going to have a task called propose.
This is of course going to be the task which is about proposing a motion.
And so the description what is this task.
It's going to be your proposing the motion and then the motion that gets passed in when we do that part.
Come up with a clear argument in favor of the motion.
Be very convincing.
Then we're going to have an expected output, which is going to be quite simple.
The expected output is going to be your clear argument in favor of the motion in a concise manner.
The agent.
So this is where you associate a task with an agent.
And obviously this is going to be associated with the debater agent.
And then there's one other thing we can do here which is an output file.
We want to put this in a subdirectory output and we will call it propose.md.
And so there you have our proposal task.
So now we're going to have another task which I'm going to copy and paste.
And this one is going to be oppose.
This is the debater that's saying no description.
Instead of proposing you are in opposition to the motion, come up with a clear argument against the
motion.
Looks like Kostas can help there.
It does help.
Be very convincing.
Your clear argument against the motion.
And that should be oppose.
It's amazing, isn't it?
So cursive does all the work for us.
And now we have our final task, which is going to be called decide.
And uh, the as a little tip here, something which is worth knowing is that you cannot call your tasks
the same thing as you call your agents, or you will have a problem with conflicting names.
So sometimes it's better to call this like proposed task, opposed task.
But I've kept it short.
But we couldn't, for example, call this task judge.
Otherwise that would conflict with the agent that we called judge.
All right.
So description we will say review.
Let me see.
Now review the arguments.
Here we go.
Review the arguments presented by the debaters and decide which side is more convincing.
And we'll just change this to delete all of this.
We don't need any of that.
We just need to say the expected output is your decision on which side is more convincing.
And let's say and why.
All right.
And then the this should go please to a folder outputs and decide folder output.
All right.
That seems good.
So there are our tasks.
Okay.
So the final step really is is the final steps is setting up pi and Main.py.
And then we'll be ready to go.
So this is the default module crew dot pi.
And you can see it's got some stuff in here based on the standard scaffolding.
It has created a class.
And it's got this crew base decorator around it.
And this class is named the same as the name of our project debate.
So it's set that for us and it called it Debate Crew, which is exactly right.
Now one of the things I dislike a bit is that it does generate all of this scaffolding code, all this
standard code with lots of comments, and you can read some of the comments and follow the links.
And it's got stuff like there's, there's ways that you can add in functions that get called at the
beginning and end and stuff like that.
But I do find that these comments are get in the way a bit, and I usually start by coming through and
deleting everything in these just to keep it nice and clean.
But what you'll see that it's done that is nice is that it brings in the agent's config and the tasks
config.
It just brings them in from the config folder right here.
So those are set as variables for this class.
And you can see how it refers directly to our configuration.
And of course, that means that if you had different configuration files, then you could bring them
in just like that.
Then this is stuff about how you can bring in your own tools.
And then this is where we set up our agents.
So obviously we don't have an agent called researcher.
We have an agent called debater.
And the agent decorator is telling crew that this is an agent.
It's going to return an agent, the config.
We're going to want to change that to debater and we'll leave it verbose.
True.
Which means that we'll get a nice sort of print as it's running with what's going on.
And then we'll have another agent and remember the name of this guy.
Well, even if you don't, luckily cursor does and it's filled it in in both places.
There we go.
The judge is our other agent.
All right.
And now I'm getting rid of the comments about tasks.
But it tells you about how you can do things like track outputs and dependencies and the like.
But we're going to go on and define our, our tasks.
They have a again the decorator task.
And now we're going to have a task called propose.
And there we go.
Cursor fills it in.
Now it has an output file listed there.
But we don't need that because it's already specified in our config file.
So that's not actually needed.
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
all on one line like this, we don't need to be on multiple lines.
And now you can see how very simple this whole function is going to look.
And look cursor is going to do it for us.
And then we can just delete that.
Sorry I'm tidying this all up when you see how much better it is when this is in JupyterLab.
And you don't have to watch me doing all this.
So don't hate me.
I'll be quick, but I think it's nicer if we have it looking nice and sharp like that.
You see how nice and simple and clean this is?
And that's the benefit of using the the config that we don't need to, to have too much here.
And then the other task is oppose.
And obviously it brings in the config for oppose.
And then the final one is decide.
And there we go.
Thank you cursor for filling that in for us.
So those are our two agents and three tasks.
And we are down to the final section here.
Okay.
So now we now create this the crew.
And this is, this is in the the function crew.
And it has the decorator crew.
And I'm going to take out the, the piece there which we will be coming to later.
So we just simply have to create an instance of crew.
We populate the agents with agents and as cry helpfully tells us, this is automatically created by
the agent decorator.
We populate it with the tasks that are similarly created.
This is where we choose to be sequential rather than hierarchical in our process, and that we want
to be verbose.
And then there's some stuff about being hierarchical if you want to.
And uh, look, if you want to use that nice little comment from the crew team in there.
Okay.
that's it for our crew object.
We're almost finished.
That was our crew module.
We're now going to the main module where we finish things off.
So this this is the again there's all of this stuff that you can read.
This main file is intended to run your crew locally.
So refrain from adding unnecessary logic.
Gotcha.
So inputs when we're running the crew, this is where we choose those template values that we put in
our YAML file.
This is where we choose what we want them to be.
And so what we want them to be here is we want to have a motion and we want to give ourselves a nice
motion.
We don't we don't have this.
We only have the one field motion.
And what motion?
What do we think that we would like them to debate?
Let's have the motion is there should be a that was that was where I was heading with this uh, cursor.
I must be super predictable, but it does seem like a good one to have our eyes A's debate.
Let's not say there should be.
Let's say there needs to be strict laws to regulate llms.
There we go.
That's a nice meaty topic for them to debate.
And then we've got our stuff down here.
We will come back to this stuff.
We don't care about any of that.
That is all it should take.
We should now be ready to run our first crew just based on that.
Actually, just before we run, let me make another little change that in this main module.
I'm just going to make sure we print the result to the screen just to be satisfying.
It will be saved to a file as well.
Results equals debate.
And then we will print result dot raw.
That will print the raw output from the final task sent to the final agent.
And then maybe one other little change I'll make is I realize we're right now sending both the debater
and the judge to be OpenAI, but it would be more interesting to switch this one up.
Let's let's flip it.
As cursor suggests.
Let's use Claude 37 sonnet latest.
The latest Claude 3.7 model so that we have anthropic judging OpenAI's debates.
And this also means that we'll be using anthropic this time, which was harder for us last time.
Okay, so with that now I think we should be ready.
We can bring up a terminal.
Here it is.
We will want to change into the directory for crew and then the directory for debate.
And now we simply type crew.
I run to kick off the run.
And the first time you do this, it's going to do some UV stuff to build the environment.
But I've already done it, so it's running right away.
You can see it's executing tasks.
The debater, each of the agents is running it's debate right now.
It's the the debater for the proposer has already said the against is now debating.
And now we're deciding on the winner of the debate based on the arguments.
It is anthropic.
That is thinking.
And with any luck, we will soon see whether anthropic decides for or against the motion.
Here we go.
Let me see.
In evaluating, I found the arguments in favor of the motion to be more convincing.
So the view is that there should be strict laws to regulate large language models, such as the very
one that is making the judgment here.
Okay.
So that ran.
And look, that's quite a wordy response that came from anthropic.
There you get to see in here the trace of the thinking that happened.
And you'll see that an output directory has been created.
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,
and you'll see that there is weighty argument in favor of LM law regulation that you can read about
about the ethical, safety and social challenges necessitating strict regulatory frameworks.
And then the opposing thinking as well.
It's no doubt going to be about hindering creativity.
Yes.
Very good.
And I'm sure there's some compelling arguments there, too.
And then the decision is the thing that we already saw printed a moment ago that came from anthropic.
And so that is our first experiment into the world of crew.
We set up our yamls.
We set up our overall our our module for crew, the crew module.
And then the main.py was where we set the motion, which was the thing that was templated in the various
YAML documents.
And we actually ran our debates with debates, crew kickoff passing in the inputs, this dictionary
of the templated keys with their values.
So I hope you enjoyed our first foray into crew AI, and I very much encourage you to do the same thing.
Well, of course you will actually see this debates project in there, but you can go and make a second
one.
Or just run this by typing query run and get a handle.
Get a good sense for how crew AI works.