chore: version 2.10.0

* feat: 权限验证功能

* chore: v2.10.0

* feat: 500 服务异常页面

* feat: 只有结束才会滚动到底部

* chore: 修改 CHANGELOG

* chore: 不存在时输出默认报错
This commit is contained in:
Redon
2023-03-07 22:12:15 +08:00
committed by GitHub
parent a2ffa3cb3a
commit ffd4da91cf
30 changed files with 376 additions and 60 deletions

View File

@@ -8,11 +8,14 @@ import { sendResponse } from '../utils'
import type { ApiModel, ChatContext, ChatGPTUnofficialProxyAPIOptions, ModelConfig } from '../types'
const ErrorCodeMessage: Record<string, string> = {
401: '提供错误的API密钥 | Incorrect API key provided',
429: '服务器限流,请稍后再试 | Server was limited, please try again later',
503: '服务器繁忙,请稍后再试 | Server is busy, please try again later',
500: '服务器繁忙,请稍后再试 | Server is busy, please try again later',
403: '服务器拒绝访问,请稍后再试 | Server refused to access, please try again later',
400: '[OpenAI] 模型的最大上下文长度是4096个令牌请减少信息的长度。| This model\'s maximum context length is 4096 tokens.',
401: '[OpenAI] 提供错误的API密钥 | Incorrect API key provided',
403: '[OpenAI] 服务器拒绝访问,请稍后再试 | Server refused to access, please try again later',
429: '[OpenAI] 服务器限流,请稍后再试 | Server was limited, please try again later',
502: '[OpenAI] 错误的网关 | Bad Gateway',
503: '[OpenAI] 服务器繁忙,请稍后再试 | Server is busy, please try again later',
504: '[OpenAI] 网关超时 | Gateway Time-out',
500: '[OpenAI] 服务器繁忙,请稍后再试 | Internal Server Error',
}
dotenv.config()
@@ -106,10 +109,11 @@ async function chatReplyProcess(
return sendResponse({ type: 'Success', data: response })
}
catch (error: any) {
const code = error.statusCode || 'unknown'
const code = error.statusCode
global.console.log(error)
if (Reflect.has(ErrorCodeMessage, code))
return sendResponse({ type: 'Fail', message: ErrorCodeMessage[code] })
return sendResponse({ type: 'Fail', message: `${error.statusCode}-${error.statusText}` })
return sendResponse({ type: 'Fail', message: error.message ?? 'Please check the back-end console' })
}
}