From 9910e5d825fc7e13db1b9bb4739235788467fe6b Mon Sep 17 00:00:00 2001 From: ikechan8370 Date: Sat, 4 Mar 2023 11:07:50 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8DAPI=E5=92=8CAPI3?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E8=BF=9E=E7=BB=AD=E5=AF=B9=E8=AF=9D=E5=A4=B1?= =?UTF-8?q?=E6=95=88=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/chat.js | 14 ++++++++++---- utils/config.js | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/apps/chat.js b/apps/chat.js index d7ddcec5..07fb41e1 100644 --- a/apps/chat.js +++ b/apps/chat.js @@ -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) } @@ -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, @@ -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') { @@ -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 } : {}) } diff --git a/utils/config.js b/utils/config.js index 3ffae49f..95b014c3 100644 --- a/utils/config.js +++ b/utils/config.js @@ -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 = {}