AI Agents with Autogen — A basic agent

Neural Notes
2 min readDec 29, 2024

--

Introduction to Autogen

Autogen is an innovative approach to automation that brings systems and processes to life through dynamic, self-generating workflows. It enables machines to collaborate, communicate, and adapt in real-time, creating smarter, more efficient solutions without constant human intervention.

By using AI-powered agents, Autogen can handle complex tasks, share information, and refine results on the go, reducing manual effort and enhancing productivity. Whether it’s coding, problem-solving, or data analysis, Autogen simplifies workflows, making it a game-changer for businesses and developers alike.

It’s automation, but smarter, faster, and more intuitive.

To install Autogen in your Python environment, just do

pip install pyautogen

A Basic Agent Sample

import autogen
import os
from dotenv import load_dotenv
from autogen import ConversableAgent

#load the environment variables.
load_dotenv()

#configure llm. This agent is going to work with ChatGPT 4o model
#A python dict that holds model info. This way in case we need to work with
#multiple models we can add here and use it
llm_config = {
"model":"gpt-4o", "api_key":os.getenv("OPENAI_API_KEY")
}

#the agent creation process. See below for an explanation for ConversableAgent
#class
agent = ConversableAgent(
name="FirstAgent", #agent name
llm_config=llm_config, # this is where our LLM details go to the agent
human_input_mode="NEVER", #no user input while the agent is working.
)

#send input to the agent and get the response back.
reply = agent.generate_reply(messages=[{"content": "How to take amazing mobile photographs?", "role":"user"}])

#display the response
print(reply)

What is a Conversable Agent?

ConversableAgent Class

The ConversableAgent class is designed to make AI agents more interactive and collaborative. Think of it as a framework for creating AI entities that can communicate, share information, and work together seamlessly.

This class equips agents with the ability to understand messages, respond intelligently, and even collaborate with other agents or humans to solve problems. It’s the backbone of creating conversational, task-oriented AI systems that feel intuitive and helpful.

In short, the ConversableAgent class transforms agents from static tools into dynamic teammates.

In this post, we learned what is Autogen, how to write a simple agent that does one way response and the key steps to write such an agent.

From the next post, we shall see building more complex agents.

--

--

Neural Notes
Neural Notes

Written by Neural Notes

I write on Philosophy, Technology (AI), and topics that help us to live a good life.

No responses yet