Skip to content

Commit

Permalink
fix: 修复API和API3模式连续对话失效的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ikechan8370 committed Mar 4, 2023
1 parent 55910dd commit 9910e5d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions apps/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export class chatgpt extends plugin {
}
let Keyv
try {
Keyv = await import('keyv').default
Keyv = await import('keyv').Keyv
} catch (err) {
await this.reply('依赖keyv未安装,请执行pnpm install keyv', true)
}
Expand Down Expand Up @@ -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 })
} else {
previousConversation = JSON.parse(previousConversation)
if (Config.debug) {
logger.info({ previousConversation })
}

conversation = {
conversationId: previousConversation.conversation.conversationId,
parentMessageId: previousConversation.parentMessageId,
Expand All @@ -493,7 +497,7 @@ export class chatgpt extends plugin {

try {
if (Config.debug) {
logger.mark(conversation)
logger.mark({ conversation })
}
let chatMessage = await this.sendMessage(prompt, conversation, use, e)
if (use !== 'api3') {
Expand All @@ -507,9 +511,11 @@ export class chatgpt extends plugin {
previousConversation.conversationSignature = chatMessage.conversationSignature
} else {
// 或许这样切换回来不会404?
previousConversation.conversation.parentMessageId = chatMessage.id
previousConversation.parentMessageId = chatMessage.id
}
if (Config.debug) {
logger.info(chatMessage)
}
console.log(chatMessage)
previousConversation.num = previousConversation.num + 1
await redis.set(`CHATGPT:CONVERSATIONS:${e.sender.user_id}`, JSON.stringify(previousConversation), Config.conversationPreserveTime > 0 ? { EX: Config.conversationPreserveTime } : {})
}
Expand Down
2 changes: 1 addition & 1 deletion utils/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const defaultConfig = {
debug: true,
defaultTimeoutMs: 120000,
chromeTimeoutMS: 120000,
version: 'v2.0.13'
version: 'v2.0.14'
}
const _path = process.cwd()
let config = {}
Expand Down

0 comments on commit 9910e5d

Please sign in to comment.