NanoClaw 轻量级 AI 助手搭建教程

NanoClaw 轻量级 AI 助手搭建教程

> 超轻量级个人 AI 助手,仅 ~4000 行代码,比 OpenClaw 小 99%!

项目简介

NanoClaw (nanobot) 是由 HKUDS 开发的超轻量级 AI 助手:

  • 25,906+ Stars GitHub 热门项目
  • 📏 仅 3,932 行核心代码
  • 🚀 闪电般启动,更低资源占用
  • 🔌 支持多种聊天平台:Telegram、Discord、Feishu、Slack 等

功能特性

| 功能 | 说明 |
|------|------|
| 🤖 AI 对话 | 支持 Claude、GPT、DeepSeek 等模型 |
| 🔍 网络搜索 | 集成 Brave Search |
| 🧠 记忆系统 | 持久化对话上下文 |
| 📅 定时任务 | 自动执行计划任务 |
| 🔌 插件支持 | MCP 插件系统 |
| 💬 多平台 | Telegram/Discord/飞书/Slack/QQ |

快速开始

方式一:pip 安装(推荐)

# 安装
pip install nanobot-ai

初始化


nanobot onboard

配置 API Key


nano ~/.nanobot/config.json

方式二:源码安装

git clone https://github.com/HKUDS/nanobot.git
cd nanobot
pip install -e .

配置指南

1. 添加 API Key

编辑配置文件 ~/.nanobot/config.json

{
  "providers": {
    "openrouter": {
      "apiKey": "sk-or-v1-xxx"
    }
  },
  "agents": {
    "defaults": {
      "model": "anthropic/claude-opus-4-5",
      "provider": "openrouter"
    }
  }
}

2. 获取 API Key

| 提供商 | 地址 |
|--------|------|
| OpenRouter | https://openrouter.ai/keys |
| DeepSeek | https://platform.deepseek.com |
| Anthropic | https://console.anthropic.com |
| 智谱 GLM | https://open.bigmodel.cn |

对话使用

# 启动对话
nanobot agent

接入聊天平台

Telegram(推荐)

    • 创建机器人

- 搜索 @BotFather
- 发送 /newbot
- 复制 Token

      • 配置
   {
     "channels": {
       "telegram": {
         "enabled": true,
         "token": "YOUR_BOT_TOKEN",
         "allowFrom": ["YOUR_USER_ID"]
       }
     }
   }
   
        • 启动
   nanobot gateway
   

飞书

{
  "channels": {
    "feishu": {
      "enabled": true,
      "app_id": "YOUR_APP_ID",
      "app_secret": "YOUR_APP_SECRET"
    }
  }
}

Discord

          • 创建 Application:https://discord.com/developers/applications
          • 添加 Bot,开启 Message Content intent
          • 配置 Token
{
  "channels": {
    "discord": {
      "enabled": true,
      "token": "YOUR_DISCORD_TOKEN"
    }
  }
}

Docker 部署

# docker-compose.yml
version: '3.8'
services:
  nanobot:
    image: ghcr.io/hkuds/nanobot:latest
    volumes:
      - ./config:/root/.nanobot
    environment:
      - NANOBOT_CONFIG=/root/.nanobot/config.json
    restart: unless-stopped
docker-compose up -d

常用命令

| 命令 | 说明 |
|------|------|
| nanobot agent | 启动对话模式 |
| nanobot gateway | 启动网关(多平台) |
| nanobot onboard | 初始化配置 |
| nanobot --help | 查看帮助 |

总结

NanoClaw 是目前最轻量的 AI 助手方案:

✅ 超轻量(~4000行代码)
✅ 部署简单(pip/Docker)
✅ 多平台支持
✅ 开源免费

GitHub: https://github.com/HKUDS/nanobot

发表回复

后才能评论