乐于分享
好东西不私藏

资源告急?用nanobot替代openclaw:一个仅需4000行代码的轻量级AI助手部署实践

资源告急?用nanobot替代openclaw:一个仅需4000行代码的轻量级AI助手部署实践

什么是nanobot?

nanobot是一个超轻量级的个人AI助手框架,灵感来源于OpenClaw。比 OpenClaw 代码量减少 99%,却实现了核心的智能体功能。
nanobot 的主要特点:
超轻量级:作为 OpenClaw 的极简实现,体积缩小 99%,速度显著提升。
适合研究:代码简洁清晰,易于理解、修改和扩展,方便进行科研实验。
极速体验:极小的资源占用意味着更快的启动速度、更低的硬件需求以及更迅速的迭代能力。
简单易用:支持一键部署,开箱即用
部署实践
安装
本文以源码安装为实例,更多安装过程参考项目即可。
git clone https://github.com/HKUDS/nanobot.gitcd nanobotpip install -e .
初始化配置
[root@3up7Z nanobot]# nanobot onboard✓ Created config at /root/.nanobot/config.jsonConfig template now uses `maxTokens` + `contextWindowTokens``memoryWindow` is no longer a runtime setting.  Created SOUL.md  Created USER.md  Created HEARTBEAT.md  Created TOOLS.md  Created AGENTS.md  Created memory/MEMORY.md  Created memory/HISTORY.md🐈 nanobot is ready!Next steps:  1. Add your API key to ~/.nanobot/config.json     Get one at: https://openrouter.ai/keys  2. Chat: nanobot agent -m "Hello!"Want Telegram/WhatsApp? See: https://github.com/HKUDS/nanobot#-chat-apps[root@3up7Z nanobot]#
初始化完成后,会生成一份默认的config.json文件如下,后续按需修改。
{  "agents": {    "defaults": {      "workspace": "~/.nanobot/workspace",      "model": "anthropic/claude-opus-4-5",      "provider": "auto",      "maxTokens": 8192,      "contextWindowTokens": 65536,      "temperature": 0.1,      "maxToolIterations": 40,      "reasoningEffort": null    }  },  "channels": {    "sendProgress": true,    "sendToolHints": false,    "whatsapp": {      "enabled": false,      "bridgeUrl": "ws://localhost:3001",      "bridgeToken": "",      "allowFrom": []    },    "telegram": {      "enabled": false,      "token": "",      "allowFrom": [],      "proxy": null,      "replyToMessage": false,      "groupPolicy": "mention"    },    "discord": {      "enabled": false,      "token": "",      "allowFrom": [],      "gatewayUrl": "wss://gateway.discord.gg/?v=10&encoding=json",      "intents": 37377,      "groupPolicy": "mention"    },    "feishu": {      "enabled": false,      "appId": "",      "appSecret": "",      "encryptKey": "",      "verificationToken": "",      "allowFrom": [],      "reactEmoji": "THUMBSUP",      "groupPolicy": "mention"    },    "mochat": {      "enabled": false,      "baseUrl": "https://mochat.io",      "socketUrl": "",      "socketPath": "/socket.io",      "socketDisableMsgpack": false,      "socketReconnectDelayMs": 1000,      "socketMaxReconnectDelayMs": 10000,      "socketConnectTimeoutMs": 10000,      "refreshIntervalMs": 30000,      "watchTimeoutMs": 25000,      "watchLimit": 100,      "retryDelayMs": 500,      "maxRetryAttempts": 0,      "clawToken": "",      "agentUserId": "",      "sessions": [],      "panels": [],      "allowFrom": [],      "mention": {        "requireInGroups": false      },      "groups": {},      "replyDelayMode": "non-mention",      "replyDelayMs": 120000    },    "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,      "replyInThread": true,      "reactEmoji": "eyes",      "allowFrom": [],      "groupPolicy": "mention",      "groupAllowFrom": [],      "dm": {        "enabled": true,        "policy": "open",        "allowFrom": []      }    },    "qq": {      "enabled": false,      "appId": "",      "secret": "",      "allowFrom": []    },    "matrix": {      "enabled": false,      "homeserver": "https://matrix.org",      "accessToken": "",      "userId": "",      "deviceId": "",      "e2EeEnabled": true,      "syncStopGraceSeconds": 2,      "maxMediaBytes": 20971520,      "allowFrom": [],      "groupPolicy": "open",      "groupAllowFrom": [],      "allowRoomMentions": false    },    "wecom": {      "enabled": false,      "botId": "",      "secret": "",      "allowFrom": [],      "welcomeMessage": ""    }  },  "providers": {    "custom": {      "apiKey": "",      "apiBase": null,      "extraHeaders": null    },    "azureOpenai": {      "apiKey": "",      "apiBase": null,      "extraHeaders": null    },    "anthropic": {      "apiKey": "",      "apiBase": null,      "extraHeaders": null    },    "openai": {      "apiKey": "",      "apiBase": null,      "extraHeaders": null    },    "openrouter": {      "apiKey": "",      "apiBase": null,      "extraHeaders": null    },    "deepseek": {      "apiKey": "",      "apiBase": null,      "extraHeaders": null    },    "groq": {      "apiKey": "",      "apiBase": null,      "extraHeaders": null    },    "zhipu": {      "apiKey": "",      "apiBase": null,      "extraHeaders": null    },    "dashscope": {      "apiKey": "",      "apiBase": null,      "extraHeaders": null    },    "vllm": {      "apiKey": "",      "apiBase": null,      "extraHeaders": null    },    "ollama": {      "apiKey": "",      "apiBase": null,      "extraHeaders": null    },    "gemini": {      "apiKey": "",      "apiBase": null,      "extraHeaders": null    },    "moonshot": {      "apiKey": "",      "apiBase": null,      "extraHeaders": null    },    "minimax": {      "apiKey": "",      "apiBase": null,      "extraHeaders": null    },    "aihubmix": {      "apiKey": "",      "apiBase": null,      "extraHeaders": null    },    "siliconflow": {      "apiKey": "",      "apiBase": null,      "extraHeaders": null    },    "volcengine": {      "apiKey": "",      "apiBase": null,      "extraHeaders": null    },    "volcengineCodingPlan": {      "apiKey": "",      "apiBase": null,      "extraHeaders": null    },    "byteplus": {      "apiKey": "",      "apiBase": null,      "extraHeaders": null    },    "byteplusCodingPlan": {      "apiKey": "",      "apiBase": null,      "extraHeaders": null    },    "openaiCodex": {      "apiKey": "",      "apiBase": null,      "extraHeaders": null    },    "githubCopilot": {      "apiKey": "",      "apiBase": null,      "extraHeaders": null    }  },  "gateway": {    "host": "0.0.0.0",    "port": 18790,    "heartbeat": {      "enabled": true,      "intervalS": 1800    }  },  "tools": {    "web": {      "proxy": null,      "search": {        "provider": "brave",        "apiKey": "",        "baseUrl": "",        "maxResults": 5      }    },    "exec": {      "timeout": 60,      "pathAppend": ""    },    "restrictToWorkspace": false,    "mcpServers": {}  }}
配置模型
以配置千问的模型qwen3.5-flash为例子,修改配置文件如下:
"agents": {    "defaults": {      "workspace""~/.nanobot/workspace",      "model""qwen3.5-flash",      "provider""custom",      ...    },...},  "providers": {    "custom": {      "apiKey""sk-****7539a1",      "apiBase""https://dashscope.aliyuncs.com/compatible-mode/v1",      "extraHeaders"null    },...  }
配置完成后我们的nanobot就准备好了,现在测试聊天如下
[root@3up7Z nanobot]# nanobot agent🐈 Interactive mode (type exit or Ctrl+C to quit)You: 北京是那个国家的首都🐈 nanobot北京是中国的首都。You:Goodbye!
对接渠道
以飞书为例,需要到飞书开放平台预创建应用获取到appId和appSecret,并配置文件config.json中,文件修改如下:
"channels": {  ...      "feishu": {      "enabled"true,      "appId""cli_***ced",      "appSecret""qoKo****cH7",      "encryptKey""",      "verificationToken""",      "allowFrom": ["*"],// or "ou_YOUR_OPEN_ID"      "reactEmoji""THUMBSUP",      "groupPolicy""mention"    },...}
现在可以通过飞书聊天啦
本站文章均为手工撰写未经允许谢绝转载:夜雨聆风 » 资源告急?用nanobot替代openclaw:一个仅需4000行代码的轻量级AI助手部署实践

猜你喜欢

  • 暂无文章