From 1af6e77dd1c2e72a518a4d96bd03d3a273b127c8 Mon Sep 17 00:00:00 2001 From: Soulter <37870767+Soulter@users.noreply.github.com> Date: Thu, 6 Apr 2023 22:28:31 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20bing=E4=B8=8D=E6=83=B3=E7=BB=A7?= =?UTF-8?q?=E7=BB=AD=E8=AF=9D=E9=A2=98=E5=90=8E=E8=87=AA=E5=8A=A8=E9=87=8D?= =?UTF-8?q?=E7=BD=AE=E5=B9=B6=E9=87=8D=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cores/qqbot/core.py | 9 ++++++++- model/command/command_openai_official.py | 1 - model/provider/provider_rev_edgegpt.py | 4 +++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/cores/qqbot/core.py b/cores/qqbot/core.py index ba537453..404fcc44 100644 --- a/cores/qqbot/core.py +++ b/cores/qqbot/core.py @@ -488,7 +488,14 @@ def oper_msg(message, at=False, msg_ref = None): send_qq_msg(message, f"[RevBing] 正忙,请稍后再试",msg_ref=msg_ref) return else: - chatgpt_res = str(asyncio.run_coroutine_threadsafe(rev_edgegpt.text_chat(qq_msg), client.loop).result()) + chatgpt_res, res_code = str(asyncio.run_coroutine_threadsafe(rev_edgegpt.text_chat(qq_msg), client.loop).result()) + if res_code == 0: # bing不想继续话题,重置会话后重试。 + send_qq_msg(message, f"Bing不想继续话题了, 正在自动重置会话并重试。", msg_ref=msg_ref) + asyncio.run_coroutine_threadsafe(rev_edgegpt.forget(), client.loop) + chatgpt_res, res_code = str(asyncio.run_coroutine_threadsafe(rev_edgegpt.text_chat(qq_msg), client.loop).result()) + if res_code == 0: # bing还是不想继续话题,大概率说明提问有问题。 + send_qq_msg(message, f"Bing仍然不想继续话题, 请检查您的提问。", msg_ref=msg_ref) + return if REV_EDGEGPT in reply_prefix: chatgpt_res = reply_prefix[REV_EDGEGPT] + chatgpt_res except BaseException as e: diff --git a/model/command/command_openai_official.py b/model/command/command_openai_official.py index 578a4383..573a632b 100644 --- a/model/command/command_openai_official.py +++ b/model/command/command_openai_official.py @@ -33,7 +33,6 @@ class CommandOpenAIOfficial(Command): return True, self.draw(message) return False, None - def reset(self, session_id: str): diff --git a/model/provider/provider_rev_edgegpt.py b/model/provider/provider_rev_edgegpt.py index 30d358b5..aee31776 100644 --- a/model/provider/provider_rev_edgegpt.py +++ b/model/provider/provider_rev_edgegpt.py @@ -34,6 +34,8 @@ class ProviderRevEdgeGPT(Provider): resp = await self.bot.ask(prompt=prompt, conversation_style=ConversationStyle.creative) print("[RevEdgeGPT] "+str(resp)) resp = resp['item']['messages'][len(resp['item']['messages'])-1]['text'] + if 'I\'m sorry but I prefer not to continue this conversation. I\'m still learning so I appreciate your understanding and patience.' in resp: + return '', 0 if resp == prompt: resp += '\n\n如果你没有让我复述你的话,那代表我可能不想和你继续这个话题了,请输入reset重置会话😶' break @@ -46,5 +48,5 @@ class ProviderRevEdgeGPT(Provider): self.busy = False print("[RevEdgeGPT] "+str(resp)) - return resp + return resp, 1