i007.cc

i007.cc

优先队列-降维打击

05.价值资料

微信中使用ChatGPT

原文地址

 

至尊宝l

于 2022-12-16 16:09:22 发布

502
收藏
分类专栏: ChatGPT 文章标签: 微信 chatgpt docker
版权

ChatGPT
专栏收录该内容
2 篇文章0 订阅
订阅专栏
微信中使用ChatGPT
ChatGPT 微信 Bot
1. Ubuntu
2. 卸载旧版本
3. apt 安装
4. 添加软件源的GPG密钥
5. 添加docker源到sources.list
6. 安装 docker
7. 启动 docker
8. 建立docker用户组
9. 测试
10. wechat-chatgpt 搭建
11. 获取 会话令牌
12. 运行
13. 使用微信小号扫码登录
14. 重新登录
14.1 停止运行容器
14.2 重新运行容器
15. 使用
参考
1. Ubuntu
系统版本
# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04 LTS
Release: 20.04
Codename: focal
1
2
3
4
5
6
2. 卸载旧版本
apt-get remove docker docker-engine docker.io
1
3. apt 安装
apt-get install -y apt-transport-https ca-certificates curl gnupg lsb-release
1
4. 添加软件源的GPG密钥
curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | gpg –dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
1
5. 添加docker源到sources.list
echo “deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable” | tee /etc/apt/sources.list.d/docker.list > /dev/null
1
6. 安装 docker
apt update

apt-get install -y docker-ce docker-ce-cli containerd.io
1
2
3
7. 启动 docker
systemctl enable docker
systemctl start docker
1
2
8. 建立docker用户组
groupadd docker
usermod -aG docker $USER
1
2
9. 测试
# docker run –rm hello-world
Unable to find image ‘hello-world:latest’ locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete
Digest: sha256:faa03e786c97f07ef34423fccceeec2398ec8a5759259f94d99078f264e9d7af
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the “hello-world” image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/

For more examples and ideas, visit:
https://docs.docker.com/get-started/
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
10. wechat-chatgpt 搭建
# git clone https://github.com/fuergaosi233/wechat-chatgpt.git
# cd wechat-chatgpt/
1
2
11. 获取 会话令牌
1. https://chat.openai.com/chat登录
2. 浏览器打开更多工具>开发者工具。
3. 打开应用程序 > Cookies。
4. 复制 __Secure-next-auth.session-token 的值,配置config.yaml
https://chat.openai.com/api/auth/session

chatGPTAccountPool:
– session_token:

1
2
3
4
5
6
7
8
9
12. 运行
# cd wechat-chatgpt/

1
2
修改config.yaml
cp config.yaml.example config.yaml

chatGPTAccountPool:
– session_token: eyJh……
chatPrivateTiggerKeyword: “”

docker run -d –name wechat-chatgpt -v $(pwd)/config.yaml:/app/config.yaml holegots/wechat-chatgpt:latest
1
2
3
4
5
6
7
13. 使用微信小号扫码登录
docker logs -f wechat-chatgpt
1
14. 重新登录
获取最新的Cookies __Secure-next-auth.session-token 值,修改config.yaml
14.1 停止运行容器
# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
fd62d8c0451b holegots/wechat-chatgpt:latest “npm run dev” 50 minutes ago Up 50 minutes wechat-chatgpt
# docker stop fd62d8c0451b
1
2
3
4
14.2 重新运行容器
删除之前容器
docker container rm wechat-chatgpt
1
docker run -d –name wechat-chatgpt -v $(pwd)/config.yaml:/app/config.yaml holegots/wechat-chatgpt:latest
1
2
3
15. 使用
发送私信或者群@ 触发

消息回复慢,vps延迟高,可以换延迟低的vps
# ping openai.com
PING openai.com (184.27.123.193) 56(84) bytes of data.
64 bytes from a184-27-123-193.deploy.static.akamaitechnologies.com (184.27.123.193): icmp_seq=1 ttl=47 time=385 ms
64 bytes from a184-27-123-193.deploy.static.akamaitechnologies.com (184.27.123.193): icmp_seq=2 ttl=47 time=377 ms
64 bytes from a184-27-123-193.deploy.static.akamaitechnologies.com (184.27.123.193): icmp_seq=3 ttl=47 time=377 ms
1
2
3
4
5
参考
wechat-chatgpt
docker-从入门到实践
参考链接:
github仓库
准备服务器
进入腾讯云服务器官网,搜索“轻量应用服务器”
立即选购

注意,地区要选海外,镜像选Docker镜像

购买之后,就进入控制台

然后登陆到shell

安装部署
查看一下docker,是否安装好
lighthouse@VM-0-12-ubuntu:~$ docker -v
Docker version 20.10.5, build 55c4c88
1
2
克隆仓库
# git clone https://github.com/fuergaosi233/wechat-chatgpt.git
1
查看openai的token,并复制出来

修改配置文件
cp config.yaml.example config.yaml
vim config.yaml
1
2
把上一步获得的token,填在token位置

拉取docker仓库,并运行
docker run -d –name wechat-chatgpt -v $(pwd)/config.yaml:/app/config.yaml holegots/wechat-chatgpt:latest
1
查看运行状态
sudo docker logs -f wechat-chatgpt
1
有一个二维码出来,然后用自己的测试号扫码登陆
登陆之后,就可以用自己的大号与他聊天测试了

 

其他命令
查看运行的docker即contarin的状态

lighthouse@VM-0-12-ubuntu:~$ sudo docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8f511d18643a holegots/wechat-chatgpt “npm run dev” 2 hours ago Up 29 minutes wechat-chatgpt
1
2
3
重启

sudo docker restart wechat-chatgpt
1
停止

sudo docker stop wechat-chatgpt
1
获得container id

sudo docker container ls -al
1
删除container

sudo docker container rm cd59
1
再重新运行

sudo docker run -d –name wechat-chatgpt -v $(pwd)/config.yaml:/app/config.yaml holegots/wechat-chatgpt
1
文章知识点与官方知识档案匹配,可进一步学习相关知识
云原生入门技能树首页概览9001 人正在系统学习中

发表回复