feat: 尝试把20条后溢出的对话自动塞到扩展后面

This commit is contained in:
ikechan8370 2023-03-30 17:19:18 +08:00
parent 019dc5e0c3
commit 9c3d1bc5e4

View file

@ -259,9 +259,12 @@ export default class SydneyAIClient {
})
let pm = []
// 无限续杯
let exceedConversations = []
previousCachedMessages.reverse().forEach(m => {
if (pm.filter(m => m.author === 'user').length < Config.maxNumUserMessagesInConversation - 1) {
pm.push(m)
} else {
exceedConversations.push(e)
}
})
pm = pm.reverse()
@ -435,6 +438,13 @@ export default class SydneyAIClient {
if (Config.debug) {
logger.info(context)
}
if (exceedConversations.length > 0) {
context += '\nThese are some conversations records between you and I: \n'
context += exceedConversations.map(m => {
return `${m.author}: ${m.text}`
}).join('\n')
context += '\n'
}
if (context) {
obj.arguments[0].previousMessages.push({
author: 'user',