diff --git a/public/script.js b/public/script.js index 3c0a5529d..aaa2040c1 100644 --- a/public/script.js +++ b/public/script.js @@ -4470,18 +4470,24 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro for (let i = coreChat.length - 1; i >= 0; i--) { const depth = coreChat.length - i - (isContinue ? 2 : 1); const isPrefix = isContinue && i === coreChat.length - 1; + + // In group chats, only include reasoning from the currently generating character + const isOtherGroupMember = selected_group && coreChat[i].name !== name2; + coreChat[i] = { ...coreChat[i], - mes: promptReasoning.addToMessage( - coreChat[i].mes, - getRegexedString( - String(coreChat[i].extra?.reasoning ?? ''), - regex_placement.REASONING, - { isPrompt: true, depth: depth }, + mes: isOtherGroupMember + ? coreChat[i].mes + : promptReasoning.addToMessage( + coreChat[i].mes, + getRegexedString( + String(coreChat[i].extra?.reasoning ?? ''), + regex_placement.REASONING, + { isPrompt: true, depth: depth }, + ), + isPrefix, + coreChat[i].extra?.reasoning_duration, ), - isPrefix, - coreChat[i].extra?.reasoning_duration, - ), }; if (promptReasoning.isLimitReached()) { break; diff --git a/public/scripts/openai.js b/public/scripts/openai.js index dda588fa2..fdba275f3 100644 --- a/public/scripts/openai.js +++ b/public/scripts/openai.js @@ -604,8 +604,10 @@ function setOpenAIMessages(chat) { const originApi = chat[j]?.extra?.api; const originModel = chat[j]?.extra?.model; const isSameModel = originApi === currentApi && originModel === currentModel; - const signature = isSameModel ? chat[j]?.extra?.reasoning_signature : null; - const reasoning = isSameModel ? String(chat[j]?.extra?.reasoning ?? '') : ''; + // In group chats, only include reasoning from the currently generating character + const isOtherGroupMember = selected_group && chat[j].name !== name2; + const signature = isSameModel && !isOtherGroupMember ? chat[j]?.extra?.reasoning_signature : null; + const reasoning = isSameModel && !isOtherGroupMember ? String(chat[j]?.extra?.reasoning ?? '') : ''; // Remove reasoning metadata from invocations if the API/model don't match if (Array.isArray(invocations) && invocations.length > 0) {