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 fd5f069 commit 95ae88a
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 @@ -574,9 +574,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 95ae88a

Please sign in to comment.