目 录CONTENT

文章目录
VPS

将ChatGPT接入电报Telegram教程(同时支持gpt3.5/gpt4.0/绘画功能)

yyzq
2023-04-25 / 0 评论 / 4 点赞 / 1,055 阅读 / 373 字
广告 广告

前言:

ChatGPT接入电报Telegram之前出过一个版本是低版本的,不太好用那么今天换一个项目接入电报,接下来我们来看看怎么操作。

准备条件:

1.获取chatgpt的api-key

获取您的OpenAI API密钥

2.获取电报机器人的tg-key

从 @BotFather 获取您的 Telegram 机器人令牌。

3.用到github上一个开源项目

https://github.com/karfly/chatgpt_telegram_bot

4.准备一台服务器是centos系统(国外的X86架构的)

购买VPS
https://duan.yyzq.cf/vps

5.服务器安装好docker与docker-compose

参考这个
https://www.ywsj.cf/s/docker

搭建开始

进入VPS
克隆项目

git clone https://github.com/karfly/chatgpt_telegram_bot

进入目录

cd chatgpt_telegram_bot

复制config.yml和config.env文件

mv config/config.example.yml config/config.yml
mv config/config.example.env config/config.env

编辑config.yml填好tg-key与api-key

cd config #进入config目录
vim config.yml
telegram_token: "6075906134:AAEAw7BTPmCdTWAtjm-gPH0zTLC2nKeyCZ4"
openai_api_key: "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"
use_chatgpt_api: true
allowed_telegram_usernames: []  # if empty, the bot is available to anyone. pass a username string to allow it and/or user ids as integers
new_dialog_timeout: 600  # new dialog starts after timeout (in seconds)
return_n_generated_images: 1
n_chat_modes_per_page: 5
enable_message_streaming: true  # if set, messages will be shown to user word-by-word

# prices
chatgpt_price_per_1000_tokens: 0.002
gpt_price_per_1000_tokens: 0.02
whisper_price_per_1_min: 0.006

构建镜像

cd .. #退出上一层
docker-compose --env-file config/config.env up --build

打开容器

docker-compose up -d

使用电报机器人
image-1682425614074

4
广告 广告

评论区