From d6cb085c40437f9e689658c7e65b64696386a361 Mon Sep 17 00:00:00 2001 From: ikechan8370 Date: Thu, 27 Feb 2025 20:19:38 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=80=9D=E8=80=83=E8=BD=AC=E5=8F=91?= =?UTF-8?q?=EF=BC=9Bclaude=E4=B8=8A=E4=B8=8B=E6=96=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/chat.js | 2 +- model/core.js | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/apps/chat.js b/apps/chat.js index 76a522c..1a3e7ca 100644 --- a/apps/chat.js +++ b/apps/chat.js @@ -788,7 +788,7 @@ export class chatgpt extends plugin { let thinking = chatMessage.thinking_text for (let processor of postProcessors) { let output = await processor.processInner({ - text: response, thinking + text: response, thinking_text: thinking }) response = output.text thinking = output.thinking_text diff --git a/model/core.js b/model/core.js index 21c8b35..87a833c 100644 --- a/model/core.js +++ b/model/core.js @@ -262,6 +262,27 @@ class Core { system: opt.system.claude, max_tokens: Config.apiMaxToken } + if (opt.settings.enableGroupContext && e.isGroup) { + let chats = await getChatHistoryGroup(e, Config.groupContextLength) + const namePlaceholder = '[name]' + const defaultBotName = 'GeminiPro' + const groupContextTip = Config.groupContextTip + let botName = e.isGroup ? (e.group.pickMember(getUin(e)).card || e.group.pickMember(getUin(e)).nickname) : e.bot.nickname + option.system = option.system.replaceAll(namePlaceholder, botName || defaultBotName) + + ((opt.settings.enableGroupContext && e.group_id) ? groupContextTip : '') + option.system += 'Attention, you are currently chatting in a qq group, then one who asks you now is' + `${e.sender.card || e.sender.nickname}(${e.sender.user_id}).` + option.system += `the group name is ${e.group.name || e.group_name}, group id is ${e.group_id}.` + option.system += `Your nickname is ${botName} in the group,` + if (chats) { + option.system += 'There is the conversation history in the group, you must chat according to the conversation history context"' + option.system += chats + .map(chat => { + let sender = chat.sender || {} + return `【${sender.card || sender.nickname}】(qq:${sender.user_id}, ${roleMap[sender.role] || 'normal user'},${sender.area ? 'from ' + sender.area + ', ' : ''} ${sender.age} years old, 群头衔:${sender.title}, gender: ${sender.sex}, time:${formatDate(new Date(chat.time * 1000))}, messageId: ${chat.message_id}) 说:${chat.raw_message}` + }) + .join('\n') + } + } let img = await getImg(e) if (img && img.length > 0) { const response = await fetch(img[0])