perf: 使用异步重写部分代码

This commit is contained in:
Soulter
2023-10-12 11:16:49 +08:00
parent 123c21fcb3
commit 89fc7b0553
5 changed files with 40 additions and 48 deletions

View File

@@ -40,7 +40,6 @@ class Command:
def check_command(self,
message,
session_id: str,
loop,
role,
platform,
message_obj):

View File

@@ -17,7 +17,6 @@ class CommandOpenAIOfficial(Command):
def check_command(self,
message: str,
session_id: str,
loop,
role: str,
platform: str,
message_obj):
@@ -25,7 +24,6 @@ class CommandOpenAIOfficial(Command):
hit, res = super().check_command(
message,
session_id,
loop,
role,
platform,
message_obj

View File

@@ -15,7 +15,6 @@ class CommandRevChatGPT(Command):
def check_command(self,
message: str,
session_id: str,
loop,
role: str,
platform: str,
message_obj):
@@ -23,7 +22,6 @@ class CommandRevChatGPT(Command):
hit, res = super().check_command(
message,
session_id,
loop,
role,
platform,
message_obj

View File

@@ -13,8 +13,7 @@ class CommandRevEdgeGPT(Command):
def check_command(self,
message: str,
session_id: str,
loop,
session_id: str,
role: str,
platform: str,
message_obj):
@@ -23,7 +22,6 @@ class CommandRevEdgeGPT(Command):
hit, res = super().check_command(
message,
session_id,
loop,
role,
platform,
message_obj
@@ -32,7 +30,7 @@ class CommandRevEdgeGPT(Command):
if hit:
return True, res
if self.command_start_with(message, "reset"):
return True, self.reset(loop)
return True, self.reset()
elif self.command_start_with(message, "help"):
return True, self.help()
elif self.command_start_with(message, "update"):
@@ -40,7 +38,7 @@ class CommandRevEdgeGPT(Command):
return False, None
def reset(self, loop):
def reset(self, loop = None):
if self.provider is None:
return False, "未启动Bing语言模型.", "reset"
res = asyncio.run_coroutine_threadsafe(self.provider.forget(), loop).result()