Skip to content

Commit

Permalink
update for chatgpt3.5 web (#562, #551#issuecomment-1803668105, #543#i…
Browse files Browse the repository at this point in the history
…ssuecomment-1803666487)
  • Loading branch information
josStorer committed Nov 12, 2023
1 parent e82f62e commit 946cadc
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/services/apis/chatgpt-web.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -84,28 +84,28 @@ export async function generateAnswersWithChatgptWebApi(port, question, session,
})
.join('; ')

if (!config.chatgptArkoseReqUrl)
const needArkoseToken = !usedModel.includes(Models[chatgptWebModelKeys[0]].value)
if (needArkoseToken && !config.chatgptArkoseReqUrl)
throw new Error(
t('Please login at https://chat.openai.com first') +
'\n\n' +
t(
"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.",
),
)
const arkoseToken = await fetch(
config.chatgptArkoseReqUrl + '?' + config.chatgptArkoseReqParams,
{
method: 'POST',
body: config.chatgptArkoseReqForm,
headers: {
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
},
},
)
.then((resp) => resp.json())
.then((resp) => resp.token)
.catch(() => null)
if (!arkoseToken)
const arkoseToken = config.chatgptArkoseReqUrl
? await fetch(config.chatgptArkoseReqUrl + '?' + config.chatgptArkoseReqParams, {
method: 'POST',
body: config.chatgptArkoseReqForm,
headers: {
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
},
})
.then((resp) => resp.json())
.then((resp) => resp.token)
.catch(() => null)
: null
if (needArkoseToken && !arkoseToken)
throw new Error(
t('Failed to get arkose token.') +
'\n\n' +
Expand Down

0 comments on commit 946cadc

Please sign in to comment.