All right. To get things started, let's get some of the boilerplate code in here. And let's start build our crew. So, first thing that you want to do is make sure that you import the agent task and the crew class again. Once that you import that, you're good to go and ready to get started. All right. So now that you imported the agent, the task, and the crew class, we can set up the model that we're going to be using. So for this one we're going to be using GPT-4. So you have been using GPT-3.5 up to this point. But we are moving to four now because we're going to be handling with more data. So you want to make sure that you have that extra context window to handle all the information that we are going to be sending to this agent. So let me just copy and paste in here. Another thing that you're going to notice is that we are using serper API here. So serper is basically an API that allows you to search Google. And you're going to be provided with AI key that you can use. But you can also go into their website and sign up and they offer free credits. But honestly, there's a lot of other like search tools that we could use as well. We just choose to use serper in this example. So let's go ahead and just execute that. All right. So now we're ready to dive into tools. We basically want to make sure that we use some of the crewAI tools. And we also want to make sure that we create a simple custom tool to show you how that looks. So let's go ahead and start creating our agents. We are going to have two agents for this. The first one is going to be a sales wrap agent, because we are going to be doing a sales use case this time. The sales rep has one goal, and that is identify high value leads that match our ideal customer profile. People like to call that ICP in sales is a big use case for multi-agent systems. So probably you're going to see a lot of that around the internet as well. You can see that in the back story. We set some context around the fact that the sales agent works at crewAI in some of the mission around it and everything. You also going to notice that this agent is not allowed to delegate any work or ask any questions. It's just supposed to do what it's told. We're also going to create a new agent. and that's going to be our lead sales rep agent. So let's execute this and then create a new one. So this leads sales rep agent. You're going to see that it builds on top of our previous one. It has a different go. This go is kind of the actual personalized content. And build a personalized communication with this lead that we're going to be working on. So the idea of this crew at the end of the day, it's given a lead, find out a way to communicate with them that helps them to get an interest on through crewAI. So let's see how that's going to play out. So let's first execute this agent. All right. So now we have those two agents created. Now it's time for us to look into the tools that we are going to use. We are going to be using the crewAI tools package again. So you can go ahead and type that out and import those tools. You're going to see that we are using three tools this time. We are using a directory read tool we're using a file read tool, and we are using a serper dev tool. So the directory read tool allows your agent to read any directory that it wants. Or again you can kind of like confine its options by seeing a specific directory that you want wanted to run. Then the file read to the same thing. And the Serp tool we already talked about that in another lesson. It allows you to search the internet. So let's go ahead and instantiate those three tools. So you can create a directory read tool, the file read tool and the search tool. And the one thing that you're going to notice is that on the directory read tool, we are specifying that we want it to be able to read only this local instructions directory. So in this directory, there are a series of instructions as markdown files on how to handle companies from different sizes. So we're going to have big companies, small companies and medium companies, instructions on how to handle them. And we're letting our agents being able to read these files by setting up these tools that allow them to actually, look at that folder. So as you can see, we now have three tools that we're using here: are directory read tool or file read tool, indoor search tool. And you can see there are all similar but the directory read tool is actually passing one attribute called directory. This attributes forcing this tool to only allow the agent to read this one single directory in this case is a local directly called instructions. So this local directory basically holds a set of instructions on how to handle some of those customers. If it's a big customer or a small customer or whatever it might be. Let's look at those files real quick. So here you can see that there are three files inside that directory, a file that has a set of instructions to how to handle a small business, and how to handle tech startups, and on how to handle, like, more enterprise deals. And you can see here there's like a specific template. There is key strategic points to address. There is there is introduction. So everything that our agent might need in order to actually engage with like a specific company. So now that we have our tools here, we can create a custom tool just to see what that would look like. So every framework out there it's going to give you a pattern to create a custom crew, and crewAI is no different. It offers a couple different ways that you can use to create a custom tool. So in this case, the way that we are going to be using is by inheriting from a class inside crewAI, we can import this class. It's called BaseTool. And now that we've imported it, we can create our own class, that's going to be our tool, that inherits from that. So in this case our class will be called Sentiment analysis tool. So you can envision that at least you would do some sort of sentiment analysis. But this could be anything. This could be an external API call or whatever you want. But in this case we're just going to fake it a little bit to make sure that we build a custom tool. And we learned how to do it. So one thing that every tool needs to have inquiry crewAI is a name and a description. So in here we are setting the name of this tool to sentiment analysis tool. And the description tells the agent when it should use this tool. And what is its purpose. So in here we're saying that it analyzes the sentiment of a text. And then in order to actually implement the tool, all you got to do is create this run function inside that class. So, as long as you have this underscore run function in there, you can add any code that you want. So, in here is where you would call an API or where you would take an action or send an email or anything you wish your tool to do. In this case, we're keeping it very simple because it's just an example and we are just returning the word positive. So this is a sentiment analysis tool that always returns that the sentiment is positive. So now that we create a stew we can actually instantiated. So that we can use it. The same way that we did with the tools of both we said, the directory, the file, and the search tool. So you can go ahead and just do that. And now you have the sentiment analysis tool and you can pass that to your agents and tasks. So, now that we use our tools let's create our tasks and assign them properly. Here we are going to be able to see how we can focus in specific and clear goals on what we want to achieve by using this tool. So the first task that we are going to create is a lead profiling task. So the lead profiling task basically conducts an analysis on a given lead in order to understand its sector, how big it is, information that might be useful for us to engage with this potential customer. So, in here you can see that we are providing it with a set of tools, are directly read tool our file or read tool and our search tool. So with these tools, this agent when performing this task are going to be able to look at those instruction files that we saw before, read them and then using the surfer API, search the internet for more information about this lead. So let's go ahead and create this task. Now we're going to need a new task. This new task is going to help with creating a personalized message to outreach for this specific lead. So I can paste it in here. And you're going to see that this task has a different set of tools. It doesn't need to read the directory any longer, because by now it already knows it is a big or small company and already has done some research on them. This task is focuses specifically on doing a sentiment analysis and doing any further search that might be necessary in order to make sure that we talk with this customer in an appropriate manner. So you can go ahead and also create this. Okay. So now that we created the two tasks, you can create your crew. The crew is pretty straightforward the same way that we have been doing so far. We pass in the agents. We pass in the tasks. You can set the verbose mode to two, and you also set the memory so that this crew is using the memory functionality and features. You don't necessarily need to if you don't need, but I think it might be a good use case. So let's go ahead and run this. Now you can kick off this crew, and kicking it off should be pretty straightforward. So in this case we're passing a set of inputs. Remember that these inputs are going to be interpolated in any place that we use them, both in the tasks and in the agents. So these inputs are going to be used into any place in the tasks descriptions or the agents definitions. Anywhere where we try to interpolate these variables we can now pass their values in here. So in this case we're simulating that the lead name is Deep Learning and AI. In there, the industry is online learning platform. The key decision maker is Andrew. And he is the CEO of the company. And the basic milestone that they have is a product launch. So we can go ahead now and kickoff this crew. So everything starts with a first sales representative. And it's going to start by conducting this in-depth analysis of the DeepLearning.AI company and basically trying to learn more about it. So you can see here that it started by searching the internet, trying to understand more about DeepLearning.AI. So in here you can see all this search results that it got from Google. And if you scroll further you're going to see that it by mistake decided to try to read one of the websites as a file. And you know that we just talked about how tools need to gracefully fail. This is a great example of this. This file content read tool is not meant to read a website, but actually a file from your file system. So if you didn't plan for that, you would throw an exception in your execution would stop. But crewAI automatically handles data so that it fails gracefully. So you can see that despite of it showing an exception, it tells the agent that it got this error. So the agent kind of like now understands that it can directly access the external links using the read files content. So it's it's learning from the tool that it tried to use. So it then go back into search the internet to try to find more information about DeepLearning.AI. So if you're building your own thing, or depending on your choices or framework, you might notice that if your tool finds an exception, the decision there is let that exception actually blow up. And when that exception wblows up, it stops the execution of your agent. So that means that hours that it was completed so far is gone, and your agent execution stops, so you can't move forward. That means that you would then need to add an extra layer so that you can treat for that, either kind of like kickoff your agent from the scratch or do something else with that error. So for crew, it was a conscious decision early on that we would prevent exceptions from stopping execution. But you might find other frameworks that choose it otherwise and choose to allow exceptions, actually stop executions. And that is the commission's choices that you can make. And if you're doing something from scratch, because, again, you don't need to be using a framework, you can be building these agents yourself. It's just going to be a lot of more coding. But it's something that you need to be mindful of. How you want to handle exceptions when using tools is a big thing as agents, So you can see that again, it finds a bunch of different research and put together a DeepLearning.AI company profiles with a background of 1 or 2 key personnel, recent business development potential needs, engagement strategy, everything that we need to know about the company. Now our next agent kicks in, the lead sales representative. We're using the research that your agent did before, it's going to try to come up with a good way to engage with DeepLearning.AI. So in here you can see that again, it's doing some research online. Keep in mind then this is where some of that caching strategy that we talked about comes in. If this agent tries to do the same research or the same search online that another agent did, it's gonna hit a caching layer. And instead of actually doing the search. So you're going to be saving and rate limits and and the request in basically is going to just work faster. And here you can see that it comes up with an email where we can send to Andrew. The subject is: "Enhance DeepLearning.AI's Educational Impact with crewAI's Advanced Analytics." And then it goes on explaining. And you can see that even references The Batch. The Batch is actually a newsletter from DeepLearning.AI. And we never told these agents anything about it. They learn about it automatically through the research that they made. So now we have an email that we could engage. And we actually have a few other options here. So you can see that it gives another option. Now a little bit more focus on AI drive tools. And another one talking more about a partnership. So you can choose what email you want to use to actually engage with this company. This is such a great use case. Throughout or interactions with the community that has been building multi-agent systems independently of what framework they are using, we realize that there is a few verticals they are very common, and sales is a big one because a lot of the sales process involves reporting, involves researching, involves engaging in all that are things that can now be automated through agents. So it's going to be common for you going out there and talking with other people. There are building agents to see that they are doing things in this verticals. And this is honestly a very interesting space in general.