Building Autonomous Agents with Python & AutoGen
Building Autonomous Agents with Python & AutoGen
Single LLMs are smart. Teams of LLMs are geniuses. Microsoft's AutoGen allows you to spawn multiple agents that talk to each other.
The Concept
Imagine a virtual software company:
- Product Manager Agent: Defines the requirements.
- Coder Agent: Writes the code.
- Reviewer Agent: Checks the code for bugs.
Installation
```bash pip install pyautogen ```
The Code
```python from autogen import AssistantAgent, UserProxyAgent, config_list_from_json
Configuration
config_list = config_list_from_json(env_or_file="OAI_CONFIG_LIST")
Create Assistant (The Coder)
assistant = AssistantAgent( name="coder", llm_config={"config_list": config_list} )
Create User Proxy (The Executor)
user_proxy = UserProxyAgent( name="user_proxy", code_execution_config={"work_dir": "coding", "use_docker": False} )
Start the chat
user_proxy.initiate_chat( assistant, message="Plot a chart of NVDA stock price year-to-date. Save it as nvda.png." ) ```
What Happens?
- Coder writes a Python script to fetch data and plot.
- User Proxy executes the script on your machine.
- If it fails, User Proxy sends the error back.
- Coder fixes the bug and sends new code.
- Loop continues until success.
Conclusion
AutoGen represents the future of software development: Humans supervising a digital workforce.
Share this article
About Karthik Reddy
Senior Python Developer. Open Source Contributor to AutoGen.