Integrate with WeChat Chatbot

Here are the steps to build a WeChat chatbot using the BrillAI platform:

1. Register and Log in to the BrillAI Platform

Go to the official BrillAI website (inference.top) and choose a suitable login method. Register and log in to your account.

2. Obtain the WeChat Bot Project from GitHub

Select an open-source WeChat chatbot project on GitHub, such as chatgpt-on-wechat, and clone it locally to prepare for configuration.

3. Configure the Chatbot

After cloning the project locally, navigate to the project directory. Follow the Quick Start guide provided in the official documentation to set up the environment. Start by installing the necessary packages:

The package installation process may take some time. Once all the required packages are installed, follow the instructions in the official documentation to generate a config.json file for configuration. Execute the following command to create a config.json file using the template provided in the project directory:

The official documentation also mentions that an OpenAI API key is required. The BrillAI platform is compatible with OpenAI's API keys. You can find a default API key in the User Dashboard under API Keys on the BrillAI platform. Alternatively, you can create a new API key by clicking the "Create API Key" button in the top left corner. For simplicity, we'll use the default API key. Click the copy button next to it and save the key for later use.

With the API key in hand, return to the config.json file in the project directory and make the necessary additions or modifications to the configuration settings as required. Since BrillAI is an AI service platform compatible with ChatGPT, and the parameters in the template file are not exhaustive according to the config.py documentation, you'll need to include some additional parameters.

In the configuration, replace the open_ai_api_key with the default API key from BrillAI that you saved earlier. Similarly, update open_ai_api_base to BrillAI's API base URL. Since BrillAI is compatible with OpenAI's API, you also need to add "bot_type": "chatGPT". Finally, for the model parameter, select the model you want to use from those available on the BrillAI platform.

You can find the model you want to use in the BrillAI dashboard under Chat → LLM → Model, in the dropdown list of available models. Here, we’ll use Qwen2.5-72B-Instruct as the selected model.

After completing and saving the config.json file, open the command line in the project directory and type the following command to start the chatbot:

Then, scan the QR code to log in to WeChat and turn your WeChat account into a chatbot.

  1. Configure Image Generation Functionality

Next, we’ll demonstrate how to configure the chatbot to enable image generation. First, log in to the BrillAI homepage (inference.top). After logging in, select the Image module. You’ll see two text-to-image models available. For this example, we’ll use the sd3-medium model.

To enable image generation in the chatbot, update the config.json file with the necessary settings. Specify the model name, image dimensions, and the trigger keyword for the response. Here’s an example configuration:

With this setup, you can now use the drawing feature seamlessly in WeChat conversations. To use the feature, simply prefix your message with bot or @bot, followed by the image generation prefix.

Last updated