Skip to content

Commit

Permalink
fix: 修复超时展示不必要的提示信息
Browse files Browse the repository at this point in the history
  • Loading branch information
weaigc committed Nov 25, 2023
1 parent de25dcc commit a6e15dc
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/lib/bots/bing/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand All @@ -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)
Expand Down

0 comments on commit a6e15dc

Please sign in to comment.