SuperAPI AI 工具集

autogpt-agents

智能体与模型

查看项目

更新于 10-15 08:33

技能介绍

AutoGPT 是一个自主 AI 智能体平台,用于构建、部署和管理持续运行的 AI 智能体,可通过可视化界面或开发工具包两种方式使用。

一、用途与适用场景 当需要构建持续运行的自主智能体、创建基于可视化工作流的 AI 智能体、部署带外部触发器(Webhook、定时任务)的智能体、搭建复杂的多步骤自动化流水线,或需要无代码/低代码的智能体构建器时,可以使用 AutoGPT。若需要更强的智能体逻辑控制,可考虑 LangChain/LlamaIndex;若需要基于角色的多智能体协作,可考虑 CrewAI;若需要简单的托管式智能体部署,可考虑 OpenAI Assistants;若需要微软生态集成,可考虑 Semantic Kernel。

二、主要能力

  1. 可视化智能体构建器:拖拽式、基于节点的工作流编辑器。
  2. 持续执行:智能体通过触发器持久运行。
  3. 市场:可共享和复用预构建的智能体与区块。
  4. 区块系统:面向 LLM、工具、集成的模块化组件。
  5. Forge 工具包:用于创建自定义智能体的开发者工具。
  6. 基准测试系统:标准化的智能体性能测试。

三、快速开始(安装,Docker)

克隆仓库

git clone https://github.com/Significant-Gravitas/AutoGPT.git cd AutoGPT/autogpt_platform

复制环境文件

cp .env.example .env

启动后端服务

docker compose up -d --build

启动前端(在另一个终端)

cd frontend cp .env.example .env npm install npm run dev

访问平台:

  • 前端 UI:http://localhost:3000
  • 后端 API:http://localhost:8006/api
  • WebSocket:ws://localhost:8001/ws

四、架构概览 AutoGPT 有两个主要系统:

  1. AutoGPT Platform(生产):带 React 前端的可视化智能体构建器;带执行引擎的 FastAPI 后端;PostgreSQL + Redis + RabbitMQ 基础设施。
  2. AutoGPT Classic(开发):Forge(智能体开发工具包)、Benchmark(性能测试框架)、CLI(用于开发的命令行界面)。

五、核心概念

  1. 图与节点:智能体表示为包含由链接连接的节点的图。示例结构:Graph(Agent)包含 Node(Input)对应 Block(AgentInputBlock)、Node(Process)对应 Block(LLMBlock)、Node(Decision)对应 Block(SmartDecisionMaker)、Node(Output)对应 Block(AgentOutputBlock)。
  2. 区块:可复用的功能组件。区块类型包括:INPUT(智能体入口点)、OUTPUT(智能体输出)、AI(LLM 调用、文本生成)、WEBHOOK(外部触发器)、STANDARD(通用操作)、AGENT(嵌套智能体执行)。
  3. 执行流程:用户/触发器 → 图执行 → 节点执行 → Block.execute(),其中涉及输入、队列系统、输出产出。

