While CrewAI is great for tasks, Microsoft Autogen is the king of conversational agents that can "Talk and Code" their way to a solution. In this lesson, we learn how to architect an Autogen swarm where agents iterate on each other's work autonomously.
import autogen
config_list = [{"model": "gpt-4", "api_key": "..."}]
assistant = autogen.AssistantAgent("assistant", llm_config={"config_list": config_list})
user_proxy = autogen.UserProxyAgent("user_proxy", code_execution_config={"work_dir": "coding"})
user_proxy.initiate_chat(assistant, message="Write a Python script to scrape 10 leads from LinkedIn.")
Autogen agents can execute the code they write. This is powerful but dangerous. A professional architect always runs Autogen in a Docker Container to ensure the agents cannot accidentally delete files on the host machine.
Design an Autogen system that: (1) Writes a Python function (2) Runs a test on it (3) If the test fails, the agent must read the error and fix the code autonomously.