This commit is contained in:
Reekin
2025-01-03 14:05:15 +08:00
committed by GitHub
2 changed files with 38 additions and 2 deletions

View File

@@ -83,6 +83,8 @@ export interface ChatSession {
clearContextIndex?: number;
mask: Mask;
overrideModelConfig?: Partial<ModelConfig>;
}
export const DEFAULT_TOPIC = Locale.Store.DefaultTopic;
@@ -542,7 +544,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:
@@ -679,7 +683,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),
),
);
}
const memoryPrompt = get().getMemoryPrompt();