Skip to content

Commit

Permalink
fix: sydney和自定义的无限续杯
Browse files Browse the repository at this point in the history
  • Loading branch information
ikechan8370 committed Mar 28, 2023
1 parent 4b93b5e commit 192beb2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
14 changes: 12 additions & 2 deletions utils/SydneyAIClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: '你好,你是谁?',
Expand Down Expand Up @@ -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'
Expand All @@ -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
}
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion utils/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand Down

0 comments on commit 192beb2

Please sign in to comment.