diff --git a/utils/SydneyAIClient.js b/utils/SydneyAIClient.js index 883bd55..8dd7a6a 100644 --- a/utils/SydneyAIClient.js +++ b/utils/SydneyAIClient.js @@ -257,6 +257,13 @@ export default class SydneyAIClient { author: message.role === 'User' ? 'user' : 'bot' } }) + let pm = [] + previousCachedMessages.reverse().forEach(m => { + if (pm.filter(m => m.author === 'user').length < Config.maxNumUserMessagesInConversation - 1) { + pm.push(m) + } + }) + pm = pm.reverse() // const hello = [ // { // text: '你好,你是谁?', @@ -286,7 +293,7 @@ export default class SydneyAIClient { author: 'bot' }, // ...(Config.sydneyBrainWash ? Array.from({ length: Math.max(1, Config.sydneyBrainWashStrength - Math.floor(previousCachedMessages.length / 2)) }, () => [...hello]).flat() : []), - ...previousCachedMessages, + ...pm, { text: message, author: 'user' @@ -306,7 +313,7 @@ export default class SydneyAIClient { }, // ...(Config.sydneyBrainWash ? Array.from({ length: Math.max(1, Config.sydneyBrainWashStrength - Math.floor(previousCachedMessages.length / 2)) }, () => [...hello]).flat() : []), // ...groupId ? groupRecord : [], - ...previousCachedMessages + ...pm ] : undefined } @@ -511,6 +518,9 @@ export default class SydneyAIClient { } const messages = event?.arguments?.[0]?.messages if (!messages?.length || messages[0].author !== 'bot') { + if (event?.arguments?.[0]?.throttling?.maxNumUserMessagesInConversation) { + Config.maxNumUserMessagesInConversation = event?.arguments?.[0]?.throttling?.maxNumUserMessagesInConversation + } return } const message = messages.length diff --git a/utils/config.js b/utils/config.js index 3782268..d32a36f 100644 --- a/utils/config.js +++ b/utils/config.js @@ -73,7 +73,8 @@ const defaultConfig = { enableGroupContext: false, groupContextLength: 50, enableRobotAt: true, - version: 'v2.4.6' + maxNumUserMessagesInConversation: 18, + version: 'v2.4.7' } const _path = process.cwd() let config = {}