mirror of
https://github.com/wassname/chatGPTBox.git
synced 2026-07-09 15:34:50 +08:00
chore: update bing client and improve error messages (#337)
This commit is contained in:
@@ -118,5 +118,8 @@
|
||||
"Close All Chats In This Page": "Close All Chats In This Page",
|
||||
"When Icon Clicked": "When Icon Clicked",
|
||||
"Open Settings": "Open Settings",
|
||||
"Focus to input box after answering": "Focus to input box after answering"
|
||||
"Focus to input box after answering": "Focus to input box after answering",
|
||||
"Bing CaptchaChallenge": "You must pass Bing's verification. Please go to https://www.bing.com/search?q=Bing+AI&showconv=1&FORM=hpcodx and send a message",
|
||||
"Exceeded quota": "You exceeded your current quota, check https://platform.openai.com/account/usage",
|
||||
"Rate limit": "Rate limit exceeded"
|
||||
}
|
||||
|
||||
@@ -118,5 +118,8 @@
|
||||
"Close All Chats In This Page": "关闭本页所有聊天",
|
||||
"When Icon Clicked": "当图标被点击时",
|
||||
"Open Settings": "打开设置",
|
||||
"Focus to input box after answering": "回答结束后自动聚焦到输入框"
|
||||
"Focus to input box after answering": "回答结束后自动聚焦到输入框",
|
||||
"Bing CaptchaChallenge": "你必须通过必应的验证, 打开 https://www.bing.com/search?q=Bing+AI&showconv=1&FORM=hpcodx 并发送一条消息",
|
||||
"Exceeded quota": "余额不足或过期, 检查此链接: https://platform.openai.com/account/usage",
|
||||
"Rate limit": "请求频率过高"
|
||||
}
|
||||
|
||||
@@ -118,5 +118,8 @@
|
||||
"Close All Chats In This Page": "關閉本頁所有對話",
|
||||
"When Icon Clicked": "當圖示被點擊時",
|
||||
"Open Settings": "開啟設定",
|
||||
"Focus to input box after answering": "回答結束後自動聚焦到輸入框"
|
||||
"Focus to input box after answering": "回答結束後自動聚焦到輸入框",
|
||||
"Bing CaptchaChallenge": "妳必須通過必應的驗證, 打開 https://www.bing.com/search?q=Bing+AI&showconv=1&FORM=hpcodx 並發送壹條消息",
|
||||
"Exceeded quota": "余額不足或過期, 檢查此網址: https://platform.openai.com/account/usage",
|
||||
"Rate limit": "請求頻率過高"
|
||||
}
|
||||
|
||||
@@ -234,6 +234,7 @@ export default class BingAIClient {
|
||||
author: 'system',
|
||||
},
|
||||
...previousCachedMessages,
|
||||
// We still need this to avoid repeating introduction in some cases
|
||||
{
|
||||
text: message,
|
||||
author: 'user',
|
||||
@@ -241,13 +242,6 @@ export default class BingAIClient {
|
||||
]
|
||||
: undefined
|
||||
|
||||
if (context) {
|
||||
previousMessages.push({
|
||||
text: context,
|
||||
author: 'context', // not a real/valid author, we're just piggybacking on the existing logic
|
||||
})
|
||||
}
|
||||
|
||||
// prepare messages for prompt injection
|
||||
previousMessagesFormatted = previousMessages
|
||||
?.map((previousMessage) => {
|
||||
@@ -257,14 +251,16 @@ export default class BingAIClient {
|
||||
case 'bot':
|
||||
return `[assistant](#message)\n${previousMessage.text}`
|
||||
case 'system':
|
||||
return `N/A\n\n[system](#additional_instructions)\n- ${previousMessage.text}`
|
||||
case 'context':
|
||||
return `[user](#context)\n${previousMessage.text}`
|
||||
return `[system](#additional_instructions)\n${previousMessage.text}`
|
||||
default:
|
||||
throw new Error(`Unknown message author: ${previousMessage.author}`)
|
||||
}
|
||||
})
|
||||
.join('\n\n')
|
||||
|
||||
if (context) {
|
||||
previousMessagesFormatted = `${context}\n\n${previousMessagesFormatted}`
|
||||
}
|
||||
}
|
||||
|
||||
const userMessage = {
|
||||
@@ -313,13 +309,14 @@ export default class BingAIClient {
|
||||
'cricinfo',
|
||||
'cricinfov2',
|
||||
'dv3sugg',
|
||||
'nojbfedge',
|
||||
],
|
||||
sliceIds: ['222dtappid', '225cricinfo', '224locals0'],
|
||||
traceId: genRanHex(32),
|
||||
isStartOfSession: invocationId === 0,
|
||||
message: {
|
||||
author: 'user',
|
||||
text: jailbreakConversationId ? '' : message,
|
||||
text: message,
|
||||
messageType: jailbreakConversationId ? 'SearchQuery' : 'Chat',
|
||||
},
|
||||
conversationSignature,
|
||||
|
||||
@@ -55,7 +55,13 @@ export function registerPortListener(executor) {
|
||||
err.message.includes(m),
|
||||
)
|
||||
)
|
||||
port.postMessage({ error: t('Exceeded maximum context length') + '\n' + err.message })
|
||||
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 port.postMessage({ error: err.message })
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user