跳到内容

AutoGPT Agent 用户指南

注意

本指南假设你位于 AutoGPT Agent 所在的 autogpt 文件夹中。

命令行界面

运行 ./autogpt.sh(或其任何子命令)并带上 --help 会列出所有可用的子命令和参数

$ ./autogpt.sh --help
Usage: python -m autogpt [OPTIONS] COMMAND [ARGS]...

Options:
  --help  Show this message and exit.

Commands:
  run    Sets up and runs an agent, based on the task specified by the...
  serve  Starts an Agent Protocol compliant AutoGPT server, which creates...

对于 Windows 用户

在 Windows 上,请使用 .\autogpt.bat 而不是 ./autogpt.sh。其他所有内容(子命令、参数)应保持一致。

与 Docker 一起使用

对于 Docker 用户,请将示例中的脚本替换为 docker compose run --rm auto-gpt

docker compose run --rm auto-gpt --ai-settings <filename>
docker compose run --rm auto-gpt serve

run – CLI 模式

run 子命令使用传统的 CLI 界面启动 AutoGPT。

./autogpt.sh run --help
$ ./autogpt.sh run --help
Usage: python -m autogpt run [OPTIONS]

  Sets up and runs an agent, based on the task specified by the user, or
  resumes an existing agent.

Options:
  -c, --continuous                Enable Continuous Mode
  -y, --skip-reprompt             Skips the re-prompting messages at the
                                  beginning of the script
  -l, --continuous-limit INTEGER  Defines the number of times to run in
                                  continuous mode
  --speak                         Enable Speak Mode
  --debug                         Enable Debug Mode
  --gpt3only                      Enable GPT3.5 Only Mode
  --gpt4only                      Enable GPT4 Only Mode
  --skip-news                     Specifies whether to suppress the output of
                                  latest news on startup.
  --install-plugin-deps           Installs external dependencies for 3rd party
                                  plugins.
  --ai-name TEXT                  AI name override
  --ai-role TEXT                  AI role override
  --constraint TEXT               Add or override AI constraints to include in
                                  the prompt; may be used multiple times to
                                  pass multiple constraints
  --resource TEXT                 Add or override AI resources to include in
                                  the prompt; may be used multiple times to
                                  pass multiple resources
  --best-practice TEXT            Add or override AI best practices to include
                                  in the prompt; may be used multiple times to
                                  pass multiple best practices
  --override-directives           If specified, --constraint, --resource and
                                  --best-practice will override the AI's
                                  directives instead of being appended to them
  --component-config-file TEXT    Path to the json configuration file.
  --help                          Show this message and exit.

此模式允许运行单个 Agent,并在终止时保存 Agent 的状态。这意味着你可以在稍后恢复 Agent。另请参阅 Agent 状态

注意

由于历史原因,当未指定子命令时,CLI 将默认使用 run 子命令:运行 ./autogpt.sh run [OPTIONS] 与运行 ./autogpt.sh [OPTIONS] 效果相同,但这在将来可能会改变。

💀 连续模式 ⚠️

在**没有**用户授权的情况下运行 AI,100% 自动化。**不建议**使用连续模式。它具有潜在危险,可能导致你的 AI 永久运行或执行你通常不会授权的操作。请自行承担风险使用。

./autogpt.sh --continuous

要退出程序,请按 Ctrl+C

serve – Agent Protocol 模式(带 UI)

使用 serve 时,应用程序将公开一个符合 Agent Protocol 的 API 并提供前端服务,默认地址为 http://localhost:8000。你可以使用 AP_SERVER_PORT 环境变量配置服务端口。

./autogpt.sh serve --help
$ ./autogpt.sh serve --help
Usage: python -m autogpt serve [OPTIONS]

  Starts an Agent Protocol compliant AutoGPT server, which creates a custom
  agent for every task.

Options:
  --debug                     Enable Debug Mode
  --gpt3only                  Enable GPT3.5 Only Mode
  --gpt4only                  Enable GPT4 Only Mode
  --install-plugin-deps       Installs external dependencies for 3rd party
                              plugins.
  --help                      Show this message and exit.

有关应用程序 API 的更多信息,请参阅 agentprotocol.ai

参数

注意

大多数参数等同于配置选项。有关所有可用配置选项,请参阅 .env.template

注意

将尖括号(<>)中的内容替换为你想要指定的值

以下是运行 AutoGPT 时可以使用的一些常用参数

  • 使用不同的 AI 设置文件运行 AutoGPT

    ./autogpt.sh --ai-settings <filename>
    
  • 使用不同的 Prompt 设置文件运行 AutoGPT

    ./autogpt.sh --prompt-settings <filename>
    

注意

其中一些标志有简写形式,例如 --prompt-settings 的简写为 -P
使用 ./autogpt.sh --help 获取更多信息。

Agent 状态

单个 Agent 的状态存储在 data/agents 文件夹中。你可以通过多种方式使用它:

  • 在稍后恢复你的 Agent。
  • 为你的 Agent 创建“检查点”,以便你随时可以回到其历史中的特定点。
  • 分享你的 Agent!

工作空间

Agent 可以读写文件。这发生在 workspace 文件夹中,该文件夹位于 data/agents/<agent_id>/。除非将 RESTRICT_TO_WORKSPACE 设置为 False,否则 Agent 无法访问此文件夹之外的文件。

警告

我们不建议禁用 RESTRICT_TO_WORKSPACE,除非 AutoGPT 在沙箱环境中运行且不会造成任何损害(例如 Docker 或虚拟机)。

日志

活动日志、错误日志和调试日志位于 logs 文件夹中。

提示

你的 Agent 是否出现奇怪的行为?你是否有有趣的用例?你是否想报告错误?请按照以下步骤启用你的日志。你可以在提交问题报告或与我们讨论问题时附上这些日志。

打印调试日志

./autogpt.sh --debug

禁用命令

禁用命令的最佳方法是禁用或移除提供这些命令的组件。但是,如果你想有选择地禁用某些命令,可以在 .env 中使用 DISABLED_COMMANDS 配置。将你想禁用的命令名称放入其中,用逗号分隔。你可以在这里找到内置组件中的命令列表。

例如,要禁用 Python 编程功能,请将其设置为以下值:

DISABLED_COMMANDS=execute_python_code,execute_python_file