xiahaoyun / wechat-chatgpt

Use ChatGPT On Wechat via wechaty

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Welcome to wechat-chatgpt 👋

Version License: ISC Twitter: fuergaosi

Use ChatGPT On Wechat via wechaty
English | 中文文档

Deploy on Railway

🌟 Feature

  • Use ChatGPT On Wechat via wechaty
  • Support OpenAI Accounts Pool
  • Support use proxy to login
  • Add conversation Support (Everyone will have their own session)
  • Add Dockerfile
  • Publish to Docker.hub
  • Add Railway deploy
  • Auto Reload OpenAI Accounts Pool
  • Add sendmessage retry for 429/503

Use with docker in Linux(recommended)

cp config.yaml.example config.yaml
# Change Config.yaml
# run docker command in Linux or WindowsPowerShell
docker run -d --name wechat-chatgpt -v $(pwd)/config.yaml:/app/config.yaml holegots/wechat-chatgpt:latest
# login with qrcode
docker logs -f wechat-chatgpt

Use with docker in Windows

# Create and modify config.yaml in the current directory
# run docker command in WindowsPowerShell
docker run -d --name wechat-chatgpt -v $(pwd)/config.yaml:/app/config.yaml holegots/wechat-chatgpt:latest
# In the Windows command line (cmd) environment, you may mount the current directory like this:
docker run -d --name wechat-chatgpt -v %cd%/config.yaml:/app/config.yaml holegots/wechat-chatgpt:latest
# login with qrcode
docker logs -f wechat-chatgpt

Upgrade docker image version

docker pull holegots/wechat-chatgpt:latest
docker stop wechat-chatgpt
docker rm wechat-chatgpt
# run docker command in Linux or WindowsPowerShell
docker run -d --name wechat-chatgpt -v $(pwd)/config.yaml:/app/config.yaml holegots/wechat-chatgpt:latest
# In the Windows command line (cmd) environment, you may mount the current directory like this:
docker run -d --name wechat-chatgpt -v %cd%/config.yaml:/app/config.yaml holegots/wechat-chatgpt:latest
# login with qrcode
docker logs -f wechat-chatgpt

Install

npm install && poetry install

Usage with manual

Copy config

You need copy config file for setting up your project.

cp config.yaml.example config.yaml

Get and config Openai account

If you don't have this OpenAI account and you live in China, you can get it here.

A:Use account and password

You need get OpenAI account and password. Your config.yaml should be like this:

chatGPTAccountPool:
  - email: <your email>
    password: <your password>
# if you hope only some keywords can trigger chatgpt on private chat, you can set it like this:
chatPrivateTiggerKeyword: ""

⚠️ Trigger keywords must appear in the first position of the received message. ⚠️ Pls make sure your network can log in to OpenAI, and if you fail to login in try setting up a proxy or using SessionToken.
Setup proxy:

export http_proxy=<Your Proxy>

B: Use Session Token

If you cant use email and password to login your openai account or your network can't login, you can use session token. You need to follow these steps:

  1. Go to https://chat.openai.com/chat and log in or sign up.
  2. Open dev tools.
  3. Open Application > Cookies. image
  4. Copy the value for __Secure-next-auth.session-token and save it to your config Your config.yaml should be like this:
chatGPTAccountPool:
  - session_token: <your session_token>

Start Project

npm run dev

If you are logging in for the first time, then you need to scan the qrcode.

Usage with Railway

Railway is a deployment platform where you can provision infrastructure, develop with that infrastructure locally, and then deploy to the cloud.This section describes how to quickly deploy a wechat-chatgpt project using Railway.

Firstly, you'll need to sign up for a Railway account and sign in using GitHub verification.

Then click the one-click deployment button below to deploy.

Deploy on Railway

After some validation is complete, you can begin the deployment.You will see the following interface:

railway-deployment

Some environment variables need to be configured:

  • CHAT_GPT_EMAIL : Your OpenAI Account email, if you have session_token, It's optional.

  • CHAT_GPT_PASSWORD : Your OpenAI Account password, if you have session_token, It's optional.

  • CHAT_GPT_SESSION_TOKEN : Your OpenAI Account session_token, if you have email and password, It's optional.See above for how to get it.

  • CHAT_GPT_RETRY_TIMES : The number of times to retry when the OpenAI API returns 429 or 503.

  • CHAT_PRIVATE_TRIGGER_KEYWORD : If you hope only some keywords can trigger chatgpt on private chat, you can set it.

Click the Deploy button and your service will start deploying shortly.The following interface appears to indicate that the deployment has begun:

railway-deploying

When the deployment is displayed successfully, click to view the logs and find the WeChat login link in Deploy Logs.

railway-deployed

Click to enter and use your prepared WeChat to scan the code to log in.

Log in successfully and start sending and receiving messages(This process can take several minutes):

railway-success

Author

👤 holegots

🤝 Contributing

Contributions, issues and feature requests are welcome!
Feel free to check issues page.

Show your support

Give a ⭐️ if this project helped you!

About

Use ChatGPT On Wechat via wechaty


Languages

Language:TypeScript 88.1%Language:Python 8.5%Language:Dockerfile 2.8%Language:Shell 0.6%