mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-17 13:57:10 +00:00
fix: 修复API和API3模式连续对话失效的bug
This commit is contained in:
parent
55910dda96
commit
9910e5d825
2 changed files with 11 additions and 5 deletions
14
apps/chat.js
14
apps/chat.js
|
|
@ -168,7 +168,7 @@ export class chatgpt extends plugin {
|
||||||
}
|
}
|
||||||
let Keyv
|
let Keyv
|
||||||
try {
|
try {
|
||||||
Keyv = await import('keyv').default
|
Keyv = await import('keyv').Keyv
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
await this.reply('依赖keyv未安装,请执行pnpm install keyv', true)
|
await this.reply('依赖keyv未安装,请执行pnpm install keyv', true)
|
||||||
}
|
}
|
||||||
|
|
@ -481,6 +481,10 @@ export class chatgpt extends plugin {
|
||||||
// await redis.set(`CHATGPT:CONVERSATIONS:${e.sender.user_id}`, JSON.stringify(previousConversation), { EX: CONVERSATION_PRESERVE_TIME })
|
// await redis.set(`CHATGPT:CONVERSATIONS:${e.sender.user_id}`, JSON.stringify(previousConversation), { EX: CONVERSATION_PRESERVE_TIME })
|
||||||
} else {
|
} else {
|
||||||
previousConversation = JSON.parse(previousConversation)
|
previousConversation = JSON.parse(previousConversation)
|
||||||
|
if (Config.debug) {
|
||||||
|
logger.info({ previousConversation })
|
||||||
|
}
|
||||||
|
|
||||||
conversation = {
|
conversation = {
|
||||||
conversationId: previousConversation.conversation.conversationId,
|
conversationId: previousConversation.conversation.conversationId,
|
||||||
parentMessageId: previousConversation.parentMessageId,
|
parentMessageId: previousConversation.parentMessageId,
|
||||||
|
|
@ -493,7 +497,7 @@ export class chatgpt extends plugin {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (Config.debug) {
|
if (Config.debug) {
|
||||||
logger.mark(conversation)
|
logger.mark({ conversation })
|
||||||
}
|
}
|
||||||
let chatMessage = await this.sendMessage(prompt, conversation, use, e)
|
let chatMessage = await this.sendMessage(prompt, conversation, use, e)
|
||||||
if (use !== 'api3') {
|
if (use !== 'api3') {
|
||||||
|
|
@ -507,9 +511,11 @@ export class chatgpt extends plugin {
|
||||||
previousConversation.conversationSignature = chatMessage.conversationSignature
|
previousConversation.conversationSignature = chatMessage.conversationSignature
|
||||||
} else {
|
} else {
|
||||||
// 或许这样切换回来不会404?
|
// 或许这样切换回来不会404?
|
||||||
previousConversation.conversation.parentMessageId = chatMessage.id
|
previousConversation.parentMessageId = chatMessage.id
|
||||||
|
}
|
||||||
|
if (Config.debug) {
|
||||||
|
logger.info(chatMessage)
|
||||||
}
|
}
|
||||||
console.log(chatMessage)
|
|
||||||
previousConversation.num = previousConversation.num + 1
|
previousConversation.num = previousConversation.num + 1
|
||||||
await redis.set(`CHATGPT:CONVERSATIONS:${e.sender.user_id}`, JSON.stringify(previousConversation), Config.conversationPreserveTime > 0 ? { EX: Config.conversationPreserveTime } : {})
|
await redis.set(`CHATGPT:CONVERSATIONS:${e.sender.user_id}`, JSON.stringify(previousConversation), Config.conversationPreserveTime > 0 ? { EX: Config.conversationPreserveTime } : {})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ const defaultConfig = {
|
||||||
debug: true,
|
debug: true,
|
||||||
defaultTimeoutMs: 120000,
|
defaultTimeoutMs: 120000,
|
||||||
chromeTimeoutMS: 120000,
|
chromeTimeoutMS: 120000,
|
||||||
version: 'v2.0.13'
|
version: 'v2.0.14'
|
||||||
}
|
}
|
||||||
const _path = process.cwd()
|
const _path = process.cwd()
|
||||||
let config = {}
|
let config = {}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue