{"id":13456686,"url":"https://github.com/cheungchazz/WeChat-AIChatbot-WinOnly","last_synced_at":"2025-03-24T11:31:03.673Z","repository":{"id":188129048,"uuid":"678151529","full_name":"cheungchazz/WeChat-AIChatbot-WinOnly","owner":"cheungchazz","description":"基于chatgpt-on-wechat框架，只能运行在Win平台的项目，通过本项目可以将微信或者企业微信个人号接入ChatGpt、文心一言、FastGpt、LinkAI，可以文字对话、语音对话、图片交互、文件交互等。","archived":false,"fork":false,"pushed_at":"2023-11-14T01:33:50.000Z","size":93738,"stargazers_count":320,"open_issues_count":9,"forks_count":74,"subscribers_count":7,"default_branch":"main","last_synced_at":"2024-10-29T00:32:18.188Z","etag":null,"topics":["bot","chatbot","wecaht","wework"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cheungchazz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2023-08-13T21:12:20.000Z","updated_at":"2024-10-25T09:46:37.000Z","dependencies_parsed_at":"2023-08-13T22:42:09.024Z","dependency_job_id":"c67dd375-15bc-4afb-bb6e-21a83b30e247","html_url":"https://github.com/cheungchazz/WeChat-AIChatbot-WinOnly","commit_stats":null,"previous_names":["chazzjimel/wechat-aichatbot-winonly","cheungchazz/wechat-aichatbot-winonly"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cheungchazz%2FWeChat-AIChatbot-WinOnly","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cheungchazz%2FWeChat-AIChatbot-WinOnly/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cheungchazz%2FWeChat-AIChatbot-WinOnly/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cheungchazz%2FWeChat-AIChatbot-WinOnly/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cheungchazz","download_url":"https://codeload.github.com/cheungchazz/WeChat-AIChatbot-WinOnly/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245260775,"owners_count":20586464,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bot","chatbot","wecaht","wework"],"created_at":"2024-07-31T08:01:26.030Z","updated_at":"2025-03-24T11:31:03.182Z","avatar_url":"https://github.com/cheungchazz.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# 简介\n\n\u003e **本项目只能在win系统运行**，\u003cu\u003e基于[chatgpt-on-wechat](https://github.com/zhayujie/chatgpt-on-wechat)二改，完全使用了源项目的框架，鸣谢！\u003c/u\u003e支持Win平台的PC客户端以及企微客户端，本项目会持续更新，也会逐渐开发插件，一个人开发，勿催，感谢！\n\n项目支持的消息通道及功能如下：\n\n- [x] **Wework**：PC端的企微个人号消息通道，依赖 [ntwork](https://github.com/chazzjimel/ntwork)，限制[WeCom_4.0.8.6027版本](https://dldir1.qq.com/wework/work_weixin/WeCom_4.0.8.6027.exe)，**只能在Win平台运行项目**。\n\n  - [x] 发送消息：文本/图片/视频/文件/群聊@/链接卡片/GIF\n  - [x] 接收消息：All\n  - [ ] 短板缺陷：无法发送语音条信息\n\n- [x] **Wechat** ：PC端的个微消息通道，依赖 [ntchat项目](https://github.com/billyplus/ntchat) ，最高支持Python310环境版本，限[WeChat3.6.0.18版本](https://github.com/tom-snow/wechat-windows-versions/releases/download/v3.6.0.18/WeChatSetup-3.6.0.18.exe)，**只能在Win平台运行项目**。\n  - [x] 发送消息：文本/图片/视频/文件/群聊@/链接卡片/GIF\n  - [x] 接收消息：All\n  - [x] 其他功能：同意加好友请求/创建群/添加好友入群/邀请好友入群/删除群成员/修改群名/修改群公告\n  - [ ] 短板缺陷：无法发送语音条信息\n\n# **详细功能列表：**\n\n- [x] 聊天对话：私聊、群聊对话，支持fastgpt、openai、azure、文心一言对话模型通道\n- [x] 语音对话：语音消息可选文字或语音回复，支持 azure, openai等语音模型，语音回复仅文件格式，weworktop可实现语音条回复\n- [x] 绘画插件：默认openai绘画支持，项目集成MJ绘画插件，待海艺开放API会优先接入做适配\n- [x] 联网插件：内置联网插件，通过GPT的函数调用功能实现，目前能用，持续优化中\n- [x] 高度定制：依赖fastgpt接口，可实现每个群聊对应不同的应用知识库\n\n\n# 更新日志\n\n\u003e**2023.08.15：** 更新FastGpt接入逻辑，支持单群单知识库，未配置默认走全局base。\n\u003e\n\u003e```json\n\u003e  {\n\u003e      \"fast_gpt\": true,\n\u003e      \"fastgpt_list\": {\n\u003e        \"R:108864****63985\": \"fastgpt-1aps*****pg47-64b16a*******181317\",\n\u003e        \"R:107******373863\": \"fastgpt-1aps8*****gni1kpg47-64b168*****cd181267\"\n\u003e    \t}\n\u003e  }\n\u003e```\n\u003e\n\u003e**2023.08.08：** 添加Wework（企微个人号）消息通道。\n\u003e\n\u003e**2023.07.25：** 适添加wechat消息通道，项目兼容[FastGPT](https://github.com/labring/FastGPT) API接口，直接修改open_ai_api_key和open_ai_api_base即可使用。\n\n# 快速开始\n\n## 准备\n\n### 1.运行环境\n\n仅支持Windows 系统同时需安装 `Python`。\n\u003e 建议Python版本在 3.7.1~3.10 之间。\n\n**(1) 下载项目代码：**\n\n```bash\ngit clone https://github.com/chazzjimel/WeChat-AIChatbot-WinOnly\ncd chatgpt-on-wechat/\n```\n\n**(2) 安装核心依赖 (必选)：**\n\n```bash\npip3 install -r requirements.txt\n```\n\n**(3) 拓展依赖 (可选，建议安装)：**\n\n```bash\npip3 install -r requirements-optional.txt\n```\n\u003e 如果某项依赖安装失败请注释掉对应的行再继续。\n\n其中`tiktoken`要求`python`版本在3.8以上，它用于精确计算会话使用的tokens数量，强烈建议安装。\n\n\n使用`google`或`baidu`语音识别需安装`ffmpeg`，\n\n默认的`openai`语音识别不需要安装`ffmpeg`。\n\n参考[#415](https://github.com/zhayujie/chatgpt-on-wechat/issues/415)\n\n使用`azure`语音功能需安装依赖，并参考[文档](https://learn.microsoft.com/en-us/azure/cognitive-services/speech-service/quickstarts/setup-platform?pivots=programming-language-python\u0026tabs=linux%2Cubuntu%2Cdotnet%2Cjre%2Cmaven%2Cnodejs%2Cmac%2Cpypi)的环境要求。\n:\n\n```bash\npip3 install azure-cognitiveservices-speech\n```\n\n## 配置\n\n配置文件的模板在根目录的`config-template.json`中，需复制该模板创建最终生效的 `config.json` 文件：\n\n```bash\n  cp config-template.json config.json\n```\n\n然后在`config.json`中填入配置，以下是对默认配置的说明，可根据需要进行自定义修改（请去掉注释）：\n\n```json\n# config.json文件内容示例\n{\n  \"open_ai_api_key\": \"YOUR API KEY\",                          # 填入上面创建的 OpenAI API KEY\n  \"model\": \"gpt-3.5-turbo\",                                   # 模型名称。当use_azure_chatgpt为true时，其名称为Azure上model deployment名称\n  \"proxy\": \"\",                                                # 代理客户端的ip和端口，国内环境开启代理的需要填写该项，如 \"127.0.0.1:7890\"\n  \"single_chat_prefix\": [\"bot\", \"@bot\"],                      # 私聊时文本需要包含该前缀才能触发机器人回复\n  \"single_chat_reply_prefix\": \"[bot] \",                       # 私聊时自动回复的前缀，用于区分真人\n  \"group_chat_prefix\": [\"@bot\"],                              # 群聊时包含该前缀则会触发机器人回复\n  \"group_name_white_list\": [\"ChatGPT测试群\", \"ChatGPT测试群2\"], # 开启自动回复的群名称列表\n  \"group_chat_in_one_session\": [\"ChatGPT测试群\"],              # 支持会话上下文共享的群名称  \n  \"image_create_prefix\": [\"画\", \"看\", \"找\"],                   # 开启图片回复的前缀\n  \"conversation_max_tokens\": 1000,                            # 支持上下文记忆的最多字符数\n  \"speech_recognition\": false,                                # 是否开启语音识别\n  \"group_speech_recognition\": false,                          # 是否开启群组语音识别\n  \"use_azure_chatgpt\": false,                                 # 是否使用Azure ChatGPT service代替openai ChatGPT service. 当设置为true时需要设置 open_ai_api_base，如 https://xxx.openai.azure.com/\n  \"azure_deployment_id\": \"\",                                  # 采用Azure ChatGPT时，模型部署名称\n  \"azure_api_version\": \"\",                                    # 采用Azure ChatGPT时，API版本\n  \"character_desc\": \"你是ChatGPT, 一个由OpenAI训练的大型语言模型, 你旨在回答并解决人们的任何问题，并且可以使用多种语言与人交流。\",  # 人格描述\n  # 订阅消息，公众号和企业微信channel中请填写，当被订阅时会自动回复，可使用特殊占位符。目前支持的占位符有{trigger_prefix}，在程序中它会自动替换成bot的触发词。\n  \"subscribe_msg\": \"感谢您的关注！\\n这里是ChatGPT，可以自由对话。\\n支持语音对话。\\n支持图片输出，画字开头的消息将按要求创作图片。\\n支持角色扮演和文字冒险等丰富插件。\\n输入{trigger_prefix}#help 查看详细指令。\",\n  \"accept_friend\": false,                                     # 配置itchat和ntchat自动通过好友请求\n  \"channel_type\": \"wx\",#通道类型，支持：{ntchat,wework,weowrktop}\n  \"fast_gpt\": false,                                           # 标识模型接口是否是fastgpt\n  \"ntchat_smart\": false,                                    # 配置ntchat多开，为true时接管当前已登录微信，默认true\n  \"wework_smart\": false,                                 # 配置wework多开，为true时接管当前已登录企业微信，默认true\n  \"fastgpt_list\": {\n        \"R:108864****63985\": \"fastgpt-1aps*****pg47-64b16a*******181317\",\n        \"R:107******373863\": \"fastgpt-1aps8*****gni1kpg47-64b168*****cd181267\"\n    },\t\t\t\t\t\t\t# 每个群聊ID配置对应的key即可实现单群单知识库，未配置的默认\n  \"wework_http\": \"http://127.0.0.1:8000\",  # weworktop通道http接口地址，默认127.0.0.1:8000\n  \"wework_callback_port\": 8001,  # weworktop回调端口\n  \"voice_openai_api_key\": \"\",\t\t# 使用了fasgpt仍然有openai语音识别需求的，要在这里配置一下openai的参数\n  \"voice_openai_api_base\": \"\",\t\t# 使用了fasgpt仍然有openai语音识别需求的，要在这里配置一下openai的参数\n }\n```\n**配置说明：**\n\n**1.个人聊天**\n\n+ 个人聊天中，需要以 \"bot\"或\"@bot\" 为开头的内容触发机器人，对应配置项 `single_chat_prefix` (如果不需要以前缀触发可以填写  `\"single_chat_prefix\": [\"\"]`)\n+ 机器人回复的内容会以 \"[bot] \" 作为前缀， 以区分真人，对应的配置项为 `single_chat_reply_prefix` (如果不需要前缀可以填写 `\"single_chat_reply_prefix\": \"\"`)\n\n**2.群组聊天**\n\n+ 群组聊天中，群名称需配置在 `group_name_white_list ` 中才能开启群聊自动回复。如果想对所有群聊生效，可以直接填写 `\"group_name_white_list\": [\"ALL_GROUP\"]`\n+ 默认只要被人 @ 就会触发机器人自动回复；另外群聊天中只要检测到以 \"@bot\" 开头的内容，同样会自动回复（方便自己触发），这对应配置项 `group_chat_prefix`\n+ 可选配置: `group_name_keyword_white_list`配置项支持模糊匹配群名称，`group_chat_keyword`配置项则支持模糊匹配群消息内容，用法与上述两个配置项相同。（Contributed by [evolay](https://github.com/evolay))\n+ `group_chat_in_one_session`：使群聊共享一个会话上下文，配置 `[\"ALL_GROUP\"]` 则作用于所有群聊\n\n**3.语音识别**\n\n+ 添加 `\"speech_recognition\": true` 将开启语音识别，默认使用openai的whisper模型识别为文字，同时以文字回复，该参数仅支持私聊 (注意由于语音消息无法匹配前缀，一旦开启将对所有语音自动回复，支持语音触发画图)；\n+ 添加 `\"group_speech_recognition\": true` 将开启群组语音识别，默认使用openai的whisper模型识别为文字，同时以文字回复，参数仅支持群聊 (会匹配group_chat_prefix和group_chat_keyword, 支持语音触发画图)；\n+ 添加 `\"voice_reply_voice\": true` 将开启语音回复语音（同时作用于私聊和群聊），但是需要配置对应语音合成平台的key，由于itchat协议的限制，只能发送语音mp3文件，若使用wechaty则回复的是微信语音。\n\n**4.其他配置**\n\n+ `model`: 模型名称，目前支持 `gpt-3.5-turbo`, `text-davinci-003`, `gpt-4`, `gpt-4-32k`  (其中gpt-4 api暂未完全开放，申请通过后可使用)\n+ `temperature`,`frequency_penalty`,`presence_penalty`: Chat API接口参数，详情参考[OpenAI官方文档。](https://platform.openai.com/docs/api-reference/chat)\n+ `proxy`：由于目前 `openai` 接口国内无法访问，需配置代理客户端的地址，详情参考  [#351](https://github.com/zhayujie/chatgpt-on-wechat/issues/351)\n+ 对于图像生成，在满足个人或群组触发条件外，还需要额外的关键词前缀来触发，对应配置 `image_create_prefix `\n+ 关于OpenAI对话及图片接口的参数配置（内容自由度、回复字数限制、图片大小等），可以参考 [对话接口](https://beta.openai.com/docs/api-reference/completions) 和 [图像接口](https://beta.openai.com/docs/api-reference/completions)  文档，在[`config.py`](https://github.com/zhayujie/chatgpt-on-wechat/blob/master/config.py)中检查哪些参数在本项目中是可配置的。\n+ `conversation_max_tokens`：表示能够记忆的上下文最大字数（一问一答为一组对话，如果累积的对话字数超出限制，就会优先移除最早的一组对话）\n+ `rate_limit_chatgpt`，`rate_limit_dalle`：每分钟最高问答速率、画图速率，超速后排队按序处理。\n+ `clear_memory_commands`: 对话内指令，主动清空前文记忆，字符串数组可自定义指令别名。\n+ `hot_reload`: 程序退出后，暂存微信扫码状态，默认关闭。\n+ `character_desc` 配置中保存着你对机器人说的一段话，他会记住这段话并作为他的设定，你可以为他定制任何人格      (关于会话上下文的更多内容参考该 [issue](https://github.com/zhayujie/chatgpt-on-wechat/issues/43))\n+ `subscribe_msg`：订阅消息，公众号和企业微信channel中请填写，当被订阅时会自动回复， 可使用特殊占位符。目前支持的占位符有{trigger_prefix}，在程序中它会自动替换成bot的触发词。\n\n**本说明文档可能会未及时更新，当前所有可选的配置项均在该[`config.py`](https://github.com/zhayujie/chatgpt-on-wechat/blob/master/config.py)中列出。**\n\n## 运行\n\n### 1.本地运行（默认Wechat客户端，仅限window平台）\n\n如果是开发机 **本地运行**，直接在项目根目录下执行：\n\n```bash\npython3 app.py\n```\n### 2. PC本地部署wechat（仅限window平台）\n\n1.主项目安装主要依赖后，还需要安装ntchat依赖\n\n```\npip install ntchat\n```\n\n2.安装指定PC微信版本：[WeChat3.6.0.18版本](https://github.com/tom-snow/wechat-windows-versions/releases/download/v3.6.0.18/WeChatSetup-3.6.0.18.exe)，扫码登陆好，关闭自动更新微信\n\n3.修改主项目配置项：config.json文件内\n\n```json\n\"channel_type\": \"ntchat\"\n```\n\n4.运行 app.py\n\n### 3. PC本地部署wework（仅限window平台）\n\n1.主项目安装主要依赖后，还需要安装ntchat依赖\n\n```\npip install ntwork\n```\n\n2.安装指定PC企微专用版本：[WeCom_4.0.8.6027版本](https://github.com/tom-snow/wechat-windows-versions/releases/download/v3.6.0.18/WeChatSetup-3.6.0.18.exe)，扫码登陆好，关闭自动更新企业微信\n\n3.修改主项目配置项：config.json文件内\n\n```json\n\"channel_type\": \"wework\"\n```\n\n4.运行 app.py\n\n### 4. PC本地部署高级企微接口（仅限window平台）\n\n1.安装指定PC企微专用版本：[WeCom_4.0.8.6027版本](https://github.com/tom-snow/wechat-windows-versions/releases/download/v3.6.0.18/WeChatSetup-3.6.0.18.exe)，扫码登陆好，关闭自动更新企业微信\n\n2.修改主项目配置项：config.json文件内\n\n```json\n\"channel_type\": \"weworktop\"\n```\n\n3.管理员运行企微接口程序，基础版在项目文件夹”WeChat-AIChatbot-WinOnly\\channel\\weworktop\\“内，运行WeworkApi.exe，不用输入key直接点击启动服务，启动成功企微打开后下一步\n\n4.运行 app.py\n\n\n\n\n\n## 硬核功能展示\n\n![](https://github.com/chazzjimel/WeChat-AIChatbot-WinOnly/blob/main/docs/images/001.png)\n\n![](https://github.com/chazzjimel/WeChat-AIChatbot-WinOnly/blob/main/docs/images/002.png)\n\n![](https://github.com/chazzjimel/WeChat-AIChatbot-WinOnly/blob/main/docs/images/003.png)\n\n![](https://github.com/chazzjimel/WeChat-AIChatbot-WinOnly/blob/main/docs/images/004.png)\n\n![](https://github.com/chazzjimel/WeChat-AIChatbot-WinOnly/blob/main/docs/images/005.png)\n\n![](https://github.com/chazzjimel/WeChat-AIChatbot-WinOnly/blob/main/docs/images/006.png)\n\n![](https://github.com/chazzjimel/WeChat-AIChatbot-WinOnly/blob/main/docs/images/007.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcheungchazz%2FWeChat-AIChatbot-WinOnly","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcheungchazz%2FWeChat-AIChatbot-WinOnly","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcheungchazz%2FWeChat-AIChatbot-WinOnly/lists"}