fix: handle empty message edge cases in getNextMessageToSummarize
This commit is contained in:
@@ -232,7 +232,7 @@
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function getNextMessageToSummarize(): Message {
|
function getNextMessageToSummarize(): Message | null {
|
||||||
const char = DBState.db.characters[$selectedCharID];
|
const char = DBState.db.characters[$selectedCharID];
|
||||||
const chat = char.chats[DBState.db.characters[$selectedCharID].chatPage];
|
const chat = char.chats[DBState.db.characters[$selectedCharID].chatPage];
|
||||||
const firstMessage =
|
const firstMessage =
|
||||||
@@ -256,7 +256,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (firstMessage?.trim() === "") {
|
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 };
|
return { role: "char", chatId: "first message", data: firstMessage };
|
||||||
@@ -601,16 +605,18 @@
|
|||||||
{#if true}
|
{#if true}
|
||||||
<!-- Next message to summarize -->
|
<!-- Next message to summarize -->
|
||||||
{@const nextMessage = getNextMessageToSummarize()}
|
{@const nextMessage = getNextMessageToSummarize()}
|
||||||
<div class="mt-4">
|
{#if nextMessage}
|
||||||
<span class="text-sm text-textcolor2 mb-2 block">
|
<div class="mt-4">
|
||||||
HypaV3 will summarize {nextMessage.chatId}
|
<span class="text-sm text-textcolor2 mb-2 block">
|
||||||
</span>
|
HypaV3 will summarize [{nextMessage.chatId}]
|
||||||
<div
|
</span>
|
||||||
class="p-2 max-h-48 overflow-y-auto bg-zinc-800 rounded-md whitespace-pre-wrap"
|
<div
|
||||||
>
|
class="p-2 max-h-48 overflow-y-auto bg-zinc-800 rounded-md whitespace-pre-wrap"
|
||||||
{nextMessage.data}
|
>
|
||||||
|
{nextMessage.data}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user