EN

Swarms 多智能体编排框架

用于构建、部署和扩展多智能体系统的 Python 智能体框架

核验日期

核心信息

以下信息由程序从官方接口读取,不经模型改写。

许可证
Apache-2.0
语言
Python
维护方
kyegomez
核验日期

它是什么

项目方称,Swarms 是企业级、可用于生产的多智能体编排框架。项目方称,Swarms Python 是可用于构建、部署和扩展多智能体系统的智能体框架。项目方称,Swarms 提供面向顺序、并发和层级架构的套件,并集成了 MCP、x402 和技能。项目方称,Swarms 是开源、社区驱动的框架。

主要能力

  1. 顺序工作流按严格的顺序执行任务,形成每个智能体在前一个智能体工作之上继续的流水线。

  2. 并发工作流同时运行多个智能体,允许任务并行执行。

  3. AgentRearrange 允许用简单的字符串语法定义智能体之间复杂的非线性关系。

  4. GraphWorkflow 把智能体作为有向无环图中的节点来编排。

  5. MixtureOfAgents 架构把任务并行交给多个专家智能体处理。

怎么上手

  1. 智能体是 swarm 的构建单元,是由 LLM、工具和记忆驱动的自主实体。

  2. 一个 swarm 由多个协同工作的智能体组成。

  3. 在自动循环模式下,智能体会持续推理和行动,直到达到停止条件,而不是在固定的迭代次数后停止。

摘自 README · bash
# pip
$ pip3 install -U swarms

# uv (recommended): https://github.com/astral-sh/uv
$ uv pip install swarms

# poetry
$ poetry add swarms
摘自 README · bash
# Clone the repository
$ git clone https://github.com/kyegomez/swarms.git
$ cd swarms
$ pip install -r requirements.txt
摘自 README · bash
# Pull the image
$ docker pull swarmscorp/swarms:latest

# Run a script from the current directory, passing your API key from the shell
$ docker run --rm -e OPENAI_API_KEY -v "$PWD:/app" swarmscorp/swarms python agent.py

# Open a Python shell with swarms installed
$ docker run -it --rm -e OPENAI_API_KEY swarmscorp/swarms
摘自 README
OPENAI_API_KEY=""
WORKSPACE_DIR="agent_workspace"
ANTHROPIC_API_KEY=""
GROQ_API_KEY=""
SWARMS_TELEMETRY_ON
摘自 README · python
from swarms import Agent

# Initialize a new agent
agent = Agent(
    model_name="gpt-5.4", # Specify the LLM
    max_loops="auto",              # Set the number of interactions
    interactive=True,         # Enable interactive mode for real-time feedback
    temperature=None,
)

# Run the agent with a task
agent.run("What are the key benefits of using a multi-agent system?")
摘自 README · python
from swarms import Agent, SequentialWorkflow

# Agent 1: The Researcher
researcher = Agent(
    agent_name="Researcher",
    system_prompt="Your job is to research the provided topic and provide a detailed summary.",
    model_name="gpt-5.4",
)

# Agent 2: The Writer
writer = Agent(
    agent_name="Writer",
    system_prompt="Your job is to take the research summary and write a beautiful, engaging blog post about it.",
    model_name="gpt-5.4",
)

# Create a sequential workflow where the researcher's output feeds into the writer's input
workflow = SequentialWorkflow(agents=[researcher, writer])

# Run the workflow on a task
final_post = workflow.run("The history and future of artificial intelligence")
print(final_post)

适合谁

GraphWorkflow 中每个节点是一个智能体,每条边声明一个依赖,因此节点只有在所有上游节点完成后才会运行。AutoSwarmBuilder 根据任务描述自动生成专门的智能体及其工作流。GroupChat 是一个异步、自选发言的群聊。

GroupChat 没有轮流顺序:多个智能体可以同时对同一条消息作出反应,沉默的智能体保持沉默。在 HierarchicalSwarm 中,导演智能体制定计划并把任务分配给专门的工作智能体;导演会评估结果,并可以在反馈循环中发出新的指令。HeavySwarm 实现了受 X.AI 的 Grok heavy 实现启发的 5 阶段工作流。

HeavySwarm 的可选实时仪表盘会在运行时展示分析过程。社交算法提供了用于定义智能体之间自定义通信模式的灵活框架。Swarms 提供至少 60 种多智能体结构。

X402 是面向 API 端点的加密货币支付协议。X402 支持以按次付费的模式让智能体变现。Agent Skills 是 Anthropic 推出的轻量级、基于 markdown 的格式,用于定义模块化、可复用的智能体能力。

两个托管的 MCP 服务器为助手提供实时的 Swarms 上下文,而不是可能早于某次重命名的训练数据。Swarms 采用 Apache License 2.0 许可。

来源

本页内容整理自以下官方来源,点击可核对原文。

核验日期 ·

本页由 AI 依据上述官方来源整理,并经自动核对,未经本站实测。 发现错误?告诉我们。