in this video we're going to build something from absolute scratch using crew AI this is going to be a real world use case this is something that I need to build I'll explain what it is and I will show you step by step exactly how I go about building it a lot of this stuff I don't know exactly how I'm going to build I'm going to be testing it I'm going to be making mistakes and I'm going to share it all with you we're likely going to be using open AI models including GPT 401 we're going to be using perplexity I have a lot of ideas about how this should go and so let me tell you what we're going to be building today something that me and my team have been thinking about is building out an educational portal basically all the information that you need to become proficient at AI everything from the very Basics to very complex tutorials and we want to automate a lot of it for at least the first drafts so we're looking to build out usually text based educational content and tutorials there's going to be images as well stepbystep guides and I want a crew to put that together for me so with that in mind let's get started started so I'm going to try to use cursor today I have not really used cursor a lot in the past I'm usually using VSS code but let's use cursor and we're going to take this as far as we can today we might make this a part one out of two or three we'll see so we'll take it as far as we can so the first thing we need to do let's just spin up a new cond environment because python environment management is hard so cond create - nedu python equals 3. 12 proceed yes all right now we're just going to act activate the new environment cond to activate edu there we go now let's install crew AI so pip install crew AI all right so it's installing crew AI next we're going to install length trce so pip install length tr- python D SDK okay so this is all going into that cond environment that we just created again always use Python environment management whether it's VM or cond or something else because python environment management is the bane of my existence all right so we got both of those installed now installing crew and getting it set up really could not be easier so what we're going to type is crew AI create crew and we're going to call it edu the edu crew and then hit enter and so what this is going to do is create the skeleton of an app for us it's going to put together all the files we need and it just makes things really easy and here we go already so it downloaded everything we need select the provider to set up so we're actually going to use a number of different providers today but let's start with open AI okay so select a model to use we'll use GP t40 mini we want speed and we want low cost at least for the start we'll experiment with higher end more expensive models soon okay now we need an API key so I'm on open AI create a new key we're going to call this edu and I'll create secret key copy paste it in hit enter and there we go so you could see it created all the files that we need right away now we need to open up this folder where all of these things were created so let's do CD edu and then aside from that we click open a folder we're going to go to the desktop select edu and there we go we now have our crew up and running then I just make sure the edu conduit environment is active so there it is so it should be working now here we can see we have main. py crew.
py the config includes agents. yaml and tasks. yl now out of the box it comes with two agents and two tasks that it knows how to execute so let's just take a look and we're going to run it just to make sure it works so we have the res Arch task and the reporting task and basically what it's going to be doing is research on a topic and then giving us a report in markdown on that topic we can see the agents right here we have a researcher agent and a reporting analyst agent let's see what happens so before we run it let's do crew aai install hit enter okay so it's getting everything we need installed we notice a new environment has been created do you want to select it for the workspace folder now I always get confused at this question because I was already in an environment I believe it's asking me what environment the actual code editor should be in so I'm going to click yes we might have to fix that later unfortunately and yeah if anybody knows how to make python environment management easier let me know in the comments cuz still after almost two and a half Decades of coding this is very difficult for me today's video is brought to you by mamut mammut AI brings all of the best models together in one place for one price Claude llama G GPT 40 mraw Gemini Pro and even gpt1 and rather than having to pay for each of these AI separately you pay $10 to mammut and they bring it all together in one place plus they have image generation mid Journey flux Pro Dolly and stable diffusion again all for $10 models are frequently updated as soon as they're released so be sure to check out mamut for access to all the best models for one low price m m.
a that is m a m m o u t h. AI thanks again to mamut and then let's just test it out crew AI run let's see if it works so running the crew perfect so it is looking like it's going to work okay so we actually got some warnings invalid escape sequence interesting but it doesn't look like that really matters all that much okay here we go we have an agent doing the research really basic stuff so far we just want to make sure it's working all right and if we go to the report. MD we can see the report was created successfully Perfect all right again very basic we're not actually hitting the web at all we're not using any tools you can add tools custom tools right here custom tool.
i you can add built-in tools from Lang chain there's a lot that we can do we're not quite there yet all right now that we know it's working let's make sure we can get Lang trce installed correctly so I'm going to go to Lang trace. I already have an account let's sign in I'm going to create a project this is going to be called edu and as the project type I'm going to select crew AI create project Okay click setup project generate API key so I'm going to select this initialization code right here copy and we're going to put that in main. py at the very top right below the import okay so it looks like L Trace python SDK is not installed we did install it of course python environment issue so I'm going to try using the built-in AI so AI fix and chat here we go install the module okay look how slow that's going all right we'll come back to that in a moment so I suspect the environment that is being used for the actual editor is not the environment that we installed everything on because we have it installed so now let's see what environment we're using so I'm going to hit command shift p we're going to look for interpreter python select interpreter and we're going to to look for our edu so there it is right there so let's select that and perfect now it's not underlined that was the issue and it should be installed now so let's run it again and let's see crew aai run so I didn't save it in time so I'm going to abort that and let's try to run it one more time this time I actually saved it all right yeah we're still getting Ling Trace no module found issue I ran into this exact same thing yesterday I don't really understand but let's see so it definitely looks like we're on the correct environment at least for the editor now why isn't it being found is the question so I'm going to hit cond of list I think that's it let's look for Lang trace and there it is so it is in the list so why isn't this working all right I don't know what to do here so let's see what happens if I just actually instead of doing crew AI run let's see what happens if I just run it from main.
py might not be the yeah okay no module Maybe crewp is the right place to start it from nope all right after battling with python environments for the last 25 minutes I think I finally got it working yes there we go okay so what I had to do is essentially get rid of cond wipe the VM environment start from scratch and then just make sure that the python version matched make sure that the Lang Trace SDK was installed properly the C module was installed properly and now now it works there we go so we have a new report right there now let's get back into the edu project and Lang trace and there we go finally we got it working okay all right so the next thing I want to do is get perplexity installed I don't really want to deal with web scraping cuz that's always really hard to do and so I'm going to try to use perplexities API and just let it do the research for me now I've not done this before with crew so we'll see if it works so here's perplexity let's generate a new API key copy now we have perplexity so the first thing I need to do is set up a new llm and in the crew aai docs it actually tells you how to do it so we should be able to do it pretty easily so we're going to copy this code right here let's switch back to cursor and we should be able to just paste it in right here I'm going to move this import I don't need to say this again so I'm simply going to grab llm and add it to the end there and we're going to be defining a new llm perlex I definitely want to use a different model than this and then we also need our API key here I don't need this cuz we're going to Define it below so two things let's figure out which model we want to use and then let's also input the API key there all right so API key is right there and now let's figure out what model we want to use so right here learn more supported models now this is very unhelpful when I click supported models this is the page it takes me to so not great but let's see if we can find out Which models are available docs supported models okay there we go so interesting we are only going to be able to use these models okay let's start with this one llama 3. 1 sonar large this is kind of the perplexity based models so I'm just going to copy it we'll see switch back to cursor we're going to use there we go llama 3. 1 all right so let's see if we can get this to work now now the researcher we're going to add a new parameter here llm equals and I'm actually going to rename this to perplexity llm and look at that that's so nice cursor so I'm just going to hit tab tab and it just fills out everything for me that's so nice all right so let's give it a try let's just see if that works so I'm going to run it again so now the researcher should have access to the perplexity API and hopefully Lang Trace also captures it all right right so we got some errors let's see what happened so I'm not sure what happened there so I'm going to just copy all these issues and ask it to tell me what's going on add to chat what's the error getting a 404 error which doesn't sound right no it it is it's inputting the right code here so either we didn't set this up right or possibly it's not an open AI compatible API endpoint but I I think it is all right so what I'm going to do just to make sure it works is let's switch back to the previous version of what it had here so we'll use mraw 7B instruct okay I'll hit save let's see if we can get this to work and then we know we've narrowed down the issue nope same thing ah I see I deleted this part okay so add that back in hit save and let's run it again running the crew all right error again perplexity exception 404 all right let's just make sure that we can actually hit the API successfully so I'm going to say write me code to test this API endpoint to make sure it's working all right so I'm going to copy all of this let's create a new file paste it in and I'll save it test.
py great let's run it all right yeah so we're still getting a 404 error code why is that it's pretty obvious we're hitting the perplexity API incorrectly let's check out the documentation all right so I'm going to copy the code and actually ask perplexity what I'm doing wrong all right there are several issues with it here is the corrected code all right the correct endpoint is that fine messages expects an array okay let's just see if that works so we're getting a new error at least invalid model okay that's true so let's change out the model name now all right so let's use this model again let's see if we can get this to work so here's for the model boom let's hit play and I think that's working this time there we go perfect okay so now we know it works so let's see how we can get this to work back in our crew code so I'm going to to instead just put the model name the base URL let's leave the same let's see if we have to add chat completions to it so let's do crew AI run okay yes perplexity exception 404 so SL chat SL completions let's see if that fixes it one more time let's run it nope that did not work okay so I'm going to set it back now slv1 still let's try asking perplexity again so now I say I I'm trying to get crew AI to use the perplexity API and getting a 404 error using this code so enter let's see if that can give us the solution okay here's the corrected code the base URL should be without V1 okay let's try that let's remove the V1 right there okay add the correct endpoint ah I see okay let's add the correct endpoint hopefully that is a thing and make sure you're using one of the supported models wow I got to say perplexity is excellent as a coding assistant all right let's give it a try now let's see if that works and if not we'll pipe it back in and see if it can correct it again so crew AI run let's go is it working I think it might be working it's definitely doing something yes yes it worked amazing all right good progress and let's see what we were able to get out of it this time are we going to get better research let's find out okay so putting together everything now good let's the report okay so we have report. MD here we go comprehensive report on current and emerging large language models GPT 40 with multimodal capabilities Falcon 180b which is kind of old llama 2 llama 3 dbrx so basically gave me a list of models that's okay all right let's check the traces let's just make sure everything looks good there so I'll go over to Lang Trace let's refresh the page and here we go so we can see that it is using interesting Lama 3. 1 one yep okay so that's right the large versions it's using GPT 40 mini let's click into it we can see the traces here and then we can also see the cost over here look at that absolutely just cheap great great great okay so let's experiment with some models now let's use the bigger version of the perplexity model to see if we get better results so we'll take the huge version right there and let's use use that right there we're still going to use GPT 40 mini to put together the report but let's see let's actually take a look at what we're getting back from perplexity and let's go back to the trace so let's click in let's see where it's actually grabbing the perplexity here's open AI where's perplexity okay so one thing that's not actually clear is if the perplexity API is actually using live web data because all of the information it gave me like nitron I guess that's more recent but like Bloom and Falcon 180b these are old models so let me see let's see if we can change it to make sure we're getting the latest and actually I'm going to ask perplexity if it uses the web through the API so does the perplexity API search the web like the regular interface does so it doesn't support Pro search that's okay it does use the same search subsystem it currently only supports the sonar models the API search cap capabilities are more limited okay so that's fine maybe search is available through the chat GPT API all right so is chat GPT search available through the open AI API let's see no it is not okay so I think we're going to have to use something else to do web search so let's ask what's the best web search tool for crew AI all right serper Dev tool EXA duck duck search or duck ducko search should say let's use serper I think that's fine so we need to install crew AI tools so let's do that so pip install crew AI brackets tools hit enter nope that did not work what what am I doing wrong here okay ah I got it wrong okay so there's no quotes there let's try to install it again boom there we go okay so now that that's installed first I'm just going to comment out this perplexity llm let's comment this out okay so now it's using GPT 40 mini still but now we're going to give it the ability to actually search the web okay so it actually gives us a good example here so let's go ahead and copy that all right so here we're going to paste that so from crew AI tools import and we really only need the serer dev tool so let's get rid of these other ones for now all right so we will need a serer API key okay so serer dodev let's do sign up and here we are okay let's see a python example we don't really need that we just really need the API key so let's grab one copy all right so let's set this so let's put the key there so we set it as an environment variable let's go ahead and put this under where we actually call the serer tools we don't have OS installed or called I should say uh AI fix and chat and we just need to import it yeah okay so we'll import it at the very top under these boom so that should work and now we have to instantiate the tools so I'll copy that under here put it right there okay hopefully this is the right order we'll fix it if it's not and now for our researcher we're going to give the researcher a tool tool Search tool perfect okay now let's see what happens if we just run it like that cre AI run okay yeah look at that it is returning search results beautiful so now we get up-to-date information still kind of boring the output it's giving but that's okay we just want to make sure this stuff is working now all right it's done let's look at the report comprehensive report on current trends in ai llms multimodal ai agentic ai open source llms small language models ethics enhanced contextual length Okay I think this is actually looking better much better actually okay next let's give it a topic I'm actually going to want to use all right so we're not going to use perplexity sorry perplexity you're out of there we don't need this llm right there right now all right so first I'm going to get rid of this API key cuz I don't want it in my actual code I'm going to put it in the environment variable okay so help me put this inm I know how to do this I'm just going through the steps here I kind of like using the AI to make it foolproof for me okay so add the API key so apply okay so let's make sure it's in there boom look at that that's so cool okay let's make sure M has it it doesn't why don't you have it there except cep load.
M all right so we need to import OS there we also need to do Fromm load. M okay that should be good now but it's not in here oh there we go look at that cursor's so good all right so we put all the keys here we need one more key now so let's go to crew and let's do that here so we actually have to run install python. M so we'll do that in a moment I'm going say put this in the m file okay so serer API key apply beautiful okay so yep accept it once again we are going to need to import M and then we need to add this let's apply apply the key to M file okay one click it's done all right good okay so now we've gotten rid of all our API keys from our main files and of course let's add it to get ignore and it already is okay good now let's run it one more time just to make sure everything works yes good good good now while that's running let's look at some of the traces all right so the last run it is using GPT 40 mini only we see some tool usage really nice look at that all right and then let's see the cost too it's very inexpensive right now now of course if we use one of the 01 models it'll become much more expensive but we might get a lot better results let's see what happens all right so it worked now let's look at the report one more time cost effective models weaponization concerns okay so it actually gave me something completely different cuz it's such a broad topic that I defined in main.
py this is the topic AI llms so broad now let's do something much more specific all right so for the topic I'm going to say basics of how retrieval augmented generation Works let's run it I'm going to do this once and then I'm going to switch the model out for 01 mini and see if we just get a better response out of it okay so doing a bunch of web search perfect review the context you got and expand each topic into a full section for a report make sure it's detailed and of course we haven't even changed the definitions of the agents so we'll take a look at that too actually before this video is done all right so it finished let's look at the report retrieval augmented generation definition and purpose good two-phase operation Good integration with llms okay this is actually pretty good it's not that expansive so let's just look at the definitions agents first your season researcher senior data researcher let's just say it's a senior researcher cuz I don't want it to just be a data researcher and then uncover Cutting Edge developments no so right incredibly compelling educational content on this topic so actually I'm going to add and comprehensive boy I think I'm a convert to cursor it is awesome you're a season researcher with a knack for uncovering the latest developments for uncovering so it's not really the latest developments so what I'm going to say instead is you're a seasoned researcher with a knack for putting together the most relevant information for educational content on topic okay known for your ability to find the most relevant and comprehensive information and present it in a clear and concise manner okay and then for the reporting analist I think I'm going to rewrite it as I'm going to leave the name the same I don't want to change it so let's say educational content creator actually I am going to change it here okay educational content creator so since we Chang the name there let's go to crew .