From 5b3ee2dbe8caee660154370f9c2e5da0ea5154e8 Mon Sep 17 00:00:00 2001 From: Soulter <37870767+Soulter@users.noreply.github.com> Date: Sat, 22 Apr 2023 06:07:33 +0000 Subject: [PATCH 01/12] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=9B=9E?= =?UTF-8?q?=E5=A4=8D=E5=86=85=E5=AE=B9=E5=B1=8F=E8=94=BD=E8=AF=8D=E6=97=A0?= =?UTF-8?q?=E6=95=88=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cores/qqbot/core.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cores/qqbot/core.py b/cores/qqbot/core.py index db0ff5871..292997f7d 100644 --- a/cores/qqbot/core.py +++ b/cores/qqbot/core.py @@ -590,9 +590,8 @@ def oper_msg(message, group=False, msg_ref = None, platform = None): # 敏感过滤 # 过滤不合适的词 - judged_res = chatgpt_res for i in uw.unfit_words: - judged_res = re.sub(i, "***", judged_res) + chatgpt_res = re.sub(i, "***", chatgpt_res) # 百度内容审核服务二次审核 if baidu_judge != None: check, msg = baidu_judge.judge(judged_res) From 754842be7c0fd9dfc43efb15bf0a71f116f35f21 Mon Sep 17 00:00:00 2001 From: Soulter <37870767+Soulter@users.noreply.github.com> Date: Sat, 22 Apr 2023 14:35:22 +0800 Subject: [PATCH 02/12] Update README.md --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index 2ea9b1708..5b645e9d8 100644 --- a/README.md +++ b/README.md @@ -129,6 +129,7 @@ pip install -r requirements.txt ``` > ⚠Python版本应>=3.9 + ### 配置 **详细部署教程链接**https://soulter.top/posts/qpdg.html @@ -137,6 +138,18 @@ pip install -r requirements.txt - 启动main.py +## 感谢 +本项目使用了一下项目: + +[ChatGPT by acheong08](https://github.com/acheong08/ChatGPT) + +[EdgeGPT by acheong08](https://github.com/acheong08/EdgeGPT) + +[go-cqhttp by Mrs4s](https://github.com/Mrs4s/go-cqhttp) + +[nakuru-project by Lxns-Network](https://github.com/Lxns-Network/nakuru-project) + + ## ⚙配置文件说明: ```yaml # 如果你不知道怎么部署,请查看https://soulter.top/posts/qpdg.html From 43ac0ef87ca153f1b12135503d58fa1f9bc8fd7c Mon Sep 17 00:00:00 2001 From: Soulter <37870767+Soulter@users.noreply.github.com> Date: Sat, 22 Apr 2023 08:09:22 +0000 Subject: [PATCH 03/12] fix: remove `judge_res` --- cores/qqbot/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cores/qqbot/core.py b/cores/qqbot/core.py index 292997f7d..721312984 100644 --- a/cores/qqbot/core.py +++ b/cores/qqbot/core.py @@ -594,7 +594,7 @@ def oper_msg(message, group=False, msg_ref = None, platform = None): chatgpt_res = re.sub(i, "***", chatgpt_res) # 百度内容审核服务二次审核 if baidu_judge != None: - check, msg = baidu_judge.judge(judged_res) + check, msg = baidu_judge.judge(chatgpt_res) if not check: send_message(platform, message, f"你的提问得到的回复【百度内容审核】未通过,不予回复。\n\n{msg}", msg_ref=msg_ref, gocq_loop=gocq_loop, qqchannel_bot=qqchannel_bot, gocq_bot=gocq_bot) return From a6555681a001993348b2cdf93684fa5ea0949048 Mon Sep 17 00:00:00 2001 From: Soulter <37870767+Soulter@users.noreply.github.com> Date: Sun, 23 Apr 2023 15:31:33 +0800 Subject: [PATCH 04/12] Update requirements.txt --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 8730ccb84..1080b3896 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,4 +7,4 @@ EdgeGPT~=0.1.22.1 chardet~=5.1.0 Pillow~=9.4.0 GitPython~=3.1.31 -git+https://github.com/Lxns-Network/nakuru-project.git \ No newline at end of file +nakuru-project-test~=0.0.1 From 18ffaa2b91a0bbdd7ac9939f69e8d3f534d3c32c Mon Sep 17 00:00:00 2001 From: Soulter <37870767+Soulter@users.noreply.github.com> Date: Sun, 23 Apr 2023 08:31:22 +0000 Subject: [PATCH 05/12] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E5=90=84?= =?UTF-8?q?=E7=A7=8D=E6=8A=A5=E9=94=99=E7=AE=A1=E7=90=86=EF=BC=9B=20feat:?= =?UTF-8?q?=20=E5=90=AF=E5=8A=A8=E6=97=B6=E6=A3=80=E6=9F=A5=E4=BE=9D?= =?UTF-8?q?=E8=B5=96=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cores/qqbot/core.py | 15 +++++---- main.py | 46 ++++++++++++++++---------- model/provider/provider_rev_edgegpt.py | 1 + 3 files changed, 39 insertions(+), 23 deletions(-) diff --git a/cores/qqbot/core.py b/cores/qqbot/core.py index 721312984..f642f402f 100644 --- a/cores/qqbot/core.py +++ b/cores/qqbot/core.py @@ -187,12 +187,15 @@ def initBot(cfg, prov): input("[System-err] 请退出本程序, 然后在配置文件中填写rev_ChatGPT相关配置") if REV_EDGEGPT in prov: - if cfg['rev_edgegpt']['enable']: - from model.provider.provider_rev_edgegpt import ProviderRevEdgeGPT - from model.command.command_rev_edgegpt import CommandRevEdgeGPT - rev_edgegpt = ProviderRevEdgeGPT() - command_rev_edgegpt = CommandRevEdgeGPT(rev_edgegpt) - chosen_provider = REV_EDGEGPT + if not os.path.exists('./cookies.json'): + input("【错误】导入Bing模型时发生错误,没有找到cookies文件或者cookies文件放置位置错误。windows启动器启动的用户请把cookies.json文件放到和启动器相同的目录下。\n如何获取请看https://github.com/Soulter/QQChannelChatGPT仓库介绍。") + else: + if cfg['rev_edgegpt']['enable']: + from model.provider.provider_rev_edgegpt import ProviderRevEdgeGPT + from model.command.command_rev_edgegpt import CommandRevEdgeGPT + rev_edgegpt = ProviderRevEdgeGPT() + command_rev_edgegpt = CommandRevEdgeGPT(rev_edgegpt) + chosen_provider = REV_EDGEGPT if OPENAI_OFFICIAL in prov: if cfg['openai']['key'] is not None: from model.provider.provider_openai_official import ProviderOpenAIOfficial diff --git a/main.py b/main.py index 245a2ce1d..cbbd67632 100644 --- a/main.py +++ b/main.py @@ -5,10 +5,15 @@ import os, sys abs_path = os.path.dirname(os.path.realpath(sys.argv[0])) + '/' def main(loop, event): - import cores.qqbot.core as qqBot - import yaml - ymlfile = open(abs_path+"configs/config.yaml", 'r', encoding='utf-8') - cfg = yaml.safe_load(ymlfile) + try: + import cores.qqbot.core as qqBot + import yaml + ymlfile = open(abs_path+"configs/config.yaml", 'r', encoding='utf-8') + cfg = yaml.safe_load(ymlfile) + except BaseException as e: + print(e) + input("yaml库未导入或者配置文件格式错误,请退出程序重试。") + exit() if 'http_proxy' in cfg: os.environ['HTTP_PROXY'] = cfg['http_proxy'] @@ -39,19 +44,26 @@ def check_env(): print("请使用Python3.8运行本项目") input("按任意键退出...") exit() - # try: - # print("检查依赖库中...") - # if os.path.exists('requirements.txt'): - # os.system("pip3 install -r requirements.txt") - # elif os.path.exists('QQChannelChatGPT'+ os.sep +'requirements.txt'): - # os.system('pip3 install -r QQChannelChatGPT'+ os.sep +'requirements.txt') - # os.system("clear") - # print("安装依赖库完毕...") - # except BaseException as e: - # print("安装依赖库失败,请手动安装依赖库。") - # print(e) - # input("按任意键退出...") - # exit() + + print("正在更新三方依赖库...") + mm = os.system('pip install -r QQChannelChatGPT/requirements.txt') + if mm == 0: + print("依赖库安装完毕。") + else: + while True: + res = input("依赖库可能安装失败了。\n如果是报错ValueError: check_hostname requires server_hostname,请尝试先关闭代理后重试。\n输入y回车重试\n输入c回车使用国内镜像源下载\n输入其他按键回车继续往下执行。") + if res == "y": + mm = os.system('pip install -r QQChannelChatGPT/requirements.txt') + if mm == 0: + print("依赖库安装完毕。") + break + elif res == "c": + mm = os.system('pip install -r QQChannelChatGPT/requirements.txt -i https://mirrors.aliyun.com/pypi/simple/') + if mm == 0: + print("依赖库安装完毕。") + break + else: + break # 检查key with open(abs_path+"configs/config.yaml", 'r', encoding='utf-8') as ymlfile: diff --git a/model/provider/provider_rev_edgegpt.py b/model/provider/provider_rev_edgegpt.py index 34a0d74b8..319f83da8 100644 --- a/model/provider/provider_rev_edgegpt.py +++ b/model/provider/provider_rev_edgegpt.py @@ -1,6 +1,7 @@ from model.provider.provider import Provider from EdgeGPT import Chatbot, ConversationStyle import json +import os class ProviderRevEdgeGPT(Provider): def __init__(self): From 6e6f6d5cd46b67c82de9bf1cd64e854d28a88951 Mon Sep 17 00:00:00 2001 From: Soulter <37870767+Soulter@users.noreply.github.com> Date: Sun, 23 Apr 2023 16:51:46 +0800 Subject: [PATCH 06/12] Update README.md --- README.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 5b645e9d8..da00300bb 100644 --- a/README.md +++ b/README.md @@ -13,21 +13,20 @@ ## ⭐功能: -通知:部署好后,如果使用的是bing或者逆向ChatGPT库,需要使用切换模型指令`/bing`或者'/revgpt' - 近期新功能: - 支持一键切换语言模型(使用/bing /revgpt /gpt分别可以切换newbing、逆向ChatGPT、官方ChatGPT模型) - 热更新 - 接入QQ,支持在QQ上和QQ频道上同时聊天!https://github.com/Soulter/QQChannelChatGPT/issues/82 +- 更强大的Windows启动器,环境配置自动搞定。链接:https://github.com/Soulter/QQChatGPTLauncher/releases/latest 支持的AI语言模型(请在`configs/config.yaml`下配置): - 逆向ChatGPT库 - 官方ChatGPT AI -- 文心一言(即将支持,链接https://github.com/Soulter/ERNIEBot 欢迎Star) +- 文心一言(即将支持) - NewBing - Bard (即将支持) -部署QQ频道机器人教程链接:https://soulter.top/posts/qpdg.html +部署此项目的教程链接:https://soulter.top/posts/qpdg.html ### 基本功能
From 300f3b6df880a2cfb39319dacfb0d7fbcfbab174 Mon Sep 17 00:00:00 2001 From: Soulter <37870767+Soulter@users.noreply.github.com> Date: Sun, 23 Apr 2023 16:52:07 +0800 Subject: [PATCH 07/12] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index da00300bb..f7d3edae7 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ 欢迎体验😊(频道名: GPT机器人 | 频道号: x42d56aki2) | QQ群号:322154837): - + From 376b2fef400a2cf7c12bd04045956020bbcca649 Mon Sep 17 00:00:00 2001 From: Soulter <37870767+Soulter@users.noreply.github.com> Date: Sun, 23 Apr 2023 09:05:30 +0000 Subject: [PATCH 08/12] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=90=AF?= =?UTF-8?q?=E5=8A=A8=E5=89=8D=E6=A3=80=E6=9F=A5=E4=BE=9D=E8=B5=96=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index cbbd67632..47bac864d 100644 --- a/main.py +++ b/main.py @@ -45,20 +45,24 @@ def check_env(): input("按任意键退出...") exit() + if os.path.exists('requirements.txt'): + pth = 'requirements.txt' + else: + pth = 'QQChannelChatGPT'+ os.sep +'requirements.txt' print("正在更新三方依赖库...") - mm = os.system('pip install -r QQChannelChatGPT/requirements.txt') + mm = os.system('pip install -r '+pth) if mm == 0: print("依赖库安装完毕。") else: while True: res = input("依赖库可能安装失败了。\n如果是报错ValueError: check_hostname requires server_hostname,请尝试先关闭代理后重试。\n输入y回车重试\n输入c回车使用国内镜像源下载\n输入其他按键回车继续往下执行。") if res == "y": - mm = os.system('pip install -r QQChannelChatGPT/requirements.txt') + mm = os.system('pip install -r '+pth) if mm == 0: print("依赖库安装完毕。") break elif res == "c": - mm = os.system('pip install -r QQChannelChatGPT/requirements.txt -i https://mirrors.aliyun.com/pypi/simple/') + mm = os.system(f'pip install -r {pth} -i https://mirrors.aliyun.com/pypi/simple/') if mm == 0: print("依赖库安装完毕。") break From e92ecdd3f8fdbd0730a1882cc7c2d040af709a66 Mon Sep 17 00:00:00 2001 From: Soulter <37870767+Soulter@users.noreply.github.com> Date: Sun, 23 Apr 2023 17:16:31 +0800 Subject: [PATCH 09/12] Update README.md --- README.md | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index f7d3edae7..4daa33f4e 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,16 @@
-# QQChannelChatGPT -在QQ和QQ频道上使用ChatGPT、NewBing等语言模型,稳定,一次部署,同时使用。 +QQChannelChatGPT -教程:https://soulter.top/posts/qpdg.html +[![Language](https://img.shields.io/badge/language-python-green.svg?style=plastic)](https://www.python.org/) +[![License](https://img.shields.io/badge/license-AGPL3-orange.svg?style=plastic)](https://github.com/Soulter/QQChannelChatGPT/blob/master/LICENSE) +![Python](https://img.shields.io/badge/python-3.9+-blue) + +_✨在QQ和QQ频道上使用ChatGPT、NewBing等语言模型,稳定,一次部署,同时使用✨_ -欢迎体验😊(频道名: GPT机器人 | 频道号: x42d56aki2) | QQ群号:322154837): +_✨教程:https://soulter.top/posts/qpdg.html✨_ + +_✨欢迎体验😊(频道名: GPT机器人 | 频道号: x42d56aki2) | QQ群号:322154837)✨_ From 807cad5c48b53baf9156abf14fdb5d783f31a056 Mon Sep 17 00:00:00 2001 From: Soulter <37870767+Soulter@users.noreply.github.com> Date: Mon, 24 Apr 2023 08:00:45 +0000 Subject: [PATCH 10/12] =?UTF-8?q?fix:=20=E5=88=A0=E9=99=A4=E5=90=AF?= =?UTF-8?q?=E5=8A=A8=E6=97=B6=E5=AF=B9qq=E9=A2=91=E9=81=93appid=E4=B8=8D?= =?UTF-8?q?=E5=BA=94=E8=AF=A5=E7=9A=84=E6=A3=80=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/main.py b/main.py index 47bac864d..bd12b993a 100644 --- a/main.py +++ b/main.py @@ -70,13 +70,13 @@ def check_env(): break # 检查key - with open(abs_path+"configs/config.yaml", 'r', encoding='utf-8') as ymlfile: - import yaml - cfg = yaml.safe_load(ymlfile) - if cfg['openai']['key'] == '' or cfg['openai']['key'] == None: - print("请先在configs/config.yaml下添加一个可用的OpenAI Key。详情请前往https://beta.openai.com/account/api-keys") - if cfg['qqbot']['appid'] == '' or cfg['qqbot']['token'] == '' or cfg['qqbot']['appid'] == None or cfg['qqbot']['token'] == None: - print("请先在configs/config.yaml下完善appid和token令牌(在https://q.qq.com/上注册一个QQ机器人即可获得)") + # with open(abs_path+"configs/config.yaml", 'r', encoding='utf-8') as ymlfile: + # import yaml + # cfg = yaml.safe_load(ymlfile) + # if cfg['openai']['key'] == '' or cfg['openai']['key'] == None: + # print("请先在configs/config.yaml下添加一个可用的OpenAI Key。详情请前往https://beta.openai.com/account/api-keys") + # if cfg['qqbot']['appid'] == '' or cfg['qqbot']['token'] == '' or cfg['qqbot']['appid'] == None or cfg['qqbot']['token'] == None: + # print("请先在configs/config.yaml下完善appid和token令牌(在https://q.qq.com/上注册一个QQ机器人即可获得)") def get_platform(): import platform From 3c593fb6f74820ad0325370c9b70ff969be58467 Mon Sep 17 00:00:00 2001 From: Soulter <37870767+Soulter@users.noreply.github.com> Date: Mon, 24 Apr 2023 19:34:11 +0800 Subject: [PATCH 11/12] Update README.md --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 4daa33f4e..949a5c9f8 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ _✨在QQ和QQ频道上使用ChatGPT、NewBing等语言模型,稳定,一次部署,同时使用✨_ -_✨教程:https://soulter.top/posts/qpdg.html✨_ +_✨教程:https://github.com/Soulter/QQChannelChatGPT/wiki ✨_ _✨欢迎体验😊(频道名: GPT机器人 | 频道号: x42d56aki2) | QQ群号:322154837)✨_ @@ -31,7 +31,7 @@ _✨欢迎体验😊(频道名: GPT机器人 | 频道号: x42d56aki2) | QQ群 - NewBing - Bard (即将支持) -部署此项目的教程链接:https://soulter.top/posts/qpdg.html +部署此项目的教程链接:https://github.com/Soulter/QQChannelChatGPT/wiki ### 基本功能
@@ -136,7 +136,7 @@ pip install -r requirements.txt ### 配置 -**详细部署教程链接**https://soulter.top/posts/qpdg.html +**详细部署教程链接**https://github.com/Soulter/QQChannelChatGPT/wiki ### 启动 - 启动main.py @@ -156,7 +156,7 @@ pip install -r requirements.txt ## ⚙配置文件说明: ```yaml -# 如果你不知道怎么部署,请查看https://soulter.top/posts/qpdg.html +# 如果你不知道怎么部署,请查看https://github.com/Soulter/QQChannelChatGPT/wiki # 不一定需要key了,如果你没有key但有openAI账号或者必应账号,可以考虑使用下面的逆向库 From 250435f3e75e10f9c5c974f01d6b6a03c2d4187c Mon Sep 17 00:00:00 2001 From: Soulter <37870767+Soulter@users.noreply.github.com> Date: Tue, 25 Apr 2023 09:29:35 +0800 Subject: [PATCH 12/12] Update requirements.txt --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 1080b3896..3804be2d4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ requests~=2.28.1 openai~=0.27.4 qq-botpy~=1.1.2 -revChatGPT~=4.0.8 +revChatGPT~=5.0.0 baidu-aip~=4.16.9 EdgeGPT~=0.1.22.1 chardet~=5.1.0