• Communication and Q&A group: 204785790
  • Provide test robot QQ: 2196084348

Realize a more intelligent QQ robot by calling the Completion API provided by the OpenAI GPT-3 model

technology stack

  • Mirai high-efficiency QQ robot support library

  • YiriMirai is a lightweight, low-coupling Python SDK based on mirai-api-http.

  • OpenAI API OpenAI API

project structure

  • pkg.database Database operation related

    • The database is used to store the history of the session to ensure that the content of the conversation can be remembered after the program is restarted
  • pkg.openai OpenAI API related

    • Used to call OpenAI’s API to generate reply content
  • pkg.qqbot QQ robot related

    • Process the message received by QQ, call the API and reply


Sign up for an OpenAI account

Refer to the following article

Just 1 yuan to get ChatGPT registration
Teach you how to register ChatGPT step by step, super detailed

After successful registration, please go to the personal center to check the api_key
After completing the registration, use the following automated or manual deployment steps

Automated Deployment

Deploy using this installer

  • This installer currently only supports Windows x64 platform, other platforms please deploy manually

manual deployment

Manual deployment works on all platforms
  • Please use Python 3.9.x or above
  • Please pay attention to the consumption of OpenAI account quota
    • Each account only has a free limit of 18 US dollars. If the bank card is not bound, an error will be reported when it exceeds
    • OpenAI charging standard: used by defaulttext-davinci-003Model $0.02/thousand words

Configure Mirai

Follow this tutorial to configure Mirai and YiriMirai
After starting mirai-console, useloginCommand to log in to the QQ account and keep the mirai-console running

Configure the main program

  1. clone this project
git clone https://github.com/RockChinQ/QChatGPT
cd QChatGPT
  1. install dependencies
pip3 install -r requirements.txt
  1. Run the main program once to generate configuration files
  1. edit configuration fileconfig.py

Fill in the configuration information according to the comments in the file

  1. Run the main program
  • Install as prompteduvicornorhypercornPleasedon’t wantInstallation, these two are not required, there is currently an unknown bug
  • If an error is reportedTypeError: As of 3.10, the *loop* parameter was removed from Lock() since it is no longer necessaryplease refer to here

If there is no error message, the operation is successful


use private chat

  1. Add robot QQ as a friend
  2. Send a message to the robot and the robot will reply automatically
  3. able to pass!helpView help information

private chat example

group chat use

  1. Pull the robot into the group
  2. at the robot and send a message, the robot will reply automatically
  3. at robot and send!helpView help information

group chat example

#dialogue #robot #bot #developed #based #OpenAI #ChatGPT #implemented #miraiChatGPT #supports #oneclick #deployment

Leave a Comment

Your email address will not be published. Required fields are marked *