From a6e15dc4d86c04fc839b0ba8789334b5b25705ba Mon Sep 17 00:00:00 2001 From: weaigc <879821485@qq.com> Date: Sat, 25 Nov 2023 14:46:07 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=B6=85=E6=97=B6?= =?UTF-8?q?=E5=B1=95=E7=A4=BA=E4=B8=8D=E5=BF=85=E8=A6=81=E7=9A=84=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lib/bots/bing/index.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/lib/bots/bing/index.ts b/src/lib/bots/bing/index.ts index 06ecabba..07cd945e 100644 --- a/src/lib/bots/bing/index.ts +++ b/src/lib/bots/bing/index.ts @@ -363,10 +363,11 @@ export class BingWebBot { return e }) const conversation = this.conversationContext! + const originalInvocationId = conversation.invocationId conversation.invocationId++ if (response.status !== 200) { - conversation.invocationId-- + conversation.invocationId = originalInvocationId params.onEvent({ type: 'ERROR', error: new ChatError( @@ -388,10 +389,11 @@ export class BingWebBot { }) const textDecoder = createChunkDecoder() - let t const timeout = () => { + try { + abortController.abort('timeout') + } catch (e) {} if (params.options.retryCount??0 > 5) { - conversation.invocationId-- params.onEvent({ type: 'ERROR', error: new ChatError( @@ -400,10 +402,12 @@ export class BingWebBot { ), }) } else { + conversation.invocationId = originalInvocationId params.options.retryCount = (params.options.retryCount ?? 0) + 1 this.sydneyProxy(params) } } + let t = setTimeout(timeout, 6000) for await (const chunk of streamAsyncIterable(response.body!)) { clearTimeout(t) t = setTimeout(timeout, 6000)