mirror of
https://github.com/LiteyukiStudio/nonebot-plugin-marshoai.git
synced 2024-11-23 09:37:37 +08:00
增加对错误信息的建议解决方案
This commit is contained in:
parent
0d0cbd62f3
commit
1ad1e389a6
4
azure.py
4
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
|
||||
|
13
util.py
13
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
|
Loading…
Reference in New Issue
Block a user