AutoGen Tutorial 🤖 Create Collaborating AI Agent teams

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
you can now use aogen to create multiple AI agents to work together to complete a task that you defined let's take a look at what aogen is and then I'll show you how to quickly start using it autogen is a new framework by Microsoft and it was announced at the end of September of 20123 its main goal is to simplify the orchestration optimization and automation of llm workflows basically it makes it very simple and flexible to create multiple agents def their roles and set them up to work together all you have to do if you follow their announcement blog post is to define a set of Agents with specialized capabilities and roles and also to define the interaction Behavior between the agents so it all sounds a little bit vague here or an abstract but let's take a look at the code examples that they have for us and then we'll have a better idea of how to use multiple agents together as part of their GitHub repository there is a nice documentation and example section for autogen I will make sure to leave the link in the description for you if you want to go ahead and follow along with the code um there are a bunch of different types of examples here today I'm going to start with the automated task solving with code generation execution and the debugging example so just have uh it copied on my own drive on my collab notebook uh the first thing that we need to do of course is to install pi autogen and they have um the code written for me so that's something that I've already done so we can move on and next thing is to set up your configuration with open AI uh how they manage to do this is by a config list file so what you need to do is to create yourself a config oore cigor list file and in there you're going to specify the model that you want to use and your open AI API key this is uh part of my open AI API key and then then you can upload that file without any extensions to GitHub uh one thing not GitHub sorry collab one thing that I had trouble with was in this example here they are they're only using single code uh quotation marks but it expects the model expects it to be double quotation marks so the code expects it to be the double quotation marks so if you uh use only the single ones it's not going to work so make sure when you're creating your file that it is a valid Json file plus it us uses the double quotation Works once that's done we can set up the configuration things are going to work well there uh if you want you can also set up configuration for other types of models today I'm going to use gp4 that's why uh I'm only specifying the API key for gp4 if it hasn't changed by the way last time I checked you had to add some funds to your open AI account to be able to use gp4 so make sure you have some funds on open AI otherwise you might not be able to use this code so so when we are using aen the first thing that got my attention was that there are multiple different agent types and in the simplest example we have the assistant agent and we have the user proxy agent and we are calling them initializing them through altogen the assistant agent is basically the AI assistant like when you're typing to chat GPT and the assistant that replies to you that is going to be the assistant agent the user proxy agent is the proxy for you so instead of having a user a human you're going to have the user proxy agent and it's going to act like a user so let's go over their parameters to understand understand them a bit better so we have the name for them this is not cons consequential uh it's just for us to um understand who is talking when we're reading the conversation down below um you can so the assistant agent is going to answer the questions or answer in the chat chat based on an llm uh and that's why we need to set up a llm configuration so we are setting it to config list which is basically our open AI API key the seed to make sure that the results are reproducible and a temperature and the configuration is basically very similar to as they're saying here um or at least is compatible with the open AI API configuration so if there is a configuration you were using with the open AI API before you can use it here too and then let's take a look at the user proxy agent again we pass it a name and then there is something called the human input mode so for the human input mode you have three options one of them is never the other one is always and the other one is terminate this parameter specifies if this user proxy agent is going to wait for feedback or input from the actual human which is the user so us if you say never it's never going to wait for feedback or input from the user from the human if you say terminate it's going to wait for a input from the user once the conversation is terminated and I'm going to talk about it in a second when that happens or you can say always in that case before the user proxy agent does anything it's going to wait for an input from the user but we want these agents to work together so obviously we're going to set to never so that they can do their job without us interfering then we set some termination limits for example one of them is Max consecutive auto reply so this agent will reply maximum of 10 times and then it's going to stop or another way to terminate this chat is for the assistant to send the message terminate so this is what we're doing here we're checking what the message from the assistant is if it is terminate it is going to be the termination message for the chat and then we have the code execution config so this one specifies whether this agent is going to run the code or not so what would we so what would happen if you were using chat GPT and ask you ask it to create some sort of code for you it will create the code you will take the code paste it into for example Visual Studio code and then run it and if there is an error you would go back to chat GPT and say hey the code didn't work but instead by setting the code execution config not false you're saying that this user proxy agent can run The Code by itself so it's not going to ask for you to say to run it it's going to run it by itself and if there are any errors it's is going to return um those errors to the assistant agent so that the assistant agent can work on the code a bit more and it's very straightforward and it's kind of Common Sense the next thing that we need to do is for the user proxy agent to initiate the chat just like a human wood by going to um a interface where they can have a chat with a AI agent uh and it will send the assistant agent a message and the message will be the task the task is what date is today compare the year-to-date gain for meta and Tesla so if we run this so that we can watch it happening from the beginning the user proxy agent to the assistant says what date is today compare the year-to DAT gain for meta and Tesla the assistant says first let's get the current date using Python and then gives us some code next we need to fet the stock prices and then um it tells you what it needs to do for that which Library it needs to use which is why Finance please install the library if you haven't done so already you can install it using the following command even tells you what um code to run what pip command to run to install the library and then gives you a bit more of a code and then it's time for the proxy user and then it executes the code and then it says hey there's an error the date is not defined and then back to the assistant I apologize for the oversight maybe if I close this you can see it better it seems there was an error because the date module was not imported so it revises the code sends it back to you we execute it again or the user proxy agent executes it again there was another problem I apologize for the confusion says the assistant it seems that the ticker symbol for The Meta platforms changed from FB to meta corrects it sends it again and then the user runs the code and is able to calculate the results and then the assistant says great the code has executed successfully and then it gives you the result the answer to the question that you asked in the first place in a proper way in a readable human readable way and it says as of today the year-to DAT gain for meta platforms is approximately 13737 and for Tesla it is approximately 9.34% and it gives a bit more of an analysis here and one it's once it's done it tells us to terminate in my opinion this is amazing amazing that these models can just work together and solve problems and actually give you the answer that you're looking for uh and the rest of this notebook there are actually a bunch more examples of them creating some uh plot and then saving that plot on a file so if you want to go further with it of course definitely go ahead I think it's very interesting so this is a chart that they create but uh to not make this video very long I actually want to show you another example with three uh um agents so again what we need to do is install Pi autogen of course and then make sure the configuration is set up uh yeah nice that my run time wasn't reset uh so like before I again uploaded the OA oi config list here so basically how it works here is that we have three agents working together we have a coder so like before someone who prepares the code we have the user proxy so someone who acts in behalf of the human and then we have a vis critic so visual visualization critic so what the task is here we ask the coder to write the code to generate a visualization which is the the user proxy asks for it and then the VIS critic the visualization critic gives some feedback so let's see how we set this up um so they set up the in the example they set up the LM config here but you know it could also just like before it can just be in the coder assist assant agents uh definition uh the user proxy is more or less the same we give it a name there is a system message that says that you are a human admin you don't have to pass a system um message you only have to do it if you want to specify something um in detail that you want the user proxy agent to do um and there is a code execution config and then again we say human input mode is never for the coder we again pass it a name and a llm config because it's going to be using a large language model to generate the code and the more interesting one here is the critic so we pass it the name but then we pass it a really long system message and in this one we are basically prompting it to take a look at a bunch of things and then write rate the visualization that was created so we say critic you are a helpful assistant highly skilled in evaluating the quality of a given visualization code by providing a score from 1 to 10 and then we also give it we also pass it some criteria so whether there are any bugs um how was Data transformation the goal compliance how well the code meets the specified visualization goals a visualization type data encoding Aesthetics and so on and so forth it even says You must provide a score for each of the above dimensions and then again we pass it the llm config because again it's going to depend on a large language model to give the answers as opposed to the user proxy agent which only runs a code that was provided to it differently than from last time they have a group chat component and that's the one that we're going to use so we create a group chat we pass all the agents that's that are going to be in this group chat uh we specify determination limit to be 20 so there is going to be a maximum of 20 rounds and then we create a manager using this group chat configuration and then again user proxy initiates the chat by sending a message to the group chat and the messages download the data from this link and then plot a visualization that tells us about the relationship between weight and horsepower I'll just make it a bit bigger so it's a bit more readable and then let's take a look at the conversation that took place so the user proxy again prompts the chat as we mentioned and then the coder says all right here are the steps we're going to follow and then it gives you step by step what it's going to do and then it creates the code and all the PIP installs that we need to do and then it says you can save the above transcript in a python file named download and plot.py and run it and then the plot will be saved on this PNG the critic says there are no bugs information transformation is good compliance is good encoding it can be better and the Aesthetics can be better and then to improve the code it gives the assistant some pointers and then the coder says thanks for the feedback I'll add grade lines to the plot along with the color gradient based on a density of points for better representation and then updates the code the critic comes back again and looks like the Aesthetics points are better now and then it says still there can be some improvements with encoding and then our user proxy executes the code and the coder says oh there are some problems S updates the code runs again and as you can see it's a very involved conversation between three agents of working together to create the best code possible uh to plot a data set which is extremely impressive uh in my opinion if you want to take a look at more of the examples I will like I said make sure to um have the link in the description for all the examples and there's some really good documentation that will help you understand how to use the group chat option how to use different types of uh agents here and overall make use of this library to maybe even automate some of your work which I think would be very cool um I hope this was helpful if you have any questions don't forget to leave a comment below and if you want more advanced tutorials on ulten also let us know maybe we can take some time to create something custom and then uh work on that and I'll share that with you thanks for watching and I will see you in the next [Music] video
Info
Channel: AssemblyAI
Views: 15,791
Rating: undefined out of 5
Keywords:
Id: 0GyJ3FLHR1o
Channel Id: undefined
Length: 15min 13sec (913 seconds)
Published: Mon Oct 30 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.