Re-Render prompt manager on worldinfo settings change

This commit is contained in:
maver 2023-07-03 19:06:18 +02:00
parent 4509df0fd9
commit 011278c533
2 changed files with 17 additions and 8 deletions

View File

@ -344,9 +344,12 @@ PromptManagerModule.prototype.init = function (moduleConfiguration, serviceSetti
document.getElementById(this.configuration.prefix + 'prompt_manager_popup_entry_form_close').addEventListener('click', closeAndClearPopup);
document.getElementById(this.configuration.prefix + 'prompt_manager_popup_close_button').addEventListener('click', closeAndClearPopup);
// Re-render Prompt manager on openai preset change
// Re-render prompt manager on openai preset change
eventSource.on(event_types.OAI_PRESET_CHANGED, settings => this.render());
// Re-render prompt manager on world settings update
eventSource.on(event_types.WORLDINFO_SETTINGS_UPDATED, () => this.render());
this.log('Initialized')
};

View File

@ -1,4 +1,4 @@
import { saveSettings, callPopup, substituteParams, getTokenCount, getRequestHeaders, chat_metadata, this_chid, characters, saveCharacterDebounced, menu_type } from "../script.js";
import { saveSettings, callPopup, substituteParams, getTokenCount, getRequestHeaders, chat_metadata, this_chid, characters, saveCharacterDebounced, menu_type, eventSource, event_types } from "../script.js";
import { download, debounce, initScrollHeight, resetScrollHeight, parseJsonFile, extractDataFromPng, getFileBuffer, delay, getCharaFilename, deepClone } from "./utils.js";
import { getContext } from "./extensions.js";
import { NOTE_MODULE_NAME, metadata_keys, shouldWIAddPrompt } from "./authors-note.js";
@ -1369,6 +1369,7 @@ function onWorldInfoChange(_, text) {
}
saveSettingsDebounced();
eventSource.emit(event_types.WORLDINFO_SETTINGS_UPDATED);
}
export async function importWorldInfo(file) {
@ -1505,36 +1506,41 @@ jQuery(() => {
}
});
const saveSettings = () => {
saveSettingsDebounced()
eventSource.emit(event_types.WORLDINFO_SETTINGS_UPDATED);
}
$(document).on("input", "#world_info_depth", function () {
world_info_depth = Number($(this).val());
$("#world_info_depth_counter").text($(this).val());
saveSettingsDebounced();
saveSettings();
});
$(document).on("input", "#world_info_budget", function () {
world_info_budget = Number($(this).val());
$("#world_info_budget_counter").text($(this).val());
saveSettingsDebounced();
saveSettings();
});
$(document).on("input", "#world_info_recursive", function () {
world_info_recursive = !!$(this).prop('checked');
saveSettingsDebounced();
saveSettings();
})
$('#world_info_case_sensitive').on('input', function () {
world_info_case_sensitive = !!$(this).prop('checked');
saveSettingsDebounced();
saveSettings();
})
$('#world_info_match_whole_words').on('input', function () {
world_info_match_whole_words = !!$(this).prop('checked');
saveSettingsDebounced();
saveSettings();
});
$('#world_info_character_strategy').on('change', function () {
world_info_character_strategy = $(this).val();
saveSettingsDebounced();
saveSettings();
});
$('#world_info_overflow_alert').on('change', function () {