mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-17 13:57:10 +00:00
fix: sydney 超时的bug
This commit is contained in:
parent
51abbeab3c
commit
45f7034be7
1 changed files with 49 additions and 7 deletions
|
|
@ -7,7 +7,7 @@ import crypto from 'crypto'
|
||||||
|
|
||||||
import HttpsProxyAgent from 'https-proxy-agent'
|
import HttpsProxyAgent from 'https-proxy-agent'
|
||||||
import { Config } from './config.js'
|
import { Config } from './config.js'
|
||||||
import {isCN} from "./common.js";
|
import { isCN } from './common.js'
|
||||||
|
|
||||||
if (!globalThis.fetch) {
|
if (!globalThis.fetch) {
|
||||||
globalThis.fetch = fetch
|
globalThis.fetch = fetch
|
||||||
|
|
@ -347,9 +347,16 @@ export default class SydneyAIClient {
|
||||||
const messageTimeout = setTimeout(() => {
|
const messageTimeout = setTimeout(() => {
|
||||||
this.cleanupWebSocketConnection(ws)
|
this.cleanupWebSocketConnection(ws)
|
||||||
if (replySoFar) {
|
if (replySoFar) {
|
||||||
let message = {}
|
let message = {
|
||||||
message.adaptiveCards[0].body[0].text = replySoFar
|
adaptiveCards: [
|
||||||
message.text = replySoFar
|
{
|
||||||
|
body: [
|
||||||
|
{ text: replySoFar }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
text: replySoFar
|
||||||
|
}
|
||||||
resolve({
|
resolve({
|
||||||
message
|
message
|
||||||
})
|
})
|
||||||
|
|
@ -370,8 +377,18 @@ export default class SydneyAIClient {
|
||||||
clearTimeout(firstTimeout)
|
clearTimeout(firstTimeout)
|
||||||
this.cleanupWebSocketConnection(ws)
|
this.cleanupWebSocketConnection(ws)
|
||||||
if (replySoFar) {
|
if (replySoFar) {
|
||||||
|
let message = {
|
||||||
|
adaptiveCards: [
|
||||||
|
{
|
||||||
|
body: [
|
||||||
|
{ text: replySoFar }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
text: replySoFar
|
||||||
|
}
|
||||||
resolve({
|
resolve({
|
||||||
message: replySoFar
|
message
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
reject('Request aborted')
|
reject('Request aborted')
|
||||||
|
|
@ -400,7 +417,21 @@ export default class SydneyAIClient {
|
||||||
if (!messages?.length || messages[0].author !== 'bot') {
|
if (!messages?.length || messages[0].author !== 'bot') {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const message = messages.length ? messages[messages.length - 1] : null
|
const message = messages.length
|
||||||
|
? messages[messages.length - 1]
|
||||||
|
: {
|
||||||
|
adaptiveCards: [
|
||||||
|
{
|
||||||
|
body: [
|
||||||
|
{ text: replySoFar }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
text: replySoFar
|
||||||
|
}
|
||||||
|
resolve({
|
||||||
|
message
|
||||||
|
})
|
||||||
if (messages[0].contentOrigin === 'Apology') {
|
if (messages[0].contentOrigin === 'Apology') {
|
||||||
console.log('Apology found')
|
console.log('Apology found')
|
||||||
stopTokenFound = true
|
stopTokenFound = true
|
||||||
|
|
@ -443,7 +474,18 @@ export default class SydneyAIClient {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const messages = event.item?.messages || []
|
const messages = event.item?.messages || []
|
||||||
const message = messages.length ? messages[messages.length - 1] : null
|
const message = messages.length
|
||||||
|
? messages[messages.length - 1]
|
||||||
|
: {
|
||||||
|
adaptiveCards: [
|
||||||
|
{
|
||||||
|
body: [
|
||||||
|
{ text: replySoFar }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
text: replySoFar
|
||||||
|
}
|
||||||
if (!message) {
|
if (!message) {
|
||||||
reject('No message was generated.')
|
reject('No message was generated.')
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue