diff --git a/app/components/chat.tsx b/app/components/chat.tsx index 9990a359e..841a0831b 100644 --- a/app/components/chat.tsx +++ b/app/components/chat.tsx @@ -116,6 +116,8 @@ import { ExportMessageModal } from "./exporter"; import { getClientConfig } from "../config/client"; import { useAllModels } from "../utils/hooks"; import { MultimodalContent } from "../client/api"; +import { InputRange } from "./input-range"; +import { config } from "process"; import { ClientApi } from "../client/api"; import { createTTSPlayer } from "../utils/audio"; @@ -858,6 +860,31 @@ export function EditMessageModal(props: { onClose: () => void }) { } > + + + chatStore.updateCurrentSession( + (session) => + ((session.overrideModelConfig ??= {}).historyMessageCount = + e.currentTarget.valueAsNumber), + ) + } + > + ; } 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();