The EASY Way to Create AI Agents with CrewAI in Record Time! | [Day 1 of 8]

4.27k views2137 WordsCopy TextShare
Tyler AI
πŸ‘‰ Join My Community: https://www.skool.com/the-ai-agent-5174/about πŸ‘‰ Book With Me: https://calendl...
Video Transcript:
in this video I'm going to show you how to create a crew and then we're going to use a single CLI command to create it in just seconds this video is kicking off a whole series where we go from creating a crew with a single command using local llms creating our own custom tools integrating brand new features from crew AI scheduling our crew to be automated every day and then integrating agent Ops so we can see what's happening in the background and how much everything costs so I created a new folder called crew AI series which will be using throughout this whole series so this is going to be a day one project so you're going to type in crew AI create and we want to create a crew then I'm just going to type in day one just day one for the day one project okay this this could take a little bit depending on your machine but it's going to go ahead and go through the whole folder structure and create everything we need and I'll be back when it's done I mean look at this it's done has the read me all the tools if we need them the configuration the main file and the crew so if you open up the source file over here you have the configuration for the agents and the task you have a custom tool if you need to create it we don't need to for this day we will in the future uh but then we have the crew let me lower this then we have the crew here we have the task and I'm about to go over all of this and actually right before we get into it make sure you have everything updated okay so here in your terminal go ahead and type in PIP install uh- capital u just to kind of force the upgrade because maybe by the time you watch this video there's some new updates you're going to type in crew Ai and then uh poopy crew AI tools okay so let this run let it update everything it needs to and we'll be back okay so in our crew python file this is where the whole crew is created we can get rid of some of these comments here they're there for you to reference on what things are we have two agents here we have the the researcher and the reporting analyst we can go get rid of this and for each agent for each of these functions it's returning an agent so for the configuration it's going to get the researcher from the yo file and all the properties under underneath of it for the reporting analyst is doing the same thing for the configuration it's going to go to the config file and get anything everything for the reporting analyst and return everything from there so it knows so this agent knows how to perform and then for the task we have a research task and a reporting task the research task is returning a class of type task it's going to get the research task so it knows everything it needs to do for this task then the same thing for reporting task it's going to do everything it's going to get everything from the task yl property for the reporting task return it here so it knows like how to perform or what to perform like what's the expected output uh from this task and then this is an output file we're going to get to this another video so just go ahead and remove that but if you wanted to you could keep that there and whatever the second agent's output is it will make that markdown file for you now for the crew again there are some things to know here the decorators that's what these are called above the functions they are in lowercase okay but then whenever it goes to actually create or return something that's a capitalized okay because that's a class so in the return crew here it gets has self. has self. agents self.
task um the thing about this is that for the agents you don't have to put in as an array like you have a lot times before you have to say oh I need the uh the research agent and the reporting analyst as a list here when it does the self. agents here it knows any agent that has a decorator it's just going to pull that for you you don't have to worry about that and the same thing for the tasks we want this to Pro the process to be sequential so it's going to go in order for each agent and just execute each task we're going to keep that simple okay now let's just go ahe and change the names real quick because I said this should be uh it's going to create the jokes and then it's going to do something else with it in the second agent so for the researcher how about we call this uh joke Creator and then cursor is amazing I can just hit Tab and it knows to change it here as well so for the reporting analyst let's say let's call this the add emojis and then for the task the task um or for the agent configuration that's going to be called add emojis which will change there so this is the joke task and this is the add Emoji task okay that simple we don't need to do anything else here now if we go to the configuration uh folder under day one and the agent CMO file we need to change the researcher to be a joke Creator but for the goal of the joke Creator I want to say create a list of 10 and jokes then the backstory is that you're a seasoned joke Creator uncovering the latest developments and jokes I mean it's not that's not a big deal right we can we can modify that um this one add emojis to the jokes and then the backstory is you're a meticulous Emoji adder and whatever with the complex jokes okay and again I'm just using cursor so that's why it's kind of uh I can press tab button because it's kind of expecting me to maybe want that way so just let's just keep this simple okay so now we have the joke Creator and AD emojis agents changed in the agents. emo file now we need to change the task.
EML file so I come here this is a joke task um I don't need anything for like 2024 uh I can get rid of this you can just create a list with 10 bull points of jokes now the thing that's kind of interesting here is there's a couple ways we can tie the task to the agent because how do we know which if we have like 10 task and 10 agents how do we know which task is to go with it with agent well there's a couple ways and one of them and this might actually be the easier way is under the task emo property file you can have this agent property for the joke task and then this is going to say the joke this task is going to be tied to the joke Creator so now I want to change the um the Emoji uh the Emoji task I want this instead of being tied to the agent analist report I want this to be tied to the ad add emojis agent okay so now these tasks know which agents to go for we have done we're finished modifying the agents and the task em property files the tools here this is a custom tool we don't need this so you can actually just delete this so you don't have to like worry about that we are going to come to that another time um there is a EnV file here within the project however we're not going to do that create a new file here called EnV okay this is where we're going to store our open API key files and any other API keys or anything else related to local llms here so you're going to type in open AI API key and then go ahead and grab your API key in the next video we'll be using I'll show you how to use local llms now one thing we need to do um because we are loading it from a different directory like outside this specific project you can come up here to the crew. py you can from EnV we're going to use the load. EnV function which is going to grab the open AI API key variable and insert it where we need to all right now the last file we need to do anything with is the main python file again we can get rid of some of this you can keep that I mean there's a lot of reference here like comments that are referencing what you can help what the community help with to understand what's going on but we only need for this Example The Run function all these other ones the Train the replay replay and the test just get rid of those we don't need them and in order to actually execute this we need to execute the Run function and now in order to run the the crew we're going to say day one crew.
crew the function and then we're going to use the kickoff function and that's going to actually execute the agents in order that they're that they're in the crew and it's going to go ahead and execute all of the tasks that they're supposed to now you see there's an inputs here you don't need this right now we're going to use this in another video in the series I'm going to show you what that is um that's basically you can use the inputs there and they can be directed into the agents or the task yo properties and so you can give them more information from outside of of the crew so you can add things into the task and the Agents of the crew but we'll get that to another video uh so basically we're done now we've modified it the way we want so that it is going to create jokes for us and then it's going to add emojis to each of them however there are two things we need to change because as of right now it's not going to work so up here in the day one. crew import this this will be changed but we don't need the day one the crew the file is in the same same project level so we don't need that then if you go into your day one crew so go to crew. py the class day one crew you don't need these parenthe parentheses either okay they don't need to be there because you you'll get an error so with those updates we are now done so not only have we created a crew in seconds right we modified it to the way we want to and now we can run it and see how it works now all we have to do is you have to CD into the day one Source Day One Directory because that is where the main python file is then we can just say python main.
Copyright Β© 2024. Made with β™₯ in London by YTScribe.com