AutoGen Tutorial 🔥 How to Build POWERFUL AI Agents

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
autogen the dawn of AI agents so this is autogen a multi-agent conversational framework that allows you to leverage AI to build applications build scripts and do all sorts of crazy stuff it's free to get started it's easy to get started it's under the creative common license so you can use it to build whatever you want and this is where a lot of the AI research and a lot of functionality is going the ability to utilize multiple agents to create whatever it is that you want whether that's a department that's developing code or your own content Development Department or a research Department whatever you want in the previous video we covered all the different things you can do with it but a lot of people had trouble starting this up so this video is going to serve as a little bit of a quick start I'm going to show you how to install it even if you've never used anything like this before and then we're going to run through a few quick simple examples at the end of this video you should be able to use this and leverage this to create bigger and better things you're going to have all the sort of Base knowledge that you need to really get cooking with this I'll have links down below for a page that's going to have a lot more resource information in case you get stuck and with that in mind let's get started all right so let's talk about how to install autogen if you haven't done it before here's the GitHub autogen sort of project page if you're trying to get into Ai and building apps with AI trying to learn more about AI this is a good thing to know how to use this is a good thing to learn now a lot of the stuff before AI it was kind of most of the people using this were actual software developers Etc now that the AI is out a lot lot more people are interested in this so let's get started so this is GitHub this this is Microsoft autogen page Microsoft did something very cool which is they they used a Creative Commons license which means that you're able to use it pretty much for whatever you want do you want to build with it and sell applications you can do it there's really no restrictions so first and foremost a lot of people still don't fully appreciate the power of Chad GPT and what can do so I'm going to be using Chad GPT here to demonstrate how to learn some of these things so I'm going to ask this is my GPT plus we're on default I would like to install autogen a GitHub project that uses python assume a fresh computer with nothing installed what do I need to install to run it so first and foremost it starts by saying install Git it it will tell you how to do it on Windows Mac OS Linux whatever you're using next is going to tell you to install python so this is good if you're just starting out trying to get into it you need to install python python is a really good coding language that is used a lot with AI in one of my past videos I said that python is the the best language for AI and people try to kill me in the comments so I had to walk that back just a little bit still great language for AI you know it even gives you a little link so it's python.org downwinds or whatever if you use Linux or whatever it's right here SL download so you just download the latest release python is massive it's Global it's a lot of people are contributing to it so it's not like some weird side project all right so you run the installer and you do this and it tells you how to do that with Mac OS and Linux then you clone the GitHub repository so often here you know if you click on code this gives you the uh URL to clone whatever this project is you can clone it to your computer then you can work on Etc most of the time you'll be doing that in this particular one we might not have to but basically clone the GitHub means that you take whatever the code that they have on the website here on the project and just copies it over to your computer and you can take it and you can change it do whatever you want with it if you're contributing to the project you can even once you added your own sort of modifications to it upload it back to here and now it's available for everyone to use That's The Power of GitHub all right so then we install dependencies we'll talk about that and then we run the project now one thing that it doesn't talk about here is the IDE what is the ID tell me briefly about what an IDE is and why it's useful no jargon so an IDE is an integrated development environment so basically it's the program that you use to code right so think of it like a feature Rich word processor for code just like you would open Microsoft Word to write your favorite whatever write your documents right the IDE that's the thing where you write code for python I like py charm so if you just search download py charm py like python charm you know it's going to be hopefully one of the first um one of the first ones so you click on it it looks like this the professional version costs money but the community version is free free built with open- source code array so you download that when you load it up it looks a little bit like this this is what py charm looks like we'll go over everything in just a second here so so far what we've done is we've installed python to be able to start programming in that language we've installed py charm which is the developer environment the word processor for code so now we have the language and we have the thing to modify it and code with it the next thing that we're going to need is the openai API key so API Keys they're used widely across a a lot of different platforms what they allow you to do is to connect different functionalities from different things together so for example let's say I'm writing code and I want to pull in my various Gmail emails into it there's a Gmail API that allows me to do that there's one for YouTube there's one for open AI there's one for whatever it's like little hooks that you can hook into that software and just pull out the stuff that you need the way that I usually describe it's kind of like a restaurant right when you go into a restaurant you don't go in the kitchen and cook your own food you order it from the waiter and he brings it to an API is like that waiter he's going to go in the kitchen get whatever you need from from whatever software you need so you got to make that account with open AI you go under API keys and you create a new secret key we'll go over where to put that in just a second but one thing I want to mention is lots of people run into issues with billing if you get any error messages along the lines of like GPT 4 doesn't exist when you try to run some of this code or anything else like that open AI related that might be because your billing is not set up correctly basically the way that that I was able to fix that is I went into this billing overview I cancelled the plan that I had and I signed up for another plan and I basically just added 50 bucks to it as a prepaid thing I think you don't have to do 50 you can start with five but basically they want a credit card on file for for you to be able to use it and as as soon as they charge you even $1 you're clear to go but before then there's some like security issues so something to be aware of but basically set this up you need a credit card on file you can just add some money and not set up autocharge that way there's a limit to how much money you could blow through in case you accidentally you know mess something up but in general they do have usage limits so it's hard to charge up a massive amounts of money all right so now you've installed py charm go ahead and load it up it's going to look a little bit like this I've been messing around with autogen here but let's go ahead and we'll start a brand new project we're going to go file new project bam we're going to call it autogen test how about that the rest we can leave as is and here we're going to create a a new document so generally you call the main that py s sort of that that main python document that you're working on so we're going to click create Microsoft Defender I'm just going to click automatically all right so it starts out with this little thing and a little sort of just welcome script and so up here are the little tabs of the different different files that we're running so I'm going to go ahead and just uh Delete all of this and let's briefly talk about the layout that we're looking at here so this is where the code goes so this is where we're adding the code this is where we're coding and then we can hit this little play button to execute that code this is where the a lot of the output will be if we have any error messages they will show up here if we request something to be shown to us like we say print out this information it'll be shown here and so this is referred to as run so basically this is like the Run window and then all the various files and everything else that we have if we have to If it creates like a PDF it'll show up here and then here is the terminal so for the most part these are the two buns that you need to know you need to know terminal and you need to know the run run is sort of where where it's showing us what it's doing and terminal is very similar to if you run the command prompt on windows so the terminal is basically a built-in version of this so I'm going to close that and yeah that's about it so let's get started so we're going to go back to uh autogen their little page here and so basically this is how you install it so this pip thing that's a that's a commandline tool so you're going to see that a lot so when you see pip pip often times you're going to say pip and install something so that's basically how you install a lot of these packages for python that you need so whenever you see pip install something that's what it means it's just you're adding the thing the software the functionality that you you need to run whatever it is you're doing so pip install py autogen now you can just copy that or I'm going to type it in so you go here to terminal and we're going to just type it in PIP install py auto gen so when people say pip install that's what they mean and we hit enter and it's going to start installing autogen so as you can see here it's running through all the various things that it needs to make it work just give it a quick second and it'll be done so and now it's done all right and here it has the quick start code so we're going to go ahead and we're going to copy that and we're going to throw it in our sort of code window right here bam so really fast in general how this is laid out by the way you can create uh as many lines between between the code as you want so lines here don't matter you can create a million different you know blank lines that's not a problem indentation does matter so uh don't indent without reason but create blank lines as needed anything you see here like this with this hashtag symbol at the start of the line that's called comments so the computers don't read this this is just for humans to read so I'm going to go ahead and delete that really fast and so this comment is this initiates an automated Chan between two agents to solve the task all right thanks for that and so generally in python in the beginning we're saying all the things that we need to install all the librar so we say bring this in bring this in like we need all these books all these instruction so in the beginning we write those so you're going to see things like from and import Etc in the beginning and then you have all your various functions that you're running here so one really quick thing is we need to import all right so import space and we're going to import open AI so we're going to go back go back to terminal and we're going to install open AI how do we install open AI pip install open Ai and so that's going to run install all the various files you need now I already have that installed so all is good next uh we're going to add this open ai. aior key equals and then in these little parentheses we're going to add our API key so that's the thing we were talking about earlier we go here API Keys we create we say create new secret key right we name it something if we want then create secret key then this is going to be our new secret key we copy it over go here so basically this is how it would look like without the key in there we put that key that we just copied in there boom that's ready to go all right and then this last line is what we need to focus on next so as you can see here the message that we're giving to our AI agent is this plot a chart of of Nvidia and test a stock price change year to date so that's the sort of example message we can put whatever we want in there so let's get started I've tried a couple different ways of how to approach building software with this one thing that seems to work really well is to start with something very simple and Broad so don't start trying to explain in great detail what you want from the very beginning usually it helps to be a little bit almost vague a little bit and and see where it takes you you can always backtrack you can always start over but often times I found that when you give it sort of a very high level goal it starts thinking through about it and says well here are some ways we can do it and it actually tell you why some of those ways are bad so later on you can actually see what a better approach might be we might we might see what that looks like in just a second but let's start with this something simple I'm going to tell it to build a simple snake game that's a very common thing to use the snake game is probably one of the oldest games that that has been around for a while so I think this is a really good test and I'll show you how to build on that and how to add to it in just a second so once we do that we're going to go ahead and we're going to clear we're going to hit this uh run button so we're going to run main main is this our our file that we're working on we're going to hit run main all right so it's thinking about it and it's passing our Command to the AI build a simple snake game and now goes to work thinking about it now it's communicating with open AI API so gpc4 is thinking hard about how to achieve this thing this task that we've set for it all right so outputs this so it says yeah I'm happy to help with the task here's a snake game and here's the step-by-step guide that it's going to follow so it's going to create it's going to import the curses Library which will help us in making characters move on the screen it's going to create a window of a snake which is a box and then food which is created randomly in the window and a score to show so it'll give you the code to make that happen and it'll put them between this little little Tilda three Tilda Python and at the end it will close out that code with you know again the three kind of Tilda symbols right so this is the code that it gives us and then it says save the code into a file called snake game. py and then run this file you can move the snake with the arrow keys eat the green food and the game ends when the snake touches its body or the edge of a window couple things we can do here we can actually create a brand new file we can even start with a basic word editor throw the code in there say it as a py file so I'm going to take this code right copy it we're going to take a notepad we're going to paste the code in there right we're going to click save as and we're going to just uh we're going to save as all files and um snake game. py boom we're going to save it here it is it appears on our desktop you can still modify within the notepad and just keep saving over it right but if we run it here here's that game here's that file as you can see it's running and when when you crash into the side it just stops working which is fine we can add sort of an ending screen later and so just like that it goes around the map eating the pi shows pi as the um fruit okay so let's crash into the window all right so this is H just like notepad just it's called idle it just helps highlight you can edit these Pi files with many different applications the most basic is the notepad here we switch to something called idle it's basically the same as the notepad but it highlights the python code in different colors for easier readability you can continue using notepad to save and run the snake game in different colors what different things do just easier for readability but it's basically the same thing so what we're going to do so it looks like the snake game works as advertised and then crashes if you bump into the wall okay perfect so next let's do this let's add a score that goes up by one when the snake eats a fruit display score in the top left of the screen all right so we're going to get that going when the snake eats a Groot I hope it knows I rout all right so it gives us back the script the score will start at zero and increase by one Let's uh go let's see if it works so we paste that in here make sure this is deleted and then save it all right so that's our script let's start it all right so look it says score zero and then as we continue it Chomps down on the various fruits of the pies if you will and uh yeah oops I hit the wall this is why I will never be a twitch streamer all right what else can we add to our cool little snake game let's make it grow faster just so it kind of like so we can just see the progression faster make the snake grow by 10 units once it eats the fruit let's see if that works all right so it comes back with in this code the snake Grows by 10 units every time it eats the fruit all right and explains what it changed to make that happen all right so let's scroll down here and we'll grab this code again we paste that into our notebook and then save it and then run it let's see what happens so I ideally it's going to grow by 10 yeah look at that let's see if it continues yeah keeps growing by 10 so it's about 20 I mean I'm not count counting but I assume it's it's that did I miss that yep okay cool so this way we can just test things much faster without having to eat a million different things yeah there we go okay and boom all right well that's exciting but let's add one last thing let's add enemies let's add an enemy that drops from the sky if it crosses the snake it cuts off the last part of the snake if it hits the head of the snake the game is over all right so it comes back with in the code above we introduced you checks to verify whether the enemy either crosses the snake or hits the head of a snake all right let's see so decided to randomly decide a starting point for the enemy on the x- axis and start dropping it towards the bottom if the enemy crosses the snake it cuts off the last part of the snake very very cool if this works uh that' be kind of cool okay so we paste it in here and then we're going to go ahead and save and run it let's see oh there's the little enemy all right all right so as I'm running around eating the little little fruit pieces the enemies that are dropping from the sky are attempting to cut off a portion of me let's see if oh there it is Boom cuts off the last part but it didn't do anything or did it hm so that didn't seem like it did anything let me try it again let me let me see if I can do it again and see there it is okay boom so no that doesn't oh I see okay so what it did was it cut off the last part of the snake meaning the last block of the snake Okay how it interpreted what I said was cut off the last part of the snake it it meant it it figured like cut off the last little Edge the little last piece of the snake I was thinking more like no like cut the whole thing in half CLE it in half how about that okay let's go back to here so that works well but let's have the entire second part of the snake get cut off so if enemy crosses the snake at the center then the snake loses half of its body let's see if that is better said let's see if that makes a little bit more sense so in other words the snake gets cut at the point where the enemy crosses it although I could see how in a different game having losing just like one piece could also work depends on how you want to build the game to me I was just envisioning like it just cuts it in half wherever it drops but let's see if it's able to figure that out all right so it did that so we cut the rest of the list from that point which effectively gets rid of the second part of the snake from the point of impact yes so getting rid of the snake from the point of impact is yeah that's a good way of saying it all right so we're going to take that code we're going to put into our little document let's run it all right let's go so let me need a few pieces here and we'll see how that worked out all right so here we go we're getting pretty long here and it should cut off the second part and yep so as you can see here it completely cut off the half of the snake and it just it just lies there uh which is pretty gruesome if you think about it O Okay that took off most of it okay so let's just test to see what happens if we go over this part again does that do anything doesn't have any functionality it just kind of like cleans it up I guess but it doesn't really do anything okay that's fine it just sort of deletes it but it's not like it eats it again which that could be another interesting gameplay mechanic like you can just eat the you know the remains to grow bigger I guess so that's basically how we created a you know very simple snake game with some added functionality how we built on top of it and then when we ran into issues with it you know not doing what we wanted we just explained hey that's not quite what we're looking for and it went in there and once again you know kind of ouch and I corrected the mistakes and continued doing it now as I was messing around with a lot of stuff it does have certain bugs every once in a while that you have to figure out most of the time when you tell it about the bug it figures it out some of it is just about what environment you're running in so sometimes like for example initially I was trying to post it in here and run it from here like a testing environment but I found that it's definitely a lot better to just post it into a notebook like this and run it from here one thing I noticed here so it changes the file name so now it it calls it snake game Enemy cut so this is a great way so it's kind of automatically keeping a version control so as you're adding new things it's changing the file name so if you were saving it as the file name dat recommends you would have you know five different files each with a separate version of the game right so if you find that you know you went down a path that you didn't want to go down you can go back and find that original one be like okay let's go back here before we implemented all these changes so it's interesting that naturally it's really good at doing s of these like best practices so I would definitely give it an a for that there were other things that I tried building that did not work out so certain things it still has a hard time understanding but maybe it fails something like one in seven things that I ask of it so even right now is this sort of beta version is a very very early version of what it's supposed to be it's still still pretty effective it's still pretty useful with that let's take a look at one more thing that it can do so we're going to terminate this process and we're going to try something else so we're going to put a new message so here's Hacker News by Y combinator and let's see if we can just get the top 10 headlines from here so get the top 10 news headlines from Hacker News so let's see if it knows what the heck that means so we're going to hit run this code initially fetches the IDS of the top stories and retrieves the detail of the story the top 10 news headlines will be printed along with their URLs all right in the beginning explains how it's thinking about doing it so to get the top 10 news headlines from Hacker News we can use Hacker News API which returns data in Json format all right and we'll use the Json library to parse this data all right so let's do it so I'm going to throw this code into this testing a little environment and see if I can just run it from there boom okay so all I did was I created a little new tab a little new um python document right here and I just copied and pasted the code into there as is I didn't have to change anything now if you don't have these things install you just pip install them like we talked about earlier and yeah look at this so uh first blood test were dozens of hereditary cancers approved by the FDA is that what we yeah that's it let's see what else a call for developers a call for Developers research find Parkinson's disease Parkinson yeah yeah so it it seems to be doing really well it pulled all the titles and it gives us the uh the URL for each weird Weird Al Yankovic I apologize I'm having an ADHD moment let's get back to what we were doing which is yeah so that's how you get the top 10 Hacker News Headlines you can do it for many other things you know be careful because scraping websites sometimes causes issues and might be against terms of service Etc so very often this will try to use the API to create that code so I just wanted to jump in here really fast and kind of show you what the advanced version of this looks like as you can see this is running right now so what I did here is I've added one more agent and his name is coder so he's sort of the default assistant agent that is capable of solving problems with code so we've added him and we've added a Critic and so the critic is a helpful assistant skilled in evaluating the quality of a given visualization code so he's there to look at bugs if there are any bugs or logic errors Etc data transformation goal compliance meaning that is the code sort of compliant with the objective that was given and these other things which don't really apply to what we're going to do here but if you're looking to do certain visual things with code this would be a perfect credit by the way this is just something that I got from the autogen GitHub page so you you can sort of manually customize these agents as much as you want to I just wanted to show you what's available there right now and then we're going to have our user proxy so that's us we've created a group chat with user proxy coder and critic so the three of us working together and we've set a maximum of 20 rounds of discussion until we're done and I'm giving them the same sort of uh prompt that I did earlier so create a snake game but I'm also saying include scoring enemies and obstacles so let's take a look at how they will navigate that so it starts you know the coder starts basically in the same way that he did before and starts giving the code to run the snake game but this is where it gets different the critic jumps in and he's providing his feedback to the to the coder and you know to to everybody else in this group discussion as well so he's saying your score on bugs is 10 out of 10 you did great so there's doesn't seem to be any bugs or anything like that and the data transformation is appropriately handled the snake and the food are stored and they're updated as needed go compliance seven not so much while you met the goal of creating a snake game and scoring system it doesn't yet include enemies and obstacles Etc all right so the other things don't apply but Aesthetics well an eight so since the Aesthetics of the game is quite straightforward these are sort of the classic Aesthetics of snake so as we get more and more complex with our projects it'll be interesting how they score the various things that that they can do and based on those ratings here are some suggestions consider implementing the missing functionalities and as well as some of the details like having the visual display better improve the gaming experience by giving real-time feedback on the score and so the coder says okay your suggestions for improving the Snake Game are well taken one thing I love about these AI agents is that at no point are they going to get mad flip over the table and storm out of the room cussing everybody on the way out they take criticism well and they do their best to improve based on the criticisms given all right so the game includes a scoring system and then he says for Simplicity and straightforwardness I have decided not to include obstacles and enemies in the game all right so he added this this is the new code that we're seeing and at the end the crit comes in again and you know kind of gives them some of the same scores but again go compliance is still a seven so it still lacks the enemies and obstacles and but he GES some more improvements such as a pause function so at this point it kicks it back to me now I can sort of add my thoughts or just exit or whatever so I just say continue because I want to see where where this is going so the coder goes okay so yeah based on your suggestions I'll add a pause function and a endgame message so he goes ahead and does that by the way really fast I've tried running this without it pausing to ask me for suggestion so in your user proxy which is right here you can actually add something right here that says don't ask me for my input unfortunately what happens with that is uh often we will hit the open AI API token limit so it'll actually kind of it'll stop everything because we're using up too many tokens per minute so and there's ways to get around that depending on how complicated you want to get so I just added this uh you know have it pause to hear from me before it continues so that's the simplest solution but sometimes if you wanted to run install everything automatically you can you just needed to add the code that kind of limits the rate at which it uses up tokens token are basically how many words it's using to you know write all this stuff out all right so the coder comes back you know the goal compliance improved you know half a percentage Point 7.5 now but it's still you know we still don't have the enemies and the obstacles but he gives some more Improvement suggestions continue to refine the UI and give some more other options including having a SC high score feature now they want my opinion I'm going to say add enemies cuz that was part of the sort of original requirements so he you know the coder kind of complains he's like well it's substantial complexity but we're going to add red bricks that act as enemies if the snake hits a brick the game is over so you get the idea I'm going to add a advanced tutorial at some point once I figure out how to use this better but as you can see here this is getting quite Advanced the things that you can do with this with simple pre-built blocks of text like this is pretty impressive and it's only going to get better as more and more people use it and improve it Etc all right let's get back to it so I think now you have everything that you need to start messing around this stuff to to install it and start using it start by doing just very simple very basic things keep an eye on how much the API is costing you so for me for example so I've been playing around with this for two days and this is just for those two days $711 and actually well I Jen used a GPT 4 so this it's it's $7 but I've done a lot of different stuff on it the session that you saw I would guess it would probably cost about $2 worth of these API credits so I mean it's not that bad but depending on how much you use you know you could probably charge up quite a bit something to keep in mind you can always um use chpt 3.5 turbo which is significantly less expensive you know if Chad Dev it uses 3.5 and for all those apps it was costing something like 4 cents to 8 cents per app for the entire thing including documentation everything else so you know if you don't need the advanced stuff from GPT 4 that might work a lot better although for coding you really want to be using GPT 4 in in general and then once you're ready you know here's the GitHub for autogen it has tons of other you know discussions and various other things you can try there's a Discord Channel where you can chat with other devs last time I jumped on there there wasn't too many people on there but that was like the day it came out so I'm sure more and more people are going to start piling in there and keep in mind that I think a lot of the AI research and stuff like that is going this direction of having multiple agents working together and this is a free thing from Microsoft that allows you to start creating stuff like this and messing around with it so while a lot of it is kind of just kind of demos and and testing don't be surprised when a few months from now or a year from now this exact framework will be used to create something amazing something that's going to create millions of dollars worth of value I mean that's pretty much almost guaranteed to happen either it's going to be through autogen which is Microsoft's um sort of open source project or it might be something else but this is the space to watch so I hope that was helpful if you liked it hit thumbs up subscribe if something really didn't make sense leave a comment go ahead and type hash te te and I'll try to prioritize those so use that to kind of get my attention in the comments cuz there's been quite a lot of comments I can't at this point get through all of them but if if there's something in here that is not making sense to you or specifically I'm saying something that you're not able to replicate something's breaking down you know let me know I do want to know about it I'll try my best to fix it or figure out how to explain it better or find a solution for it all right and this is going to be natural 20.com learn a/ gen so this is I'll leave a link in the show notes down below but I'm adding more and more stuff to here I'll add this video to here as well as a couple other ones that hopefully will help and um maybe help troubleshoot some issues if you're having them with that said thank you for watching and I'll see you next time
Info
Channel: Wes Roth
Views: 109,031
Rating: undefined out of 5
Keywords: meetkevin, Stephen Gardner, ClearValue Tax, Graham Stephan
Id: oAsJVZlDOgQ
Channel Id: undefined
Length: 30min 43sec (1843 seconds)
Published: Tue Oct 03 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.