fix: squashing system messages would fail to skip example messages

This commit is contained in:
Aisu Wata 2024-04-01 01:24:29 -03:00
parent a5d00d356b
commit 41860bdc57
1 changed files with 6 additions and 2 deletions

View File

@ -2233,8 +2233,12 @@ export class ChatCompletion {
continue;
}
if (!excludeList.includes(message.identifier) && message.role === 'system' && !message.name) {
if (lastMessage && lastMessage.role === 'system') {
const shouldSquash = (message) => {
return !excludeList.includes(message.identifier) && message.role === 'system' && !message.name;
}
if (shouldSquash(message)) {
if (lastMessage && shouldSquash(lastMessage)) {
lastMessage.content += '\n' + message.content;
lastMessage.tokens = tokenHandler.count({ role: lastMessage.role, content: lastMessage.content });
}