From the course: Building AI Agents for Beginners by Microsoft

Which AI agent framework to use

(bright gentle music) - What are agentic frameworks? Why do we use them? And how to decide which one to choose? We're going to answer these questions in the second lesson of the AI Agents for beginners course. In this course, we take you from concept to code covering the fundamentals of building AI agents. And in this short video, actually follows along with the written lesson, including translations and a code sample, which you can find at the link above and below this video. So let's start by defining what agent frameworks are. And these are tools that enable anyone building AI agents to have a bit more control over task management. Because as mentioned in the first lesson, agents are focused on completing tasks. And we'll talk a bit more about this in our multi-agent chapter, but for some use cases, we need multiple agents working on a set of tasks and agentic frameworks help us to decide what agent will complete that task. Also, contextual understanding. See, agents need to have information about the context and environment state. If an agent, for example, is to book a hotel room, it needs to know that there are hotel rooms available to book. So agentic frameworks allow us to better manage this context. Also, agent collaborations. See, how these agents complete the task together is up to us to define, and agentic frameworks allow us to do that more effectively. They create spaces and use protocols to allow agents to communicate between each other. These frameworks also come with tools or connections to allow us to absorb and evaluate our agents' performance. So which ones should you choose? There are many out there and in this course we are focused on three different agentic frameworks and services so you can get a better understanding how they work. First is the Azure AI Agent service. This currently is only designed to be used for single agents, both through code and the UI, and it integrates really well with existing Azure services and capabilities you might be already using. We also off use two different agentic frameworks, Semantic Kernel and AutoGen. Both these frameworks can utilize agents built with the Azure AI agent service, as well as other services like GitHub models, which we have code samples for throughout this lesson. Semantic Kernel on one hand is an enterprise focused framework and the team behind it are really focused on a developer experience for teams building AI agents in production. It offers support for C#, Java and Python and a variety of different connectors to other model services. We also have AutoGen, which was born out of teams in Microsoft Research, has a strong focus on taking the latest in agentic research and enabling other researchers and developers to test and experiment with those ideas in code. And as always, the best advice is to start small, working with one agent through something like the Azure AI Agent Service. And then when you have an eight year agents working, you can combine them by using one of the frameworks that has multi-agent support like Semantic Kernel or AutoGen, depending if you're building for production or just exploring the latest in agentic research with AutoGen. We have more information on how to decide which tool is right for you in the written lesson. And while listening to someone talk about this is helpful, thanks for watching by the way, getting hands on is the best way to get a better understanding of how these tools work. So let's head over to our code editor and to do so. So now we're here back at our code editor and we have three different samples, one using Semantic Kernel, AutoGen, and the Azure AI agent service. As mentioned, you can find this code at the link above and below the video to run it yourself. We'll start with the Semantic Kernel example. This is something we already kind of ran in the last lesson where we'll be be able to define different plugins. In this case, we have this destinations plugin, which takes a list of different destinations and allows a random destination to be returned whenever a user is asking for a planning of a trip. And again, we're defining that agent using a ChatCompletionAgent, the kernel, so everything that we've been adding, so all the services and tools have some instructions and then any other settings, additional settings that we need. And basically we're going down here. We can see that the user's planning a day trip. We can also see that it's actually making a call to that function. So get random destination and then getting the results, which is New York. And then the agent is going ahead and then taking that information from that function and making a plan for New York. Sounds like a lovely trip. On the AutoGen side, a similar sort of setup. In this case, we're going to create a client, which is a check completion of the model behind it. Or we can also do some different settings, whether it's like a JSON output, which is really important where we're talking about working with different functions, different parts of our system. And then we can define the agent in a way where we have the name of the agent, the model client that we just defined. We don't have any tools here, but this is where AutoGen allows us to define any custom tools. And then lastly, the system message, which is similar to Semantic Kernel's agent instructions. In this case, we're just going to ask for a great study vacation. So giving out the agent a little bit more details here on, you know, the type of vacation that we want to have. And then we see, you know, the interaction. The agent comes back or the assistant comes back with the plan and it's, you know, seven day trip to Maui. Sounds lovely. So, and lastly, we're going to look at the Azure AI Agent Service. So again, this is your first time seeing this service. We have a setup video that will actually show you how to set up these connection strings, 'cause this is how we're using this agent through the project that we've made in the Azure AI Foundry. And with the Azure AI Agent Service, it's a little different setup. In this case, we're going to create an agent kind of at the runtime in terms of interactions with the user. We're going to create a thread. And a thread basically is to set up between the messages that are being collected between the user and the agent. And in this case, we're going to start with a user's interaction asking for a bar chart of, you know, with the different amount of travelers and destinations. And the way that we're kind of also focusing on this in terms of the ability for the agent to use that is that we have different tools built into the Azure AI Agent Service. And in this case, we have the code interpreter tool. So this allows the agent to generate some code, and, in this case, it's going to generate some Python code to actually generate bar chart. So we see this thread, and then we have this run status. So this is actually the interactions, which once the agent is start running the different tools. And then we can see that it's actually created an image. And then we can even display that image right below here with a bar chart with the amount of the destination and the amount of travelers. So go in, look at the code samples, play around with different settings, and like I said, we're going to be running different samples throughout this course so you can really see the differences between the different services and frameworks that we're offering in this course. But we'll see you in the next lesson.

Contents