#918 Save default position and depth for A/N
This commit is contained in:
parent
f3cff9cd28
commit
93123062af
|
@ -3826,7 +3826,7 @@
|
|||
<small>Will be automatically added as the author's note for this character. Will be used in groups, but
|
||||
can't be modified when a group chat is open.</small>
|
||||
|
||||
<textarea id="extension_floating_chara" class="text_pole" rows="8" maxlength="10000" placeholder="Example:\n[Scenario: wacky adventures; Genre: romantic comedy; Style: verbose, creative]"></textarea>
|
||||
<textarea id="extension_floating_chara" class="text_pole" rows="8" maxlength="10000" placeholder="Example: [Scenario: wacky adventures; Genre: romantic comedy; Style: verbose, creative]"></textarea>
|
||||
<div class="extension_token_counter">
|
||||
Tokens: <span id="extension_floating_chara_token_counter">0</span>
|
||||
</div>
|
||||
|
@ -3860,10 +3860,21 @@
|
|||
<div class="inline-drawer-content">
|
||||
<small>Will be automatically added as the Author's Note for all new chats.</small>
|
||||
|
||||
<textarea id="extension_floating_default" class="text_pole" rows="8" maxlength="10000" placeholder="Example:\n[Scenario: wacky adventures; Genre: romantic comedy; Style: verbose, creative]"></textarea>
|
||||
<div class="extension_token_counter">
|
||||
<textarea id="extension_floating_default" class="text_pole" rows="8" maxlength="10000" placeholder="Example: [Scenario: wacky adventures; Genre: romantic comedy; Style: verbose, creative]"></textarea> <div class="extension_token_counter">
|
||||
Tokens: <span id="extension_floating_default_token_counter">0</span>
|
||||
</div>
|
||||
<div class="floating_prompt_radio_group">
|
||||
<label>
|
||||
<input type="radio" name="extension_default_position" value="0" />
|
||||
After scenario
|
||||
</label>
|
||||
<label>
|
||||
<input type="radio" name="extension_default_position" value="1" />
|
||||
In-chat @ Depth <input id="extension_default_depth" class="text_pole widthUnset" type="number" min="0" max="99" />
|
||||
</label>
|
||||
</div>
|
||||
<label for="extension_default_interval">Insertion Frequency</label>
|
||||
<input id="extension_default_interval" class="text_pole widthUnset" type="number" min="0" max="999" /><small> (0 = Disable, 1 = Always)</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -14,9 +14,6 @@ export { MODULE_NAME as NOTE_MODULE_NAME };
|
|||
|
||||
const MODULE_NAME = '2_floating_prompt'; // <= Deliberate, for sorting lower than memory
|
||||
|
||||
const DEFAULT_DEPTH = 4;
|
||||
const DEFAULT_POSITION = 1;
|
||||
const DEFAULT_INTERVAL = 1;
|
||||
export var shouldWIAddPrompt = false;
|
||||
|
||||
export const metadata_keys = {
|
||||
|
@ -120,6 +117,28 @@ async function onExtensionFloatingPositionInput(e) {
|
|||
saveMetadataDebounced();
|
||||
}
|
||||
|
||||
async function onDefaultPositionInput(e) {
|
||||
extension_settings.note.defaultPosition = e.target.value;
|
||||
saveSettingsDebounced();
|
||||
}
|
||||
|
||||
async function onDefaultDepthInput() {
|
||||
let value = Number($(this).val());
|
||||
|
||||
if (value < 0) {
|
||||
value = Math.abs(value);
|
||||
$(this).val(value);
|
||||
}
|
||||
|
||||
extension_settings.note.defaultDepth = value;
|
||||
saveSettingsDebounced();
|
||||
}
|
||||
|
||||
async function onDefaultIntervalInput() {
|
||||
extension_settings.note.defaultInterval = Number($(this).val());
|
||||
saveSettingsDebounced();
|
||||
}
|
||||
|
||||
async function onExtensionFloatingCharPositionInput(e) {
|
||||
const value = e.target.value;
|
||||
const charaNote = extension_settings.note.chara.find((e) => e.name === getCharaFilename());
|
||||
|
@ -194,10 +213,26 @@ function onExtensionFloatingDefaultInput() {
|
|||
}
|
||||
|
||||
function loadSettings() {
|
||||
const DEFAULT_DEPTH = 4;
|
||||
const DEFAULT_POSITION = 1;
|
||||
const DEFAULT_INTERVAL = 1;
|
||||
|
||||
if (extension_settings.note.defaultPosition === undefined) {
|
||||
extension_settings.note.defaultPosition = DEFAULT_POSITION;
|
||||
}
|
||||
|
||||
if (extension_settings.note.defaultDepth === undefined) {
|
||||
extension_settings.note.defaultDepth = DEFAULT_DEPTH;
|
||||
}
|
||||
|
||||
if (extension_settings.note.defaultInterval === undefined) {
|
||||
extension_settings.note.defaultInterval = DEFAULT_INTERVAL;
|
||||
}
|
||||
|
||||
chat_metadata[metadata_keys.prompt] = chat_metadata[metadata_keys.prompt] ?? extension_settings.note.default ?? '';
|
||||
chat_metadata[metadata_keys.interval] = chat_metadata[metadata_keys.interval] ?? DEFAULT_INTERVAL;
|
||||
chat_metadata[metadata_keys.position] = chat_metadata[metadata_keys.position] ?? DEFAULT_POSITION;
|
||||
chat_metadata[metadata_keys.depth] = chat_metadata[metadata_keys.depth] ?? DEFAULT_DEPTH;
|
||||
chat_metadata[metadata_keys.interval] = chat_metadata[metadata_keys.interval] ?? extension_settings.note.defaultInterval ?? DEFAULT_INTERVAL;
|
||||
chat_metadata[metadata_keys.position] = chat_metadata[metadata_keys.position] ?? extension_settings.note.defaultPosition ?? DEFAULT_POSITION;
|
||||
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_depth').val(chat_metadata[metadata_keys.depth]);
|
||||
|
@ -216,6 +251,9 @@ function loadSettings() {
|
|||
}
|
||||
|
||||
$('#extension_floating_default').val(extension_settings.note.default);
|
||||
$('#extension_default_depth').val(extension_settings.note.defaultDepth);
|
||||
$('#extension_default_interval').val(extension_settings.note.defaultInterval);
|
||||
$(`input[name="extension_default_position"][value="${extension_settings.note.defaultPosition}"]`).prop('checked', true);
|
||||
}
|
||||
|
||||
export function setFloatingPrompt() {
|
||||
|
@ -361,7 +399,10 @@ jQuery(async () => {
|
|||
$('#extension_floating_chara').on('input', onExtensionFloatingCharaPromptInput);
|
||||
$('#extension_use_floating_chara').on('input', onExtensionFloatingCharaCheckboxChanged);
|
||||
$('#extension_floating_default').on('input', onExtensionFloatingDefaultInput);
|
||||
$('#extension_default_depth').on('input', onDefaultDepthInput);
|
||||
$('#extension_default_interval').on('input', onDefaultIntervalInput);
|
||||
$('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);
|
||||
$('#ANClose').on('click', function () {
|
||||
$("#floatingPrompt").transition({
|
||||
|
|
Loading…
Reference in New Issue