From 14c36ceb522f62471189a8240b9367f2237a1e77 Mon Sep 17 00:00:00 2001 From: Soulter <37870767+Soulter@users.noreply.github.com> Date: Sat, 25 Mar 2023 10:03:48 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E6=8E=A5=E5=85=A5=E6=96=87?= =?UTF-8?q?=E5=BF=83=E4=B8=80=E8=A8=80=EF=BC=88=E5=AE=8C=E5=85=A8=E4=B8=8D?= =?UTF-8?q?=E7=A8=B3=E5=AE=9A=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cores/qqbot/core.py | 15 +++++++++++++-- main.py | 2 ++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/cores/qqbot/core.py b/cores/qqbot/core.py index 2d0494a30..40f328912 100644 --- a/cores/qqbot/core.py +++ b/cores/qqbot/core.py @@ -66,6 +66,7 @@ version = '2.7 ChineseAreGood Ver.' # 语言模型提供商 REV_CHATGPT = 'rev_chatgpt' OPENAI_OFFICIAL = 'openai_official' +REV_ERNIE = 'rev_ernie' provider = '' # 逆向库对象及负载均衡 @@ -77,6 +78,7 @@ gpt_config = {} # 百度内容审核实例 baidu_judge = None + def new_sub_thread(func, args=()): thread = threading.Thread(target=func, args=args, daemon=True) thread.start() @@ -182,7 +184,7 @@ def upload(): 初始化机器人 ''' def initBot(cfg, prov): - global chatgpt, provider, rev_chatgpt, baidu_judge + global chatgpt, provider, rev_chatgpt, baidu_judge, rev_ernie global now_personality, gpt_config, config, uniqueSession, history_dump_interval, frequency_count, frequency_time,announcement, direct_message_mode, version provider = prov @@ -241,6 +243,9 @@ def initBot(cfg, prov): # 得到GPT配置信息 if 'openai' in cfg and 'chatGPTConfigs' in cfg['openai']: gpt_config = cfg['openai']['chatGPTConfigs'] + elif prov == REV_ERNIE: + from addons.revERNIE import revernie + rev_ernie = revernie.wx # 百度内容审核 if 'baidu_aip' in cfg and 'enable' in cfg['baidu_aip'] and cfg['baidu_aip']['enable']: @@ -647,7 +652,13 @@ def oper_msg(message, at=False, msg_ref = None): print("[System-Err] Rev ChatGPT API错误。原因如下:\n"+str(e)) send_qq_msg(message, f"Rev ChatGPT API错误。原因如下:\n{str(e)} \n前往官方频道反馈~") return - + elif provider == REV_ERNIE: + try: + chatgpt_res = "[RevERNIE]"+str(rev_ernie.chatViaSelenium(qq_msg)) + except BaseException as e: + print("[System-Err] Rev ERNIE API错误。原因如下:\n"+str(e)) + send_qq_msg(message, f"Rev ERNIE API错误。原因如下:\n{str(e)} \n前往官方频道反馈~") + return # 记录日志 logf.write("[GPT] "+ str(chatgpt_res)+'\n') logf.flush() diff --git a/main.py b/main.py index e2db10643..9d91c5309 100644 --- a/main.py +++ b/main.py @@ -31,6 +31,8 @@ def main(loop, event): def privider_chooser(cfg): if 'rev_ChatGPT' in cfg and cfg['rev_ChatGPT']['enable']: return 'rev_chatgpt' + elif 'rev_ernie' in cfg and cfg['rev_ernie']['enable']: + return 'rev_ernie' else: return 'openai_official'