Skip to content

Commit

Permalink
fix: prevent users from setting a extremly short history that resulti…
Browse files Browse the repository at this point in the history
…ng in no content being sent for the title summary
  • Loading branch information
skymkmk committed Sep 13, 2024
1 parent 37c0cfe commit fa48ace
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/store/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit fa48ace

Please sign in to comment.