diff --git a/src/lib/Others/HypaV3Modal.svelte b/src/lib/Others/HypaV3Modal.svelte index 717f6fd5..3ac09afd 100644 --- a/src/lib/Others/HypaV3Modal.svelte +++ b/src/lib/Others/HypaV3Modal.svelte @@ -232,7 +232,7 @@ }; } - function getNextMessageToSummarize(): Message { + function getNextMessageToSummarize(): Message | null { const char = DBState.db.characters[$selectedCharID]; const chat = char.chats[DBState.db.characters[$selectedCharID].chatPage]; const firstMessage = @@ -256,7 +256,11 @@ } if (firstMessage?.trim() === "") { - return chat.message[0]; + if (chat.message.length > 0) { + return chat.message[0]; + } + + return null; } return { role: "char", chatId: "first message", data: firstMessage }; @@ -601,16 +605,18 @@ {#if true} {@const nextMessage = getNextMessageToSummarize()} -
- - HypaV3 will summarize {nextMessage.chatId} - -
- {nextMessage.data} + {#if nextMessage} +
+ + HypaV3 will summarize [{nextMessage.chatId}] + +
+ {nextMessage.data} +
-
+ {/if} {/if}