六、构建智能体 使用可视化构建器:打开 Agent Builder(http://localhost:3000);从 BlocksControl 面板添加区块;在节点之间拖拽连接;在每个节点中配置输入;使用 PrimaryActionBar 运行智能体。

可用区块包括:

  • AI 区块:AITextGeneratorBlock(使用 LLM 生成文本)、AIConversationBlock(多轮对话)、SmartDecisionMakerBlock(条件逻辑)。
  • 集成区块:GitHub、Google、Discord、Notion 连接器;Webhook 触发器与处理器;HTTP 请求区块。
  • 控制区块:输入/输出区块;分支与决策节点;循环与迭代区块。

七、智能体执行 触发器类型:

  1. 手动执行: POST /api/v1/graphs/{graph_id}/execute Content-Type: application/json

{ "inputs": { "input_name": "value" } }

  1. Webhook 触发: POST /api/v1/webhooks/{webhook_id} Content-Type: application/json

{ "data": "webhook payload" }

  1. 定时执行: { "schedule": "0 */2 * * *", "graph_id": "graph-uuid", "inputs": {} }

监控执行: WebSocket 更新: const ws = new WebSocket('ws://localhost:8001/ws');

ws.onmessage = (event) => { const update = JSON.parse(event.data); console.log(Node ${update.node_id}: ${update.status}); };

REST API 轮询: GET /api/v1/executions/{execution_id}

八、使用 Forge(开发) 创建自定义智能体:

设置 forge 环境

cd classic ./run setup

从模板创建新智能体

./run forge create my-agent

启动智能体服务器

./run forge start my-agent

智能体结构: my-agent/ ├── agent.py # 主智能体逻辑 ├── abilities/ # 自定义能力 │ ├── init.py │ └── custom.py ├── prompts/ # 提示词模板 └── config.yaml # 智能体配置

实现自定义能力: from forge import Ability, ability

@ability( name="custom_search", description="Search for information", parameters={ "query": {"type": "string", "description": "Search query"} } ) def custom_search(query: str) -> str: """Custom search ability.""" # Implement search logic result = perform_search(query) return result

九、基准测试 运行基准测试:

运行所有基准测试

./run benchmark

运行特定类别

./run benchmark --category coding

使用特定智能体运行

./run benchmark --agent my-agent

基准测试类别:Coding(代码生成与调试)、Retrieval(信息查找)、Web(网页浏览与交互)、Writing(文本生成任务)。

VCR 录制:基准测试使用录制的 HTTP 响应以保证可复现性:

录制新 cassette

./run benchmark --record

使用现有 cassette 运行

./run benchmark --playback

十、集成 添加凭据:进入 Profile > Integrations;选择提供商(OpenAI、GitHub、Google 等);输入 API 密钥或授权 OAuth;凭据会被加密并安全存储。

在区块中使用凭据:区块会自动访问用户凭据: class MyLLMBlock(Block): def execute(self, inputs): # Credentials are injected by the system credentials = self.get_credentials("openai") client = OpenAI(api_key=credentials.api_key) # ...

支持的提供商:OpenAI(API Key,用于 LLM、嵌入)、Anthropic(API Key,用于 Claude 模型)、GitHub(OAuth,用于代码、仓库)、Google(OAuth,用于 Drive、Gmail、Calendar)、Discord(Bot Token,用于消息)、Notion(OAuth,用于文档)。

十一、部署 Docker 生产配置示例:

docker-compose.prod.yml

services: rest_server: image: autogpt/platform-backend environment: - DATABASE_URL=postgresql://... - REDIS_URL=redis://redis:6379 ports: - "8006:8006"

executor: image: autogpt/platform-backend command: poetry run executor

frontend: image: autogpt/platform-frontend ports: - "3000:3000"

环境变量:DATABASE_URL(PostgreSQL 连接)、REDIS_URL(Redis 连接)、RABBITMQ_URL(RabbitMQ 连接)、ENCRYPTION_KEY(凭据加密)、SUPABASE_URL(身份验证)。

生成加密密钥: cd autogpt_platform/backend poetry run cli gen-encrypt-key

十二、最佳实践 从简单开始:先用 3-5 个节点的智能体;增量测试:每次修改后运行并测试;使用 Webhook:为事件驱动型智能体提供外部触发器;监控成本:通过 credits 系统跟踪 LLM API 使用;版本化智能体:在修改前保存可用版本;基准测试:使用 agbenchmark 验证智能体质量。

十三、常见问题 服务未启动:

检查容器状态

docker compose ps

查看日志

docker compose logs rest_server

重启服务

docker compose restart

数据库连接问题:

运行迁移

cd backend poetry run prisma migrate deploy

智能体执行卡住:

检查 RabbitMQ 队列

访问 http://localhost:15672 (guest/guest)

清除卡住的执行

docker compose restart executor

十四、资源 文档:https://docs.agpt.co 仓库:https://github.com/Significant-Gravitas/AutoGPT Discord:https://discord.gg/autogpt 许可证:MIT(Classic)/ Polyform Shield(Platform)