Полная расшифровка видео «OpenAI’s Swarm: The Future of Multi-Agents AI Systems?». Нажмите на таймкод, чтобы открыть видео с этого момента. Нужно другое видео? Воспользуйтесь генератором расшифровки YouTube.
0:00 have you ever wondered how to build AI systems where multiple agents work together seamlessly maybe you have used framework like Lang chain crew a or autogen but today I won't talk about any of these today I will talk about open Ai and open AI is exploring this as well and released a new open-source project called swarm the foundations and concepts of multi-agent systems and in this video I will give you an overview of what swarm is all about diving inside the open source repository and examp to understand its main concept if you're new here my name is dona and I have been diving into AI for more than 3 years now I have also been working with businesses to help them with automations and AI Solutions like voice agent I'm also running a school community and all the
0:46 links are in the description of this video now let's get started and first let's get some a bit of context behind that Library so this is a library developed by Elan bio which is one of the ml engineer at open AI and he tweeted like that reliable multi-agent systems can actually be very simple you just need to write abstractions check out our new cookbook and handoffs and routines so there is a cookbook that you can um access directly the link will be in the school community and also in the description of the video and this is the link which talk about orchestrating agents routines and handoffs so there have these two concept and the first one is routines and routines is pretty pretty straightforward because it's about giving like kind of like um recipe
1:33 to like follow step by step and that's what you're going to give to the agents this is pretty similar to what you will give in vapy for example to your AI voice agent where you will say uh first you ask uh probing questions then second you propose a fix and then Third only if not satisfied you offer refound so this is like for example for customer support agent uh and this is like the script that the customer support agent has to go to go through basically basically uh and this is the concept of routine and then you have the concept of handoffs which is talked about later in this article uh which is about like transferring a conversation to another agent so if you have multiple agents you will simply take the same conversation and transfer that to another agent kind
2:19 of like what a basic customer support call can do when you're calling uh for customer support so this is like a whole guub project called swarm and in this project as you can see here it says that it's only educational framework that it doesn't really uh it's not really ready for production I mean not yet but like you don't know if what open air is going to do with it maybe they're going to just release it uh later on after they see and test and everything but I would be cautious with using this uh in in production and if you look at the code right here for example you can see that it's it's pretty uh pretty intuitive because you simply have to create one agent then you create a second agent you give them instruction functions but we
3:06 will dive deeper into this uh right now so if you go in the package and if you go into the examples you can see like a couple of of different examples and the one that I want to kind of talk about uh right now first before we dive into more complex setups is the basic package which contains the basics examples and the first first one is this one where this is like really really basic it's like just scraping the surface where you see that um he creates like um a client here with which is like a swarm which is just the library and then you have an agent that is created and this agent is just like you have the name and you have the instruction and then you have the messages which are the list of the
3:52 previous messages of that user and the response where they run that agent and the message and then it simply prints out the latest message this of course is not usable it's just the demo it's just the most basic uh bare minimum demo that you can build basically and then the second one is another one where you have like um this is one is like simple Loop no helpers and in this one there is actually this notion of having a chat with the agent but the agent is still pretty basic again name instructions um but there is this logic here where it's like while true so like inter ating indefinitely until the user quits that to answer their questions with this code right here you can build like a basic
4:38 kind of chat GPT agent like that is like basically nothing more than the chat completion right because there's only one agent but then you have another one which is context variables so in this case this is also like a single agent there's no no more than one agent but you can start including some variables in context inside the agent so here you can add the name of the customer for example their user ID and you can create this agent like this so you still give the name the instruction and then you can give a function and the function is like the same Principle as function calling where you give it something that it can do and in this case what it's going to do is it's going to print the account details of that user so this
5:25 agent has the possibility to print the Account Details that's that's really basic next one in the in the same package is function calling so this one is like a proper function calling examples it's the same as before right like you still have the the function but it's a different function and that function is able to get the weather this is where I start getting interesting because the message of the user would be what's the weather is in New York City and then it would automatically answer the question and show the the weather based on that function get weather which in this case is just returning directly a static value but of course if you want to implement this you would like implement it with an API to get the weather automatically and then the agent will figure out that it has to get the
6:11 the temperature from that function and now you're going to tell me yeah this is like possible to do that already with chat completion function calling and everything and and you would be right but the thing is we want to go into a setup where you have multiple agent and the next one is exactly this one so this one agent handoff is showing like the basic functionality which is handoffs and that functionality allows you to transfer from one agent to another agent so here you have an English agent that has instruction where it only speaks in English and then you have a Spanish agent that only speaks in Spanish and what you can do is you can create that function right here that transfer from one agent to another one so what it's going to do is it doesn't
6:56 really care about what is the first agent is is just going to think about what's the next agent to redirect and in this case it simply return the agent that you want to redirect to so in this case the Spanish agent if you would want to have transfer to English agent you would just use the same thing change the text here change the uh VI like the agent there and it will also do that and what this is doing is nothing more than adding to the English agent a function that allows it to transfer to the Spanish agent and as you you can see it's not really hard to like build this this framework and this workflow and this is like what this project is basically showing around that you don't necessarily need to use l chain or uh L
7:42 graph or even crew AI or autojen you can simply like build your own framework yourself and know fully what everything is doing and have control over everything and what I wanted to to show you is the airline project because this is like a full multi-agent setup that um Elan just wrote and it's really interesting to to get into it and see how everything is structured so this example demonstrate a multi-agent setup for handling different customer service request in an airline context using the swamp framework so it's kind of like imagine that this would be a chatbot on the airline website that would handle um like triage request handle flight modifications cancellation and lost package cases so it kind of like uh
8:28 customer support um chatbot that can help uh with all of these and for that they created three agent the first agent is a triage agent so that one is determining the type of request and transfer to the appropriate agent so it's kind of like if you think about it when like when we have something like vapy for example you have the squad and you have like the receptionist this is like the first one that is going to like identify which agent to redirect to and automatically transfer the conversation and theer user to that other agent and the first one is a flight modification agent so this one handled requests related to flight modification further tring them into so that one is like a first agent that can then transfer into other agents as well
9:14 and this other agents are like specific agents for cancelling flights or changing flights and then you have another one which is for lost baggage agent um as it says to handle those baggage inquiries so now you have like all of these agents so 1 2 3 four five five agents that are doing five different things with five different functions and let's see how this is structured and how it's made in this project to to get some inspiration so we can see that there are three different package and the first one that is pretty interesting would be the data routines and this one has like a prompt folder which is like a starter prompt so this is like the The Prompt that they're going to give to every single agent and then you have a triage system prompt as well for the triage agent and then if
10:02 you go back you have other uh prompts as well right here so here you have the policies prompt so this one is for example the the refund canellation request uh St a prompt and then you have the the policy here with the routine so the routine is like the step by step as I was saying before is the step by-step process to handle flight cancellation to handle flight change policy and then you have the same exact same thing with uh baggages to like handle the loss baggage policy so you have all of these different policies that you can create and then add them into each agent as a routine the next thing as well after that is the configurations so here you have two files one's for agents and one
10:48 for tools if I go into tools it's pretty straightforward these are just all of the tools that the agents can use so in this case you have a change flight one you have a initiate ref found initiate flight credits case resolved uh to say that the case has been resolved and initiate baggage research all of these are just printing out text for now because this is just a simple demo but imagine this connecting to the different apis doing some requests uh in the background and kind of like doing all of that logic to to handle this specific uh function and then inside this configs folder you also have agents and agents are all about um like you have the agents at the bottom so here you have for example our first agent so this is like the triage
11:35 agent and then you give these functions that are in this uh tools file that I've just showed you you can add the different tools to that agents and also adding the functions to transfer to another agent this is like the the handoffs as I was talking about and this is like the functions that you have right here so you can see this transfer to flight modifications this transfer to the flight cancel a agent so all of these are simple functions that return an agent so you have either a function to return an agent or a tool that returns which is also a function that returns and do some work in the background calling apis and and so on and now here you have the first agent which is the the triage agent then you have the flight modification agent so
12:21 here you have the in instruction and you have the functions as well and then you have other agents right here like the flight canc which takes the stter prompt from the other page and also integrate the the routine which is the policy and then the list of all of the different functions so there's nothing crazy here it's just reusing uh function calling from open AI with uh adding some extra layers with that agent class from that library and kind of like some extra functions but the library is is in itself is pretty small compared to other libraries like lra or crew AI or autogen and you don't really need to know anything to start integrating like you it's it's really like I'm pretty amazed of how simple they manage to make
13:08 it and here you have all of the agents and then you have the main class to execute these agents and this is like if you go back to the airline right here and then you go to main as you can see it's pretty simple and here you have like some extra things so you have context variables which as we saw before helps to add some context into that agent so you can inject directly some information about the customer about the the flight and this will help to the agent to have this this context information to to perform actions and then you just have to run this run demol loop with the triage agents like the first agent of the whole workflow the context variables it's this thing right here and then and then debug through
13:53 it's probably to get to have access to like some some logs and so on uh and that's that's mainly it like it's it's pretty prettyy simple uh and the last part that is interesting in this project is the evil and this is about testing the agent so what's interesting here is like if you go into eval cases you can see that here on this Json file you we can test that the function is being called so we put a random conversation here it says I want to change my flight to one day earlier and then we see that the function called is transfer to flight change so it actually you can test that the function is being called based on the conversation and this is extremely useful if you want to test the agent and be sure that any changes that you're doing is not breaking everything so I would highly recommend you to check
14:39 this GitHub repo and if you want me to build a specific um swarm of AI agent doing something specific you can go to my school Community make a post and I will probably uh and I will look at all of the posts and I will decide like which one uh is the most interesting and then I will make a full video on the school Community where I will be building this whole thing from zero to the end so I would highly recommend you to also join the the school Community because this is where uh you can directly talk to me interact with me sending me messages posting things and then I can give you feedback as well so so yeah I would put the link in the description and see you there so that's one in a nutshell we covered routines which give your agents
15:25 structure and also handoffs we let them pass conversation smoothly between agents but remember this is an experimental framework but it's also a great way to understand some multi-agent Concepts and we actually don't know what open a will do with it this framework might in the future be integrated in the openai API for example maybe the playground or why not in its main product if you have any question that are interested in knowing more about AI like voice agents automations or AI tools and wants to connect with other like-minded people feel free to join my school Community Link in the description I also run some live building sessions and Q&A and it's completely free to join thanks for watching and see you in the next video