The chatgpt-on-wechat (CoW) project is a large model-based intelligent dialogue robot that supports WeChat official accounts, enterprise WeChat applications, Feishu, and DingTalk access. You can choose GPT3.5/GPT4.0/Claude/Gemini/ LinkAI/ChatGLM/KIMI/Wenxin Yiyan/iFlytek/Tongyi Qianwen/LinkAI can process text, voice and pictures, access external resources such as the operating system and the Internet through plug-ins, and support customized enterprise AI based on its own knowledge base. application.
The latest version supports functions as follows:
DEMO video: https://cdn.link-ai.tech/doc/cow_demo.mp4
Add a small assistant to WeChat to join the open source project exchange group:
LinkAI is a one-stop AI application platform for enterprises and developers, aggregating multimodal large models, knowledge bases, Agent plug-ins, workflows and other capabilities, supporting one-click access to mainstream platforms and managing them, supporting SaaS and privatized deployment. Multiple modes.
LinkAI has accumulated rich AI solutions in private domain operations, intelligent customer service, enterprise efficiency assistant and other scenarios, and has accumulated the best practices for large-scale application in various industries such as e-commerce, culture and education, health, new consumption, and technology manufacturing. , committed to helping more enterprises and developers embrace AI productivity.
Enterprise Services and Product Consultancy Contact a product consultant:
2024.10.31: Improvement of program stability in version 1.7.3, database functions, Claude model optimization, linkai plug-in optimization, offline notifications
2024.09.26: Version 1.7.2 and version 1.7.1, iFlytek and other models optimization, O1 models, quick installation and management scripts
2024.08.02: IFLYTEK 4.0 model, knowledge base citation source display, and related plug-in optimization in version 1.7.0
2024.07.19: Version 1.6.9 adds gpt-4o-mini model, Alibaba voice recognition, and Qiwei application channel routing optimization
2024.07.05: Version 1.6.8 and version 1.6.7, Claude3.5, Gemini 1.5 Pro, MiniMax model, workflow picture input, model list improvement
2024.06.04: 1.6.6 and 1.6.5 versions, gpt-4o model, DingTalk streaming cards, iFLYTEK voice recognition/synthesis
2024.04.26: Version 1.6.0, adding Kimi access, gpt-4-turbo version upgrade, file summary and voice recognition problem fix
2024.03.26: Version 1.5.8 and version 1.5.7, new GLM-4 and Claude-3 models, edge-tts voice support
2024.01.26: 1.5.6 version and 1.5.5 version, DingTalk access, tool plug-in upgrade, 4-turbo model update
2023.11.11: Version 1.5.3 and version 1.5.4, adding the Tongyi Qianwen model and Google Gemini
2023.11.10: Version 1.5.2, adding Feishu channel, image recognition dialogue, and blacklist configuration
2023.11.10: Version 1.5.0, new
gpt-4-turbo,dall-e-3,ttsmodel access is added, and multimodal capabilities of image understanding & generation, speech recognition & generation are improved
2023.10.16: Supports plug-ins such as LinkAI network search, mathematical calculation, web access through intent identification, refer to the plug-in document
2023.09.26: The plug-in adds one-click summary and dialogue functions of file/article links. Reference for use: Plugin Description
2023.08.08: Access to Baidu Wenxin Yiyan model and support Midjourney drawing through plug-in
2023.06.12: Connect to the LinkAI platform, you can create a domain knowledge base online and create an exclusive customer service robot. Use the reference access document.
View earlier update logs: Archive logs
Quickly start detailed documentation: project construction documentation
Quick installation script, detailed instructions for using: One-click installation startup script
bash <( curl -sS https://cdn.link-ai.tech/code/cow/install.sh )The project uses the OpenAI interface by default. You need to go to the OpenAI registration page to create an account. After creating the account, you go to the API management page to create an API key and save it. You need to configure this key in the project later. The interface requires overseas network access and credit card payment bound.
The default dialogue model is openai's gpt-3.5-turbo, which consumes $0.002 per 1000 tokens (about 750 English words or 500 Chinese characters, including requests and replies). The image generation is a Dell E model, which consumes $0.016 per picture.
The project also supports the use of LinkAI interface, and does not require an agent. It can use Kimi, Wenxin, iFlytek, GPT-3.5, GPT-4o and other models, supporting customized knowledge bases, network search, MJ drawing, document summary, workflow and other capabilities. . Modify the configuration and use it with one click, refer to the access document.
Supports Linux, MacOS, and Windows systems (can run on Linux servers for a long time), and Python is required to be installed.
It is recommended that the Python version be between 3.7.1 and 3.9.X, and the 3.8 version is recommended. 3.10 and above are available on MacOS. It is not certain whether it can run normally on other systems.
Note: Docker or Railway deployment does not require the installation of python environment and downloading the source code, and you can fast forward to the next section directly.
(1) Cloning the project code:
git clone https://github.com/zhayujie/chatgpt-on-wechat
cd chatgpt-on-wechat/Note: If you encounter network problems, you can choose domestic mirror https://gitee.com/zhayujie/chatgpt-on-wechat
(2) Install core dependencies (required):
Ability to create robots using
itchatand have the minimum set of dependencies required for text communication capabilities.
pip3 install -r requirements.txt(3) Expand dependencies (optional, recommended installation):
pip3 install -r requirements-optional.txtIf a dependency installation fails, comment out the corresponding line before continuing
The template of the configuration file is in the root directory config-template.json . You need to copy the template to create the final effective config.json file:
cp config-template.json config.json Then fill in the configuration in config.json . The following is an explanation of the default configuration, which can be customized and modified as needed (note that please remove the comments when using it to ensure the complete JSON format):
# config.json文件内容示例
{
" model " : " gpt-3.5-turbo " , # 模型名称, 支持 gpt-3.5-turbo, gpt-4, gpt-4-turbo, wenxin, xunfei, glm-4, claude-3-haiku, moonshot
" open_ai_api_key " : " YOUR API KEY " , # 如果使用openAI模型则填入上面创建的 OpenAI API KEY
" open_ai_api_base " : " https://api.openai.com/v1 " , # OpenAI接口代理地址
" proxy " : " " , # 代理客户端的ip和端口,国内环境开启代理的需要填写该项,如 "127.0.0.1:7890"
" single_chat_prefix " : [ " bot " , " @bot " ], # 私聊时文本需要包含该前缀才能触发机器人回复
" single_chat_reply_prefix " : " [bot] " , # 私聊时自动回复的前缀,用于区分真人
" group_chat_prefix " : [ " @bot " ], # 群聊时包含该前缀则会触发机器人回复
" group_name_white_list " : [ " ChatGPT测试群" , " ChatGPT测试群2 " ], # 开启自动回复的群名称列表
" group_chat_in_one_session " : [ " ChatGPT测试群" ], # 支持会话上下文共享的群名称
" image_create_prefix " : [ "画" , "看" , "找" ], # 开启图片回复的前缀
" conversation_max_tokens " : 1000, # 支持上下文记忆的最多字符数
" speech_recognition " : false, # 是否开启语音识别
" group_speech_recognition " : false, # 是否开启群组语音识别
" voice_reply_voice " : false, # 是否使用语音回复语音
" character_desc " : "你是基于大语言模型的AI智能助手,旨在回答并解决人们的任何问题,并且可以使用多种语言与人交流。 " , # 人格描述
# 订阅消息,公众号和企业微信channel中请填写,当被订阅时会自动回复,可使用特殊占位符。目前支持的占位符有{trigger_prefix},在程序中它会自动替换成bot的触发词。
" subscribe_msg " : "感谢您的关注!n这里是ChatGPT,可以自由对话。n支持语音对话。n支持图片输出,画字开头的消息将按要求创作图片。n支持角色扮演和文字冒险等丰富插件。n输入{trigger_prefix}#help 查看详细指令。 " ,
" use_linkai " : false, # 是否使用LinkAI接口,默认关闭,开启后可国内访问,使用知识库和MJ
" linkai_api_key " : " " , # LinkAI Api Key
" linkai_app_code " : " " # LinkAI 应用或工作流code
}Configuration instructions:
1. Personal chat
single_chat_prefix (if you do not need the prefix trigger, you can fill in "single_chat_prefix": [""] )single_chat_reply_prefix (if you do not need a prefix, you can fill in "single_chat_reply_prefix": "" )2. Group Chat
group_name_white_list to enable automatic group chat replies. If you want to take effect on all group chats, you can directly fill in "group_name_white_list": ["ALL_GROUP"]group_chat_prefixgroup_name_keyword_white_list configuration item supports fuzzy matching group names, while the group_chat_keyword configuration item supports fuzzy matching group message content, and the usage is the same as the above two configuration items. (Contributed by evolay)group_chat_in_one_session : Make group chats share a session context, and configuration ["ALL_GROUP"] will be used for all group chats3. Voice recognition
"speech_recognition": true will enable voice recognition. By default, openai's whisper model is used to recognize it as text, and reply with text. This parameter only supports private chat (note that since voice messages cannot match the prefix, once enabled, it will automatically reply to all voices. Support voice-triggered drawing);"group_speech_recognition": true will enable group speech recognition. By default, openai's whisper model is used to recognize it as text, and reply with text. The parameters only support group chats (it will match group_chat_prefix and group_chat_keyword, and support voice-triggered drawing);"voice_reply_voice": true will enable voice reply voice (both private chat and group chat)4. Other configurations
model : The model name, currently supports gpt-3.5-turbo , gpt-4o-mini , gpt-4o , gpt-4 , wenxin , claude , gemini , glm-4 , xunfei , moonshot , etc., refer to common/const for all model names. py filetemperature , frequency_penalty , presence_penalty : Chat API interface parameters, please refer to the official OpenAI documentation for details.proxy : Since the openai interface is currently inaccessible in China, you need to configure the address of the proxy client. For details, please refer to #351image_create_prefixconfig.py .conversation_max_tokens : represents the maximum number of words in the context that can be remembered (one question and answer is a group of conversations. If the accumulated number of words in the conversation exceeds the limit, the earliest group of conversations will be removed first)rate_limit_chatgpt , rate_limit_dalle : maximum Q&A rate per minute, drawing rate, queue up and process in order after speeding.clear_memory_commands : In-dialogue commands, actively clear the previous memory, and customize the command alias for string arrays.hot_reload : After the program exits, temporary storage is equal to the status and is closed by default.character_desc configuration saves a passage you said to the robot, he will remember this passage and serve as his setting, and you can customize any personality for him (see this issue for more information about the context of the conversation)subscribe_msg : Please fill in the subscription message, official account and enterprise WeChat channel. It will automatically reply when subscribed, and special placeholders can be used. Currently supported placeholders are {trigger_prefix}, which will be automatically replaced by the trigger word of bot in the program.5.LinkAI configuration (optional)
use_linkai : Whether to use the LinkAI interface, it can be accessed in China after opening it, use the knowledge base and Midjourney painting, reference documentslinkai_api_key : LinkAI Api Key, can be created in the consolelinkai_app_code : LinkAI application or workflow code, optional This document may not be updated in time, and all currently optional configuration items are listed in this config.py .
If the development machine is running locally , execute it directly in the project root directory:
python3 app.py # windows环境下该命令通常为 python app.pyAfter the terminal outputs the QR code, scan the code to log in. When outputting "Start auto replying", it means that the automatic reply program has been successfully run (note: the account used for logging in needs to have completed real-name authentication at the payment location). After scanning the code to log in, your account becomes a robot. You can trigger automatic reply via configured keywords on the mobile phone (any friend sends a message to you, or sends a message to your friend yourself), refer to #142.
Use the nohup command to run the program in the background:
nohup python3 app.py & tail -f nohup.out # 在后台运行程序并通过日志输出二维码After scanning the code to log in, the program can run in the server background. At this time, the log can be closed through ctrl+c , which will not affect the operation of the background program. Use ps -ef | grep app.py | grep -v grep command to view the processes running in the background. If you want to restart the program, you can kill the corresponding process first. After the log is closed, if you want to open again, just enter tail -f nohup.out . In addition, there are scripts for one-click running and closing the program for use in the scripts directory.
Multi-account support: Copy multiple copies of the project, start the program separately, and use different accounts to scan the code to log in to achieve simultaneous operation.
Special command: The user sends #reset to the robot to clear the user's context memory.
Using docker to deploy does not require downloading source code and installation dependencies, you only need to obtain the docker-compose.yml configuration file and start the container.
The premise is that
dockeranddocker-composeneed to be installed. The successful installation is to executedocker -vanddocker-compose version(or docker compose version) to view the version number, and you can go to the docker official website to download.
(1) Download the docker-compose.yml file
wget https://open-1317903499.cos.ap-guangzhou.myqcloud.com/docker-compose.yml After the download is completed, open docker-compose.yml to modify the required configuration, such as OPEN_AI_API_KEY and GROUP_NAME_WHITE_LIST , etc.
(2) Start the container
Run the following command in the directory where docker-compose.yml is located to start the container:
sudo docker compose up -d Running sudo docker ps can view containers with NAMES chatgpt-on-wechat, which means running successfully.
Notice:
docker-compose is 1.X version, you need to execute sudo docker-compose up -d to start the containerFinally, run the following command to view the container run log, scan the QR code in the log to complete the log:
sudo docker logs -f chatgpt-on-wechat(3) Plug-in use
If you need to modify the plug-in configuration in the docker container, you can complete it by mounting it. Rename the plug-in configuration file to config.json , place it in the same directory as docker-compose.yml , and chatgpt-on-wechat in docker-compose.yml Add volumes mapping under chatgpt-on-wechat section:
volumes:
- ./config.json:/app/plugins/config.json
Railway offers free quotas of $5 per month and up to 500 hours. (Update 07.11: Most accounts are no longer available for free)
Deploy Now button.open_ai_api_key , character_desc .One-click deployment:
FAQs: https://github.com/zhayujie/chatgpt-on-wechat/wiki/FAQs
Or directly consult the project assistant online (the corpus is being continuously improved, and the reply is for reference only)
Welcome to access more applications, refer to Terminal code to implement the logic of receiving and sending messages to access. At the same time, new plug-ins are welcome to be added, refer to the plug-in instructions.
Welcome to submit PR, Issues, and Star for support. If you encounter problems when the program runs, you can view the list of FAQs, and then go to Issues to search. Individual developers can join the open source exchange group to participate in more discussions, and corporate users can contact product consultants for consultation.