本教程将指导你使用 gensokyo-telegram 和 gensokyo-llm 在 Telegram 上部署一个 LLM 聊天机器人。
首先,下载 gensokyo-telegram:
- 打开 Telegram 应用。
- 搜索
BotFather。 - 创建一个新的机器人,并按照
BotFather提供的指引完成设置。
你将收到如下消息:
Done! Congratulations on your new bot. You will find it at t.me/Txxx. You can now add a description, about section, and profile picture for your bot, see /help for a list of commands. By the way, when you've finished creating your cool bot, ping our Bot Support if you want a better username for it. Just make sure the bot is fully operational before you do this.
重要:保护好你的 HTTP API Token,它将用于接下来的步骤。
- 访问你的机器人链接:t.me/Txxx。
- 使用收到的
<<Your Token>>作为你的botToken。
- 首次运行
.exe文件,按提示释放脚本。 - 运行
.bat文件。 - 打开
config.yml配置文件,进行以下设置:botToken: 填入你的botToken。useNgrok: 设置为true。webHookPath: 保持为空 ("")。customcert: 设置为false。
- 访问 ngrok 官网,并注册或登录。
- 在获取开始(getting started)部分找到
your authtoken。 - 将
authtoken输入到ngrokKey配置中。 - 设置
highway为true。 - 设置
sendDirectResponse为true。
- 在
docs/中级-轻松对接豆包大模型.md完成豆包模型的配置。 - 确保
gensokyo-llm的iPWhiteList包含127.0.0.1。 - 使用默认端口
46233。
- 打开
gensokyo-telegram的yml配置文件。 - 添加
gensokyo-llm的反向 WebSocket 地址到ws_address配置:ws_address: ["ws://127.0.0.1:46233"]
- 在
config.yml的systemPrompt配置项中配置好提示词。
- 双击运行
gensokyo-llm。 - 双击运行你已配置好的
gensokyo-telegram。 - 发送信息给你的 bot,检查是否能成功接收信息。
