don't format messages with undefined content
| @@ -5301,6 +5301,11 @@ function formatMessageHistoryItem(chatItem, isInstruct, forceOutputSequence) { | ||
| 5301 | 5301 | const itemName = chatItem.is_user ? chatItem['name'] : characterName; |
| 5302 | 5302 | const shouldPrependName = !isNarratorType; |
| 5303 | 5303 | |
| 5304 | + // Don't format messages with undefined content | |
| 5305 | + if (chatItem.mes === undefined) { | |
| 5306 | + return "" | |
| 5307 | + } | |
| 5308 | + | |
| 5304 | 5309 | // Don't include a name if it's empty |
| 5305 | 5310 | let textResult = chatItem?.name && shouldPrependName ? `${itemName}: ${chatItem.mes}\n` : `${chatItem.mes}\n`; |
| 5306 | 5311 | |