Machine 1: Deployment of QQ Chatbot based on GPT3.0 model + mirai QQ#
date: January 7, 2023
slug: 13
status: Published
tags: Technology
type: Post
1. Register OpenAI Account#
Registration method: 1. If you have a US phone number (Google Voice is not available), you can register directly. 2. If you don't have a US phone number, you can use an SMS verification platform. 3. Lazy people like me choose to register through pdd directly. The specific registration process is not described here. After successful registration, go to the personal center to view the API key, which will come with a free API call quota of 18 USD.
2. Automated Deployment Method#
Docker is preferred for Linux, and an installer is preferred for Windows.
Deployment on Linux Platform#
(Using CentOS as an example)
There are two possibilities for someone who doesn't use Docker. One is that they don't have the ability to use Docker. Because they can't afford servers and can't understand documents, their lives are all failures. The second possibility is that they have the ability but choose not to use Docker. When they have the ability but don't use Docker, their ideological level is so low that it is appalling. A capable person who does not take action to prove himself can only prove the low level of his behavior and moral cultivation. It is dark and not truly recognized by society.
Project Address: QChatGPT-Docker-Installer
1. Install Docker and Docker Compose#
- Install Docker:
sudo curl -sSL https://get.daocloud.io/docker|sh
- Start Docker:
systemctlstart docker
- Guard Docker:
sudo systemctl daemon-reload
- Install Docker-compose:
sudo pip3 install docker-compose
If pip is not available, execute the following command:
sudo yum install python3-pip
2. Download the Required Files#
i. Clone the Repository#
git clone https://github.com/mikumifa/QChatGPT-Docker-Installer
cd QChatGPT-Docker-Installer
ii. Deployment#
chmod +x loadFile.sh && ./loadFile.sh
After deployment, the file directory will be as follows:
.
├── bot
│ ├── config-template.py
│ ├── LICENSE
│ ├── main.py
│ ├── pkg
│ ├── README.md
│ ├── requirements.txt
│ ├── res
│ ├── sensitive.json
│ └── tests
├── docker-compose.yaml
├── loadFile.sh
├── mirai
│ ├── LICENSE
│ ├── mcl
│ ├── mcl.cmd
│ ├── mcl.jar
│ └── README.md
├── _mirai.Dockerfile
└── _setup.Dockerfile
3. Configure and Start mirai#
i. Initialize mirai#
docker compose run --rm mirai
ii. Log in to QQ on mirai#
login <Robot QQ Number> <Robot QQ Password>
Note: It is best not to set device lock for the small account used as a robot. When logging in, you may need to slide the verification code. At this time, you need to use
iii. Configure Auto Login#
After the robot account is successfully logged in, execute the following command:
autologinadd <Robot QQ Number> <Robot QQ Password>
autologin setConfig <Robot QQ Number> protocol ANDROID_PAD
After completion,
Ctrl+C
to exit.
iv. Write Configuration File#
- Create
config.py
in thebot
folder, copy the contents ofconfig-template.py
into it, editconfig.py
, and modify the required items. - In the
mirai/config/net.mamoe.mirai-api-http
folder, findsetting.yml
, which is the configuration file formirai-api-http
. Modify the content of this file to:
adapters:
- ws
debug: true
enableVerify: true
verifyKey: yirimirai
singleMode: false
cacheSize: 4096
adapterSettings:
ws:
host: localhost
port: 8080
reservedSyncId: -1
verifyKey
should be the same as the
verifyKey
in
bot
's
config.py
4. Start#
i. Start mirai container#
docker compose run -itd mirai
This command will start the mirai container in the background.
ii. Start the main program container#
docker compose run -itd setup
This command will start the main program container in the background and complete the configuration.
When I reached this step, I couldn't recognize the -itd command, and in the end, I didn't use -itd, and just -d seemed to work, so let's use it as it is, anyway, there was no error.
Installer Version#
(Supports Windows, CentOS, Ubuntu, and Raspbian arm64)
Project Address: qcg-installer This project is a one-click deployment script written in Go language for the QChatGPT project, which automates the deployment of dependencies.
- Note: The downloaded Python and mirai are both portable versions and do not affect other system environments.
1. Download the Installer#
- Download the executable file from the Release page, if unable to access, please go to Gitee
- Save it to an empty directory on your computer, run it directly, and wait for the environment to be configured.
- After completion, enter the
api-key
andQQ number
as prompted. - Installation is complete.
2. Run the Program#
After each restart, follow the steps below to start the program:
i. Start mirai#
- Run
run-mirai.bat
(Windows) or./run-mirai.sh
(Linux) to start mirai. - Enter
login <QQ number> <QQ password>
to log in to the account as prompted (see the above Linux deployment for Tencent authentication tutorial).
ii. Run the main program#
- After logging in, run
run-bot.bat
(Windows) or./run-bot.sh
(Linux) to start the main program.
iii. Common Issues#
- If mirai prompts "QQ version is too low", see this issue.
- If running
run-bot.bat
crashes, see this solution. - If prompted to install
uvicorn
orhypercorn
after starting, do not install them as they may cause unknown bugs.