← All trails
EP 02 / 235:18Live now

Hello, ConversableAgent

Install AG2, configure a model, ship a working agent in 20 lines.

Time to ship. By the end of this episode you have a working AG2 agent running locally, installed, configured, and answering you in your terminal.

What we cover:

Heads up: AG2 supports OpenAI, Anthropic, Gemini, local models via Ollama, and more. The example uses OpenAI for simplicity, swap the llm_config to use any other.

Next episode: we give this agent a tool so it can actually do something instead of just talk.

Links

Code

# Install: pip install ag2

import os
from autogen import ConversableAgent

assistant = ConversableAgent(
    name="planner",
    llm_config={
        "model": "gpt-4o",
        "api_key": os.environ["OPENAI_API_KEY"],
    },
    system_message="You are a concise planning assistant.",
)

reply = assistant.run("Plan a 3-step research pass on 'agent frameworks'.")
print(reply.summary)