perf: code and inform

This commit is contained in:
archer
2023-07-04 21:24:32 +08:00
parent 8635de866f
commit 2a45fe520b
20 changed files with 97 additions and 163 deletions

View File

@@ -181,33 +181,13 @@ export const getApiKey = async ({
return Promise.reject(ERROR_ENUM.unAuthorization);
}
const keyMap = {
[OpenAiChatEnum.GPT35]: {
userOpenAiKey: user.openaiKey || '',
systemAuthKey: getSystemOpenAiKey()
},
[OpenAiChatEnum.GPT3516k]: {
userOpenAiKey: user.openaiKey || '',
systemAuthKey: getSystemOpenAiKey()
},
[OpenAiChatEnum.GPT4]: {
userOpenAiKey: user.openaiKey || '',
systemAuthKey: getSystemOpenAiKey()
},
[OpenAiChatEnum.GPT432k]: {
userOpenAiKey: user.openaiKey || '',
systemAuthKey: getSystemOpenAiKey()
}
};
if (!keyMap[model]) {
return Promise.reject('App model is exists');
}
const userOpenAiKey = user.openaiKey || '';
const systemAuthKey = getSystemOpenAiKey();
// 有自己的key
if (!mustPay && keyMap[model].userOpenAiKey) {
if (!mustPay && userOpenAiKey) {
return {
userOpenAiKey: keyMap[model].userOpenAiKey,
userOpenAiKey,
systemAuthKey: ''
};
}
@@ -219,7 +199,7 @@ export const getApiKey = async ({
return {
userOpenAiKey: '',
systemAuthKey: keyMap[model].systemAuthKey
systemAuthKey
};
};