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