增加对错误信息的建议解决方案

This commit is contained in:
Asankilp 2024-10-01 00:30:03 +08:00
parent 0d0cbd62f3
commit 1ad1e389a6
2 changed files with 15 additions and 2 deletions

View File

@ -33,7 +33,7 @@ nekocmd = on_alconna(
) )
model_name = config.marshoai_default_model model_name = config.marshoai_default_model
context = MarshoContext() context = MarshoContext()
context_limit = 15 context_limit = 50
@ -140,7 +140,7 @@ async def neko(
#await UniMessage(f""" 剩余token{remaining_tokens}""" #await UniMessage(f""" 剩余token{remaining_tokens}"""
# ).send() # ).send()
except Exception as e: except Exception as e:
await UniMessage(str(e)).send() await UniMessage(str(e)+suggest_solution(str(e))).send()
# await UniMessage(str(e.reason)).send() # await UniMessage(str(e.reason)).send()
traceback.print_exc() traceback.print_exc()
return return

13
util.py
View File

@ -64,3 +64,16 @@ def get_prompt():
marsho_prompt = config.marshoai_prompt marsho_prompt = config.marshoai_prompt
spell = SystemMessage(content=marsho_prompt+prompts) spell = SystemMessage(content=marsho_prompt+prompts)
return spell 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