feat: 知识库对外api
This commit is contained in:
@@ -7,7 +7,8 @@ export const openaiError: Record<string, string> = {
|
||||
'Bad Gateway': '网关异常,请重试'
|
||||
};
|
||||
export const openaiError2: Record<string, string> = {
|
||||
insufficient_quota: 'API 余额不足'
|
||||
insufficient_quota: 'API 余额不足',
|
||||
invalid_request_error: '输入参数异常'
|
||||
};
|
||||
export const proxyError: Record<string, boolean> = {
|
||||
ECONNABORTED: true,
|
||||
|
||||
@@ -25,8 +25,11 @@ export const jsonRes = <T = any>(
|
||||
msg = error;
|
||||
} else if (proxyError[error?.code]) {
|
||||
msg = '服务器代理出错';
|
||||
} else if (openaiError2[error?.response?.data?.error?.type]) {
|
||||
msg = openaiError2[error?.response?.data?.error?.type];
|
||||
} else if (error?.response?.data?.error) {
|
||||
msg =
|
||||
openaiError2[error?.response?.data?.error?.type] ||
|
||||
error?.response?.data?.error?.message ||
|
||||
'openai 错误';
|
||||
} else if (openaiError[error?.response?.statusText]) {
|
||||
msg = openaiError[error.response.statusText];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user