Have You Picked the Wrong AI Agent Framework?

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
the agent-based workflow is one of the hottest Trends in the AI world right now and if you are building one you've probably chosen the wrong way to build it and by wrong I mean more verbose more complicated and more time consuming the Frameworks out there want you to think that this stuff is hard but it's not in this video I'm going to show you how to build one far easier than any other tutorial out on YouTube right now most of the tools out there require reams of repetitive boilerplate that has little need to actually be there in most cases you can do it a lot more simply and again in this video I'm going to remind you of an easier way to get the same thing done you're probably going to smack yourself on the forehead when you see how easy this can be in most cases now let's get right to it and take a look at an example using crew AI I saw this tutorial by code with Brandon and it does a great job in fact all the videos on his channel are really well done and you should check them out in this one he shows how to use crew to automate components of his YouTube strategy he researches topics comes up with possible titles in a description and and preps an email to send out to subscribers this is potentially an hour or two of work condensed down and completed in seconds that's amazing you may not be a YouTuber but you have processes that you do every day that could be automated just like this this has been the promise of AI and agents since the very beginning and it's one of the reasons why people are really excited have the robots do your work but there are a few problems with this let's take a look at the code in the main python file we see that we Define some agents and tasks and here we're assigning tasks to agents and then we're kicking off the app so the way most of these systems work is that they have agents that manage stuff kind of like people in a team at any company and just like those people in a team they perform various tasks and so with crew and other Frameworks we model those same Concepts but for most workflows that you're going to automate these tend to have a onetoone relationship rather than the many to many relationship they're capable of in Brandon's example there are four tasks and one agent for each and Brandon isn't alone most of the examples I've seen by others or even in the crew examples repo tends to do the exact same thing so if most workflows are going to do that then having to Define an agent and a task is just extra work with no real value but even if you did have one agent performing multiple tasks the goals and backstories you need to create tend to be a bit ambiguous and in many cases just confuse the model rather than help make a better agent flow but I don't think that is even my biggest gripe with these Frameworks in most of the examples there is a well-defined workflow that we're trying to automate but rather than use that workflow we're creating a manager agent which comes up with the workflow on its own sometimes it does and sometimes it doesn't but every time it takes a little bit of extra time to complete now you might respond that if you use chat GPT it's hardly any time at all but then we get all the security and privacy issues that you probably already know about so that's not really a viable answer for a lot of folks out there and then maybe the language you're strongest at is rust or go or typescript or something else For No Good Reason many of these Frameworks require python which is its own set of problems pretty early on olama switch from python to go to make things easier and more powerful but there's no reason that you as a user needs to know about that I've seen the same progression for so many projects out there the first two issues coming up with the workflow and the verbose agent task definitions show that in many situations in in the cases of most of the examples out there this is the wrong tool for the job and that's a common pattern with any newer technology we've seen this so many times over and over again all over the place spinning up kubernetes when you just need to host a single website on one machine is the wrong tool for the job using Lang chain when you just need to write a simple rag solution is the wrong tool for the job whipping out your Dremel when you need to get rid of a nail you never did I mention we CAU the Dremel multipro oh is the wrong tool for the job all of these kubernetes Lang chain and the Dremel are the right tool when you're using them for the right thing the right thing in the case of crew AI or other agent Frameworks is when you have a job that doesn't have a welldefined workflow where you need the model to do something close to reasoning and understanding to solve it but that's a situation in a small minority of use cases now some will say that even if you know the workflow of a much more complex project crew would be the right solution but I don't think so it's always going to be easier and more scalable by keeping it simple and using something like a state machine Library like xate to manage the flow so let's take a look at an alternative to using crew to automate one of the workflows that we have now I am also a YouTuber so I'm going to go ahead and automate what Brandon did I'll be doing this with typescript and bnjs now first let's run the app YT research it takes in a topic which I've set to AI models local olama and then it searches on YouTube for Relevant videos that have done really well it actually finds 50 videos and then I sort them based on a kind of a arbitrary formula for each video I have days since published views likes and number of comments I normalize the views by subscribers and likes and comments by views the views is more important than the likes and the likes are more important than comments and newer videos rank higher than older ones so I divide by days since published that formula looks like this so then I take the top 15 of the videos found and format them as Brandon did in his video next I take the topic I said above along with a short description I created of what I thought I was about making along with this list of 15 well performing titles and I have a model come up with 10 good titles for my potential video next I use the topic and description to make a more filled out description which also points to my newsletter which you can find at techn evangelist. newsletter and my patreon which you can find at patreon.com techno evangelist finally I use that description to come up with an email to my newsletter subscribers announcing the new video running the whole process takes less than 90 seconds that is far less time than it takes me to come up with one really bad title for my videos I fumble around creating a description and they never sound as good as this one and I never even thought of sending an email to my Subs so I'll definitely be doing that in the future Now using crew to perform this same workflow took about 400 50 lines or so of code not including the code required to interact with the YouTube API sure there are comments and spacing to make it easy to read so let's just say 300 lines of code let's take a look at my version at the top I have some imports the two external dependencies are AMA and a package called Dirty Json which makes it easier to deal with Json embedded in Json then I pull in the functions for searching YouTube collecting inut for my user and my prompts so let's get the search results from the YouTube API it pulls 50 of them which have been assigned a score by me so I sort by that score and then I print out the output before moving on let's take a quick look at that code reaching out to the YouTube API video search tool makes a call out to the YouTube API with a topic my API key and the number of results that I need and then it pulls out the pieces I need and returns an array of all the videos to get the stats I need to call video details tool on that same video and that gets me all that stuff then I generate a string based on the format of the report Brandon wanted and here we can see the score I assigned to it finally I've returned an array of the stats the report string and the score okay so now back to the main script I can make a call to olama generate and set a system prompt and user prompt that user prompt tells the model the topic description and a list of well performing titles as well as the Json template to use now I'm using function calling here because this is an application that's going to use the output later on I could have defined all the functions that could be used and let the model choose but I know which function is needed for this so there's no reason to do that that spits out my Json object of titles which I can parse and display now I'm using the generate endpoint instead of the chat endpoint because these are one-off calls to AMA and I don't want to deal with the hassle of using messages object since it doesn't give me any benefit here so then I can call generate again passing in the topic and my short description to have it build a more complete description again I'm using function calling to Output a well-formed Json object I set the system prompts for all of these from my prompts file shown here you can see that I have a prompt for coming up with titles the description and the email now the output here was a bit strange because there are a bunch of new lines in my Json my code had a hard time dealing with it so the really cool dirty Json package helped a lot here finally I use the new description and my topic to come up with an email to send to users if I provided it with the URL to this video this would be even more complete so not including the tool code this comes to about 60 lines of code that's a big saving over the 450 oh sorry we agreed to say that it was 300 300 lines of code required to use crew to perform exactly the same process less code often but not always means fewer bugs and easier to write and faster to just get stuff done as I mentioned before there are probably cases where crew AI is potentially useful but even those times there may be something easier I am so glad I saw that video from code with Brandon I plan to implement a workflow just like this for my own channel coming up with the tweets and Linkedin posts in the description and more can be super powerful and save me a lot of time maybe after I finalized my own process I can share it on here with all of you I look forward to seeing projects like crew AI mature a bit more right now it feels a bit too much like when I did early windows program with with that Charles petel book opened up in front of me typing out pages of boilerplate to get the simplest hello world on Windows 311 what do you think are you automating your own workflows with AI how are you doing it I would love to hear your feedback in the comments below I am sure this one is going to generate a lot of comments calling me an idiot that happened for the function calling one two though no one was actually able to show that I got anything wrong in that one I hope that in a few months this video becomes out a date because the Frameworks do a better job but who knows well I mentioned the newsletter in the patreon earlier in the video so I can just get to straight to the 20 seconds of Silence some call awkward silence that quite a few of you really love thanks so much for watching goodbye for
Info
Channel: Matt Williams
Views: 49,171
Rating: undefined out of 5
Keywords: ollama, ai, llm, localai, crewai, agency swarm, ai tutorial, ai development, ai automation, agent framworks, ai tools, ai agents for beginners, ai agents examples, ai agents tutorial, ai agents and environments, crewai local llm, crew ai ollama, crew ai local, crew ai use cases, crew ai agents, crew ai tools
Id: jLVl5V8roMU
Channel Id: undefined
Length: 13min 10sec (790 seconds)
Published: Sat Jun 01 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.