fix: prevent users from setting a extremly short history that resulting in no content being sent for the title summary

This commit is contained in:
skymkmk 2024-09-14 07:49:26 +08:00
parent 37c0cfe1e9
commit fa48ace39b
No known key found for this signature in database
GPG Key ID: 6F4CA5A97C68BD71
1 changed files with 5 additions and 1 deletions

View File

@ -595,9 +595,13 @@ export const useChatStore = createPersistStore(
countMessages(messages) >= SUMMARIZE_MIN_LEN) ||
refreshTitle
) {
const startIndex = Math.max(
0,
messages.length - modelConfig.historyMessageCount,
);
const topicMessages = messages
.slice(
messages.length - modelConfig.historyMessageCount,
startIndex < messages.length ? startIndex : messages.length - 1,
messages.length,
)
.concat(