
使用Scala Play框架構(gòu)建REST API
組件 | 最低版本 | 推薦版本 | 備注 |
---|---|---|---|
OS | Ubuntu 20.04 | Ubuntu 22.04 | Windows 需 WSL2 |
Python | 3.8 | 3.11 | 需 venv |
Docker | 20.10 | 25.0 | 含 compose plugin |
Node.js | 18 | 20 | Web GUI |
內(nèi)存 | 4 GB | 8 GB+ | 本地 LLM 需 16 GB |
API KEY | – | OpenAI 或 Azure | 需付費賬戶 |
# 1. 克隆官方倉庫
git clone https://github.com/Significant-Gravitas/AutoGPT.git
cd AutoGPT
# 2. 一鍵腳本初始化
chmod +x ./run
./run setup
腳本會自動檢測缺失依賴并安裝 Docker / Node / Poetry。
cp .env.template .env
nano .env
至少填寫:
OPENAI_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
LLM_PROVIDER=openai
如果使用 Azure,則改為 USE_AZURE=true
并填寫 azure.yaml
。
./run docker-prod
文件 | 作用 | 關(guān)鍵字段 |
---|---|---|
.env |
基礎密鑰 & 端口 | OPENAI_API_KEY , PORT |
config.json |
Agent 行為 | max_iterations , memory_backend |
plugins_config.yaml |
插件開關(guān) | allowlist , denylist |
prompt_settings.yaml |
系統(tǒng)提示詞 | constraints , resources |
示例片段(plugins_config.yaml
):
allowlist:
- web_interaction
- api_toolkit
denylist:
- image_gen
./run agent create my-agent
./run agent start my-agent --task "收集 2025 年 Q2 財報并生成摘要"
終端實時輸出子任務樹。
http://localhost:8000
docker-compose.prod.yml
關(guān)鍵片段:
services:
autogpt:
image: ghcr.io/significant-gravitas/autogpt:2025.08
env_file: .env
volumes:
- ./data:/app/data
deploy:
replicas: 2
一鍵水平擴展:
docker compose -f docker-compose.prod.yml up --scale autogpt=4
名稱 | 功能 | 安裝命令 |
---|---|---|
web_interaction | 自動瀏覽網(wǎng)頁 | ./run plugin install web_interaction |
api_toolkit | HTTP 請求 | ./run plugin install api_toolkit |
notion | Notion 寫入 | ./run plugin install notion |
plugins/
└── my_plugin/
├── __init__.py
└── my_plugin.py
my_plugin.py
:from autogpt.sdk import BasePlugin, hookimpl
class MyPlugin(BasePlugin):
@hookimpl
def on_agent_start(self, agent):
agent.logger.info("Hello from my plugin!")
echo "ALLOWLISTED_PLUGINS=my_plugin" >> .env
重啟后即可生效。
從 Apple、Google、Microsoft 官網(wǎng)抓取 2025-Q2 財報 PDF,提取關(guān)鍵指標,輸出 report.md
。
插件 | 用途 |
---|---|
web_interaction | 下載 PDF |
pdf_parser | 解析 PDF |
markdown_writer | 生成報告 |
./run agent create finance-agent
./run agent start finance-agent --task "抓取并總結(jié) 2025-Q2 財報"
Start → WebSearch → DownloadPDF → ParsePDF → WriteMarkdown → End
## 2025 Q2 財報摘要
| 公司 | 營收 | YoY |
|---|---|---|
| Apple | $97.3 B | +6 % |
| Google | $82.1 B | +12 % |
| Microsoft | $71.9 B | +15 % |
完整報告可在 data/output/report.md
下載。
訪問 http://localhost:8000/metrics 可查看:
策略 | 效果 |
---|---|
啟用本地緩存 | 減少 30% token |
使用 Groq/本地 Llamafile | 零 API 費用 |
限制 max_iterations |
防止死循環(huán) |
設定每日預算 | 自動熔斷 |
示例 .env
:
DAILY_BUDGET_USD=5
問題 | 解決 |
---|---|
Docker 權(quán)限報錯 | sudo usermod -aG docker $USER 后重登 |
中文亂碼 | 設置 export PYTHONIOENCODING=utf-8 |
插件未加載 | 檢查 plugins_config.yaml 語法縮進 |
任務卡住 | 查看 logs/debug.log 是否觸發(fā) rate limit |
2025 年的 AutoGPT 已經(jīng)把「安裝復雜」「插件難配」「成本難控」三大痛點逐一擊破。跟隨本文 5 分鐘一條龍的實戰(zhàn)步驟,你可以:
現(xiàn)在就打開終端,復制第一條命令,開始你的 AI Agent 自動化之旅吧!