Home  >  Article  >  Technology peripherals  >  It took half an hour to build a WeChat robot based on ChatGPT

It took half an hour to build a WeChat robot based on ChatGPT

WBOY
WBOYforward
2023-04-11 13:46:031567browse

I believe that everyone has been attracted by ChatGPT recently. In fact, it was popular once almost a month ago. It seems that it was only popular in the programmer circle and has not been recognized by the public. I don’t know what happened recently. It became popular again because of something, and everyone knew about it this time.

Thinking that such a popular AI can be played for fun, I tried to connect ChatGPT to my personal WeChat to tease the AI ​​in WeChat.

Let’s take a look at some chat screenshots first

It took half an hour to build a WeChat robot based on ChatGPT

It took half an hour to build a WeChat robot based on ChatGPT

You can also join a group for group chat, you can see The training data to ChatGPT is quite old, and some questions still have historical answers. However, as can be seen from the above case, the current effect is much better than before. At least it can be linked to the context. I have to say that this is definitely a milestone.

It took half an hour to build a WeChat robot based on ChatGPT

Process

To access ChatGPT in WeChat, we need the following steps

  1. Successfully register an OpenAi Account, get an API key;
  2. Run a WeChat robot program based on the open source project wechatbot;
  3. Use WeChat to scan the QR code to log in (it is recommended to use a small account);

Registration

OpenAi Due to some reasons, it is impossible to register an account normally in China, and even the website cannot be accessed normally. The detailed registration process is not within the scope of this article. Those who are interested can Reply with the keyword [chatgpt] in the background to view the registration details.

Here I will show you how to obtain an API key after successful registration. When we register successfully and log in, we can go to the link https://platform.openai.com/account/api-keys. Click Create new Secret key on the page to generate an API key. Copy the API key and store it for later use.

It took half an hour to build a WeChat robot based on ChatGPT

Run the robot program

For those with a technical background, there are several ways to run the program. It can be run based on source code or based on docker​ To run, Ah Fen will run it directly through docker for the sake of simplicity. After installing docker on the service, just run the following command directly.

docker run -itd --name wechatbot --restart=always 
 -e APIKEY=刚刚生成的 API key 
 -e AUTO_PASS=false 
 -e SESSION_TIMEOUT=60s 
 -e MODEL=text-davinci-003 
 -e MAX_TOKENS=512 
 -e TEMPREATURE=0.9 
 -e REPLY_PREFIX=ChatGPT: 
 -e SESSION_CLEAR_TOKEN=下一个问题 
 docker.mirrors.sjtug.sjtu.edu.cn/qingshui869413421/wechatbot:latest

Normally, after starting, through the docker ps command we can see that there are corresponding docker processes as follows.

It took half an hour to build a WeChat robot based on ChatGPT

Next we enter the container, query the QR code, scan the code to log in, and execute the following two lines of code in sequence. If nothing else, you can see a When the QR code comes out, just scan the code with WeChat to log in (it is recommended to use a small account).

docker exec -it wechatbot bash
tail -f -n 50 /app/run.log

After scanning the QR code to log in, we can have fun playing. However, it should be noted that API calls have a quota limit for each account. The current limit for each account is 18 US dollars. So you can just play with it and tease AI. The project address of wechatbot is here https://github.com/qingconglaixueit/wechatbot. Those who are interested can also study it.

It took half an hour to build a WeChat robot based on ChatGPT

Thinking

The emergence of ChatGPT has broken the previous artificial intelligence barrier. Although there are still many shortcomings, I believe that it will be iterated and upgraded in the future. can perform better. At the same time, AI is becoming more and more mature, and I believe that more jobs and skills will be replaced in the future.

For us, the only constant is change, so we must be prepared to accept new things, and at the same time be prepared to deal with the future, and try to make ourselves irreplaceable.

Friends who don’t know how to build can add Afen WeChat according to the following tips. Afen will pull the built robot into a special reader group and you can experience it. The slots are limited on a first-come, first-served basis.

The above is the detailed content of It took half an hour to build a WeChat robot based on ChatGPT. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:51cto.com. If there is any infringement, please contact admin@php.cn delete