Reinsert summary extension prompt instantly when changing position

This commit is contained in:
Cohee 2023-09-21 21:13:24 +03:00
parent 5dd9a87dc9
commit 25d818ecbd

View File

@ -191,18 +191,21 @@ function onMemoryPromptInput() {
function onMemoryTemplateInput() {
const value = $(this).val();
extension_settings.memory.template = value;
reinsertMemory();
saveSettingsDebounced();
}
function onMemoryDepthInput() {
const value = $(this).val();
extension_settings.memory.depth = Number(value);
reinsertMemory();
saveSettingsDebounced();
}
function onMemoryPositionChange(e) {
const value = e.target.value;
extension_settings.memory.position = value;
reinsertMemory();
saveSettingsDebounced();
}
@ -393,7 +396,7 @@ async function summarizeChatMain(context, force) {
return;
}
const summary = await generateQuietPrompt(prompt);
const summary = await generateQuietPrompt(prompt, false);
const newContext = getContext();
// something changed during summarization request
@ -518,6 +521,11 @@ function onMemoryContentInput() {
setMemoryContext(value, true);
}
function reinsertMemory() {
const existingValue = $('#memory_contents').val();
setMemoryContext(existingValue, false);
}
function setMemoryContext(value, saveToMessage) {
const context = getContext();
context.setExtensionPrompt(MODULE_NAME, formatMemoryValue(value), extension_settings.memory.position, extension_settings.memory.depth);