Skip to content

Commit 946cadc

Browse files
committed
update for chatgpt3.5 web (#562, #551#issuecomment-1803668105, #543#issuecomment-1803666487)
1 parent e82f62e commit 946cadc

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

src/services/apis/chatgpt-web.mjs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -84,28 +84,28 @@ export async function generateAnswersWithChatgptWebApi(port, question, session,
8484
})
8585
.join('; ')
8686

87-
if (!config.chatgptArkoseReqUrl)
87+
const needArkoseToken = !usedModel.includes(Models[chatgptWebModelKeys[0]].value)
88+
if (needArkoseToken && !config.chatgptArkoseReqUrl)
8889
throw new Error(
8990
t('Please login at https://chat.openai.com first') +
9091
'\n\n' +
9192
t(
9293
"Please keep https://chat.openai.com open and try again. If it still doesn't work, type some characters in the input box of chatgpt web page and try again.",
9394
),
9495
)
95-
const arkoseToken = await fetch(
96-
config.chatgptArkoseReqUrl + '?' + config.chatgptArkoseReqParams,
97-
{
98-
method: 'POST',
99-
body: config.chatgptArkoseReqForm,
100-
headers: {
101-
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
102-
},
103-
},
104-
)
105-
.then((resp) => resp.json())
106-
.then((resp) => resp.token)
107-
.catch(() => null)
108-
if (!arkoseToken)
96+
const arkoseToken = config.chatgptArkoseReqUrl
97+
? await fetch(config.chatgptArkoseReqUrl + '?' + config.chatgptArkoseReqParams, {
98+
method: 'POST',
99+
body: config.chatgptArkoseReqForm,
100+
headers: {
101+
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
102+
},
103+
})
104+
.then((resp) => resp.json())
105+
.then((resp) => resp.token)
106+
.catch(() => null)
107+
: null
108+
if (needArkoseToken && !arkoseToken)
109109
throw new Error(
110110
t('Failed to get arkose token.') +
111111
'\n\n' +

0 commit comments

Comments
 (0)