perf: 强化超出会话限制后自动重置;其他优化

This commit is contained in:
Soulter
2023-04-19 16:25:07 +08:00
parent 7aba9ff3ff
commit 8f7703c158
2 changed files with 7 additions and 4 deletions
+3 -3
View File
@@ -20,7 +20,6 @@ from nakuru import (
GroupMessage,
GroupMemberIncrease,
FriendMessage
)
from nakuru.entities.components import Plain,At
@@ -481,7 +480,7 @@ def oper_msg(message, group=False, msg_ref = None, platform = None):
chatgpt_res = ""
if chosen_provider == OPENAI_OFFICIAL:
if chosen_provider == OPENAI_OFFICIAL:
hit, command_result = command_openai_official.check_command(qq_msg, session_id, user_name, role, platform=platform)
# hit: 是否触发了指令.
if not hit:
@@ -523,7 +522,8 @@ def oper_msg(message, group=False, msg_ref = None, platform = None):
asyncio.run_coroutine_threadsafe(rev_edgegpt.forget(), bing_cache_loop).result()
res, res_code = asyncio.run_coroutine_threadsafe(rev_edgegpt.text_chat(qq_msg), bing_cache_loop).result()
if res_code == 0: # bing还是不想继续话题,大概率说明提问有问题。
send_message(platform, message, "Bing仍然不想继续话题, 请检查您的提问。", msg_ref=msg_ref, gocq_loop=gocq_loop, qqchannel_bot=qqchannel_bot, gocq_bot=gocq_bot)
asyncio.run_coroutine_threadsafe(rev_edgegpt.forget(), bing_cache_loop).result()
send_message(platform, message, "Bing仍然不想继续话题, 会话已重置, 请检查您的提问后重试。", msg_ref=msg_ref, gocq_loop=gocq_loop, qqchannel_bot=qqchannel_bot, gocq_bot=gocq_bot)
res = ""
chatgpt_res = str(res)
if REV_EDGEGPT in reply_prefix:
+4 -1
View File
@@ -36,7 +36,10 @@ class ProviderRevEdgeGPT(Provider):
self.busy = False
return '', 0
if resp == prompt:
resp += '\n\n如果你没有让我复述你的话,那代表我可能不想和你继续这个话题了,请输入reset重置会话😶'
# resp += '\n\n如果你没有让我复述你的话,那代表我可能不想和你继续这个话题了,请输入reset重置会话😶'
await self.forget()
err_count += 1
continue
break
except BaseException as e:
print(e.with_traceback)