In this second episode of CrewAI: Noob vs Pro, we’re diving into tools! I’ll show you how to avoid common beginner mistakes and build tools like a pro, including:
1️⃣ Creating custom tools for CrewAI that integrate with external apps like Trello and Reddit. 2️⃣ Using the newest CrewAI features (like the Before Kickoff decorator) to unlock next-level capabilities. 3️⃣ Building a CrewAI that automates Trello tasks—researching topics, writing articles, and updating your Trello board with actionable insights!
Want me to analyze your Crew in an upcoming video? Send it to [email protected]—your project might just get featured!
This tutorial is perfect whether you’re just starting out or ready to level up your CrewAI development. Get ready to build smarter, faster Crews that tackle real-world tasks effortlessly! 🚀
Hey guys, and welcome to the second episode
of Crew AI Noob vs Pro.
And in this episode, we're gonna be talking about tools
and how you can avoid a bunch of the common beginner
mistakes and how you can start to build tools like a pro.
And by the end of this episode,
you're gonna learn how to create your own custom tools
and use some of the newest features of Crew AI
so that you can go off and integrate your crews
with other applications, access external data,
and take on tasks that would just otherwise be impossible.
But enough talking, let's go ahead and dive
into the crew and tools I've built for you guys today
so that you can see how everything works together like magic.
All right, so here's a quick overview of the crew
that we're gonna be building together today.
First off, this crew is going to be a combination
of a research and writer tool, but with a twist.
This crew is actually gonna be connected to Trello
using a bunch of custom tools that we're gonna be working on
and building together.
And the way it works is this crew is gonna go off
and pull down all the different cards
that we have in our to-do column.
And then this crew is gonna go off and research the topic.
From there, it's gonna go off
and write some preformed articles for us.
Then once it's done, it's actually gonna use
some custom tools to then publish everything
that it learned about the article
and then publish it to our card
and move it from the to-do column over to this column.
So let me just show you.
It's going to come in here and add a comment
with everything that it found about the topic.
So a quick summary, the main thing it's gonna share
are some detailed insights, and most importantly,
actual steps that our readers and writers
could take away from this comment.
So this is exactly what the crew's gonna do.
And like I said, we used a combination
of a bunch of different tools to make all of this happen.
We're gonna get deep into some models,
and we're also gonna cover some nice utility files
to make our life so much easier.
And by the way, I'm gonna be giving away
all this source code completely for free.
Per usual, link down in the description below.
But enough talking, let's actually go ahead
and start diving in to building out
everything you see right here.
Oh, and real quick, if you're looking
to get some support on your own crews
and meet a bunch of like-minded AI developers,
I've created a free school for you guys.
We have over 4,000 members now,
and we would love for you to be a part of that community.
We have weekly free coaching calls,
and we have a bunch of support for you in there,
and we'd love to see you over in the community.
But enough of that, let's hop back to the video.
All right, so let me share a quick roadmap
of everything that we're gonna be building out together
as we go off and build the crew and the custom tools.
So first things first, we're gonna cover
all of the tasks and agents inside of the crew
so you can understand exactly
what we're trying to do at each step,
what tools we need at each step,
and just have a good understanding of our overall goal.
Next, we're going to dive in
and do a quick custom tool crash course
so you can understand everything
that goes into building a custom tool
and how all the different fields and everything
work together to help supercharge your crews.
Then finally, we're gonna take everything
you just learned in the crash course
and actually go off and start building
a bunch of tools from scratch
so that you can start working on
building out your tool muscle.
And we're also going to start looking
at one of the cooler features
that was just released inside of CrewAI
called Before Kickoff, and you're gonna see
how this makes it super easy to feed in
a bunch of raw data into our crews
to make our lives so much easier.
But enough talking, let's go ahead
and start quickly covering all the tasks
and agents inside of our crew.
All right guys, so welcome to the code
where we're gonna quickly cover the tasks
and agents inside of this crew
so that you have a great understanding
of everything that's going on
before we go off and start creating our own tools.
So quick overview, we have three tasks
and we have three agents, a research,
a writer, and a Trello, and they're basically a one-to-one.
So let's cover quickly each one of these tasks
super fast, and I'll be sharing
some noob versus pro tips along the way.
Okay, so here is our current task.
Whenever we want to go off and research
a specific subject, a pro knows
that crews love examples.
So in our case, we know that we wanna
go off and research a topic.
Well, a pro would go, cool, well I'm not
just gonna say go off and research topics.
I'm gonna go ahead and tell you the exact format
that I'm gonna be passing topics over to you.
So in this case, we're gonna be passing over
an array of objects, and the topic
can be found right here inside of the array of objects.
In addition to that, we're not just gonna say
go off and research, because that's so vague.
We're specifically gonna say you need
to go off and research on this platform.
You need to focus on gathering, in our case, what?
We basically wanna answer any questions
that LLM might have.
In our case, we're gonna say you need
to focus on gathering actual insights
for who, for developers.
That way, we have a target audience.
We already know who, you know, developers,
what needs they have, and we're gonna focus
on getting actual insights for those developers on topics.
So as you can see, we're getting hyper clear
with what we're trying to do here.
Then, what we can say is not only
do I want you to research it, I'm gonna go ahead
and give you a few examples of insights
that you would probably expect to see.
The reason why we do this is task and agents
love examples.
That way, they know how to replicate it,
and they're not just guessing at what you want.
We're giving them actionable insights with examples
so these tasks know exactly what to do.
And then finally, what we're going to do
is go ahead and pass in basically a variable
of like, yep, these are all the trailer cards
that you need to go off and research.
And then finally, a pro also knows
that when it comes to the expected output,
you need to go ahead and specify
exactly what you want to happen.
In our case, we want the expected output
to be an array of objects.
Each one of these objects is going to have
the ID of the trailer card,
the name of the original topic researched,
and then all of the research that we just found.
So, what you'll notice real fast is
instead of just like hoping that the LLM
actually gets this array of objects properly spit out,
what we can do is we know we can actually
back in our task, our research task,
we can define a new model that perfectly defines
exactly what we want to get spit out.
So, in our case, we can hop over here
and see we're in our models folder
and see that, oh, yeah, whenever you go off
and do research, research is going to include
a list of research topics where each research topic
is going to include an ID, name, and research,
just like we specified over here.
So, cool, hopefully that makes sense.
Then what we can do, let's keep chugging along.
So, next, we're going to go ahead
and start talking about articles.
So, at this point, we've done a ton of research
on the topics that we've found
and listed inside of our Trello board.
Now, what we're going to do is turn all of that research
into an actual article that we can go off and publish.
In this case, I think we're just doing
like a daily actionable newsletter for AI developers.
So, in this case, we're just going to say,
hey, use the research provide from the research task
because a pro knows the way Crew.ai works
is that the work from this task
gets passed as context to the next task by default.
You can obviously alter that,
but by default, that's exactly what's happening.
So, we're going to say, cool, yeah,
you're going to get all the research,
and now it's your turn to actually go off
and generate short actionable articles.
For each article, we just give it very specific instructions
on what a good article looks like.
Not only do we give it good instructions
on what it looks like,
we go ahead and expand in an example structure.
So, it's a very clear what the LLM needs to do
when it's going off and writing this article,
such as like, hey, talk about this topic,
key findings, details, insights, so forth,
And then finally, once again,
we're going to say the expected output
is another structured output.
And this time, once again, as a pro,
we're going to be leaning on
what is the specific output for this one.
And in our case, it's another model that we defined.
This one's an article and same thing, ID, name, and article.
That's exactly what you'll see back over in our task,
ID, name, and article.
Perfect.
So, this is exactly what we're wanting.
And then finally, we're going to allow our agent,
if you remember, we wanted our agent to go cool,
I've done all the research, I've written the article,
I now want to update our Trello board
to go off and move the card from the doing
to like, hey, we researched it,
and add a comment with the new article.
So, that's exactly what we're going to do
and update inside of our task.
We're gonna say, hey, using the input
from the previous task,
I would like you to go off and do the following things
in a very clear manner.
Step one, add the article
to a comment on the Trello card,
move the Trello card to the next column in the workflow,
and basically just confirm.
So, if anything went wrong with the tool calling
along the way, just basically let us know.
And we're going to say,
please use the Trello tools provided.
This is super helpful because you'll see in a little bit,
whenever we go off and start calling our Trello tools,
that's gonna be very helpful for the agent to know,
oh, I need a Trello tool, I need a Trello tool.
And it's gonna be able to better request
and see what tools it has available
and call on the specific tool.
So, it's gonna be super helpful.
And then finally, if there's any errors,
please let us know so that we can see it in our logs
and take the appropriate actions.
Okay, hopefully this was a super helpful
to see on our agents.
Now, let me quickly cover the agents.
Agents are not as important as tasks,
but they're obviously still,
we need them to go off and reason and act
on the actions and tasks that we've given it.
So, basically we have a researcher,
they're gonna go off and research.
They're a professional research.
A writer, they're a professional content writer.
And Trello manager, they're just a professional
at moving Trello cards around.
This would be a pretty sweet job
if all you had to do is move Trello cards around.
So, that is pretty much everything
when it comes to our crew.
And as you can see, we kind of dived in as a pro.
We've started to use some output variables
for our tasks to make sure that they spit out
a specific format.
That was one of the pro tips.
And we spent a lot of time inside of our tasks
to make sure that we gave a ton of examples.
So, enough of this, let's go ahead
and actually start diving into the fun part,
which is gonna go off and start building
all of the tools for our different agents.
So, in our case, we're going to go off
and give you a quick preview.
We're going to give our research agent
the ability to go off and search Reddit.
We're going to give our Trello manager
the ability to add comments to cards
and the ability to update cards.
So, move them from column one to column two.
So, overall, three tools.
So, now that you have a high level overview
of what we're about to go build,
let's go do a quick crash course on tools
so you understand exactly how they work with our agents,
why we need them, and understand how you can start
building your own custom tools.
So, let's go ahead and head to the next section.
All right, guys, so welcome to the fastest tool
crash course of your life.
In this section, we're quickly gonna cover
what is the relationship between agents and tools
and some of the key lessons you need to learn.
Then, second, we're actually gonna go look at a crew
that has already run so you can see,
oh, yeah, that is how an agent called a tool.
That's pretty cool.
And then, finally, we're gonna take a step deeper
into some code and actually look at the core structure
of a tool so you can actually understand
how the different parts of the tools relate
so that when we're off in the next section
building our own tools, you'll be like,
oh, yeah, that's how that relates to that.
And this all makes total sense.
So, obviously, we're gonna build a bunch of tools
in this course, so you're gonna see exactly
how everything works together
and really build up the tool muscles.
All right, cool, so let's do a quick overview
first off of what the heck are agents and tools
when it comes to working together.
So, the best way I like to think about tools
is as your agent is going off and solving problems,
every step along the way, the agent is thinking,
hmm, what is the best way I can possibly solve
the current issue and problem I'm facing?
Because if you remember, an agent is nothing more
than an LLM that's asking itself
a bunch of questions in a loop.
So, specifically, the agent is going,
okay, I'm trying to write a blog, that's my goal,
well, how can I tackle that goal?
I can first plan out an outline,
then once I plan an outline,
I can start filling in each section,
and then once it's all done, I can review it.
So, the agent put together a plan,
and then it starts acting on each step of its plan.
So, it reasons, and then it acts.
So, that's exactly how an agent works.
And then that agent, at each step along the way,
it's going, hmm, okay, I'm at a current step,
and do I have any tools available
to help me solve my current problem?
So, let's imagine in our research paper example,
it actually, once it did an outline,
it wanted to research each step.
So, the agent would go, okay, well,
if I want to see what information's available
on this topic, will this tool help me?
And what the agent's gonna look at
is it's gonna look at the name and description of that tool.
So, is getting the date gonna help me?
Nah.
Is adding the two numbers together gonna help me?
Nope.
Is searching the web gonna help me research?
Oh, yeah, that definitely seems
like it's gonna help me research.
So, it's gonna go, the agent's gonna go,
yes, I would like to use this tool.
Now, what do I need to pass over to this tool?
Oh, it looks like I just have to pass over a query
that describes what I want to go off and search.
Oh, so easy.
I would just go ahead and pass in,
I would like to research topic B.
And that's exactly how agents and tools work together.
So, at the end of the day, just know,
agents use tools to help them accomplish
their own problems that they're facing.
When it comes to tools,
the important thing that you need to know,
a tool must have a name, a description, and arguments.
Name's just the high-level name of the tool.
That's how we eventually call it.
So, it's like its unique identifier
and describes what it's gonna do.
The description is the clear description
that tells the agent exactly what this tool does.
I help you achieve blank.
Whenever the LLM and agent are doing its decision-making
on which tool to call,
it's really looking at the description.
And then finally, once it does pick a tool to use,
what information do I pass to this tool
in order to properly work with it?
That's where arguments come in.
So, those are the three important things
you need to know about tools.
But enough high-level talk.
Let's actually go ahead and look at an example
of a crew calling a tool
and actually using some of these core concepts.
So, this is an example of a senior data researcher
who's going off and trying to basically search the web.
So, this is all the different tasks,
goals, and responsibilities
that you add to your agent's YAML file.
This actually appears in nothing more
than just a normal text message in an LLM call.
And basically, what's happening
is we're just adding a lot of formatting around it.
So, you can say, hey, you are a senior data researcher.
Your job is to do this.
Your goal is to do this.
And you also have access to these tools.
And if you remember, a tool has three core components.
It has a name, it has the description,
and it has an argument.
So, you can actually see these come to play in real life.
So, you can see like, oh yeah, our SERPR,
which is a tool for searching the web.
Here is what it does.
It's a tool that can be used to search the internet
with a search query.
What arguments do we need to give the tool?
Oh, quite simple.
We need to give it,
we have the option to give it a search query.
And what's the description for it?
It's the mandatory search query
you need to pass in to search the internet.
And you need to give it a string.
Don't give me an integer.
Don't give me a Boolean.
Nothing like that.
I need a string.
So, as you can see, we're very clear
what the tool does, how it's used,
so that the agent can go off and call it.
Then what's pretty cool is now the agent,
like who's really just thinking in a loop
over and over and over again, is going, hmm,
well, my goal is to go off and compare this topic
and search about it.
So, that's my thought.
What action do I want to take?
I want to search the internet, the tool name.
I'm going to perform this tool.
And what information do I want to pass to this tool?
Well, I'm actually just going to do
exactly what the tool arguments told me to do.
I'm going to pass in a search query.
And in this case, I'm actually going to,
instead of just this description
about what needs to happen,
I'm actually going to put in the query I want to use.
So, in this case, I would like to search
the Apple Watch Ultra 2.
Is it a good watch for a marathon training?
Then what's going to happen is
we're going to actually start getting results from the tool.
So, after this, there's just going to be a huge chain
of all the different search results we've gotten
as we've searched for this topic on the internet.
So, this actually kept going on for a very long time.
So, as you can see, it's pretty cool.
We use the name of the tool,
we use the arguments to actually figure out
what to pass into it,
and we use the description to figure out
if we should use the tool in the first place or not,
based on our current goal.
So, now that you've kind of seen like,
oh yeah, that is what tool calling is in the wild,
let me actually just show you
a few of the core components of a tool
so when you're off on your own building them
and when we're in the next section building tools together,
you have a really good idea of how we go off
and actually build tools that work inside of Cruise.
So, remember, core three topics.
To build a tool, you need to have a name,
a description, and an argument.
When it comes to name, you know, like I said,
we're going to be super clear on what it does.
In our description, we're going to be hyper clear
on what action this tool helps the agent accomplish.
In this case, search the internet
is what we're going to help you do.
And then, what's the most important next thing
if the agent does decide to call the tool?
It's the argument.
It is, what information do I need to give you?
So, in our case, what we need to do
is we are going to create a pedantic base model.
So, it's just a, you know, it's a structured way of saying,
you know, I'm making a new class
and it has to have these fields.
So, in our case, we're going to say,
hey, the schema for calling a dev tool,
our SERPR dev tool, needs to have just one input field
and it's just going to be the search query field.
It's mandatory and it's a string.
You have to give it to me.
And then, all we have to do is in our tool say,
okay, cool, I'm going to make sure
to set the argument schema property to this.
That way, whenever we call the final thing
that we haven't got to talk about yet, the run.
This is where we actually trigger the tool
and actually trigger it.
We actually will be passing in this property right here.
Sorry, all of these properties right here
will be accessible right here.
So, it's kind of like a little bit of a dance
because this makes sure that all the inputs we get
are valid and then, so we're going to do
all the logic check right here
and then you can actually start accessing
each one of these different parameters
right here in your run function.
Okay, so this is just a high level overview.
Let's actually look at a really good example
that Firecrawl does.
So, you can see this actually getting
a little bit more expanded.
So, you can actually see like,
oh yeah, that is what a real tool in the wild looks like.
So, here's Firecrawl search tool.
As you can see, quick reminder,
when it comes to the arguments
that get passed into the tool,
we define them up here in a nice pedantic class
where we say like, hey, you got to give me a query.
It's mandatory, it's a string
but all these other fields are optional.
And what does, you know, what goes into each field?
Well, this is where we get very clear with our descriptions
like, yeah, this is the search you want to go off
and search the internet on.
So, you know, a pro, they make sure
they always make their descriptions very clear
on what's going to happen.
Okay, so now let's talk about a few other things
just so you can see what a real life tool looks like.
So, in our case, what's the same?
The name is the exact same,
the description is the exact same,
the argument schema is the exact same.
These are a must.
Additionally, the run class is a must
and the exact same.
The only thing different
is instead of doing our keyword spread operator,
we're just actually going to call out
each one of these items specifically.
So, you can see up here, query, query,
limit, limit, TBS, TBS.
These are the exact same one for one.
And it's cool, whenever we would actually call
the Firecrawl search tool, you would actually,
when you, you know, if you were to see the call in action
like the logs of the call,
you would see it pass over each one of these properties
one by one.
Just to show you what else is pretty cool,
that's pretty common,
you can actually make your tools like set up a constructor.
So, in this case, there's already a library out Firecrawl.
So, we're actually just saying like,
hey, use this library with this API key
and then do all the searches you'd like.
Pretty common setup that you'll see inside of tools
and we'll be doing something very similar
as we're off updating our Trello board.
So, hopefully this makes sense
and hopefully you understand the core concepts
of agents and tools and understand
how tools really just have names, descriptions, arguments
to help the agent pick one to use them.
And then whenever they do decide,
we look at the arguments to figure out,
oh yeah, give it this information.
And then finally, once everything's set up and happy
under the hood, the agent triggers run
and this is what actually goes off
and performs the action itself.
So, there's your super fast tool crash course.
Hope you liked it, but enough talk.
Let's go ahead and get our hands dirty
and start hopping over to the code
where we're gonna start building out
our first tool together.
All right, guys.
So, let's go ahead and start working on our first tool today
which is going to be our Reddit Tavli search.
Now, quick overview.
Tavli is basically just a nice Python SDK
that allows us to go off and search the internet.
Super, super easy to use.
So, let's go ahead and walk through a few
of the core things that you'd have to do
during setup if you were building this on your own.
So, the first thing would be is you would want
to create a new tools file.
So, you would just over here inside of your folder,
you'd wanna go ahead and right click and add tools
and go ahead and create your first tool.
Now, once you knock that out, what you'd wanna do next
is go ahead and add in this package right here.
So, super easy inside of,
because now crew uses UV for package management.
So, you would just go off and type UV add Tavli Python
and that would make sure that the package
would pop up inside your dependencies.
I've already done all this for you.
I just wanna go ahead and give you a quick heads up.
So, when you're on your own, you could crush this too.
All right, so now that we have some of the important stuff
out of the way, let's go ahead and in the prerequisites,
let's go ahead and look at how we would start working
on this together.
So, what I like to do and how I would say
a pro would go about building out this tool
is I would work from the run backwards
because at the end of the day,
the run is the action that you would like to perform.
So, as you can see, I just have a skeleton
that looks exactly like everything we've covered so far.
We have our input model class, we have our tool
and our tool pretty much has all the basics here,
just the core elements.
And then it has a constructor and a run method.
And I've also added this Tavli client,
which is just a nice property and attribute on our class
that we can start using to store our Tavli client.
So, let's go ahead and go at this one at a time.
Okay, so what I would like to do
is first look at how we can call this tool.
Because if you head back over to the docs,
it looks pretty straightforward.
You can see we have a Tavli client,
which all we need to do is pass to it an API key.
And once we give it an API key,
we can start running search on it.
So, let's go ahead and like I said,
we're gonna work from the end backwards.
So, over here, we're just gonna go ahead
and say I would like to return
and I would like to use my Tavli client.
So, Tavli client.
And then in our case, we're trying to search the web.
So, I'm gonna go ahead and search the web.
And then I'm gonna see what are all the potential parameters
I can pass into it.
Because what parameters I pass into search
is exactly what I want to pass in here.
And what I pass in here gets passed up here.
So, like we basically build it backwards.
So, hopefully this is making sense.
So, in our case, the main thing that I want to pass in
is the query.
I probably want to do as well max results.
And for now, I think that's fine.
I think that's pretty cool for what we have right now.
So, in our case, let's go ahead and do this.
So, I'm gonna go ahead and say query is equal to keyword.
Keyword arguments query.
And we can actually go ahead and update this together.
I'm not a big fan of the keyword arc spread operator.
I like to be pretty clear.
So, I'm gonna say query is a string,
max results an integer.
So, in our case, we're gonna update this together
and do a little bit of fanciness.
So, like I said, we're using this
to search Reddit specifically.
So, I'm going to do Reddit,
then I'm gonna pass in the query.
That way we're always searching Reddit and then topic.
And then finally, when it comes to the other parameter
that we wanted to look at, max results,
we're just gonna pass it in right here.
Cool, hopefully that makes sense.
Now, we're gonna work backwards
and start adding in the other parts.
Because remember, we're trying to go backwards.
So, we know to run our tool, our library,
we need these parameters.
Well, these parameters get specified in our arguments.
So, only thing left that we have to do
is update our argument schema
to call out those specific two items.
So, hopefully you're starting to see like,
okay, I feel confident.
This makes sense why I'm doing what I'm doing.
And in our case, we're gonna say, okay, cool.
So, query, this is just going to be a,
the query to search the web
and the max result is the maximum number of results
to return.
And we're just gonna set the default on this one to be three.
Okay, cool.
Hopefully that makes sense.
Now, there's a few other things that we have to do left.
So, next we have to actually like,
all right, our agent is gonna call this tool.
So, what do we wanna call this?
In our case, well, it's the Reddit Tavli search tool.
The reason I include Reddit and Tavli inside the name
is because I've noticed a lot of times,
beginner developers were like,
oh, go off and use the Firecrawl tool
and or go off and use the web scrape tool, insert a name,
like go use the Beautiful Soup tool.
But then in their actual tool,
in the name and the description,
they never call out the word Beautiful Soup.
So, what ends up happening is it doesn't actually go off
and know what tool to call.
So, it ends up getting weird and a stuck state.
So, that's why I'm like, oh,
I'm going to explicitly say the provider of this tool,
you know, to search Reddit and the exact, you know,
in this case, Tavli is what we're using.
So, I'm being very, very clear.
And then in this case,
we're gonna search Reddit using Tavli.
This one is so straightforward,
we don't have to add too much extra information.
But if we were doing a little bit more, we could.
And you'll see this as we build out
more complicated examples.
All right, so the last thing that is left.
So, up to this point, we now have our tool.
We've given it the agent, everything it needs.
The only thing left is our Tavli client.
The thing that's actually gonna do all the work for us,
we never instantiated it.
So, you can see back over here
in the Tavli example code,
we need to actually create the client.
Right now, we've just said like, hey, we have the client,
but actually let's go ahead and create the instance of it.
So, in our case, what we're going to do is go ahead,
during the constructor sake,
I would like to make a Tavli client using the API key.
And what I've done is I actually have a .env example file
for you guys.
So, you could come in here
and actually add all of these API keys.
So, you would just add your Tavli API key right on here,
completely free to use.
And this is how you're gonna go off and start searching.
So, you obviously just populate each one of these.
And we'll talk about each one of these
more in detail later on, but one at a time.
All right, cool.
So, now we actually have this completely set up.
So, now I'm going to show you a quick pause
and how to do a quick trick in here
to actually make everything easier.
And I wanna show you how pros go off and test tools
before they actually start connecting up to our agents.
Let me go ahead and show you this real fast.
All right, so here's the quick trick
that will really help you level up
as you're creating your tools.
Because at the end of the day,
all we're doing is writing Python code for our tools,
which means we have the ability to go off
and just run Python code to test to make sure they work.
So, that's exactly what we're going to do.
We're gonna turn this quick Python file
and actually turn it into something that we can just run.
So, what you're gonna see down here at the bottom,
if we call this file,
what we're going to do is first go ahead and create our tool.
And once we've created our tool,
we're actually gonna go off and run it.
And what are we gonna pass into this tool?
Well, we're gonna pass in a query and a max results.
So, let's go ahead and try this out together
so you can see how we can print the results.
And the reason why we're doing this
is we just want to ensure
before we actually start connecting this up to our agents,
we want to do a quick sanity check to make sure like,
oh yeah, the tools I'm building, they work.
There's no reason in having an agent do all this work
to then in the fifth task,
go off and trigger a tool and be like,
oh, it's broken and waste time.
So, let's go ahead and see this in action.
So, you can see it's gonna take a few seconds.
It's going off, Tavli searching the internet,
and it's gonna come back
and spit out everything that we just asked for.
So, in our case, we've asked it for AI and healthcare.
And as you can see, it's searching for Reddit
because we made sure to pass in Reddit first.
And then it's gonna go off and start looking up of like,
oh, you know, there's risk and data breaches.
It's actually researching.
It's using AI and mental health care by examining.
Yeah, it's doing the research that we've asked it to do.
So, all around, super cool.
So, give yourself a pat on the back.
You've now learned how to go off
and create your first tool that interacts with a library.
You now know how to make sure your tools
actually properly create the library instance
and then start running it.
And you've also learned a cool pro trick
so that you can start testing out your tools
before you start adding them into your agents.
But now that we have this one set up,
you can actually see if we hop back over to our crew.py,
we already have this hooked up and connected in right here,
right in our Reddit Tavli search tool.
So, now this agent, our researcher,
it's ready to go off and call this tool
as it's going off and doing research.
So, enough of that,
let's go ahead and start working on next,
working on our two extra tools,
which are gonna be our Trello add comment to a card.
And the next one's going to be our Trello update card,
which is gonna move things between different columns.
So, all right,
let's go ahead and hop over to tool number two.
All right, guys.
So, now it's time for us to start working
on adding our comments to our Trello cards.
And then eventually in the next phase,
we're gonna start moving the cards over here.
So, I just wanna show you real fast,
a quick recap of what's happening.
So, I have a crew that's running
and it's actually slowly working,
generating the article.
So, any second now,
we should actually see the card update here
with a comment icon.
And the second it's done adding the comment icon,
we should see it pop over to the next row
where we'll know like, yes, officially,
the topic has been researched,
the article has been generated,
life's good,
we can start sharing it in our weekly AI developer newsletter.
So, bada bing,
it added the comment
and then another step here in a second,
it moves it over.
So, as you can see,
that's exactly what our crew is doing for us.
And so, let's actually take a little deeper dive
into what this comment looks like,
just because we're gonna be working on
building this function out right now
in this tool section right now.
So, you can see,
great topic using a nice header,
summary of findings,
details and actionable items
that the person can go off and take on their own.
So, all around,
really freaking cool.
So, quick recap two,
I wanna show you guys under the hood,
what we're doing before we go off and build the tool,
just so you can understand exactly what's going on.
So, when it comes to Trello,
Trello allows you to go off
and make all sorts of requests to their app.
However, it's done all through an API.
So, in tool number one,
we were using a library
and working around that,
building backwards.
In this section,
we're gonna be working around building a tool
that's all focused around this specific API endpoint.
So, if you can master libraries and API endpoints,
you are golden when it comes to building tools.
So, as you can see,
there's only two things that we need to have.
It's the idea of the Trello card,
and then it's the text that we want to add as a comment.
Super simple.
So, enough talk,
let's go ahead and hop back over to our tool,
so we can start building it out.
So, what we're gonna do,
let's hop back over to our scaffold version of this tool.
So, this is our Trello ad card comment tool.
Remember, you need to go off
and create this tool over in the tool folder.
Now, what we're gonna do first
is we're gonna follow the exact same process,
so we can start building up some muscle memory.
So, the first thing you need to do,
if you remember,
is we're gonna work backwards from the end.
So, we are going to update our run method first.
Now, what information do we need to pass into this?
Well, in our case,
it's just two different pieces of information.
It's gonna be the ID of the Trello card,
and then it's also going to be the text,
as we just said.
So, we can come in here,
and we're gonna do two things.
We're gonna say,
I'd like to first add the card ID,
and then the text.
Super straightforward.
Now, what we're gonna do next
is, because this is where things start to get
a little bit interesting,
is we basically need to start building out
this code right here.
So, what I did whenever I was creating this
is I pretty much copied this code right here,
and I'm using cursor.
So, this is just like another pro tip
for you guys to understand
how you can go off and make your life easier.
So, I would add this over here.
I would paste in the code,
and then I would just say,
please get my run function
to work with this Trello
add comment to card API request.
Now, this is gonna go off
and take its best stab,
but I just wanna show you
that it's pretty darn good
at what it's gonna do.
So, first things first,
it's going to go ahead and add that URL.
It's gonna add the headers.
Then, it's gonna go ahead
and add the key and token,
which are super important.
You can't just make any request
to anyone to Trello board.
You have to have an API key
and API token first.
So, let's actually make
another quick change to this.
We're gonna say, looks good,
but I'd like you to add
some validation first
to make sure we have the API key and token.
Now, what this is gonna go off
and do is they're going
to hopefully reorganize this
to first get the keys,
then validate exactly.
This is exactly what we want to do.
So, yeah, as you can see,
we don't have to build tools ourselves.
We can actually really rely on AI
to help us build out these tools.
Cool, so we're gonna go ahead
and apply that.
Looks good.
Then, what you can see down here
is they're doing all sorts
of fanciness.
We really don't need
to add all of this.
We can have it,
but main thing that we wanna do
is we're just gonna say,
success, comment added successfully.
Just because our LLN doesn't even know
all the details,
it just needs to know things went well.
Otherwise, we're going to return,
error adding comment,
and then we can pass in the actual error
in a format that the LLN can understand.
Okay, cool.
So, this is looking pretty darn good, guys.
So, let's clear this out
so we can actually see exactly what we're doing.
So, we're going to have our two API keys.
And don't worry,
I have these set up in the example file for you.
So, we're going to have the API key
and API token.
I'll actually have a link to you guys
so you can actually go read
the exact blog I did
to find out how to get all this information.
I also, to make your life even easier,
because y'all are awesome,
is I went ahead and put together
this Trello utils file
so you can go off
and get all the necessary pieces of information
you need to actually successfully set up
your local testing environment.
So, just know this utils file is here for you too
to get a lot of these extra follow-up
environment variables that you need outside of,
basically to help you get all of these.
Okay, cool.
So, what we're gonna do next is,
if you remember,
because we are pros,
we're now gonna go off
and actually start trying to, you know,
test this tool locally
before we actually go ahead
and add it into a group.
And I did lie real fast.
We do have to do one other thing real fast.
Following our tried and true method,
we gotta work backwards.
So, I jumped the gun.
I apologize.
So, first, we have the proper parameters.
We're using them.
Life's good.
Now, the only thing left for us to do
is then update our argument schema.
So, in this case,
what we have to do is come up here and say,
yep, I'd like to add in these two different attributes
to our class,
a card ID and text.
And these are just,
make sure you have the description
so the LLM knows what information goes where.
And what's cool is because,
if you remember back in our task,
just to like help make everything click,
the Trello card ID is right here.
So, you can see like,
oh darn, that is getting passed into the task.
And this Trello card ID is just getting passed out
through everything from one item to the next.
And then eventually it gets passed out down here as well,
because it just gets passed along
from one output to the other.
And eventually it gets used in call down here.
So, pretty cool.
All right, so now that we have that set up,
now we can go ahead and start adding in
that method real fast
to where you can go ahead and actually see this in action.
So, here is our quick code snippet
that we're gonna use to test out our tool,
just so we can validate it before our agents do it.
And per usual,
you're gonna go ahead and instantiate the tool.
Then we need to go ahead and define our properties
that we're gonna pass into our run method,
and then go ahead and kick it off.
Now, I'm gonna go ahead and pause real quick
and find an updated test card ID,
so we can go ahead and get this working real fast.
And I'm actually gonna show you the easiest way to do this.
And it all comes back to our Trello's utils file
that I made for you guys.
Because if you remember,
another pro tip for you guys is,
a developer will only do something once.
So, if you're having to do something more than twice,
throw it in code so that you can easily
run through it again and again.
So, in our case,
we're going to use our Trello utils file
to quickly go off and get all the cards in the list.
In our case,
we're gonna get all the cards in the to-do list.
Reason we wanna do this is to get the full card ID.
So let me show you how to do this.
We're gonna first move our card back over to this section.
Let's go ahead and delete this comment.
And then what you're gonna see is,
great, we now have our card here.
And we need to basically find the ID of this card.
So now we can actually fully run the code.
So we're gonna do Python,
and we're gonna call this out,
source pro utils Trello.
And this should go off and instantly find our card ID.
So you can see it found it.
So here's our Trello card ID.
So we can come down here, paste it.
Fantastic.
Now, once again,
we get to use our new pro tool,
which is a cheat code,
which is going off and calling this new tool
that we've created.
So once again,
just because at the end of the day,
we're writing Python code,
we get to call everything.
So source pro tools, tools,
and this is the Trello add card.
So now we're gonna go ahead and kick it off.
And then hopefully,
we would like to see this get updated with a comment.
So boom, we verified that our tool works.
It has the right comment.
Things are fantastic.
So absolutely loving it.
So now what we've done is we've built two different tools.
One's a library, one's an API.
You're gonna see in the next section
how we build another API tool,
like a tool that wraps around API.
But you're gonna see how this one's a lot more complex
because there's a lot more moving parts,
but you're gonna see that the tool still works perfectly.
So, all right,
let's go ahead and hop over to the final tool.
All right, guys.
So now it's time for us to start working on the third tool.
And this tool is all about updating the card.
Specifically, we're going to update the ID list
on this card to go from the to-do list
over to the researched article generated list.
That's our whole goal.
Now, I'm gonna go ahead and show you what the API,
basically the API endpoint looks like
so you can understand exactly what's going on.
And I'm gonna show you how a pro would go about
actually turning all of this into an actionable function.
So in our case, when it comes to updating a card,
we need to do one mandatory thing,
which is pass in the ID of the card that we want to update.
And the next thing is there are a list of query parameters
that we can update on a card.
So everything from the name of the card,
basically the due date, whenever it gets started,
the address, everything about the card we can change.
And in our case, the specific thing that we want to change
is the ID list.
So this specific column has ID list one,
and this one has ID list two.
The utils file I created for you guys,
go ahead and grab all of these lists.
But that's what it can do.
So a new would go, all right, cool.
I'm going to go off and I'm going to make sure
I copy each one of these over into our card input.
A pro goes, that would take forever.
So what a pro would do is they would take a screenshot
on their Mac and they would upload it over to cursor.
So I'm going to go ahead and actually show you guys
exactly what I would do.
So we'd pass in the request.
It goes all the way down to ID labels.
They would make sure to include ID labels
in the next code snippet.
Fantastic.
They'd upload that as well.
And then they would paste in the overall command
that they're trying to run.
So they'd paste that in.
So here is the code.
Then what they would also do,
oh, it didn't update the full one.
Sorry about that.
Let's go ahead and grab the whole thing.
Fantastic.
And then what a pro would do is add in a reference
to an already existing file
so that the AI knows exactly what they need to do.
So I'm going to say, in our case,
I already know how we want to run the code.
So we're going to focus on updating the input first,
just because I want to go ahead
and show you how we can use this pro trick.
So we're going to say, please update the input.
Actually, just copy this.
The Trello card input using the queries
and params in the picture.
Please follow the style format in.
And then you're going to reference the other Trello card
just so it knows, oh yeah,
that is what a good input file looks like.
So we're going to go ahead, send that off,
and it should go ahead and start generating code
for us to go ahead and put in here.
Now, as you can see,
it's actually taking each one of those
and formatting it over.
So awesome.
That would have taken us forever to manually type out.
Thankfully, we don't have to do that right now.
So this is basically a one-to-one match for everything.
So an ID list is a string.
Yeah, basically everything is a string getting passed over
and yeah, everything is great.
Everything down to the cover is getting passed over.
The cover is the only thing that probably
is going to be a little bit more interesting
just because it's a full-blown object.
So we're going to go ahead and just put it as a dictionary.
We could get more specific,
but we're not going to touch that for now.
Okay, pretty darn cool if you ask me.
So then what we could do next is go,
all right, well, now that you know all the inputs,
what I would like to do is for you
to help me start working on the run method.
Now, what I like to do in cases like this,
where there's only one required argument
and the rest are optional,
I like to do something like this to where,
yes, this one is required.
The card ID is required.
The rest of everything else is just a query
that we could use to potentially update fields on our cards.
So in our case,
we're going to be focused on adding the ID list
and updating that,
but there's a bunch of other keyword arguments
that we could go off and update.
So let me show you how we could do this.
So I'm going to say, great.
Now, please use the at,
let's go our Trello card once again,
for inspiration as well as the previous API call
I gave you to update the run function.
Keep the params as is.
All right, cool.
So now this is exactly how I went
about building this myself.
So hopefully as you're going off,
I'm like, oh, this is what I need to do
to speed through and crank out tools
like there's no tomorrow.
So when it comes to my original code that I wrote for this,
this is 99%,
yeah, this is identical to what I wrote in the past,
except there's one change
that we're manually going to have to make,
which is kind of a quick hack,
but I'll show you exactly what I mean.
So our run works perfectly.
The only hack that you and I are going to have to make
is to actually update our query before passing it along.
So let me show you what this hack is.
So what we're trying to do is our agent knows
that it would like to move the Trello card
from list one to list two.
However, we have not provided in the task,
the ID of the next column.
So it's going to call it
and put in like a random placeholder.
So what we're going to do is like, okay, cool.
Well, if you were trying to update the ID list,
you actually meant to pass in this key in this value.
So we're just going to overwrite
whatever value it gave initially
and put in the proper value, which is in our right here.
So our Trello doing list.
So we're going to go from to do, to doing.
Okay, cool.
So hopefully that makes sense.
And hopefully you can see like, wow, that was pretty easy.
I just copy old code, new code,
and a little bit of a snippet of what I'm looking for.
And it just works.
Yeah, that's actually how easy it is to build tools.
So hopefully you guys are as excited as I am.
So now what I want to do is just show you
that this tool is working.
So let's go ahead and save the code.
Let's go ahead and copy over the old card ID.
So in our case, we're going to copy over the card ID
and then here are all of our random keyword arguments
that we're going to pass in.
So in our case, you're going to see,
we're going to update the name, the description
and the ID list.
We're going to move it over.
So let's go ahead and test it out
to make sure our tool will work.
So let's go and clear this out.
Python, this is our Trello.
Oh, sorry, our source Pro Tools Trello update card.
So this should go off and move everything
from over here to over here.
And it did, and it actually renamed it as well
to new card name.
So you can see it totally worked
and it added a description to update description.
So all around pretty freaking cool.
All right, so we now have officially
all of our different tools working.
So hopefully you like the Pro Tool Crash Course
and hopefully you understand
how to build tools like a Pro now.
And before we leave, what I want to do
is just show you one of the cooler new features of CRU
which is the before kickoff functionality
and how it's so helpful in this.
So let's go ahead and hop over to the docs
and then come back and analyze this code.
All right guys, so here's one of the last things
I wanted to show you in this video
which is the before kickoff decorator.
And a quick overview, this is a new decorator
that was just released in one of the latest versions
of Cray.
And what it allows you to do is mark a method
as something that should be executed before the crew start.
And the reason why this is so important
is this method allows you to update the inputs
that get passed into the crew.
So let me show you what that means in an actual example.
So in our case, a lot of times
when people are building crews,
they do something like this
where they do inputs is equal to
and then they'll do topic and they'll pick a random topic.
So we'll just do like AI LLMs
and then they'll update their kickoff function
to look like something like this
to where they're going like,
okay, I wanna go off and use this crew
and I wanna kick it off for these inputs.
The only problem is, is this is static.
So you're manually having to update the inputs
that get passed into the crew.
Now what's cool about using before kickoff
is you actually have the ability
to change these inputs dynamically
before the crew gets kicked off.
So let me show you this in action.
So we're over here in our crew
where we have all of our agents and our task
and our final crew, like we normally should.
And then what's awesome is we've now added in a new function
that's going to prepare our inputs
or in our case, it's going to go off
and scrape Trello for us
and pull out all the cards we need to research.
So in the past, this would have been a huge pain
because we would have had to go over to Trello
and we would have had to say,
okay, I wanna get this card.
What's the idea of this card?
Cool, I'm gonna come back over here
and update it inside of kickoff.
And it's just not a dynamic approach that's scalable
but this new approach is
because now what it's gonna do is
every time before we run the crew
is gonna go, okay, cool.
I am going to go off and use this utils file
and this utils file is going to go off.
And in our case, it's gonna get all the cards in a list
or in our case, it's gonna get all the cards
from the to-do list.
So what it's gonna do, it's gonna get all the cards.
Once it has the cards,
it's then gonna update our inputs to say, cool,
all the cards are gonna get stored
in the Trello inputs folder.
So hopefully that all makes sense.
And what I wanted to do to help this be concrete
is I actually wanted to run a side-by-side comparison
for you guys so you can see everything happening
in real time.
And I just wanna do one last quick narration
so you can see the final crew in action.
So let's go ahead and get everything ready,
clear this out and start running the crew.
All right, so before we run,
I wanna drop my last noob versus pro tip.
And that is a pro knows that there is a crew AI CLI
that we can use to help us out.
So in our case, we can actually see
there's a bunch of different commands that we can do.
So in our case, what we're trying to do is run the crew,
but if we wanted to do anything else, we 100% could.
So in our case, we're just gonna do crew AI run
to go ahead and kick off our crew in a local directory.
So now it's gonna go ahead and start running the crew.
And as you can see, first thing is,
we wanted to scrape all of the inputs from our board.
So we wanted to scrape this Llama 3.3 card to research.
So you can actually see in here somewhere
that it's gonna go ahead and call out Llama 3.3.
It's a scavenger hunt, but it's in here.
So we'll do 3.3, the first instance of it.
So yeah, you can see, oh yeah,
Trello cards right here gets called out in the name
and then it gets passed into our inputs.
So all around, pretty cool.
From there, it's gonna get passed
into our first researcher tool,
which is gonna go off and start actually trying
to research for it.
So you're going back to our tool analysis earlier.
Hey, I thought I should go off and do something.
Cool, I'm gonna use a tool to do it.
Here's my query input.
You know, I wanna look up Llama 3.3
and then you can see all the good things.
So talking about Zuckerberg,
talking about how he loves the new model.
Life's great.
Now here's our final answer for it.
So we have a bunch of different items
of things that we should report on.
And then finally, we're gonna hop over to the next one
and it's actually updating.
I don't know if you just saw it,
it hopped from our to-do over to our done section.
So we know it worked,
but I still wanna run you through exactly what happened,
which is our researcher finished up,
then it hopped over to our writer
who wrote all the insights about everything.
And then what was nice is then finally it got passed over
to our Trello workflow manager who went off
and went goes, cool,
I have all the information I possibly need.
Now it's time to go off and do a few tool calls.
So first I'm gonna add the card comment.
So in our case, I'm going to call the card.
Let's see, I'm gonna call the card with the text
and with the topic.
Let's see, it also is probably down here somewhere.
Yeah, it's gonna call it with all the right information.
Yeah, probably in here somewhere,
but it's gonna go ahead.
Oh wait, sorry, I lied.
When it comes to updating the card comment,
all it needed was the ID and the comment.
So it didn't need to add anything else.
So if you actually come back over here to the card
and you can see when it comes to Llama 3.3,
this is the exact piece of information
that was passed over here.
So topic Llama 3.3, summary of findings, key insights.
It's a 70 billion instructor model.
Yeah, so everything else.
I got the numbers wrong, but hey, don't worry.
And then finally, what you're gonna see
comment added successfully.
So then now the workflow manager goes, okay, cool.
I know the next step is to move the card,
this card over to the next ID.
As we talked about earlier, we have a placeholder
and we did that quick hacky thing
inside of our update card tool.
So anytime we were gonna update the ID list,
we were gonna come down here and just override it
and use our environment variables.
So hopefully you can kind of get inspiration from this,
but you can see it is done.
It looks great.
And the final result is exactly what we want.
We now have a nice research report on a new topic
that we could possibly go off and add to a newsletter,
start sending out to your users,
make a quick post about,
or go off and use to make a new YouTube video.
So all around, I hope you guys really like
this crew AI tool deep dive.
And you got to see a lot of ways that you can use crews,
well, specifically tools in your crews,
how you can make them from scratch, from API calls,
make them from libraries,
and you got to learn some of the newer features
like before kickoff.
So I had a ton of fun making this one.
I hope you guys learned a ton.
And that's a wrap for this second episode
of crew AI noob versus pro.
And just a few quick reminders.
First, I have all the source code completely for free
down the link description below.
And I also have that free school community with you guys
where you can meet a bunch of like-minded AI developers
and get access to our free weekly coding calls.
But outside of that,
I have a ton of other AI related content on this channel,
crew AI, link chain, you name it, I got it.
I definitely recommend checking out
what other videos pop up next on this screen.
And I cannot wait to see you guys in the next video.
See ya.