add more errors parsing and fix some errors da
This commit is contained in:
1 parent
540aea2ec6
commit
b958bddcfb
3 files changed
+63
-51
No files matched your search
+12
-7
@@ -70,19 +70,19 @@ def clean_tail_repeats(text: str, max_repeat: int = 10):
|
||||
|
||||
|
||||
def parse_response(text: str):
|
||||
if "Connection error." in text:
|
||||
if "connection error." in text:
|
||||
return {
|
||||
"type": "connection",
|
||||
"message": "ошибка подключения к провайдеру. подожди или смени провайдера в настройках узбекгпт.",
|
||||
}
|
||||
elif "Model quota exceeded" in text:
|
||||
elif "model quota exceeded" in text:
|
||||
return {
|
||||
"type": "quota",
|
||||
"message": "лимит токенов закончился. подожди или смени модель.",
|
||||
}
|
||||
elif "tier capacity exceeded." in text:
|
||||
return {"type": "tier", "message": "попробуй ещё раз!"}
|
||||
elif "Internal server" in text:
|
||||
elif "internal server" in text:
|
||||
return {
|
||||
"type": "int",
|
||||
"message": "произошла ошибка на стороне провайдера. подожди или смени провайдера в настройках узбекгпт.",
|
||||
@@ -92,10 +92,15 @@ def parse_response(text: str):
|
||||
"type": "incomplete",
|
||||
"message": "сервер петух и оборвал соединение. подожди или смени провайдера в настройках узбекгпт.",
|
||||
}
|
||||
elif "invalid token" in text:
|
||||
elif "provider error" in text:
|
||||
return {
|
||||
"type": "incomplete",
|
||||
"message": "указан неверный токен. смени провайдера или модель.",
|
||||
"type": "provider",
|
||||
"message": "врат ошибка на стороне провайдера модели. смени провайдера или модель.",
|
||||
}
|
||||
elif "rate limit" in text:
|
||||
return {
|
||||
"type": "quota",
|
||||
"message": "лимит токенов закончился у провайдера врат. подожди или смени модель.",
|
||||
}
|
||||
else:
|
||||
return {
|
||||
@@ -406,7 +411,7 @@ async def openai_generate_text(
|
||||
else:
|
||||
text = completion.choices[0].message.content
|
||||
except Exception as e:
|
||||
error = parse_response(str(e))
|
||||
error = parse_response(str(e).lower())
|
||||
print(f"{RED} -- {error['type']} - {e}{RESET}")
|
||||
return error["message"]
|
||||
else:
|
||||
|
||||
Reference in new issue
Block a user