Browse Source

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

skymkmk 1 year ago
parent
commit
fa48ace39b
1 changed files with 5 additions and 1 deletions
  1. 5 1
      app/store/chat.ts

+ 5 - 1
app/store/chat.ts

@@ -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(