02 Autogen
AutoGen Basic Sample
In this code sample, you will use the AutoGen AI Framework to create a basic agent.
The goal of this sample is to show you the steps that we will later use in the additional code samples when implementing the different agentic patterns.
Import the Needed Python Packages
Create the Client
In this sample, we will use GitHub Models for access to the LLM.
The model is defined as gpt-4o-mini. Try changing the model to another model available on the GitHub Models marketplace to see the different results.
As a quick test, we will just run a simple prompt - What is the capital of France.
Defining the Agent
Now that we have set up the client and confirmed that it is working, let us create an AssistantAgent. Each agent can be assigned a:
name - A short hand name that will be useful in referencing it in multi-agent flows.
model_client - The client that you created in the earlier step.
tools - Available tools that the Agent can use to complete a task.
system_message - The metaprompt that defines the task, behavior and tone of the LLM.
You can change the system message to see how the LLM responds. We will cover tools in Lesson #4.
Run the Agent
The below function will run the agent. We use the the on_message method to update the Agent's state with the new message.
In this case, we update the state with a new message from the user which is "Plan me a great sunny vacation".
You can change the message content to see how the LLM responds differently.