mirror of
https://github.com/wassname/chatGPTBox.git
synced 2026-08-11 11:16:18 +08:00
improve error prompt
This commit is contained in:
@@ -45,6 +45,7 @@
|
||||
"UNAUTHORIZED": "Unbefugt",
|
||||
"Please login at https://chat.openai.com first": "Bitte zuerst bei https://chat.openai.com anmelden",
|
||||
"Please login at https://claude.ai first": "Bitte zuerst bei https://claude.ai anmelden",
|
||||
"Please login at https://bing.com first": "Bitte zuerst bei https://bing.com anmelden",
|
||||
"Then open https://chat.openai.com/api/auth/session": "Dann öffne https://chat.openai.com/api/auth/sitzung",
|
||||
"And refresh this page or type you question again": "Klicken Sie anschließend auf die Schaltfläche Wiederholen in der oberen rechten Ecke",
|
||||
"Consider creating an api key at https://platform.openai.com/account/api-keys": "Erwägen Sie ein API-Schlüssel unter https://platform.openai.com/account/api-keys zu erstellen",
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
"UNAUTHORIZED": "UNAUTHORIZED",
|
||||
"Please login at https://chat.openai.com first": "Please login at https://chat.openai.com first",
|
||||
"Please login at https://claude.ai first": "Please login at https://claude.ai first",
|
||||
"Please login at https://bing.com first": "Please login at https://bing.com first",
|
||||
"Then open https://chat.openai.com/api/auth/session": "Then open https://chat.openai.com/api/auth/session",
|
||||
"And refresh this page or type you question again": "And click the retry button in the top right corner",
|
||||
"Consider creating an api key at https://platform.openai.com/account/api-keys": "Consider creating an api key at https://platform.openai.com/account/api-keys",
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
"UNAUTHORIZED": "NO AUTORIZADO",
|
||||
"Please login at https://chat.openai.com first": "Por favor, inicie sesión en https://chat.openai.com primero",
|
||||
"Please login at https://claude.ai first": "Por favor, inicie sesión en https://claude.ai primero",
|
||||
"Please login at https://bing.com first": "Por favor, inicie sesión en https://bing.com primero",
|
||||
"Then open https://chat.openai.com/api/auth/session": "Luego abra https://chat.openai.com/api/auth/session",
|
||||
"And refresh this page or type you question again": "A continuación, pulse el botón Reintentar situado en la esquina superior derecha.",
|
||||
"Consider creating an api key at https://platform.openai.com/account/api-keys": "Considere crear una clave de API en https://platform.openai.com/account/api-keys",
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
"UNAUTHORIZED": "NON AUTORISÉ",
|
||||
"Please login at https://chat.openai.com first": "Veuillez vous connecter d'abord sur https://chat.openai.com",
|
||||
"Please login at https://claude.ai first": "Veuillez vous connecter d'abord sur https://claude.ai",
|
||||
"Please login at https://bing.com first": "Veuillez vous connecter d'abord sur https://bing.com",
|
||||
"Then open https://chat.openai.com/api/auth/session": "Puis ouvrez https://chat.openai.com/api/auth/session",
|
||||
"And refresh this page or type you question again": "Cliquez ensuite sur le bouton Réessayer dans le coin supérieur droit",
|
||||
"Consider creating an api key at https://platform.openai.com/account/api-keys": "Pensez à créer une clé API sur https://platform.openai.com/account/api-keys",
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
"UNAUTHORIZED": "TIDAK DIIZINKAN",
|
||||
"Please login at https://chat.openai.com first": "Silakan masuk di https://chat.openai.com terlebih dahulu",
|
||||
"Please login at https://claude.ai first": "Silakan masuk di https://claude.ai terlebih dahulu",
|
||||
"Please login at https://bing.com first": "Silakan masuk di https://bing.com terlebih dahulu",
|
||||
"Then open https://chat.openai.com/api/auth/session": "Lalu buka https://chat.openai.com/api/auth/session",
|
||||
"And refresh this page or type you question again": "Setelah itu klik tombol Coba Lagi di sudut kanan atas",
|
||||
"Consider creating an api key at https://platform.openai.com/account/api-keys": "Pertimbangkan untuk membuat kunci API di https://platform.openai.com/account/api-keys",
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
"UNAUTHORIZED": "Non autorizzato",
|
||||
"Please login at https://chat.openai.com first": "Effettua il login su https://chat.openai.com prima",
|
||||
"Please login at https://claude.ai first": "Effettua il login su https://claude.ai prima",
|
||||
"Please login at https://bing.com first": "Effettua il login su https://bing.com prima",
|
||||
"Then open https://chat.openai.com/api/auth/session": "Quindi apri https://chat.openai.com/api/auth/session",
|
||||
"And refresh this page or type you question again": "Quindi fare clic sul pulsante Riprova nell'angolo in alto a destra",
|
||||
"Consider creating an api key at https://platform.openai.com/account/api-keys": "Considera la creazione di una chiave API su https://platform.openai.com/account/api-keys",
|
||||
|
||||
@@ -43,8 +43,9 @@
|
||||
"Float the Window": "ウィンドウをフロート/分割表示",
|
||||
"Save Conversation": "会話を保存",
|
||||
"UNAUTHORIZED": "認証されていません",
|
||||
"Please login at https://chat.openai.com first": "最初にhttps://chat.openai.com/にログインしてください",
|
||||
"Please login at https://claude.ai first": "最初にhttps://claude.ai/にログインしてください",
|
||||
"Please login at https://chat.openai.com first": "最初に https://chat.openai.com にログインしてください",
|
||||
"Please login at https://claude.ai first": "最初に https://claude.ai にログインしてください",
|
||||
"Please login at https://bing.com first": "最初に https://bing.com にログインしてください",
|
||||
"Then open https://chat.openai.com/api/auth/session": "次にhttps://chat.openai.com/api/auth/sessionにアクセス",
|
||||
"And refresh this page or type you question again": "次に、右上の「再試行」ボタンをクリックします",
|
||||
"Consider creating an api key at https://platform.openai.com/account/api-keys": "https://platform.openai.com/account/api-keysでAPIキーを作成してください",
|
||||
|
||||
@@ -43,8 +43,9 @@
|
||||
"Float the Window": "창 띄우기",
|
||||
"Save Conversation": "대화 저장",
|
||||
"UNAUTHORIZED": "인증되지 않음",
|
||||
"Please login at https://chat.openai.com first": "https://chat.openai.com에서 로그인하세요.",
|
||||
"Please login at https://claude.ai first": "https://claude.ai에서 로그인하세요.",
|
||||
"Please login at https://chat.openai.com first": "https://chat.openai.com 에서 로그인하세요.",
|
||||
"Please login at https://claude.ai first": "https://claude.ai 에서 로그인하세요.",
|
||||
"Please login at https://bing.com first": "https://bing.com 에서 로그인하세요.",
|
||||
"Then open https://chat.openai.com/api/auth/session": "그런 다음 https://chat.openai.com/api/auth/session을 열거나 다시 질문을 입력하세요.",
|
||||
"And refresh this page or type you question again": "그런 다음 오른쪽 상단의 재시도 버튼을 클릭합니다.",
|
||||
"Consider creating an api key at https://platform.openai.com/account/api-keys": "https://platform.openai.com/account/api-keys에서 API 키를 생성하는 것을 고려하세요.",
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
"UNAUTHORIZED": "NÃO AUTORIZADO",
|
||||
"Please login at https://chat.openai.com first": "Por favor, faça login em https://chat.openai.com primeiro",
|
||||
"Please login at https://claude.ai first": "Por favor, faça login em https://claude.ai primeiro",
|
||||
"Please login at https://bing.com first": "Por favor, faça login em https://bing.com primeiro",
|
||||
"Then open https://chat.openai.com/api/auth/session": "Então, abra https://chat.openai.com/api/auth/session",
|
||||
"And refresh this page or type you question again": "Depois clique no botão Retry, no canto superior direito",
|
||||
"Consider creating an api key at https://platform.openai.com/account/api-keys": "Considere criar uma chave de API em https://platform.openai.com/account/api-keys",
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
"UNAUTHORIZED": "Несанкционированный",
|
||||
"Please login at https://chat.openai.com first": "Пожалуйста, сначала войдите на https://chat.openai.com",
|
||||
"Please login at https://claude.ai first": "Пожалуйста, сначала войдите на https://claude.ai",
|
||||
"Please login at https://bing.com first": "Пожалуйста, сначала войдите на https://bing.com",
|
||||
"Then open https://chat.openai.com/api/auth/session": "Затем откройте https://chat.openai.com/api/auth/session",
|
||||
"And refresh this page or type you question again": "После этого нажмите кнопку Retry в правом верхнем углу",
|
||||
"Consider creating an api key at https://platform.openai.com/account/api-keys": "Рассмотрите возможность создания ключа API на https://platform.openai.com/account/api-keys",
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
"UNAUTHORIZED": "Yetkilendirilmemiş",
|
||||
"Please login at https://chat.openai.com first": "Lütfen önce https://chat.openai.com adresinde oturum açın",
|
||||
"Please login at https://claude.ai first": "Lütfen önce https://claude.ai adresinde oturum açın",
|
||||
"Please login at https://bing.com first": "Lütfen önce https://bing.com adresinde oturum açın",
|
||||
"Then open https://chat.openai.com/api/auth/session": "Ardından https://chat.openai.com/api/auth/session adresini açın",
|
||||
"And refresh this page or type you question again": "Ve bu sayfayı yenileyin veya sorunuzu tekrar yazın",
|
||||
"Consider creating an api key at https://platform.openai.com/account/api-keys": "https://platform.openai.com/account/api-keys adresinde bir api anahtarı oluşturmayı düşünün",
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
"UNAUTHORIZED": "未授权",
|
||||
"Please login at https://chat.openai.com first": "请先登录 https://chat.openai.com",
|
||||
"Please login at https://claude.ai first": "请先登录 https://claude.ai",
|
||||
"Please login at https://bing.com first": "请先登录 https://bing.com",
|
||||
"Then open https://chat.openai.com/api/auth/session": "然后打开 https://chat.openai.com/api/auth/session",
|
||||
"And refresh this page or type you question again": "之后点击右上角的重试按钮",
|
||||
"Consider creating an api key at https://platform.openai.com/account/api-keys": "考虑在 https://platform.openai.com/account/api-keys 创建一个API Key",
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
"UNAUTHORIZED": "未授權",
|
||||
"Please login at https://chat.openai.com first": "請先在 https://chat.openai.com 登入",
|
||||
"Please login at https://claude.ai first": "請先在 https://claude.ai 登入",
|
||||
"Please login at https://bing.com first": "請先在 https://bing.com 登入",
|
||||
"Then open https://chat.openai.com/api/auth/session": "然後開啟 https://chat.openai.com/api/auth/session",
|
||||
"And refresh this page or type you question again": "接著點擊右上角的「重試」按鈕",
|
||||
"Consider creating an api key at https://platform.openai.com/account/api-keys": "建議在 https://platform.openai.com/account/api-keys 建立一個 API 金鑰",
|
||||
|
||||
@@ -24,6 +24,7 @@ import { v4 as uuidv4 } from 'uuid'
|
||||
import { initSession } from '../../services/init-session.mjs'
|
||||
import { findLastIndex } from 'lodash-es'
|
||||
import { generateAnswersWithBingWebApi } from '../../services/apis/bing-web.mjs'
|
||||
import { handlePortError } from '../../services/wrappers.mjs'
|
||||
|
||||
const logo = Browser.runtime.getURL('logo.png')
|
||||
|
||||
@@ -168,8 +169,11 @@ function ConversationCard(props) {
|
||||
'error',
|
||||
)
|
||||
break
|
||||
default:
|
||||
if (conversationItemData[conversationItemData.length - 1].content.includes('gpt-loading'))
|
||||
default: {
|
||||
let lastItem
|
||||
if (conversationItemData.length > 0)
|
||||
lastItem = conversationItemData[conversationItemData.length - 1]
|
||||
if (lastItem && (lastItem.content.includes('gpt-loading') || lastItem.type === 'error'))
|
||||
updateAnswer(msg.error, false, 'error')
|
||||
else
|
||||
setConversationItemData([
|
||||
@@ -177,6 +181,7 @@ function ConversationCard(props) {
|
||||
new ConversationItemData('error', msg.error),
|
||||
])
|
||||
break
|
||||
}
|
||||
}
|
||||
setIsReady(true)
|
||||
}
|
||||
@@ -212,10 +217,20 @@ function ConversationCard(props) {
|
||||
removeListener: () => {},
|
||||
},
|
||||
}
|
||||
const bingToken = (await getUserConfig()).bingAccessToken
|
||||
if (session.modelName.includes('bingFreeSydney'))
|
||||
await generateAnswersWithBingWebApi(fakePort, session.question, session, bingToken, true)
|
||||
else await generateAnswersWithBingWebApi(fakePort, session.question, session, bingToken)
|
||||
try {
|
||||
const bingToken = (await getUserConfig()).bingAccessToken
|
||||
if (session.modelName.includes('bingFreeSydney'))
|
||||
await generateAnswersWithBingWebApi(
|
||||
fakePort,
|
||||
session.question,
|
||||
session,
|
||||
bingToken,
|
||||
true,
|
||||
)
|
||||
else await generateAnswersWithBingWebApi(fakePort, session.question, session, bingToken)
|
||||
} catch (err) {
|
||||
handlePortError(session, fakePort, err)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
port.postMessage({ session, stop })
|
||||
|
||||
@@ -122,6 +122,7 @@ export default class BingAIClient {
|
||||
`${this.options.host}/turing/conversation/create?bundleVersion=1.864.15`,
|
||||
fetchOptions,
|
||||
)
|
||||
if (response.status === 403) throw new Error('403 Forbidden')
|
||||
const body = await response.text()
|
||||
try {
|
||||
const res = JSON.parse(body)
|
||||
|
||||
+43
-23
@@ -1,4 +1,5 @@
|
||||
import {
|
||||
bingWebModelKeys,
|
||||
claudeWebModelKeys,
|
||||
clearOldAccessToken,
|
||||
getUserConfig,
|
||||
@@ -50,6 +51,47 @@ export async function getClaudeSessionKey() {
|
||||
return (await Browser.cookies.get({ url: 'https://claude.ai/', name: 'sessionKey' }))?.value
|
||||
}
|
||||
|
||||
export function handlePortError(session, port, err) {
|
||||
console.error(err)
|
||||
if (err.message) {
|
||||
if (!err.message.includes('aborted')) {
|
||||
if (
|
||||
['message you submitted was too long', 'maximum context length'].some((m) =>
|
||||
err.message.includes(m),
|
||||
)
|
||||
)
|
||||
port.postMessage({ error: t('Exceeded maximum context length') + '\n\n' + err.message })
|
||||
else if (['CaptchaChallenge', 'CAPTCHA'].some((m) => err.message.includes(m)))
|
||||
port.postMessage({ error: t('Bing CaptchaChallenge') + '\n\n' + err.message })
|
||||
else if (['exceeded your current quota'].some((m) => err.message.includes(m)))
|
||||
port.postMessage({ error: t('Exceeded quota') + '\n\n' + err.message })
|
||||
else if (['Rate limit reached'].some((m) => err.message.includes(m)))
|
||||
port.postMessage({ error: t('Rate limit') + '\n\n' + err.message })
|
||||
else if (['authentication token has expired'].some((m) => err.message.includes(m)))
|
||||
port.postMessage({ error: 'UNAUTHORIZED' })
|
||||
else if (
|
||||
claudeWebModelKeys.includes(session.modelName) &&
|
||||
['Invalid authorization', 'Session key required'].some((m) => err.message.includes(m))
|
||||
)
|
||||
port.postMessage({ error: t('Please login at https://claude.ai first') })
|
||||
else if (
|
||||
// `.some` for multi mode models. e.g. bingFree4-balanced
|
||||
bingWebModelKeys.some((n) => session.modelName.includes(n)) &&
|
||||
['/turing/conversation/create: failed to parse response body.'].some((m) =>
|
||||
err.message.includes(m),
|
||||
)
|
||||
)
|
||||
port.postMessage({ error: t('Please login at https://bing.com first') })
|
||||
else port.postMessage({ error: err.message })
|
||||
}
|
||||
} else {
|
||||
const errMsg = JSON.stringify(err)
|
||||
if (bingWebModelKeys.some((n) => session.modelName.includes(n)) && errMsg.includes('isTrusted'))
|
||||
port.postMessage({ error: t('Please login at https://bing.com first') })
|
||||
else port.postMessage({ error: errMsg ?? 'unknown error' })
|
||||
}
|
||||
}
|
||||
|
||||
export function registerPortListener(executor) {
|
||||
Browser.runtime.onConnect.addListener((port) => {
|
||||
console.debug('connected')
|
||||
@@ -64,29 +106,7 @@ export function registerPortListener(executor) {
|
||||
try {
|
||||
await executor(session, port, config)
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
if (!err.message.includes('aborted')) {
|
||||
if (
|
||||
['message you submitted was too long', 'maximum context length'].some((m) =>
|
||||
err.message.includes(m),
|
||||
)
|
||||
)
|
||||
port.postMessage({ error: t('Exceeded maximum context length') + '\n\n' + err.message })
|
||||
else if (['CaptchaChallenge', 'CAPTCHA'].some((m) => err.message.includes(m)))
|
||||
port.postMessage({ error: t('Bing CaptchaChallenge') + '\n\n' + err.message })
|
||||
else if (['exceeded your current quota'].some((m) => err.message.includes(m)))
|
||||
port.postMessage({ error: t('Exceeded quota') + '\n\n' + err.message })
|
||||
else if (['Rate limit reached'].some((m) => err.message.includes(m)))
|
||||
port.postMessage({ error: t('Rate limit') + '\n\n' + err.message })
|
||||
else if (['authentication token has expired'].some((m) => err.message.includes(m)))
|
||||
port.postMessage({ error: 'UNAUTHORIZED' })
|
||||
else if (
|
||||
claudeWebModelKeys.includes(session.modelName) &&
|
||||
['Invalid authorization'].some((m) => err.message.includes(m))
|
||||
)
|
||||
port.postMessage({ error: t('Please login at https://claude.ai first') })
|
||||
else port.postMessage({ error: err.message })
|
||||
}
|
||||
handlePortError(session, port, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user