Merge pull request #1239 from bdashore3/staging
Include AN into WI scanning
This commit is contained in:
commit
b5d93f477a
|
@ -4580,6 +4580,11 @@
|
|||
Tokens: <span id="extension_floating_prompt_token_counter">0</span>
|
||||
</div>
|
||||
|
||||
<label class="checkbox_label" for="extension_floating_allow_wi_scan">
|
||||
<input id="extension_floating_allow_wi_scan" type="checkbox" />
|
||||
<span data-i18n="Include in World Info Scanning">Include in World Info Scanning</span>
|
||||
</label>
|
||||
|
||||
<div class="floating_prompt_radio_group">
|
||||
<label>
|
||||
<input type="radio" name="extension_floating_position" value="2" />
|
||||
|
|
|
@ -212,6 +212,7 @@ export {
|
|||
saveChat,
|
||||
messageFormatting,
|
||||
getExtensionPrompt,
|
||||
getExtensionPromptByName,
|
||||
showSwipeButtons,
|
||||
hideSwipeButtons,
|
||||
changeMainAPI,
|
||||
|
@ -2069,6 +2070,15 @@ function getAllExtensionPrompts() {
|
|||
return value.length ? substituteParams(value) : '';
|
||||
}
|
||||
|
||||
// Wrapper to fetch extension prompts by module name
|
||||
function getExtensionPromptByName(moduleName) {
|
||||
if (moduleName) {
|
||||
return substituteParams(extension_prompts[moduleName]?.value);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
function getExtensionPrompt(position = 0, depth = undefined, separator = "\n") {
|
||||
let extension_prompt = Object.keys(extension_prompts)
|
||||
.sort()
|
||||
|
|
|
@ -235,6 +235,7 @@ function loadSettings() {
|
|||
chat_metadata[metadata_keys.depth] = chat_metadata[metadata_keys.depth] ?? extension_settings.note.defaultDepth ?? DEFAULT_DEPTH;
|
||||
$('#extension_floating_prompt').val(chat_metadata[metadata_keys.prompt]);
|
||||
$('#extension_floating_interval').val(chat_metadata[metadata_keys.interval]);
|
||||
$('#extension_floating_allow_wi_scan').prop('checked', extension_settings.note.allowWIScan ?? false);
|
||||
$('#extension_floating_depth').val(chat_metadata[metadata_keys.depth]);
|
||||
$(`input[name="extension_floating_position"][value="${chat_metadata[metadata_keys.position]}"]`).prop('checked', true);
|
||||
|
||||
|
@ -389,6 +390,11 @@ function onChatChanged() {
|
|||
$('#extension_floating_default_token_counter').text(tokenCounter3);
|
||||
}
|
||||
|
||||
function onAllowWIScanCheckboxChanged() {
|
||||
extension_settings.note.allowWIScan = !!$(this).prop('checked');
|
||||
updateSettings();
|
||||
}
|
||||
|
||||
/**
|
||||
* Inject author's note options and setup event listeners.
|
||||
*/
|
||||
|
@ -402,6 +408,7 @@ export function initAuthorsNote() {
|
|||
$('#extension_floating_default').on('input', onExtensionFloatingDefaultInput);
|
||||
$('#extension_default_depth').on('input', onDefaultDepthInput);
|
||||
$('#extension_default_interval').on('input', onDefaultIntervalInput);
|
||||
$('#extension_floating_allow_wi_scan').on('input', onAllowWIScanCheckboxChanged);
|
||||
$('input[name="extension_floating_position"]').on('change', onExtensionFloatingPositionInput);
|
||||
$('input[name="extension_default_position"]').on('change', onDefaultPositionInput);
|
||||
$('input[name="extension_floating_char_position"]').on('change', onExtensionFloatingCharPositionInput);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { saveSettings, callPopup, substituteParams, getRequestHeaders, chat_metadata, this_chid, characters, saveCharacterDebounced, menu_type, eventSource, event_types } from "../script.js";
|
||||
import { saveSettings, callPopup, substituteParams, getRequestHeaders, chat_metadata, this_chid, characters, saveCharacterDebounced, menu_type, eventSource, event_types, getExtensionPrompt, MAX_INJECTION_DEPTH, extension_prompt_types, getExtensionPromptByName } from "../script.js";
|
||||
import { download, debounce, initScrollHeight, resetScrollHeight, parseJsonFile, extractDataFromPng, getFileBuffer, getCharaFilename, getSortableDelay, escapeRegex, PAGINATION_TEMPLATE, navigation_option, waitUntilCondition } from "./utils.js";
|
||||
import { getContext } from "./extensions.js";
|
||||
import { extension_settings, getContext } from "./extensions.js";
|
||||
import { NOTE_MODULE_NAME, metadata_keys, shouldWIAddPrompt } from "./authors-note.js";
|
||||
import { registerSlashCommand } from "./slash-commands.js";
|
||||
import { getDeviceInfo } from "./RossAscends-mods.js";
|
||||
|
@ -581,8 +581,8 @@ function getWorldEntry(name, data, entry) {
|
|||
data.entries[uid].selectiveLogic = !isNaN(value) ? value : 0;
|
||||
setOriginalDataValue(data, uid, "selectiveLogic", data.entries[uid].selectiveLogic);
|
||||
saveWorldInfo(name, data);
|
||||
|
||||
});
|
||||
|
||||
template
|
||||
.find(`select[name="entryLogicType"] option[value=${entry.selectiveLogic}]`)
|
||||
.prop("selected", true)
|
||||
|
@ -1341,7 +1341,27 @@ async function getSortedEntries() {
|
|||
async function checkWorldInfo(chat, maxContext) {
|
||||
const context = getContext();
|
||||
const messagesToLookBack = world_info_depth * 2 || 1;
|
||||
let textToScan = transformString(chat.slice(0, messagesToLookBack).join(""));
|
||||
|
||||
// Combine the chat
|
||||
let textToScan = chat.slice(0, messagesToLookBack).join("");
|
||||
|
||||
// Add the depth or AN if enabled
|
||||
// Put this code here since otherwise, the chat reference is modified
|
||||
if (extension_settings.note.allowWIScan) {
|
||||
let depthPrompt = getExtensionPromptByName("DEPTH_PROMPT")
|
||||
if (depthPrompt) {
|
||||
textToScan = `${depthPrompt}\n${textToScan}`
|
||||
}
|
||||
|
||||
let anPrompt = getExtensionPromptByName(NOTE_MODULE_NAME);
|
||||
if (anPrompt) {
|
||||
textToScan = `${anPrompt}\n${textToScan}`
|
||||
}
|
||||
}
|
||||
|
||||
// Transform the resulting string
|
||||
textToScan = transformString(textToScan);
|
||||
|
||||
let needsToScan = true;
|
||||
let count = 0;
|
||||
let allActivatedEntries = new Set();
|
||||
|
|
Loading…
Reference in New Issue