What is AutoGen?
AutoGen is Microsoft's framework for building multi-agent conversations. Agents can converse autonomously, write code, execute it, and collaborate to solve complex problems. More flexible than CrewAI for open-ended conversations.
Step 1: Install AutoGen
# Install AutoGen
pip install pyautogen[blendsearch]
# For code execution
pip install docker
Step 2: Configure Agents
from autogen import ConversableAgent, UserProxyAgent
config_list = [
{"model": "gpt-4o", "api_key": "your-key"}
]
# Assistant agent
assistant = ConversableAgent(
name="Assistant",
system_message="You are a helpful AI assistant.",
llm_config={"config_list": config_list}
)
# User proxy (executes code)
user_proxy = UserProxyAgent(
name="UserProxy",
human_input_mode="NEVER",
max_consecutive_auto_reply=10,
code_execution_config={"work_dir": "coding"}
)
# Start conversation
user_proxy.initiate_chat(
assistant,
message="Write a Python script that calculates Fibonacci numbers"
)
🎉 AutoGen is Ready!
You can now build conversational AI agents. Explore more frameworks and tools.