From c9cb6139619c244aa998fd45346549d06a69298f Mon Sep 17 00:00:00 2001 From: josc146 Date: Sun, 24 Mar 2024 12:13:44 +0800 Subject: [PATCH] fix the error caused by the unnecessary ArkoseToken for free accounts (#661) --- src/services/apis/chatgpt-web.mjs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/services/apis/chatgpt-web.mjs b/src/services/apis/chatgpt-web.mjs index 5b3de116..3b984528 100644 --- a/src/services/apis/chatgpt-web.mjs +++ b/src/services/apis/chatgpt-web.mjs @@ -160,21 +160,22 @@ export async function generateAnswersWithChatgptWebApi(port, question, session, ) const config = await getUserConfig() - // eslint-disable-next-line no-unused-vars + let arkoseError const [models, requirementsToken, arkoseToken, useWebsocket] = await Promise.all([ - getModels(accessToken).catch(cleanController), // don't throw error here - getRequirementsToken(accessToken), - getArkoseToken(config), - isNeedWebsocket(accessToken).catch(cleanController), // don't throw error here - ]).catch((e) => { - cleanController() - throw e - }) + getModels(accessToken).catch(() => undefined), + getRequirementsToken(accessToken).catch(() => undefined), + getArkoseToken(config).catch((e) => { + arkoseError = e + }), + isNeedWebsocket(accessToken).catch(() => undefined), + ]) console.debug('models', models) const selectedModel = Models[session.modelName].value const usedModel = models && models.includes(selectedModel) ? selectedModel : Models[chatgptWebModelKeys[0]].value console.debug('usedModel', usedModel) + const needArkoseToken = !usedModel.includes(Models[chatgptWebModelKeys[0]].value) + if (arkoseError && needArkoseToken) throw arkoseError let cookie let oaiDeviceId