#1813 Fix squash system messages

This commit is contained in:
Cohee 2024-02-11 15:56:48 +02:00
parent cbea5bf996
commit 33d93b9761
1 changed files with 6 additions and 1 deletions

View File

@ -2166,8 +2166,13 @@ class ChatCompletion {
let squashedMessages = [];
for (let message of this.messages.collection) {
// Force exclude empty messages
if (message.role === 'system' && !message.content) {
continue;
}
if (!excludeList.includes(message.identifier) && message.role === 'system' && !message.name) {
if (lastMessage && message.content && lastMessage.role === 'system') {
if (lastMessage && lastMessage.role === 'system') {
lastMessage.content += '\n' + message.content;
lastMessage.tokens = tokenHandler.count({ role: lastMessage.role, content: lastMessage.content });
}