mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-11-16 14:03:43 +08:00
Enable to set historyMessageCount for each chat
This commit is contained in:
@@ -57,6 +57,8 @@ export interface ChatSession {
|
||||
clearContextIndex?: number;
|
||||
|
||||
mask: Mask;
|
||||
|
||||
overrideModelConfig?: Partial<ModelConfig>;
|
||||
}
|
||||
|
||||
export const DEFAULT_TOPIC = Locale.Store.DefaultTopic;
|
||||
@@ -466,7 +468,9 @@ export const useChatStore = createPersistStore(
|
||||
// short term memory
|
||||
const shortTermMemoryStartIndex = Math.max(
|
||||
0,
|
||||
totalMessageCount - modelConfig.historyMessageCount,
|
||||
totalMessageCount -
|
||||
(session.overrideModelConfig?.historyMessageCount ??
|
||||
modelConfig.historyMessageCount),
|
||||
);
|
||||
|
||||
// lets concat send messages, including 4 parts:
|
||||
@@ -580,7 +584,12 @@ export const useChatStore = createPersistStore(
|
||||
if (historyMsgLength > modelConfig?.max_tokens ?? 4000) {
|
||||
const n = toBeSummarizedMsgs.length;
|
||||
toBeSummarizedMsgs = toBeSummarizedMsgs.slice(
|
||||
Math.max(0, n - modelConfig.historyMessageCount),
|
||||
Math.max(
|
||||
0,
|
||||
n -
|
||||
(session.overrideModelConfig?.historyMessageCount ??
|
||||
modelConfig.historyMessageCount),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user