Skip to content

Commit

Permalink
Merge pull request #329 from kx-Huang/main
Browse files Browse the repository at this point in the history
Update README for getting cf_clearance token and user agent
  • Loading branch information
fuergaosi233 authored Dec 16, 2022
2 parents 8b4a8a0 + 549cdf5 commit ea8e4c7
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 12 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ CHAT_GPT_PASSWORD=
CHAT_GPT_SESSION_TOKEN=
CHAT_GPT_RETRY_TIMES=
CHAT_PRIVATE_TRIGGER_KEYWORD=
OPENAI_PROXY=
CF_CLEARANCE=
USER_AGENT=
67 changes: 55 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,18 @@ 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.
⚠️ 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:**
You can configure in `config.yaml`:

```yaml
openAIProxy: <Your Proxy>
```

Or you can export to environment variable:

```sh
export http_proxy=<Your Proxy>
```
Expand All @@ -123,14 +132,44 @@ If you cant use email and password to login your openai account or your network
2. Open dev tools.
3. Open Application > Cookies.
![image](docs/images/session-token.png)
4. Copy the value for \_\_Secure-next-auth.session-token and save it to your config
Your config.yaml should be like this:
4. Copy the value for `\_\_Secure-next-auth.session-token`, save it to your config

Your `config.yaml` should be like this:

```yaml
chatGPTAccountPool:
- session_token: <your session_token>
```

#### **Configure Cloudflare Token**

We also need Cloudflare token to build the connection successfully. Similar to getting the session token, you need to copy the value for `cf_clearance`, save it to your config file.

![image](docs/images/cloudflare-token.png)

Your `config.yaml` should be like this:

```yaml
clearanceToken: <your cloudflare_token>
```

#### **Configure User Agent**

We have provided a sample `userAgent` in `config.yaml.example`. But you can also set up your own user agent, which can be found in following steps:

1. Open dev tools
2. Open network
3. Find `User-Agent` in request headers
4. Copy the value for `User-Agent`, save it to your config

![image](docs/images/user-agent.png)

Your `config.yaml` should be like this:

```yaml
userAgent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36"
```

### Start Project

```sh
Expand All @@ -149,11 +188,11 @@ Then click the one-click deployment button below to deploy.

[![Deploy on Railway](https://railway.app/button.svg)](https://railway.app/new/template/BHJD6L?referralCode=FaJtD_)

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

![railway-deployment](docs/images/railway-deployment.png)
![railway-deployment](docs/images/railway-deployment.png)

Some environment variables need to be configured:
Some environment variables need to be configured:

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

Expand All @@ -165,21 +204,25 @@ Some environment variables need to be configured:

- **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:
- **CF_CLEARANCE** : Your Cloudflare's clearance token. See how to get a token [here](#configure-cloudflare-token).

- **USER_AGENT**: Your user-agent. See how to get [here](#configure-user-agent).

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

![railway-deploying](docs/images/railway-deploying.png)
![railway-deploying](docs/images/railway-deploying.png)

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

![railway-deployed](docs/images/railway-deployed.png)
![railway-deployed](docs/images/railway-deployed.png)

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):
Log in successfully and start sending and receiving messages(This process can take several minutes):

![railway-success](docs/images/railway-succeed.png)

Besides, in deployment, you may encounter the following issues:
Besides, in deployment, you may encounter the following issues:

- **Error: ⚠️ No chatgpt item in pool** : This error means that you have not configured the OpenAI account information correctly. You can solve this problem from the following aspects:1. Check whether the token or openAI account and password are filled in correctly. 2. The token may have expired (experience shows that the expiration time of the token is **24** hours), you can go to the chatGPT official website to re-obtain the token. 3. Redeploy Current Services.Note that the above should be modified on the Variables page in Railway Dashboard.
- **After the deployment is complete, the QR code is not generated**.Try **refreshing** the page to see again if the Deploy Logs panel generated a link and QR code.
Expand Down
Binary file added docs/images/cloudflare-token.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/user-agent.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ea8e4c7

Please sign in to comment.