Please enable Javascript to view the contents

容器化部署 Hermes Agent

 ·  ☕ 2 分钟

1. 启动容器

  • 设置镜像
1
export IMAGE=nousresearch/hermes-agent:v2026.4.16
  • 设置目录权限
1
2
mkdir -p hermes-agent-home
chmod -R 777 hermes-agent-home
  • 设置环境变量
1
2
3
cat <<EOF > hermes-agent-home/.env
GATEWAY_ALLOW_ALL_USERS=true
EOF
  • 启动 hermes-agent
1
2
3
4
5
6
7
nerdctl run -d \
  --name hermes-agent \
  --restart always \
  -v $(pwd)/hermes-agent-home:/opt/data \
  -v $(pwd)/openclaw-home/.openclaw:/root/.openclaw \
  -p 8642:8642 \
  $IMAGE gateway run
  • 启动 hermes-agent dashboard
1
2
3
4
5
6
7
nerdctl run -d \
  --name hermes-dashboard \
  --restart always \
  -p 9119:9119 \
  -v $(pwd)/hermes-agent-home:/opt/data \
  -e GATEWAY_HEALTH_URL=http://${node_IP}:8642 \
  $IMAGE dashboard --host 0.0.0.0 --insecure
  • 删除容器
1
nerdctl rm hermes-agent hermes-dashboard --force

2. 基本使用

  • 进入容器
1
nerdctl exec -it hermes-agent bash
  • 设置模型
1
/opt/hermes/.venv/bin/hermes model

这里我选择的是自定义模型 (○) 26. Custom endpoint (enter URL manually)

  • 聊天
1
/opt/hermes/.venv/bin/hermes chat -q "hi"
  • 导入 OpenClaw
1
/opt/hermes/.venv/bin/hermes claw migrate
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
┌─────────────────────────────────────────────────────────┐
│          ⚕ Hermes — OpenClaw Migration                 │
└─────────────────────────────────────────────────────────┘


◆ Migration Settings
  Source:      /root/.openclaw
  Target:      /opt/data
  Preset:      full
  Overwrite:   no (skip conflicts)
  Secrets:     yes (allowlisted only)
  • 诊断
1
/opt/hermes/.venv/bin/hermes doctor
  • 进入 TUI
1
/opt/hermes/.venv/bin/hermes
  • 添加电报
1
2
echo "TELEGRAM_BOT_TOKEN=xxx
TELEGRAM_ALLOWED_USERS=xxx" >> /opt/data/.env

添加用户白名单限制。

1
/opt/hermes/.venv/bin/hermes gateway restart

3. 远程调用集成

3.1 使用 cli 调用

  • 集成逻辑

在部署机器上部署 server 提供 API ,参考 https://github.com/shaowenchen/demo/tree/master/hermes-agent-call 。server 接受到请求之后,在主机上执行如下命令:

1
nerdctl exec -it hermes-agent /opt/hermes/.venv/bin/hermes chat --yolo -c -q "巡检一下集群"

这里的 -c 参数会让每次调用保持一个会话。

  • 使用 pm2 托管服务
1
pm2 start "python3  hermes-agent-call.py" --name hermes-agent
  • 调用方式
1
curl -X POST http://127.0.0.1:3011/call -H "Content-Type: application/json" -d '{"message":"hi"}'
1
{"ok": true, "sessionid": "", "message": "hi", "command": "nerdctl exec hermes-agent /opt/hermes/.venv/bin/hermes chat --yolo -c -q \"hi\"", "exitCode": 0, "stdout": "Hey chenshaowen! 👋\nWhat can I help you with today?", "stderr": ""}

3.2 使用 OpenAI API 调用

  • 开启 OpenAI API
1
2
3
echo "API_SERVER_ENABLED=true
API_SERVER_HOST=0.0.0.0
API_SERVER_KEY=xxxx" >> /opt/data/.env
  • 重启 Hermes Agent
1
nerdctl restart hermes-agent
  • 调用方式
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
curl --location 'http://127.0.0.1:8642/v1/chat/completions' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer xxx' \
--data '{
    "model": "default",
    "messages": [
        {
            "role": "user",
            "content": "你是谁?"
        }
    ],
    "temperature": 0.1,
    "max_tokens": 40960,
    "stream": false
}'

4. 查看面板

Hermes Agent 的面板,目前不能直接对话,主要用来配置和检查状态。


微信公众号
作者
微信公众号