Repo·github.com
multi-agentopenai-assistantsagencyautomation
Agency Swarm Framework
Agency Swarm is a framework for building AI agent teams using the OpenAI Assistants API. It allows for creating autonomous agencies with customizable communication flows and shared state management, streamlining multi-agent collaboration.
intermediate10 min4 steps
The play
- Install Agency SwarmInstall the `agency-swarm` package using pip.
- Set OpenAI API KeySet your OpenAI API key as an environment variable.
- Create a SwarmDefine your agents, their roles, and communication flow in a `Swarm` class.
- Run the SwarmInitiate the swarm with a task for the agents to collaborate on.
Starter code
from agency_swarm import Swarm
from agency_swarm import Agent
# Define agents
ceo = Agent(
name="CEO",
description="Sets the vision and strategy.",
instructions="Focus on high-level goals.",
model="gpt-4-1106-preview"
)
engineer = Agent(
name="Engineer",
description="Implements the CEO's vision.",
instructions="Write clean, efficient code.",
model="gpt-4-1106-preview"
)
# Create a swarm
swarm = Swarm(
agents=[ceo, engineer]
)
swarm.run("Develop a simple Python script to calculate the Fibonacci sequence.")Source