mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-18 06:17:06 +00:00
修复引用转发,默认bing模式并发
This commit is contained in:
parent
54cdded6c0
commit
fd1b2d7c54
2 changed files with 28 additions and 27 deletions
53
apps/chat.js
53
apps/chat.js
|
|
@ -201,32 +201,33 @@ export class chatgpt extends plugin {
|
|||
return false
|
||||
}
|
||||
}
|
||||
|
||||
let randomId = uuid()
|
||||
// 队列队尾插入,开始排队
|
||||
await redis.rPush('CHATGPT:CHAT_QUEUE', [randomId])
|
||||
let confirm = await redis.get('CHATGPT:CONFIRM')
|
||||
let confirmOn = confirm === 'on'
|
||||
if (await redis.lIndex('CHATGPT:CHAT_QUEUE', 0) === randomId) {
|
||||
if (confirmOn) {
|
||||
await this.reply('我正在思考如何回复你,请稍等', true, { recallMsg: 8 })
|
||||
}
|
||||
} else {
|
||||
if (confirmOn) {
|
||||
let length = await redis.lLen('CHATGPT:CHAT_QUEUE') - 1
|
||||
await this.reply(`我正在思考如何回复你,请稍等,当前队列前方还有${length}个问题`, true, { recallMsg: 8 })
|
||||
logger.info(`chatgpt队列前方还有${length}个问题。管理员可通过#清空队列来强制清除所有等待的问题。`)
|
||||
}
|
||||
// 开始排队
|
||||
while (true) {
|
||||
if (await redis.lIndex('CHATGPT:CHAT_QUEUE', 0) === randomId) {
|
||||
break
|
||||
} else {
|
||||
await delay(1500)
|
||||
const use = await redis.get('CHATGPT:USE')
|
||||
if (use != 'bing') {
|
||||
let randomId = uuid()
|
||||
// 队列队尾插入,开始排队
|
||||
await redis.rPush('CHATGPT:CHAT_QUEUE', [randomId])
|
||||
let confirm = await redis.get('CHATGPT:CONFIRM')
|
||||
let confirmOn = confirm === 'on'
|
||||
if (await redis.lIndex('CHATGPT:CHAT_QUEUE', 0) === randomId) {
|
||||
if (confirmOn) {
|
||||
await this.reply('我正在思考如何回复你,请稍等', true, { recallMsg: 8 })
|
||||
}
|
||||
} else {
|
||||
if (confirmOn) {
|
||||
let length = await redis.lLen('CHATGPT:CHAT_QUEUE') - 1
|
||||
await this.reply(`我正在思考如何回复你,请稍等,当前队列前方还有${length}个问题`, true, { recallMsg: 8 })
|
||||
logger.info(`chatgpt队列前方还有${length}个问题。管理员可通过#清空队列来强制清除所有等待的问题。`)
|
||||
}
|
||||
// 开始排队
|
||||
while (true) {
|
||||
if (await redis.lIndex('CHATGPT:CHAT_QUEUE', 0) === randomId) {
|
||||
break
|
||||
} else {
|
||||
await delay(1500)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
logger.info(`chatgpt prompt: ${prompt}`)
|
||||
// try {
|
||||
// await this.chatGPTApi.init()
|
||||
|
|
@ -254,7 +255,6 @@ export class chatgpt extends plugin {
|
|||
conversationSignature: previousConversation.conversationSignature
|
||||
}
|
||||
}
|
||||
const use = await redis.get('CHATGPT:USE')
|
||||
try {
|
||||
if (Config.debug) {
|
||||
logger.mark(conversation)
|
||||
|
|
@ -331,10 +331,11 @@ export class chatgpt extends plugin {
|
|||
if (chatMessage?.quote) {
|
||||
let quotemessage = []
|
||||
chatMessage.quote.forEach(function (item, index) {
|
||||
if (item) {
|
||||
if (item != '') {
|
||||
quotemessage.push(`${item}\n`)
|
||||
}
|
||||
})
|
||||
if(quotemessage.length > 0)
|
||||
this.reply(await makeForwardMsg(this.e, quotemessage))
|
||||
}
|
||||
}
|
||||
|
|
@ -422,7 +423,7 @@ export class chatgpt extends plugin {
|
|||
response.response = response.response.replace(/\[\^[0-9]+\^\]/g, (str) => {
|
||||
return str.replace(/[/^]/g, '')
|
||||
})
|
||||
response.quote = response.details.adaptiveCards?.[0]?.body?.[0]?.text?.trim().replace(/\[\^[0-9]+\^\]/g, '').replace(response.response, '').split('\n')
|
||||
response.quote = response.details.adaptiveCards?.[0]?.body?.[0]?.text?.replace(/\[\^[0-9]+\^\]/g, '').replace(response.response, '').split('\n')
|
||||
}
|
||||
} catch (error) {
|
||||
const code = error?.data?.code || 503
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ export const Config = {
|
|||
proxy: PROXY,
|
||||
debug: false,
|
||||
// 各个地方的默认超时时间
|
||||
defaultTimeoutMs: 12000,
|
||||
defaultTimeoutMs: 1000 * 60 * 2,
|
||||
// 浏览器默认超时,浏览器可能需要更高的超时时间
|
||||
chromeTimeoutMS: 120000
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue