mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-16 13:27:08 +00:00
fix: 修复sydney 502错误未被catch到的问题
This commit is contained in:
parent
7df0a3eb10
commit
85809385c8
2 changed files with 10 additions and 19 deletions
|
|
@ -122,26 +122,16 @@ export default class SydneyAIClient {
|
|||
async createWebSocketConnection () {
|
||||
await this.initCache()
|
||||
let WebSocket = await getWebSocket()
|
||||
return new Promise((resolve) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
let agent
|
||||
if (this.opts.proxy) {
|
||||
agent = new HttpsProxyAgent(this.opts.proxy)
|
||||
}
|
||||
let retryTimes = 3
|
||||
let ws
|
||||
do {
|
||||
try {
|
||||
ws = new WebSocket('wss://sydney.bing.com/sydney/ChatHub', { agent })
|
||||
break
|
||||
} catch (err) {
|
||||
logger.warn(err)
|
||||
retryTimes--
|
||||
if (retryTimes === 0) {
|
||||
throw new Error(err)
|
||||
}
|
||||
}
|
||||
} while (retryTimes > 0)
|
||||
ws.on('error', console.error)
|
||||
let ws = new WebSocket('wss://sydney.bing.com/sydney/ChatHub', { agent })
|
||||
|
||||
ws.on('error', (err) => {
|
||||
reject(err)
|
||||
})
|
||||
|
||||
ws.on('open', () => {
|
||||
if (this.debug) {
|
||||
|
|
@ -410,6 +400,7 @@ export default class SydneyAIClient {
|
|||
const event = events[0]
|
||||
switch (event.type) {
|
||||
case 1: {
|
||||
// reject(new Error('test'))
|
||||
if (stopTokenFound || apology) {
|
||||
return
|
||||
}
|
||||
|
|
@ -472,8 +463,8 @@ export default class SydneyAIClient {
|
|||
}
|
||||
const messages = event.item?.messages || []
|
||||
const message = messages.length
|
||||
? messages[messages.length - 1]
|
||||
: {
|
||||
? messages[messages.length - 1]
|
||||
: {
|
||||
adaptiveCards: [
|
||||
{
|
||||
body: [
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ const defaultConfig = {
|
|||
noiseScaleW: 0.668,
|
||||
lengthScale: 1.2,
|
||||
initiativeChatGroups: [],
|
||||
version: 'v2.1.2'
|
||||
version: 'v2.1.3'
|
||||
}
|
||||
const _path = process.cwd()
|
||||
let config = {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue