小言_互联网的博客

微信中使用ChatGPT

576人阅读  评论(0)

1. Ubuntu

  • 系统版本
# lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 20.04 LTS
Release:	20.04
Codename:	focal

2. 卸载旧版本

apt-get remove docker docker-engine docker.io

3. apt 安装

apt-get install -y apt-transport-https ca-certificates curl gnupg lsb-release

4. 添加软件源的GPG密钥

curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

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

6. 安装 docker

apt update
apt-get install -y docker-ce docker-ce-cli containerd.io

7. 启动 docker

systemctl enable docker
systemctl start docker

8. 建立docker用户组

groupadd docker
usermod -aG docker $USER

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/

 

10. wechat-chatgpt 搭建

# git clone https://github.com/fuergaosi233/wechat-chatgpt.git
# cd wechat-chatgpt/

11. 获取 会话令牌

1. https://chat.openai.com/chat登录
2. 浏览器打开更多工具>开发者工具。
3. 打开应用程序 > Cookies。
4. 复制 __Secure-next-auth.session-token 的值,配置config.yaml
chatGPTAccountPool:
  - session_token: <your session_token>

12. 运行

# cd wechat-chatgpt/
  • 修改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

13. 使用微信小号扫码登录

docker logs -f wechat-chatgpt

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

14.2 重新运行容器

  • 删除之前容器
docker container rm wechat-chatgpt
docker run -d --name wechat-chatgpt -v $(pwd)/config.yaml:/app/config.yaml holegots/wechat-chatgpt:latest

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. wechat-chatgpt
  2. docker-从入门到实践

转载:https://blog.csdn.net/u010953692/article/details/128259455
查看评论
* 以上用户言论只代表其个人观点,不代表本网站的观点或立场