feat: remove empty memoryPrompt in ChatMessages
This commit is contained in:
parent
48d44ece58
commit
0aa807df19
|
@ -428,14 +428,13 @@ export const useChatStore = createPersistStore(
|
||||||
getMemoryPrompt() {
|
getMemoryPrompt() {
|
||||||
const session = get().currentSession();
|
const session = get().currentSession();
|
||||||
|
|
||||||
return {
|
if (session.memoryPrompt.length) {
|
||||||
role: "system",
|
return {
|
||||||
content:
|
role: "system",
|
||||||
session.memoryPrompt.length > 0
|
content: Locale.Store.Prompt.History(session.memoryPrompt),
|
||||||
? Locale.Store.Prompt.History(session.memoryPrompt)
|
date: "",
|
||||||
: ";",
|
} as ChatMessage;
|
||||||
date: "",
|
}
|
||||||
} as ChatMessage;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
getMessagesWithMemory() {
|
getMessagesWithMemory() {
|
||||||
|
@ -471,16 +470,15 @@ export const useChatStore = createPersistStore(
|
||||||
systemPrompts.at(0)?.content ?? "empty",
|
systemPrompts.at(0)?.content ?? "empty",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
const memoryPrompt = get().getMemoryPrompt();
|
||||||
// long term memory
|
// long term memory
|
||||||
const shouldSendLongTermMemory =
|
const shouldSendLongTermMemory =
|
||||||
modelConfig.sendMemory &&
|
modelConfig.sendMemory &&
|
||||||
session.memoryPrompt &&
|
session.memoryPrompt &&
|
||||||
session.memoryPrompt.length > 0 &&
|
session.memoryPrompt.length > 0 &&
|
||||||
session.lastSummarizeIndex > clearContextIndex;
|
session.lastSummarizeIndex > clearContextIndex;
|
||||||
const longTermMemoryPrompts = shouldSendLongTermMemory
|
const longTermMemoryPrompts =
|
||||||
? [get().getMemoryPrompt()]
|
shouldSendLongTermMemory && memoryPrompt ? [memoryPrompt] : [];
|
||||||
: [];
|
|
||||||
const longTermMemoryStartIndex = session.lastSummarizeIndex;
|
const longTermMemoryStartIndex = session.lastSummarizeIndex;
|
||||||
|
|
||||||
// short term memory
|
// short term memory
|
||||||
|
@ -605,9 +603,11 @@ export const useChatStore = createPersistStore(
|
||||||
Math.max(0, n - modelConfig.historyMessageCount),
|
Math.max(0, n - modelConfig.historyMessageCount),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
const memoryPrompt = get().getMemoryPrompt();
|
||||||
// add memory prompt
|
if (memoryPrompt) {
|
||||||
toBeSummarizedMsgs.unshift(get().getMemoryPrompt());
|
// add memory prompt
|
||||||
|
toBeSummarizedMsgs.unshift(memoryPrompt);
|
||||||
|
}
|
||||||
|
|
||||||
const lastSummarizeIndex = session.messages.length;
|
const lastSummarizeIndex = session.messages.length;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue