From 1ad1e389a634604013b00d64ab74384f6c4c6b17 Mon Sep 17 00:00:00 2001 From: Asankilp Date: Tue, 1 Oct 2024 00:30:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AF=B9=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E7=9A=84=E5=BB=BA=E8=AE=AE=E8=A7=A3=E5=86=B3?= =?UTF-8?q?=E6=96=B9=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- azure.py | 4 ++-- util.py | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/azure.py b/azure.py index 12e0524..d0c7dda 100644 --- a/azure.py +++ b/azure.py @@ -33,7 +33,7 @@ nekocmd = on_alconna( ) model_name = config.marshoai_default_model context = MarshoContext() -context_limit = 15 +context_limit = 50 @@ -140,7 +140,7 @@ async def neko( #await UniMessage(f""" 剩余token:{remaining_tokens}""" # ).send() except Exception as e: - await UniMessage(str(e)).send() + await UniMessage(str(e)+suggest_solution(str(e))).send() # await UniMessage(str(e.reason)).send() traceback.print_exc() return diff --git a/util.py b/util.py index 8d441c9..c8e93b9 100644 --- a/util.py +++ b/util.py @@ -64,3 +64,16 @@ def get_prompt(): marsho_prompt = config.marshoai_prompt spell = SystemMessage(content=marsho_prompt+prompts) return spell + +def suggest_solution(errinfo: str): + suggestion = "" + if "content_filter" in errinfo: + suggestion = "消息已被内容过滤器过滤。请调整聊天内容后重试。" + elif "RateLimitReached" in errinfo: + suggestion = "模型达到调用速率限制。请稍等一段时间或联系Bot管理员。" + elif "tokens_limit_reached" in errinfo: + suggestion = "请求token达到上限。请重置上下文。" + if suggestion != "": + return "\n"+suggestion + else: + return suggestion \ No newline at end of file