In this video, you're going to learn how I automated my current YouTube video creation process using CrewAI. After watching this tutorial, I'm confident that you will be able to automate your own processes using this amazing technology! Plus, I also share the latest features of CrewAI v0.19.0, show you how to create your own tools for your Crew, and much more!
Timestamps 00:00 Introduction 01:19 Tutorial Overview 05:12 Setup Project 07:37 Setup Dependencies 12:02 Setup Agents 18:21 Add Agents to Main File 19:10 Setup Tasks 29:48 Add Tasks to Main File 32:51 Create Custom CrewAI Tool - YouTube Video Search 42:20 Create Custom CrewAI Tool - YouTube Detail Search 46:04 Add Tools to Agents 49:07 Setup Crew 54:10 Run Crew & Debugging 57:20 Outro
Hey guys, in this video, I'm going to show you how I've automated my entire YouTube video
creation process using crew AI to make my life 10 times easier.
And by the end of this video, you're going to learn how to set up a crew that can do
some market research on YouTube to find related videos.
It'll be able to create titles, descriptions, and also prepare an email that can get sent
out to all of your email subscribers.
You'll also learn how to create some custom tools that crew AI can use, and you'll also
learn how to set up some human in the loop feedback.
And you'll also finally learn some of the new updated crew AI features that have just
come out in the past few days.
So we got a lot to cover and don't worry if that seems like a lot, we're going to cover
everything step by step.
And I'm also going to be giving away all the source code for this video completely for
free.
All you have to do is just click that source code link down in the description below.
And before we dive into the rest of the video, I have a huge announcement that I'm excited
to share with you.
I'm launching a free school community for all of my viewers.
And in this community, you'll be able to meet like-minded developers.
You'll be able to post about bugs that you're having so that everyone can work together
to solve them.
And you'll also be able to hop on weekly coaching calls that I do with the group so that I get
to meet you guys and we get to solve problems that y'all are having.
So I'm super excited to launch this community.
It's completely for free.
All you have to do is click that link down description below and I'll be able to see
you over in school.
But enough of that, let's go ahead and dive into our crew YouTube AI.
So now it's time to dive into automating my current YouTube process.
And to help this all make sense, here are the three steps we're going to follow.
First, I'm going to quickly cover my current YouTube process.
That's a manual.
Second, I'm going to show you the final output that I want my AI crew to generate.
Just so you can see the final output that we're shooting for.
Third, what we're going to do then is hop over to Visual Studio Code, where we're actually
going to start building out the crew to actually automate the entire process.
So let's go ahead and dive into the first step and cover my manual YouTube creation
process.
So now it's time to dive into my current YouTube creation process and I want to cover all the
manual tasks that we're about to automate.
So whenever I have an idea that I want to make a video on, the first thing I'll do is
go on YouTube and see how this video topic is performing out in the wild.
Eventually, after I keep researching, what I'll find are a few very well performing videos.
And what I'll do is I'll look at the view count of the video compared to the subscriber
count of the channel.
And what you'll notice is that there are 20 times the views compared to the subscriber
count, which tells me that this is a viral video topic.
And I'll keep continuing my search just to make sure this isn't a fluke.
And I'll find videos like this as well, which is a phenomenal one.
Definitely recommend checking out after this video, of course, and what you'll notice is
this one has around 260,000 views and her channel has around 213,000 subscribers, which
once again means, you know, more views than subscribers mean that this is a viral video
topic.
Okay, cool.
Once I have figured out the video topic, I'll, you know, I'll go off and code it and I'll
go off and record the video and all that fun stuff.
And then when I'm finally done doing all of that, what I'll do is I need to, you know,
upload my video to YouTube and then I need to do a few more manual things.
First, I need to come up with a title and this is actually very hard, but we need to
automate it because it's, you know, Chachapiti could do this.
I'll also come up with a description just like this.
Once again, this takes a little bit to figure out what to do.
And then finally, what I'll do is if it's a video that I think will really appeal to
a lot of my subscribers is I'll come up with a basically newsletter blast that I could
send out as an update of like, Hey guys, I have a great new tutorial that I think you
guys should check out.
So as you can see, I'll need to come up with a subject line and a body content that I could
put inside of this email blast.
Okay, cool.
So that's my current manual process.
So let's go ahead and dive into what I want my AI output to be to simplify my life and
you know, take down this process that currently takes hours to just a few minutes.
So let me quickly cover the final output that we want our crew AI to output after we've
kind of told it that, Hey, I'm interested in making a video on this topic.
It should output this document right here.
So let's run through it real fast.
So the first thing is we want to be able to see how similar videos are performing in the
same category.
So this is a quick way just to, you know, run that check that I was showing you earlier,
like, Hey, you know, how's the view count compared to the channel subscriber count and
how long has this video been out?
And you know, we're going to be using some YouTube searching custom tools to do this
and prepare it for us.
So after I've kind of seen how videos are doing on this topic, it's going to help me
generate 10 potential, you know, high click through rate titles.
So these are, you know, some honestly pretty good titles are all under 70 characters.
They're going to look good on YouTube.
And then from there, it's going to generate a YouTube description for me that I can paste
in over into YouTube to make my life easier, you know, just tweak a few things, but this
honestly looks awesome.
It even has some links and everything.
And then finally, what this is going to do is go ahead and do an email announcement to
basically, you know, Hey, here's a recap of this latest video, which is, you know,
automating tasks using crew AI.
It's going to allow me to put like a insert to the video link.
So it's going to look exactly like the emails that I've been sending out, but this is all
automated.
This took about four minutes to run where normally that takes me, you know, honestly
hours of previous manual research, typing and so forth and so forth.
So I'm super excited for you guys to actually see how we build a crew that automates all
of this and saves basically a ton of time.
So let's go ahead and head over to a new instance of visual studio code and start building out
our own crew AI solution.
I am so pumped for you guys.
Let's go ahead and dive in.
All right, guys, now it's time for us to dive into the fun stuff where we're going to start
coding up our crew.
And just to paint a roadmap of what we're about to do next, first, we're going to create
a new folder where we're going to store our project, and then we're going to go ahead
and create the seven key files that we need to run our crew.
So let's go ahead and start working on that first step.
So what we're going to do is make a new folder called automate YouTube with crew AI.
And what we're going to do is open up that folder inside of visual studio code.
Fantastic.
And what we're going to do next, let me make a little bit bigger for you guys so you can
see it.
So I'm going to go ahead and start working on the thing, basically creating the seven
key files that we need to run our crew.
So the first file that we need to work on inside of our project is going to be called
a pie project dot Tom file.
And what this file does is it basically stores the information about our project and all
of the dependencies that we're going to need to install to basically run it.
The next file that we need to work on is going to be our main dot pie file, and this main
dot pie file is going to store all of the logic and connect all of our agents and tasks
together and basically run the crew.
The next file that we're going to work on is going to be our agents dot pie file.
And this is going to be where we store store all the logics for running our agents.
You know, the goal of the agents, the backstory and everything like that.
The next file that we're going to start working on is going to be our task dot pie file.
And this is where we actually specifically define the task that we need to execute in order for
us to actually create that output file that you saw in the previous portion of the video.
Fantastic. The next thing that we're going to do is we actually need to set up a dot ENV
file. And this is where we're going to store all of our environment variables, specifically
our open A.I. key and also our YouTube A.P.I.
key. More on that later.
And then what we need to do next is actually create a folder where we're going to store
our tools. And what we're going to do in here is we need to work on creating two different
tools. The first tool that we're going to create is going to be called our video details
dot tools pie, sorry, tool dot pie.
And this is where we're going to be able to actually look up all the information for
specific YouTube, such as like the last date it was published.
It's like count its view count and everything like that.
The other file that we're going to start working on is going to be called our YouTube
video search tool.
And this is how we can actually type in a specific basically topic that we want to learn
more about and go off and find 10 or 15 different videos on that subject.
So these are the key files that we're going to be working on inside of our project.
So let's go ahead and start diving into our pie project dot tomo.
And this is where we're like I said, going to go ahead and start defining all of our
dependencies for our project.
All right. So let's quickly go ahead and knock out this file.
And what I'm going to do is just actually go ahead and paste in the final result.
And the reason I'm doing this is because I just want to save us time so we can actually
move on to the fun stuff.
We're actually building out our crew.
But let's walk through this super quickly.
What we're doing. Oh, and real fast.
I do want to mention as a reminder, you can actually just download this file.
I have a link to the source code.
So you can actually just go ahead and download and copy and paste this into your own
environment. So you don't have to spend all the time typing it up.
But OK, let's finish walking through this line by line or right out the gate.
What you'll notice is we are going to be using a tool called Poetry.
And what we're going to be doing inside of Poetry is actually creating a virtual
environment for us. That's you know, if you've been using Python for a little bit,
you'll notice as you work with different projects,
you create different Python environments that each have their own dependencies
that are specialized for that specific project.
So that's exactly what Poetry is going to be doing for us.
And it's up to us to go ahead and give Poetry all the information it needs to
create that virtual environment for us.
So as you can see, we are going to be creating a environment called, you know,
automate YouTube with crew AI, pass in some extra metadata.
And then we're going to find the dependencies that we want to use inside of this
virtual environment. Now, here are the important parts that you need to know about
these dependencies, specifically crew AI.
We are going to be using version 0.19.0 for this tutorial.
If you actually run into a bunch of bugs when you're using crew AI,
I would definitely check out to make sure you're also using this version of crew
AI, because this dependency is getting updated religiously.
Just a few weeks ago, we are on version 11 now on version 19.
And there was a ton of, you know, improvements,
but also some breaking changes that were made along the way.
And this is actually the perfect time to go ahead and mention some of the
improvements that were added in version 19.
What you'll notice in this tweet is the efficiency of using tools is up over a
thousand percent. We're also slashing error rates by 67%.
So this tool is becoming more and more reliable. And I'm just pumped that,
you know, we're able to start using this kind of technology. So, okay,
enough of that,
let's go ahead and actually start diving into setting up this tool and setting up
our dependencies and creating an environment so we can start, you know,
go off and doing the fun stuff and start coding.
So what you need to do is go ahead and open up your terminal.
And once you're in here, what you're going to do is if I type in the word poetry,
mine will actually go ahead and, you know,
recognize that this is a command line interface.
And then I've already set up poetry.
If you need help setting up poetry,
I would definitely recommend checking out my crew AI crash course for beginners.
And I walk you through how to set up poetry on your own computer,
but enough of that,
let's go ahead and actually dive into setting up this virtual environment.
So all you need to do is just type in poetry install dash dash no root.
And what this is going to do is go off and install all those dependencies that we
just mentioned right here. So that's going to take a few seconds,
but what's it's going to do, as you can see, it just finished.
What you can do now is type in poetry shell.
And what this will do is actually go ahead and open up and activate that Python
environment that we just created. So you can see, yep, we are spawning a show.
And now in my terminal,
you'll notice that I am using the environment that we just created.
So that's super easy.
It's way easier than setting up requirements files and all that stuff.
So I'm a huge fan of this,
but what you'll notice is whenever we go over to another Python file,
what it'll do normally on your code, probably in your visual studio code,
it'll have, you know, just a random Python version down here, just like this.
Well,
what we can do is actually tell visual studio code as we go forward and start
coding up our Python project that we want to use this environment when it comes
to like doing all our linting and other fun stuff, just to make sure.
And this will make more sense once we hop into the code,
but I just want to go ahead and get us all the setup knocked out of the way
before we move forward.
So what you're going to do to set up visual studio code to work and integrate
with this new environment you just created,
you're just going to click down here and you're going to click enter interpreter
path, and you're going to paste in that shell URL right there.
So I'm just going to paste it. Fantastic.
And now you'll notice that my visual studio code is set up to use this virtual
environment. So, okay, cool. We're officially out of the setup phase.
So what we're going to do next is go ahead and outline our main dot Python dot
file. So you can see the overlay of the project.
And then we're going to start actually populating everything one by one,
such as creating our agents, our tasks, our tools, and so forth.
So let's go ahead and start, you know,
putting all of our to do's in here and then hop into coding up some Python.
So let's go ahead and paint a roadmap of what we're going to do next and the
order that we're going to do it. Well,
first what we're going to do is go off and create our agents.
Next, what we're going to do is create our task,
which are going to be used by our agents.
And then finally,
one of the other major things that we're going to do is create our different
tools that we want our agents to use.
And all of this information is actually going to be put inside of our main file,
but we'll build this out as we go.
So let's go ahead and clear all this out and start working on our agents.py
file.
So the first thing we're going to do inside of our agents.py file is go ahead and
create a class,
which we're going to call YouTube Automation Agents.
And what this is going to do is actually just go ahead and house all of our
different agents that we want to create.
So here are the list of the different agents that we want to create.
It's also important to mention that what I like to do is basically create a
agent per task. And if you remember in our final output,
what we want to do is have a YouTube researcher,
because that's how we're going to like analyze what's happening in the market.
Then we're going to create some titles for our potential YouTube video,
create a description, and then finally we're going to create an email.
So that's exactly what we're going to be doing.
So first off what I want to do is create a research manager and this person is
going to go off and like I said, research our, you know,
what's going on in YouTube and we'll implement these in a second.
I just want to go ahead and like paint a picture before we actually dive into
doing it. Okay. And let's just copy and paste.
The next one we want to do is do a title creator.
And this is going to be the agent who's responsible for creating our titles.
Then we're going to have a description creator and then make another to do for
that. And then finally, what we're going to do is have an email creator.
So def email creator. Okay. So like I said, pretty straightforward.
And the other thing that I like to do just to make sure that all of this gets
orchestrated properly is I like to define a basically a manager of some sort.
So I'm just going to call this a YouTube manager.
And what this agent is going to be responsible for is basically making sure that
we do the research first. Then we go off and create the titles.
Then the description, and then we go off and create the emails. So like I said,
this is going to be the agent who's responsible for orchestrating everything.
Now,
what I'm going to do to help speed up this process a little bit is I'm actually
going to paste in the agent that we're creating each one of these sections,
but I'm going to walk you through why I put in the information that I did in
each one of these so that when you're off creating your own agent,
you'll have some context of like, Oh yeah, I need to be thinking about this.
So let's go ahead and start knocking these out one by one.
So the first thing that we're going to do for our YouTube manager,
like I just mentioned,
this is going to be the person who oversees the entire process.
I like to think of this as the manager who is orchestrating the whole process.
So what you'll notice is we'd say that, Hey, you are a methodical,
methodical and detailed oriented manager,
and you are responsible for overseeing the preparation.
I'm going to zoom out just so you guys can see the whole thing,
but you're responsible for overseeing the preparation of the YouTube video.
Now we have to put on our manager hats and think about, well,
how do we want our different agents to work together? Well,
that's where we define it right here.
We say it is up to you to go off and do these tasks in this specific
order.
So one of the things that I like to run as a test,
whenever I'm creating agents is I should be able to hand off these instructions
to a middle schooler and on their own,
they should be able to go off and execute what I tell them.
The more constraints and the more processes and the more like basically
simplistic the instructions are,
the more likely the crew is going to go off and generate the exact results that
you're looking for. So let's go ahead and actually walk through this.
So I say, Hey, at first, it's up to you to go off and search YouTube videos.
I want a minimum of 15 videos on the same topic that we're creating a YouTube
video about. Once you've done that,
I want you to go off and create a list of titles and I give some instructions
for what makes a great YouTube title. And then from there, what we do is say,
Hey, go make a description. And then finally write an email.
Now that we have like defined the process that this agent needs to follow here,
a few other important things that I think you should know about this.
We are allowing delegation.
And the reason we do this is because we want our YouTube manager to go off and
hire our research manager or our title creator or basically any of the other
agents. And then also you'll notice I set up verbose to true so we can get some
good logs. Okay. All right,
let's speed through and actually start working on the next agent.
So the next agent we're going to work on is our research manager. Now,
if you remember,
this is going to be the manager who goes off and researches our YouTube videos.
So I should be able to say, Hey, for a given topic and description,
I want you to go off and find 15 high performing videos on the same topic.
And it's up to you to populate a research table,
which we'll talk about more in just a minute. But in this research table,
I want you to go off and basically find all the information that you need to for
a specific video.
And what you'll notice in just a few minutes when we go off and research the
videos,
you'll notice that we're going to be researching just like searching on YouTube
to go off and find videos. And then for each video that we find,
we're going to go off and actually do some additional digging to find,
you know, the view count, the subscriber count and so forth and so forth. All
right. Now here are a few other things that you need to know about this,
basically this agent. The other thing is that we're going to be using tools.
Now we haven't defined these tools yet, but this is where, like I said,
we're going to go off and search YouTube.
And then we're going to go off and search specific video details per each video.
And these are going to be some custom tools that you and I make.
So I'm super excited to dive into that in just a few minutes. All right, cool.
Now what we're going to do next is go off and start creating our titles.
Now this one is going to be, like I said, super, super straightforward,
basically just like, Hey, you are a title creator, create 10 titles. And you know,
it's going to be up to the task to like really define what goes into making a
great title. And the rest of the agents, like I said,
they're also pretty straightforward too.
When it comes to our description creator basically look identical to our title
creator, except you are now creating a description. All right.
And then we're going to move on to our final one,
which is just going to be our email agent.
And what you'll notice for this one is what we're going to do is say, Hey,
go off, you know,
it is to your job to make an email that we can use to promote the new YouTube
video.
And what we also do is give it some additional instructions because we want this
email creator to check in with us,
to make sure that we're happy with the email before we send it out.
The reason I did this is because a,
I wanted to showcase some of the new crew AI tools.
And I also just wanted to show you guys that like, Hey,
if you're not always happy with the outputs that you're getting from crew AI,
you can just throw yourself as a human in the loop to provide some feedback and
actually say like, Hey, that email was good, but you know,
maybe tone it down over here. Oh, you also need to talk about this subject.
So this is a great way to actually do that.
So I'm going to comment this out for now because we haven't set it up yet.
And yeah, everything looks great.
What we'll notice is we're getting some yellow or some green squigglies.
So we need to do is just hit command period. If you're on a Mac and it'll provide
some, uh, usually provide some code options, but if it doesn't, no biggie,
what we're going to do is just go ahead and actually import that agent.
So what we can do is just say from crew AI import agent, just like that.
And that should get rid of everything. Yep. Fantastic.
So this file is done and what we're going to do is go off next and start working
on our task. And once we've knocked out our task,
we'll start actually connecting everything together.
And actually what we're going to also do real fast,
just go ahead and start checking off our progress list.
We're going to go ahead and actually import our agents.
So what we can do is say agents are equal to our YouTube automation agents.
And now we need to import that. Fantastic. Great.
And then what we can do is actually go ahead and create our agents here as well.
So what we're going to do is just say, Hey,
we're going to make a YouTube manager and this is going to be come from our
agents file.
And we're just going to go ahead and do the rest of our agents as well.
Just like this. Fantastic. All right. Give yourself a pat on the back.
You just knocked out the first part where we set up our agents and now we're
going to go ahead. And like I said, and move on to task,
let's go and open up that file and then start adding all of our tasks.
And this is actually like the meat and potatoes of the task.
If your tasks aren't set up properly, everything's going to go, go awry.
So this is where we're going to spend most of our attention.
So let's go ahead and dive in.
So the first thing I like to do when creating my task file is to create the
class that's going to store all of my tasks.
So I'm just going to call this my YouTube automation task class.
And then what I'm going to do next is actually to find all the different tasks
in here. And to help me out,
what I like to do is actually open up my agents file.
And for each one of my agents,
I like to give them a single task that they need to work on.
So we're going to do is actually define a task for our YouTube manager,
research manager, and so forth and so forth.
So let's go ahead and start working on this first one. And what I'd like to do,
like I said,
is actually just kind of like make sure the name of the task reflects or what the
agent is going to be doing.
So in our case for our YouTube manager,
we want them to manage our YouTube video creation. And like I said,
we'll go later on and actually implement them.
But for right now let's go ahead and just paint out all the different tasks we
need to work on.
And the next one that we're going to start working on is going to be our,
you know,
our manage YouTube video research and that's going to be done by our research
manager. And then after that,
what we have next is going to be our title creation.
This one is super straightforward.
We just want to go off and create our YouTube titles.
So go ahead and do them.
And then finally,
what we're going to do next is create our YouTube video description is going to
be the next task for our descriptor creator.
And then finally,
what we're going to do next is we're going to have our email creator.
And this one is just going to be a deaf create email announcement.
Fantastic. All right. So now what we're gonna do next,
now that we know all the different tasks that we need to create,
we're going to work on the basically the manage YouTube video creation task
first. Cause it's the biggest one, a little bit complex,
but it paints the roadmap for exactly what we need to be doing inside of each
one of these other tasks. So I'm going to go ahead and actually,
just like I said,
I'm going to paste the final result and I'm going to walk you through this line
by line. So it makes sense. So that when you're creating your own task,
you'll know exactly what to do. Okay. So let's go ahead and paste this in,
close this out. And like I said,
I'm going to walk you through this line by line and you know,
we'll probably run into a few bugs.
So it'll actually be super helpful to see this being debugged in real time too.
Okay. So what are we doing inside of this task?
Well,
it's up to us whenever creating a task to define the description of the task
itself. Outside of that,
we have to define the agent that we want to execute the task.
Another thing that we're going to do,
which is a newer update and version 17 is we can actually define an output file
now. So whenever this task is done executing,
what it's going to do is actually go off and save the report to our output
folder. And it's actually going to name the final report,
our YouTube video creation report. And this is going to be super helpful.
So we're not, you know,
having to like copy and paste stuff out of our command line.
We can actually just go open up this text file.
And the other thing is we need to actually now define an expected output in the
past. This was an optional parameter or property for your task,
but now it's required. So if you're running into a few issues of like, Hey,
pedantic saying that you don't have an expected output, that's why it's,
because it's required now. So hopefully that helps,
especially if you're running into a few bugs. Okay.
So what we want to do now is actually just kind of walk through what's happening
in each one of these properties.
And I'm actually going to go ahead and import some of our missing dependencies
as we, you know, we're going line by line. So first off, we're creating a task.
So we need to actually go ahead and import that from crew AI.
We want to import our task. Fantastic.
And what you're noticing is I'm creating a super long description.
So anytime you're creating a super long description,
you can actually use ddent.
And this is actually comes from like a built-in library in Python.
So if you just do from text wrap import ddent,
what it allows you to do is do some string interpolation.
So this is how we can actually pass in, you know,
a video topic and video details. So what you'll notice is these are squiggly.
So it's up to us and our task creation to pass in the video topic and the video
details, and then also the agent, which we're calling down here. All right, cool.
So now that we've gotten all the squigglies out of the way,
let's actually walk through what I'm doing.
So we want this task to oversee the preparation of the YouTube video,
and we need to tell it what it's going to do.
So it's going to do some market research, title, ideation,
description creation, and email creation.
And the ultimate goal for this task is to create a research report.
And one of the things that I like to do whenever I'm creating my task is to
actually provide an example report so that our task knows what it's ultimately
trying to achieve. So that's what I went ahead and did down here.
I provided an example report showing like, Hey, for video one,
I want you to show me the title view count day since published.
Like this is the exact information you need to be providing to me in your final
report. I've noticed, you know, like I said, going back to the sixth grader test,
if I was to pass along this description to a sixth grader,
they could go off and be like, Oh yeah,
like I could go onto YouTube and find some similar videos. And yeah, you,
I just, you know, I need to populate the title, the view count.
Like this is very clear cut of what my expectations are for the final report.
And then, like I said, this is just, you know, part one for research.
I'm also saying this is what, you know, titles need to look like.
Here's one example does video description needs to look like.
And then finally down here, Hey,
this is what the email announcement needs to look like.
And that's exactly if you remember what the final output looks like from earlier
when I showed it to you. Okay, cool.
Just a few other things that I like to do whenever I'm creating bigger tasks like
this is I also like to provide context because sometimes crew AI would be like,
Oh, this is your example report. I'll just give you back your example report.
So that's why it's up to you to like, Hey, here's what's actually important.
You know, I only provided two videos. You need to give me 15. Oh,
I only provided three here. You actually need to give me 10.
So just these are a few things that, you know,
as you're going off and building your own task and you don't get the exact
results you need, you just need to provide a few more clarifications to your
agents. You know, they're so smart and yet so dumb at the same time.
So it's up to us to be super explicitly clear with what we want. All right,
cool.
So now that we've knocked out that first task where we define what we want and
in our description,
we now let's just go down to the end where we're actually defining our expected
output, which is now a required field.
So basically I just do a recap of what was mentioned earlier.
You need to make a report that's formatted exactly like the example report from
earlier, make sure it contains the exact quantities of everything I want.
And also this is another place to where you can actually paste the more errors
that you've gotten in the past. So in my case,
I had some issues with the crew not always giving valid URLs.
So I just explicitly say you need to have valid URLs. Okay, cool.
Now that we got done with that task,
let's go ahead and move on to our next task where we're going to be describing
basically the YouTube video research process.
So this one is also going to be pretty straightforward.
And let me walk you through this line by line again,
just so you can do this on your own too. So basically for a given video topic,
I want you to first go off and search the internet or search YouTube to find 15
high performing videos on the same topic.
Now what we're telling our agent to do is, you know, once you found those videos,
you need to go off and research the video details so that you can actually find
all of the like counts, subscriber counts and everything else.
And you'll notice that I keep referring to this, you know,
research outline and research report. Well, once again,
we need to be super explicit. So that's why I tell the task like, Hey,
this is the exact information you need to populate.
And I even give it some specific instructions on what the CSV file that generates
what it needs to look like. And once again,
anytime you have an issue with a crew not behaving as it should, it just, you know,
add another important note with, you know, errors that you've experienced.
Just go ahead and add it down here. And like I said,
it's kind of a trial by error process. All right. Um,
and what we're going to do finally is let's go ahead and actually cover our
expected output. So once again, I kind of just say like, Hey,
this is what your CSV file should look like.
And I just went ahead and populated it with two example dummy videos so that it
would know what to do as it's going off and performing its research. Okay, cool.
And, um, it is important to note right now we haven't defined any tools,
but once again,
when we go off and create our custom YouTube search tool and video detail
explore,
that's exactly what's going to be used to populate this information that we're
looking at right here.
So we're slowly building up to the point to where this whole crew is coming
together. And once again, we need to provide the missing information,
such as our video topic that we want to explore and our video details,
which are actually kind of defined a little bit more about like the YouTube,
that video that we're creating. Cool.
So now that we've imported those missing dependencies and parameters,
we're going to go ahead and move on to our next task,
which is going to be creating our YouTube titles. Now, this one is, like I said,
a little bit more straightforward. And what I basically did is, um, I said, Hey,
it's up to you to go create 10 titles based on the video topic and description.
And then we basically pass it in.
And then I kind of just give it a little bit more helpful hints about what goes
into creating a high click through rate title. First off,
it needs to be under 70 characters. And then outside of that,
I went ahead and gave it a few example titles that I've done in the past,
just so that it knows like, Oh,
this is the style of titles that you're looking for. And I went ahead and,
like I said, you just my own video topic.
So the more context and the more examples you can give it,
the better these tasks are going to perform. So once again,
let's pass in all the missing information, video topic, details, and agents.
Cool. Now we can keep cruising along. All right.
So this video description one is also going to look almost identical to the
title creation one. And what's we're going to do just like, Hey,
it's up to you to create a description for YouTube video based on a topic and
description.
And I went ahead and just gave it an example output of exactly what it needs to
do. And I just copied and pasted one of my previous, you know,
descriptions that I put on a YouTube video so that it knows exactly what to do.
And like I said, it'll just kind of change this out for, you know,
the video that it's researching. All right. Once again, like I said,
by this point, you're, you know,
hopefully feeling the repetition and that's good because this is the exact same
process process that you're going to be doing with like adding parameters in
when you're creating these different tasks. All right.
So let's move on to the final one,
which is where we're going to create our email announcement.
And this one's a longer one, but it's not too complicated.
It's just a lot of content.
Let me walk you through what we're doing in this one once again. So, Hey,
I want you to create an email. Here's the video topic. Here's the video details.
And what I do is say like, Hey,
here are a few previous emails that you could use for inspiration.
So I just went ahead and copy and pasted a few example emails that I've written
in the past, just so that I can understand my writing style and like, Hey,
this is what a format of your email should look like as you go off and make your
own. So yeah, that's exactly what we're doing here.
If you have any questions when you're going off and creating your own task,
or if you know, if you run into any issues, first off,
feel free to drop a comment below love to help.
And this is also another good time to mention that I did drop that school
community just for you guys so that you can go off and get support from other
developers who are on the journey, creating their own crews.
And we have, I think,
already over a hundred different members in the community and it's super active.
So like I said, if you have questions,
that's another place that I definitely recommend going to check out so that you
can get more help and actually just post some progress as you're, you know,
making your own task and your own crews. Okay, cool.
So the only other thing we need to do in here is go off. And once again,
add in all of our missing information. All right.
So give yourself a pat on the back.
You've completed the two hardest parts of this whole project,
setting up your agents and tasks.
And what we're gonna do now is actually go ahead and hop back over to our main
file.
And in here we're going to go ahead and start passing in our agents and our
tasks to combine them. So our agents know what to do.
So the first thing we need to do is actually import our task class that we just
created.
So what we can do is say task is equal to our YouTube automation task.
Now it's up to us to actually import that class that we just created.
So if you hit command period,
it'll provide a quick fix that you can actually import very easily.
We'll add this to the top of our files just so everything's formatted nicely.
And now that we've created our task, let's go ahead and start importing them.
So we can start, you know,
connecting our task to our agents that we just created.
So the first task that we're going to import is going to be our manage YouTube
video creation. And what you'll notice is inside of this,
we need to pass in the video topic, video details, and an agent. Well,
up to this point, we've defined agents,
but we haven't defined our video topic or video details.
So what I want to do is just provide some, you know,
background info about YouTube video.
And what I'm gonna do is actually just go ahead and paste in what we're trying
to do here,
which is we want to make a video topic about automating tasks using crew AI.
And then I just provide some details about what I'm trying to do inside of this
video. And basically it's actually what I'm trying to do in this video.
I'm showing you guys how I'm using crew AI to automate and streamline my video
preparing process.
So that's all we need to actually go off and start plugging in to all of our
different tasks.
So what we want to do is say the agent is going to be equal to the YouTube
manager.
We want the video topic to be equal to the video topic and video details equal
to the video details.
So that's pretty much everything that we want to do.
And we're just going to rinse and repeat this for each one of our other tasks.
And I do want to mention that we also need to like, you know,
this is creating a task and returning it to us. So we actually need to, you know,
get the return from this.
So I just copied the name of the task over here and set it just like that.
Fantastic. So now we have all the information we need to go off and start
creating our other tasks.
So task dot the next one is going to be video research. Once again,
we're just going to pass in our,
all the information we need to create this task and we're just going to rinse and
repeat for the rest of them. So for our manage YouTube video research,
we want our research manager to work on that task.
When it comes to our creating a video titles, we want to have our, you know,
our title creator agent working on that.
When it comes to working on our video description,
we want to make sure that we have our descriptor creator working on that one.
And then finally for our email announcements,
we want to make sure that our, you know, the proper agent of our,
what do we call them earlier? Our email creator working on that. All right,
fantastic.
So we now have all of our different tasks and all of our different agents set up.
So what we're going to move on to next is actually the part I'm most excited for
in this tutorial.
And that's where we're going to actually go off and create. Oh,
it looks like it didn't pull in the right one.
Let me make sure we did that right real fast.
When it came to our email announcements, we had create email announcement,
create, Oh, there we go. That was, sorry, it was the wrong, wrong task,
but the part I'm most excited for in this whole tutorial is actually showing you
guys how to go off and create your own custom tools.
If you're able to start refining this skill, I'm about to show you guys,
you will be able to go off and really build any cruel, any crew to do anything.
So I'm super excited to show you this.
So let's go ahead and actually dive into setting up our first new tool,
which is going to be doing YouTube video search and real quick,
before we go off and create our own tools,
I actually just want to show you the documentation that crew AI recommends for
creating your own tools. Okay.
So I'll have this link down in the description below.
So you can read it on your own if you want to dive in deeper,
but when it comes to creating your own tools,
there's really two ways you can go about doing it. Option one is by using,
you know, subclassing the base tool.
And I'll explain what all this means in just a minute.
And the other option is to go off and add the tool decorator to your functions.
Now, what I have found whenever I'm creating my own tools,
I've had much better results whenever I go off and do this option,
which is subclassing the base tools.
And all this really means is as you go off and create your own tools,
you need to provide a few specific pieces of information about the tool so that
the crew knows when it's the proper time to use it.
So it's up to you to go in and add a name, a description,
and potentially some arguments that you need to pass into the tool. Okay.
Well, I know that might be a little high level.
So let's actually hop back over to our own tool that we're about to create and
start populating some of this. Okay.
So what we're going to do is go over to our YouTube video, search.py file.
And we're actually going to go ahead and start creating this line by line.
And we're going to hop back between this and the doc.
So you can see why we're doing everything. So right out the gate,
what I'm going to do is define that.
I went to make a YouTube video search tool and what you'll recommend or what
you'll see is that we have a base tool and this actually comes from crew AI.
So this is basically just saying like, Hey, you know,
we're inheriting from this class right here. Okay.
So let's go ahead and import it to fantastic.
So now that we've done that,
it's up to us to go ahead and pass in the proper information that we want our
crew to know about this tool whenever it wants to use it. So in our case,
we're saying, Hey, this is my YouTube search, my search, YouTube videos tool.
You're going to use this tool whenever you want to search YouTube videos based
on a keyword and get back a list of video search results. Fantastic.
The next thing you'll notice is that we're passing in our argument schema.
Now what this is going to do is say, Hey,
this is the type of input that I expect to come out or to go into this tool
whenever we run it.
And this will make more sense to whenever we actually like fill out the rest of
the tool, but just like, hang with me.
This is definitely the most complicated part and you might want to rewatch this
once or twice just to really make sure that this clicks in. Okay.
So what we're going to do first is we're going to pass in and create our
basically our YouTube video search tool input. And what we're doing here,
once again is we're basically going to provide a description of what this tool's
for.
And then it's up to us to once again provide more information about what is going
to go into this tool. In our case, we're going to say that, Hey,
I want to pass in a keyword as the input.
And this keyword is going to be a string.
And we provide a description of what this input looks like.
And then we also expect whenever you use this tool to pass in max results by
default, we're going to say it's 10 and it's going to be an integer,
but you could obviously pass in your own number if you want more or less videos.
And we just say like, Hey,
this is the maximum number of results you want to to go off and search. Okay,
cool. So now we've done that.
You'll see that we get a few more squiggly lines because we need to import a few
different, basically a few different new types into our project.
So the first one is we're going to import this field one.
So let's go ahead and import that and our base model. And this is basically just,
you'll notice this comes from by Pydantic and Pydantic is basically a tool to make
sure that basically Python is not strongly typed.
So it's kind of a workaround to make sure that we are using typed properties.
And that might sound like a lot, but basically just, you know,
all that means is like we want keywords to be strings.
We want max results to be integers and Pydantic just helps us enforce typings.
Okay, cool. So what we're gonna do next is fix this squiggly mark,
which is we don't have the proper, you know,
type for when we're setting up our base model.
So we're just going to import that. Okay.
Now that we have defined all the stuff to make sure that we're, you know,
passing in the proper parameters,
let's go off and actually look at what the code looks like whenever we're
searching YouTube. So what I'm gonna do is you, whenever you're creating a tool,
you have to define an underscore run file. And why do I know to do that? Well,
if you go back to the documentation, you'll notice that it's exactly what they
have. They have an underscore run file, excuse me, function. That's, you know,
is what's going to run whenever this custom tool gets called. Okay.
So let's hop back over here and go through this line by line.
So it all makes sense of what we're doing. So what we're doing is we are saying,
Hey, whenever you run, I want to have a keyword, just like we defined earlier.
And I want to have a max result, just like we defined earlier.
And what I expect after I run this function,
I want to get back a list of video search results. And this is one other type.
This is the last type that we have to define in this class.
And what we're going to do in this one is actually define what is the exact
information we want to get back from this function. So in our case,
whenever we go off and search a video,
I want to get back the video ID, title, channel ID, channel title,
and days since this video is published. Now, like I said,
Pydentic is going to make sure that this gets returned. If it doesn't,
it's going to mark this as a failure and it's going to retry and call this tool
again until it gets back the proper information it needs. Okay.
That was a ton of, that was a ton of information.
So let's keep cruising along now that we're actually into like just normal
Python-esque code. Okay.
So whenever we're running our function to go search YouTube,
we're actually just going to be using the Google API,
which we're going to set up in just a second.
But what we're going to do is say, Hey, Google, I want you to go search.
And when you're searching, I want you to look up this information.
I want you to look up a keyword, some max results.
I only want you to find videos.
And here's my API key so that you know that I'm making this request.
Whenever you get back, whenever you make the request,
you're going to get a response.
And what we want to do is pull out all the items from that response.
And we want to slowly iterate through each one of these items and build up a
results array or a list that's populated with the specific information that
we're requesting.
And if you remember the specific information that we're building up is going to
be our video search results. So if you kind of look up here,
you'll see video ID title and so forth.
And that's the exact same information that you're going to see down here.
So I hope this is all clicking now that you kind of see like, Oh yeah, that's,
that's how you build up results. And this is, you know, how you populate them.
Okay, cool. So what we're gonna do next,
let's go ahead and fix basically importing all of our different missing items.
So I'm just going to do a bulk import real fast. Fantastic.
So now we should have all the squiggly marks gone.
And now it's up to us to go off and actually handle creating our API key.
So I'm going to do is head over to Google and show you how you can get this API
key.
So the first thing you need to do is actually head over to console.cloud.google.com.
So basically we're just going to go to Google cloud.
And if you haven't created an account before,
you just need to do that real fast. It's completely for free,
but all you need to do is just go ahead and create this account.
Once you've created an account in Google cloud,
what you'll need to do is we want to go off and create a new project.
So once you're in your dashboard,
you're just going to click your projects in the top left,
and then you're going to click new project. Once this is done,
you're just going to go ahead and like give your title a,
or you'll give your project a name.
So I'm just going to call mine crew AI automation automation.
And then I'm going to go ahead and save that real fast.
So I'm gonna click create.
This will take a few seconds to go off and create that new project. So like I said,
I'm just going to pause real fast and then Oh wait, it finished it even faster.
So we're just going to click select project next.
So what you'll notice is it updated the, you know, the active project to crew AI.
And then I'm going to type in API and services.
I believe this is the one we want. Um, nope.
We just want to type in credentials. Yep. So once you type in credentials,
you're going to click the one that says credentials, API, and services,
and this will take you to a screen that looks just like this.
And what we're trying to do,
if you remember is we want to create an API key that we could eventually pass
in right here so that we could start making requests to YouTube.
So all we need to do is, like I said,
we're going to go ahead and just come up to the top. And like I said,
this might be a little overwhelming if you've never used Google cloud before,
but in our case, all we need to do is click create credentials.
In our case, we're going to click API key. And it'll take a few seconds to do,
but once it's done finishing,
what you're going to do is actually just copy the API key that Google generates
for us. So like I said, this is a secret key.
And what you want to do is actually don't share it within the world.
And I'm gonna show you how to do that in just a second.
So you're going to copy this API key and you're going to come back over here and
we're going to go over to our dot ENV file. And inside of our dot ENV file,
we're just going to call this our YouTube API key.
It's important that the key that like said,
this title basically matches exactly what you have set right here.
YouTube API key needs to be the same thing. Fantastic.
Now to make sure that we don't accidentally share this with the world,
especially if we're going to be using GitHub is you need to create a dot get
ignore file. And what we want to do is just add dot ENV in here.
That way, whenever we go off and, you know, start pushing our code to GitHub,
we want to make sure that we don't actually paste it off to, um, you know,
and store it for everyone to see.
And what I'm going to do actually just to make your lives easier,
I'm going to make a dot ENV local file.
So whenever you come in here later and you're actually, um, like I said,
what you'll do is in your project,
you'll actually just copy this dot ENV file and you'll just rename it to instead
of dot ENV local, you'll just rename it to dot ENV. So you'll,
you only have to create a dot ENV file.
You can actually just come in here and paste your code. Okay.
I hope that makes sense. All right. Well, now that we have that set up,
let's hop back over to our video search tool and see what we need to do next.
Well, if you look, we have our YouTube API key now,
so this can actually go off and do everything that we need. So it looks, yep.
It looks fantastic. All right. So now that we have set that up,
what we're going to do is actually go ahead and move over to our YouTube video
details file.
And this is where we're going to go off and actually search for specific
information for a specific video. So we're going to walk through once more time,
how we can create a custom tool and we're going to go part by part so that all
makes sense.
And I'm a big fan of doing something twice just so that it clicks and you start
to kind of see some of the underlying basically trends and patterns when it
comes to creating tools. All right. So first things first is once again,
we want to go off and say like, Hey,
this is the tool that we want to create and this is going to be a base tool.
So what we're going to do is go ahead, import this from crew AI,
just so crew AI knows that it can use it. And then what we're going to do,
if you remember from last time is, you know, this is a tool.
So we need to define what this tool is going to do just so that our basically
our crew knows what it needs to, when it needs to use this tool and so forth.
And so forth. So, Hey, this is our get video details tool.
This is how you're going to retrieve specific details on a specific video.
Fantastic. The next thing we need to do is define our YouTube video tool input.
So this is the, what inputs do we want to pass to this tool in our case? Well,
we're looking up a specific video,
so it would make sense for our only input to be the video ID that we want to
look up.
I'm going to go ahead and actually just import all the different dependencies
real fast, just so we don't have to keep dealing with all these squiggly lines.
All right. Fantastic. Well,
now that we define the inputs that we want to pass into this tool,
let's go ahead and actually, once again,
look at the run function that we're going to create.
And I'm going to walk you through this line by line. Don't worry. But remember,
you have to define an underscore run for your tool.
And then you're going to pass in the parameters that you want to use.
And these parameters need to match the input parameters up here.
If you get some weird pedantic issue,
it's probably related to like something's not matching up. And then finally,
we need to define the output of this function. In our case,
this is going to be the video details class.
And let me go ahead and define that real fast.
So this is just going to define the type that we want our video details to look
like. And in our case, we want our video details to include the title of the
video, view count, like count, discount, comment count, and everything else.
And this is what we're going to use to help us, you know,
determine what our viral videos in this subspace.
Cause we can compare the view count over to the channel subscriber count to see
if like, Oh yeah, this is a viral video topic. All right,
well now that we've done that,
let's go ahead and walk through this line by line so that you can once again,
see how everything's working. Well, what we're gonna do once again,
make a request to the Google API for a specific video. And in our case,
we're just trying to look up the snippet and statistics for a specific video.
What we're going to do, we're going to make that request.
Once we get back our response,
what we want to do is iterate through each one or look at the items that come
back in that response. And we want to pull out specific information. In our case,
we want the, you know, the title of view count,
like count and everything else that we defined up here. All right.
So we're going to go ahead and do all that.
And once we've went ahead and actually got that information,
we're going to go off and actually create another request.
And this time we're going to look up the specific information on a channel.
Now that we have the channel URL that comes from up here, like I said,
we're just going to make another request,
get that response and pull out the final information that we need,
which is going to be our channel subscriber count.
Once we have all that information,
what we can do is package it all up into a new video detail object that we can
pass back to our tool. So like I said, that was a lot of information.
You just set up just to recap, you created new tools. As you created new tools,
you defined, you know, Hey,
this is all the information that crew AI needs to know about them.
Then you got a little fancy because you defined some specific types and you
defined what the input for this tool looks like.
And you also defined the output for this tool to make sure that Pydantic knows
exactly what are the inputs and outputs of your new tools. Okay.
That was a ton of work. I'm super proud of you guys.
And now that we just finished that let's actually head back over and start
updating our task and agents to start using the newly created tools that we just
created.
So the first thing we need to do is actually head back over to our agents file,
because this is where we commented out some of the tools we were using earlier.
So if you can see down here, you'll notice that I have in our research manager,
which is the one that's going to be responsible for going off and searching
YouTube. What we need to do is add back in those tools.
Now whenever we add back in those tools,
you're going to get some squiggly marks because like, Hey,
we haven't referenced referenced these yet.
So it's up to us to pass in these tools.
So this is the first one we need to update.
The next one that we need to update is if you look down at the bottom of the
file, we have an email creator who is going to use some human,
basically a human tool.
And all that means is this is where we're going to add some human in the loop
feedback. Now I'm going to pause real fast, cause this one's important.
What we're doing here is we're saying like, Hey,
you go off and create a draft email and then I want you to talk to me to
provide some, you know, I'll provide you some feedback.
Now what we need to do to actually use this tool is if you head to the top of
your file, what we're going to do is actually go ahead and define a human tool.
So we're going to say human tools is equal to,
and then we're just going to say load tools.
Now this is going to come from crew AI, and then we just type in the word human.
Now, if you actually go look and actually look inside the crew AI doc,
this is exactly what they recommend.
So let's go ahead and try importing these tools.
And I just need to say from a lang chain dot agents.
I want to import low tools. Fantastic.
And now what we have is our agents file has all the tools that it needs to start
operating,
but we need to go off to our main.py file and start updating our agents that we
just updated. So the first one is our, basically our research manager.
We need to start passing in our tools that we just created.
So we're going to do is come back up here and we're just going to have an area
where we're going to say, set up tools.
And all we're going to do inside of here is actually import the tools we just
created and real fast.
One thing we need to do just so we can start using this tools folder that we
created earlier,
we need to just come in here and set up in a knit underscore dot PI. Fantastic.
Just to say like, Hey, yep,
this is a folder that I want you to start using stuff.
And all we're going to do it's like I said,
just import those two tools that we created earlier from our tools folder.
I want to import the YouTube video details tool, call it right here.
And then same for our search tool.
And all we need to do is back down here inside of our agents where we were
creating our research manager by hover over this.
Now you can see we have a basically this,
so we can do YouTube video details tool is equal to our YouTube video details
tool.
And I actually made a small mistake.
We actually need to create like if you head back over here,
you'll notice that this is a class. Well,
what we want to do is actually get an instance of that class. And if the,
you know, I'll show you what that means actually.
So what we're doing is we're going to say,
I want to create two tools or two instances of our tools just like this.
So this is this is our class. This is our instance of the class.
And what we're going to do next is actually pass those in down here.
So we're going to say our YouTube video detail tool is now going to be equal to
that. And we're also going to pass in our YouTube search tool.
I'll show you how to do that.
We're going to say YouTube search tool is equal to our video search tool. Okay,
fantastic. Let's see if there's any, Oh, I got to put a comma,
but other than that, things look great. All right.
So we now have our agent set up. Let me put this up top little cleanup,
everything real fast. So we're creating our agents here. That looks great.
We have the rest of our agents. We have our search tools.
Things are looking great.
So we do need to do a few other things just to get the rest of our project
working.
We need to actually go ahead and also initialize are the fact that we're going to
be using basically chat GBT throughout the rest of our code.
Cause right now what we're about to do is actually go off and start setting up
our crew down here at the bottom of the file.
So what we're going to do down here is we're just going to say set up crew.
So we'll set it up and then I'll update our dependencies as we do it.
So we're going to do is we're going to create a new crew and we're going to say
this is equal to crew.
And then it's up to us to define all the agents that are going to live inside of
this crew. And thankfully we have auto complete.
So we're just going to pass on our YouTube manager research matter and so forth
and so forth.
The next thing that we need to do is define our task and our task basically.
Yep. It's just going to include all the tasks that we just defined up here.
And then this is where we're going to do some of the newer features that come
with crew AI.
So the first one is we are going to define the fact that we want our process to
work in a hierarchical fashion. So if I type in process,
I actually got to import crew real fast just so it's going to do some nicer
auto complete for us.
So all we need to do is just at the very top of our file,
we need to import it real fast. So we're just going to say from crew AI,
I want to import a crew and I also want to import a process.
The process is going to tell the crew how it wants to basically work together.
So in our case, we're going to say process is equal to,
and I'm going to say process dot, and we have two options.
We have sequential and sequential means we just work on one task at another,
and we kind of just like orchestrate everything to work in a line.
Whereas with hierarchical,
we kind of work on things and more of a manager structure.
I actually have a whole nother video on this feature.
Exactly what I'm talking about right now in the basically you'll see a pop-up
card for it right now. And feel free to watch that tutorial.
I go in a ton of detail with how to use this new feature.
And I found that whenever you work in a hierarchical structure,
you get a lot better results.
So that's what we're going to work on right here.
And then the final thing that we're going to do is we need to define a manager
LLM who's just going to, you know, perform all of this like hierarchical structure
of saying like, Hey, YouTube manager,
you kick off things first.
And then from there basically help orchestrating everything else.
So we need to, like I said, define a manager LLM. Well, in our case,
what we're going to do is we just want this to be an open AI. You know,
we're just going to use basically GPT-4. So right up top,
what we're going to do is we are going to initialize our LLM LLM.
So I'm just going to say, you know, open AI GPT-4 is equal to,
and this is another dependency that we need to import real fast.
It just going to be chat, open AI. There we go.
So chat open AI, and we just need to define which model that we want to use.
So in our case, what we want to do is just use GPT-4. And then, like I said,
we're just going to leave it just like that.
And one thing I will mention every time I have been running this task that
you're about to look at, it costs me about 20 cents to run.
So if you want to get, you know, run, run it for cheaper, you can use,
you know, GPT-3.5 turbo, but I don't get as well.
My results don't turn out as well unless I use GPT-4. So like I said,
definitely recommend using this one and what we can do now that we've
initialized,
what we want to do is we also want to actually import our open AI developer
key.
Now I'm not going to go into how you go off and create an open AI developer
key, just because this will, you know,
you've probably done it a hundred other times in your other videos.
And you can see how I go off and create a developer key in my other videos.
So what you want to do is in your environment variables file is you'll just want
to go off and paste in your open AI key.
And I'm just going to do that off the inside when I'm not recording. Okay,
fantastic. Well, once you have set that up, the final thing you'll need to do is,
well, pause real fast.
The reason we actually import our open AI key is because chat open AI by
default. If you actually look at what happens, if you look at the API key by
default, what it will do is actually go off and grab.
I'll actually just show you guys, we'll look in the source code.
If you look up at API key, what you'll notice is by default,
it's actually just looking up for that open AI key right there.
So if you have it defined in your environment variables,
it will actually know to go grab it by default.
So that's why we do this right here where we say, Hey,
go load all your environment variables.
It sets up our open AI LLM to work for success. All right, enough of that.
Let's hop back down to the bottom where we were defining our manager LLM.
And we're just going to pass in our newer open AI GPT four. Fantastic. Well,
now that we've set up our crew and everything,
we can actually start kicking it off. So this is the exciting part.
And what we're going to do is actually, like I said,
go ahead and kick off our crew.
And we're actually going to use one of the newer features that just came out in
version 19,
which is you can actually look up the usage metrics for each one of your crew.
Once it's done.
And what this will do is it'll show you how many tokens were used to, you know,
when it's going off and generating and researching and creating content,
basically, as all the agents are working together,
it keeps track of that and just spits it out.
So you can actually see what happened and what you'll notice is usually the more
tokens you use, the more expensive the job is. So, okay, cool.
So now that we have all that set up,
what I'm gonna do next is go off and actually show you guys how to actually run
this crew. And this is the part that I'm super excited for. Cause you know,
this is where the magic happens.
Our crew is going to go off and do all the work for us.
So all we need to do is just open up our terminal.
And once we're in our terminal,
it's important to make sure that you are working inside of your Python
environment. And the way we were able to do that earlier,
we'll just by running Python or sorry, poetry shell.
And this will spin off this Python environment and activate it for us.
So that's what you need to do first.
But once you've done that and you're in the proper environment,
all you need to do is just run Python main.py.
And what this will do is go off and kick off our crew.
So this is going to take about four or five minutes to actually execute,
but I want to walk you through what's happening at first.
And then we'll come back once it's done. So it takes a few seconds to start,
you know, kicking off the crew and figuring out what it needs to do.
It's going to start identifying some tasks and what you can see right out the
gate, what it's doing is it used our YouTube search tool.
And it's looking up automating tasks using crew AI and getting back 15 results.
And what's super cool is like, this is actually what you were going YouTube.
You actually kind of see a lot of these videos and actually kind of like see
exactly like the channel IDs. You can actually see some of the videos.
What's funny is I think I, um, I think, yeah.
So crew AI tutorial, complete crash course. That's actually one of my videos.
So it's like, it's pretty cool to realize like, yeah,
that's actually all coming from the internet.
So what we can do is we can just scroll down and you can see that like, yup.
Now that we found these videos, what we want our next task to do is like, Hey,
go look up the video details for each one of these videos.
So it's just going to do that for every single video.
It's going to go off and actually start searching up what's going on.
So this is going to take a good while to actually go off and do.
So what I'm gonna do is just come back.
Actually when it comes to the human input part of this video,
if it actually asks us for it, sometimes it doesn't.
And then what I'm gonna do is at the end, actually show you the final results.
So I'll see you guys in just a few minutes. Oh, real fast.
I do want to mention that you might get a quick error whenever your crew finishes
running.
And that's because it's trying to output a file to the output directory,
but we didn't create that directory yet.
So all you need to do is come back over here and just create a folder called
output. Like I said, just make sure you spell it right.
And then I'm going to go ahead and rerun this crew just so you guys can actually
see the final output of what we just built.
So I'm going to come back in just a few minutes and show you the final output.
All right.
So our crew just finished wrapping up running and I think you guys are gonna be
super excited about the output. So I'm gonna go and open it up real fast.
So you can see what the crew was able to put together for us over the course of
about five or six minutes. All right. So what you can see right out the top,
we have our research table.
I was a little disappointed because if you scroll down a little bit,
you'll notice it only made 10 videos. So that was kind of a bummer.
It had a lot of time basically spinning back and forth between finding new
videos, getting video details and a lot.
So I think it just kind of ran out of context space and it was only able to
output 10, but Hey, that's still amazing. Outside of that,
it had a ton of awesome different, you know, titles that had some like,
you know, followed the exact, basically parameters we set up.
They're under 70 characters.
They're exactly about what we're trying to do in the video.
So this was a huge time saver for me. And outside of that,
we have an awesome video description that I'll be able to post into YouTube
whenever I get to that part.
And then finally I have an email announcement that I'll be able to, you know,
quickly just tidy up. It did actually ask me for some human input.
It actually asked me like,
what was the URL of the video and asked me for some feedback on different things.
But yeah, I was pretty happy with it.
I'm going to be able to like copy and paste this and just kind of turn some
things into some bulleted list. But outside of that,
I was pretty happy with the way it turned out. But yeah, all around,
this was a ton of awesome work on your part. You are now an expert at, you know,
working with making custom tools, setting up agents and tasks.
And that's right for this video, guys.
I hope y'all enjoyed it and I hope you learned a ton about automating tasks with
crew AI. And just as a reminder,
you can download all the source code for this project completely for free.
Just click that link down the description below.
And I also just launched that school community just for you guys.
So be sure to click that link as well.
So you can hop over and have fun with the rest of us guys. And finally,
if you want to see any other more crew AI or AI full stack tutorials,
I have a ton of other content on my channel that you're going to want to check
out after this video.
So be sure to click wherever the video pops up after this.
And I can't wait to see on the next one. See you guys. Talk to y'all soon.