Nanobot + 智谱 GLM-4.7 使用教程

一、安装教程

1.1 下载

使用默认命令安装可能会遇到环境管理错误:

复制代码
git clone https://github.com/HKUDS/nanobot.git
cd nanobot
pip install -e .

⚠️ 注意事项:pip install -e . 报错 externally-managed-environment,建议使用 uv 进行安装,以避免环境冲突。

推荐:使用 UV 安装
  1. 安装 uv

    curl -LsSf https://astral.sh/uv/install.sh | sh
    source $HOME/.local/bin/env
    uv --version

  2. 安装 nanobot

    uv tool install nanobot-ai

  3. 验证安装

    nanobot --help


1.2 Nanobot 初始化配置

运行以下命令开始配置流程:

复制代码
nanobot onboard

1.3 Config.json 配置

编辑配置文件:

复制代码
nano ~/.nanobot/config.json

以下是完整的配置模版(请根据实际情况修改 Key 和模型名):

复制代码
{
  "agents": {
    "defaults": {
      "workspace": "~/.nanobot/workspace",
      "model": "openai/glm-4.7",
      "maxTokens": 10240,
      "temperature": 0.7,
      "maxToolIterations": 20
    }
  },
  "channels": {
    "whatsapp": {
      "enabled": false,
      "bridgeUrl": "ws://localhost:3001",
      "allowFrom": []
    },
    "telegram": {
      "enabled": false,
      "token": "",
      "allowFrom": [],
      "proxy": null
    },
    "discord": {
      "enabled": false,
      "token": "",
      "allowFrom": [],
      "gatewayUrl": "wss://gateway.discord.gg/?v=10&encoding=json",
      "intents": 37377
    },
    "feishu": {
      "enabled": false,
      "appId": "",
      "appSecret": "",
      "encryptKey": "",
      "verificationToken": "",
      "allowFrom": []
    },
    "dingtalk": {
      "enabled": false,
      "clientId": "",
      "clientSecret": "",
      "allowFrom": []
    },
    "email": {
      "enabled": false,
      "consentGranted": false,
      "imapHost": "",
      "imapPort": 993,
      "imapUsername": "",
      "imapPassword": "",
      "imapMailbox": "INBOX",
      "imapUseSsl": true,
      "smtpHost": "",
      "smtpPort": 587,
      "smtpUsername": "",
      "smtpPassword": "",
      "smtpUseTls": true,
      "smtpUseSsl": false,
      "fromAddress": "",
      "autoReplyEnabled": true,
      "pollIntervalSeconds": 30,
      "markSeen": true,
      "maxBodyChars": 12000,
      "subjectPrefix": "Re: ",
      "allowFrom": []
    },
    "slack": {
      "enabled": false,
      "mode": "socket",
      "webhookPath": "/slack/events",
      "botToken": "",
      "appToken": "",
      "userTokenReadOnly": true,
      "groupPolicy": "mention",
      "groupAllowFrom": [],
      "dm": {
        "enabled": true,
        "policy": "open",
        "allowFrom": []
      }
    },
    "qq": {
      "enabled": false,
      "appId": "",
      "secret": "",
      "allowFrom": []
    }
  },
  "providers": {
    "anthropic": {
      "apiKey": "",
      "apiBase": null,
      "extraHeaders": null
    },
    "openai": {
      "apiKey": "密钥XXXXXX",
      "apiBase": "https://open.bigmodel.cn/api/paas/v4",
      "extraHeaders": null
    },
    "openrouter": {
      "apiKey": "",
      "apiBase": null,
      "extraHeaders": null
    },
    "deepseek": {
      "apiKey": "",
      "apiBase": null,
      "extraHeaders": null
    },
    "groq": {
      "apiKey": "",
      "apiBase": null,
      "extraHeaders": null
    },
    "zhipu": {
      "apiKey": "",
      "apiBase": "https://docs.litellm.ai/docs/providers",
      "extraHeaders": null
    },
    "dashscope": {
      "apiKey": "",
      "apiBase": null,
      "extraHeaders": null
    },
    "vllm": {
      "apiKey": "",
      "apiBase": null,
      "extraHeaders": null
    },
    "gemini": {
      "apiKey": "",
      "apiBase": null,
      "extraHeaders": null
    },
    "moonshot": {
      "apiKey": "",
      "apiBase": null,
      "extraHeaders": null
    },
    "aihubmix": {
      "apiKey": "",
      "apiBase": null,
      "extraHeaders": null
    }
  },
  "gateway": {
    "host": "0.0.0.0",
    "port": 18790
  },
  "tools": {
    "web": {
      "search": {
        "apiKey": "",
        "maxResults": 5
      }
    },
    "exec": {
      "timeout": 60
    },
    "restrictToWorkspace": false
  }
}

💡 配置提示:

  1. 确保 providers.openai.apiBase 指向智谱的官方地址。
  2. 原文中 zhipu.apiBase 指向了文档地址,代码中已修正为 API 地址,以避免潜在错误。

二、验证

配置完成后,运行以下命令验证效果:

复制代码
nanobot agent -m "what is 2 + 2"

效果:

相关推荐
板子~19 小时前
OpenClaw + macOS(Mac mini)+ Tailscale Serve 远程访问踩坑全记录:从“能打开但离线”到稳定可用的修复路线
tailscale·openclaw
vibecoding日记1 天前
OpenClaw 插件系统:如何打造全能私人助理 --OpenClaw源码系列第2期
产品·ai助手·openclaw
Johny_Zhao2 天前
OpenClaw安装部署教程
linux·人工智能·ai·云计算·系统运维·openclaw
GPUStack3 天前
Token 不再焦虑:用 GPUStack + OpenClaw 搭一个“无限用”的本地 AI 助手
ai·模型推理·gpustack·openclaw
坐吃山猪7 天前
OpenClaw04_Gateway常见问题
网络·gateway·openclaw
Blockchina7 天前
OpenClaw 深度搭建与运行实录
ai agent·openclaw
行走的小派7 天前
普惠新篇章:香橙派全志系列开发板全面拥抱OpenClaw时代
全志·openclaw
冀博7 天前
2026爆款AI Agent|OpenClaw从入门到中级实操指南(含飞书对接+多Agent配置+避坑指南)
人工智能·飞书·openclaw
小马过河R7 天前
OpenClaw 记忆系统工作原理
人工智能·机器学习·语言模型·agent·openclaw·智能体记忆机制
码农垦荒笔记7 天前
OpenClaw 实战#05-5:第五层工程拆解——Skill 工程设计规范(硬干货版)
人工智能·agent·设计规范·openclaw