perf: bing不想继续话题后自动重置并重试

This commit is contained in:
Soulter
2023-04-06 22:28:31 +08:00
parent ce476ca163
commit 1af6e77dd1
3 changed files with 11 additions and 3 deletions
+8 -1
View File
@@ -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:
-1
View File
@@ -33,7 +33,6 @@ class CommandOpenAIOfficial(Command):
return True, self.draw(message)
return False, None
def reset(self, session_id: str):
+3 -1
View File
@@ -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