mirror of
https://github.com/Yidadaa/ChatGPT-Next-Web.git
synced 2025-08-09 03:11:47 +08:00
feat: session-level model config
This commit is contained in:
@@ -334,14 +334,14 @@ export const useChatStore = create<ChatStore>()(
|
||||
// get short term and unmemoried long term memory
|
||||
const shortTermMemoryMessageIndex = Math.max(
|
||||
0,
|
||||
n - config.historyMessageCount,
|
||||
n - config.modelConfig.historyMessageCount,
|
||||
);
|
||||
const longTermMemoryMessageIndex = session.lastSummarizeIndex;
|
||||
const oldestIndex = Math.max(
|
||||
shortTermMemoryMessageIndex,
|
||||
longTermMemoryMessageIndex,
|
||||
);
|
||||
const threshold = config.compressMessageLengthThreshold;
|
||||
const threshold = config.modelConfig.compressMessageLengthThreshold;
|
||||
|
||||
// get recent messages as many as possible
|
||||
const reversedRecentMessages = [];
|
||||
@@ -410,7 +410,7 @@ export const useChatStore = create<ChatStore>()(
|
||||
if (historyMsgLength > config?.modelConfig?.max_tokens ?? 4000) {
|
||||
const n = toBeSummarizedMsgs.length;
|
||||
toBeSummarizedMsgs = toBeSummarizedMsgs.slice(
|
||||
Math.max(0, n - config.historyMessageCount),
|
||||
Math.max(0, n - config.modelConfig.historyMessageCount),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -423,11 +423,12 @@ export const useChatStore = create<ChatStore>()(
|
||||
"[Chat History] ",
|
||||
toBeSummarizedMsgs,
|
||||
historyMsgLength,
|
||||
config.compressMessageLengthThreshold,
|
||||
config.modelConfig.compressMessageLengthThreshold,
|
||||
);
|
||||
|
||||
if (
|
||||
historyMsgLength > config.compressMessageLengthThreshold &&
|
||||
historyMsgLength >
|
||||
config.modelConfig.compressMessageLengthThreshold &&
|
||||
session.sendMemory
|
||||
) {
|
||||
requestChatStream(
|
||||
|
@@ -16,8 +16,6 @@ export enum Theme {
|
||||
}
|
||||
|
||||
const DEFAULT_CONFIG = {
|
||||
historyMessageCount: 4,
|
||||
compressMessageLengthThreshold: 1000,
|
||||
sendBotMessages: true as boolean,
|
||||
submitKey: SubmitKey.CtrlEnter as SubmitKey,
|
||||
avatar: "1f603",
|
||||
@@ -34,6 +32,8 @@ const DEFAULT_CONFIG = {
|
||||
temperature: 1,
|
||||
max_tokens: 2000,
|
||||
presence_penalty: 0,
|
||||
historyMessageCount: 4,
|
||||
compressMessageLengthThreshold: 1000,
|
||||
},
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user