Spaces:
Sleeping
Sleeping
Tuchuanhuhuhu
commited on
Commit
•
6a81e5d
1
Parent(s):
4d6c637
feat: 对常见报错提供更友好的错误信息
Browse files- modules/models/base_model.py +1 -1
- modules/utils.py +10 -1
modules/models/base_model.py
CHANGED
@@ -465,7 +465,7 @@ class BaseLLMModel:
|
|
465 |
yield chatbot, status_text
|
466 |
except Exception as e:
|
467 |
traceback.print_exc()
|
468 |
-
status_text = STANDARD_ERROR_MSG + str(e)
|
469 |
yield chatbot, status_text
|
470 |
|
471 |
if len(self.history) > 1 and self.history[-1]["content"] != inputs:
|
|
|
465 |
yield chatbot, status_text
|
466 |
except Exception as e:
|
467 |
traceback.print_exc()
|
468 |
+
status_text = STANDARD_ERROR_MSG + beautify_err_msg(str(e))
|
469 |
yield chatbot, status_text
|
470 |
|
471 |
if len(self.history) > 1 and self.history[-1]["content"] != inputs:
|
modules/utils.py
CHANGED
@@ -5,7 +5,7 @@ import logging
|
|
5 |
import json
|
6 |
import os
|
7 |
import datetime
|
8 |
-
from datetime import timezone
|
9 |
import hashlib
|
10 |
import csv
|
11 |
import requests
|
@@ -706,3 +706,12 @@ def get_history_filepath(username):
|
|
706 |
|
707 |
latest_file = os.path.join(dirname, latest_file)
|
708 |
return latest_file
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
import json
|
6 |
import os
|
7 |
import datetime
|
8 |
+
from datetime import timezone
|
9 |
import hashlib
|
10 |
import csv
|
11 |
import requests
|
|
|
706 |
|
707 |
latest_file = os.path.join(dirname, latest_file)
|
708 |
return latest_file
|
709 |
+
|
710 |
+
def beautify_err_msg(err_msg):
|
711 |
+
if "insufficient_quota" in err_msg:
|
712 |
+
return i18n("剩余配额不足,[进一步了解](https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98#you-exceeded-your-current-quota-please-check-your-plan-and-billing-details)")
|
713 |
+
if "The model: gpt-4 does not exist" in err_msg:
|
714 |
+
return i18n("你没有权限访问 GPT4,[进一步了解](https://github.com/GaiZhenbiao/ChuanhuChatGPT/issues/843)")
|
715 |
+
if "Resource not found" in err_msg:
|
716 |
+
return i18n("请查看 config_example.json,配置 Azure OpenAI")
|
717 |
+
return err_msg
|