initial reversion commit

This commit is contained in:
RossAscends 2024-09-06 01:48:21 +09:00
parent b5b01a1a5c
commit 8e1dad6800
6 changed files with 68 additions and 42 deletions

View File

@ -3089,14 +3089,14 @@
<small data-i18n="Story String">Story String</small>
<i class="editor_maximize fa-solid fa-maximize right_menu_button" data-for="context_story_string" title="Expand the editor" data-i18n="[title]Expand the editor"></i>
</label>
<div contenteditable="true" id="context_story_string" class="text_pole textarea_compact"></div>
<textarea id="context_story_string" class="text_pole textarea_compact autoSetHeight"></textarea>
<div class="flex-container">
<div class="flex1">
<label for="context_example_separator">
<small data-i18n="Example Separator">Example Separator</small>
</label>
<div>
<div contenteditable="true" id="context_example_separator" class="text_pole textarea_compact"></div>
<textarea id="context_example_separator" class="text_pole textarea_compact autoSetHeight"></textarea>
</div>
</div>
<div class="flex1">
@ -3104,7 +3104,7 @@
<small data-i18n="Chat Start">Chat Start</small>
</label>
<div>
<div contenteditable="true" id="context_chat_start" class="text_pole textarea_compact"></div>
<textarea id="context_chat_start" class="text_pole textarea_compact autoSetHeight"></textarea>
</div>
</div>
</div>
@ -3182,7 +3182,7 @@
</small>
</div>
<div>
<div contenteditable="true" id="custom_stopping_strings" class="text_pole textarea_compact monospace"></div>
<textarea id="custom_stopping_strings" class="text_pole textarea_compact monospace autoSetHeight"></textarea>
</div>
<label class="checkbox_label" for="custom_stopping_strings_macro">
<input id="custom_stopping_strings_macro" type="checkbox" checked>
@ -3241,7 +3241,7 @@
<small data-i18n="System Prompt">System Prompt</small>
<i class="editor_maximize fa-solid fa-maximize right_menu_button" data-for="instruct_system_prompt" title="Expand the editor" data-i18n="[title]Expand the editor"></i>
</label>
<div contenteditable="true" id="instruct_system_prompt" class="text_pole textarea_compact"></div>
<textarea id="instruct_system_prompt" class="text_pole textarea_compact autoSetHeight"></textarea>
</div>
<div>
@ -3323,7 +3323,7 @@
</span>
</small>
<div>
<div contenteditable="true" id="start_reply_with" class="text_pole textarea_compact"></div>
<textarea id="start_reply_with" class="text_pole textarea_compact autoSetHeight"></textarea>
</div>
<label class="checkbox_label" for="chat-show-reply-prefix-checkbox">
<input id="chat-show-reply-prefix-checkbox" type="checkbox" />
@ -3353,7 +3353,7 @@
<small data-i18n="System Prompt Prefix">System Prompt Prefix</small>
</label>
<div>
<div contenteditable="true" id="instruct_system_sequence_prefix" class="text_pole textarea_compact"></div>
<textarea id="instruct_system_sequence_prefix" class="text_pole textarea_compact autoSetHeight"></textarea>
</div>
</div>
<div class="flexAuto" title="Inserted after a System prompt." data-i18n="[title]Inserted after a System prompt.">
@ -3361,38 +3361,38 @@
<small data-i18n="System Prompt Suffix">System Prompt Suffix</small>
</label>
<div>
<div contenteditable="true" id="instruct_system_sequence_suffix" class="text_pole wide100p textarea_compact"></div>
<textarea id="instruct_system_sequence_suffix" class="text_pole wide100p textarea_compact autoSetHeight"></textarea>
</div>
</div>
</div>
<div class="flex-container">
<div class="flexAuto" title="Inserted before a User message and as a last prompt line when impersonating." data-i18n="[title]Inserted before a User message and as a last prompt line when impersonating.">
<small data-i18n="User Prefix">User Message Prefix</small>
<div contenteditable="true" id="instruct_input_sequence" class="text_pole textarea_compact"></div>
<textarea id="instruct_input_sequence" class="text_pole textarea_compact autoSetHeight"></textarea>
</div>
<div class="flexAuto" title="Inserted after a User message." data-i18n="[title]Inserted after a User message.">
<small data-i18n="User Suffix">User Message Suffix</small>
<div contenteditable="true" id="instruct_input_suffix" class="text_pole wide100p textarea_compact"></div>
<textarea id="instruct_input_suffix" class="text_pole wide100p textarea_compact autoSetHeight"></textarea>
</div>
</div>
<div class="flex-container">
<div class="flexAuto" title="Inserted before an Assistant message and as a last prompt line when generating an AI reply." data-i18n="[title]Inserted before an Assistant message and as a last prompt line when generating an AI reply.">
<small data-i18n="Assistant Prefix">Assistant Message Prefix</small>
<div contenteditable="true" id="instruct_output_sequence" class="text_pole wide100p textarea_compact"></div>
<textarea id="instruct_output_sequence" class="text_pole wide100p textarea_compact autoSetHeight"></textarea>
</div>
<div class="flexAuto" title="Inserted after an Assistant message." data-i18n="[title]Inserted after an Assistant message.">
<small data-i18n="Assistant Suffix">Assistant Message Suffix</small>
<div contenteditable="true" id="instruct_output_suffix" class="text_pole wide100p textarea_compact"></div>
<textarea id="instruct_output_suffix" class="text_pole wide100p textarea_compact autoSetHeight"></textarea>
</div>
</div>
<div class="flex-container">
<div class="flexAuto" id="instruct_system_sequence_block" title="Inserted before a System (added by slash commands or extensions) message." data-i18n="[title]Inserted before a System (added by slash commands or extensions) message.">
<small data-i18n="System Prefix">System Message Prefix</small>
<div contenteditable="true" id="instruct_system_sequence" class="text_pole textarea_compact"></div>
<textarea id="instruct_system_sequence" class="text_pole textarea_compact autoSetHeight"></textarea>
</div>
<div class="flexAuto" id="instruct_system_suffix_block" title="Inserted after a System message." data-i18n="[title]Inserted after a System message.">
<small data-i18n="System Suffix">System Message Suffix</small>
<div contenteditable="true" id="instruct_system_suffix" class="text_pole wide100p textarea_compact"></div>
<textarea id="instruct_system_suffix" class="text_pole wide100p textarea_compact autoSetHeight"></textarea>
</div>
</div>
<div class="flexBasis100p" title="If enabled, System Sequences will be the same as User Sequences." data-i18n="[title]If enabled, System Sequences will be the same as User Sequences.">
@ -3408,37 +3408,37 @@
<div class="flex-container">
<div class="flexAuto" title="Inserted before the first Assistant's message." data-i18n="[title]Inserted before the first Assistant's message.">
<small data-i18n="First Assistant Prefix">First Assistant Prefix</small>
<div contenteditable="true" id="instruct_first_output_sequence" class="text_pole textarea_compact"></div>
<textarea id="instruct_first_output_sequence" class="text_pole textarea_compact autoSetHeight"></textarea>
</div>
<div class="flexAuto" title="Inserted before the last Assistant's message or as a last prompt line when generating an AI reply (except a neutral/system role)." data-i18n="[title]instruct_last_output_sequence">
<small data-i18n="Last Assistant Prefix">Last Assistant Prefix</small>
<div contenteditable="true" id="instruct_last_output_sequence" class="text_pole wide100p textarea_compact"></div>
<textarea id="instruct_last_output_sequence" class="text_pole wide100p textarea_compact autoSetHeight"></textarea>
</div>
</div>
<div class="flex-container">
<div class="flexAuto" title="Inserted before the first User's message." data-i18n="[title]Inserted before the first User's message.">
<small data-i18n="First User Prefix">First User Prefix</small>
<div contenteditable="true" id="instruct_first_input_sequence" class="text_pole textarea_compact"></div>
<textarea id="instruct_first_input_sequence" class="text_pole textarea_compact autoSetHeight"></textarea>
</div>
<div class="flexAuto" title="Inserted before the last User's message." data-i18n="[title]instruct_last_input_sequence">
<small data-i18n="Last User Prefix">Last User Prefix</small>
<div contenteditable="true" id="instruct_last_input_sequence" class="text_pole wide100p textarea_compact"></div>
<textarea id="instruct_last_input_sequence" class="text_pole wide100p textarea_compact autoSetHeight"></textarea>
</div>
</div>
<div class="flex-container">
<div class="flexAuto" title="Will be inserted as a last prompt line when using system/neutral generation." data-i18n="[title]Will be inserted as a last prompt line when using system/neutral generation.">
<small data-i18n="System Instruction Prefix">System Instruction Prefix</small>
<div contenteditable="true" id="instruct_last_system_sequence" class="text_pole textarea_compact"></div>
<textarea id="instruct_last_system_sequence" class="text_pole textarea_compact autoSetHeight"></textarea>
</div>
<div class="flexAuto" title="If a stop sequence is generated, everything past it will be removed from the output (inclusive)." data-i18n="[title]If a stop sequence is generated, everything past it will be removed from the output (inclusive).">
<small data-i18n="Stop Sequence">Stop Sequence</small>
<div contenteditable="true" id="instruct_stop_sequence" class="text_pole textarea_compact"></div>
<textarea id="instruct_stop_sequence" class="text_pole textarea_compact autoSetHeight"></textarea>
</div>
</div>
<div class="flex-container">
<div class="flexAuto" title="Will be inserted at the start of the chat history if it doesn't start with a User message." data-i18n="[title]Will be inserted at the start of the chat history if it doesn't start with a User message.">
<small data-i18n="User Filler Message">User Filler Message</small>
<div contenteditable="true" id="instruct_user_alignment_message" class="text_pole textarea_compact"></div>
<textarea id="instruct_user_alignment_message" class="text_pole textarea_compact autoSetHeight"></textarea>
</div>
</div>
</div>

View File

@ -10577,6 +10577,9 @@ jQuery(async function () {
stopScriptExecution();
});
const chromeUaIdx = navigator.userAgent.lastIndexOf('Chrome/');
const chromeVersion = navigator.userAgent.substring(chromeUaIdx + 7, navigator.userAgent.indexOf('.', chromeUaIdx));
$('.drawer-toggle').on('click', function () {
var icon = $(this).find('.drawer-icon');
var drawer = $(this).parent().find('.drawer-content');
@ -10616,10 +10619,13 @@ jQuery(async function () {
}
// Set the height of "autoSetHeight" textareas within the drawer to their scroll height
$(this).closest('.drawer').find('.drawer-content textarea.autoSetHeight').each(async function () {
await resetScrollHeight($(this));
return;
});
if (chromeUaIdx == -1 || Number(chromeVersion) < 123) {
$(this).closest('.drawer').find('.drawer-content textarea.autoSetHeight').each(async function () {
await resetScrollHeight($(this));
return;
});
}
} else if (drawerWasOpenAlready) { //to close manually
icon.toggleClass('closedIcon openIcon');
@ -10691,10 +10697,12 @@ jQuery(async function () {
$(this).closest('.inline-drawer').find('.inline-drawer-content').stop().slideToggle();
// Set the height of "autoSetHeight" textareas within the inline-drawer to their scroll height
$(this).closest('.inline-drawer').find('.inline-drawer-content textarea.autoSetHeight').each(async function () {
await resetScrollHeight($(this));
return;
});
if (chromeUaIdx == -1 || Number(chromeVersion) < 123) {
$(this).closest('.inline-drawer').find('.inline-drawer-content textarea.autoSetHeight').each(async function () {
await resetScrollHeight($(this));
return;
});
}
});
$(document).on('click', '.inline-drawer-maximize', function () {

View File

@ -7,7 +7,7 @@ import {
power_user,
context_presets,
} from './power-user.js';
import { regexFromString } from './utils.js';
import { regexFromString, resetScrollHeight } from './utils.js';
/**
* @type {any[]} Instruct mode presets.
@ -42,6 +42,9 @@ const controls = [
{ id: 'instruct_system_same_as_user', property: 'system_same_as_user', isCheckbox: true, trigger: true },
];
const chromeUaIdx = navigator.userAgent.lastIndexOf('Chrome/');
const chromeVersion = navigator.userAgent.substring(chromeUaIdx + 7, navigator.userAgent.indexOf('.', chromeUaIdx));
/**
* Migrates instruct mode settings into the evergreen format.
* @param {object} settings Instruct mode settings.
@ -95,11 +98,14 @@ export async function loadInstructMode(data) {
if (control.isCheckbox) {
$element.prop('checked', power_user.instruct[control.property]);
} else {
$element[0].innerText = (power_user.instruct[control.property]);
$element.val(power_user.instruct[control.property]);
}
$element.on('input', async function () {
power_user.instruct[control.property] = control.isCheckbox ? !!$(this).prop('checked') : $(this)[0].innerText;
power_user.instruct[control.property] = control.isCheckbox ? !!$(this).prop('checked') : $(this).val;
if (chromeUaIdx == -1 || Number(chromeVersion) < 123) {
await resetScrollHeight($(this));
}
saveSettingsDebounced();
});
@ -663,7 +669,7 @@ jQuery(() => {
if (control.isCheckbox) {
$element.prop('checked', power_user.instruct[control.property]).trigger('input');
} else {
$element[0].innerText = (power_user.instruct[control.property]);
$element.val(power_user.instruct[control.property]);
$element.trigger('input');
}
}

View File

@ -105,6 +105,9 @@ export const persona_description_positions = {
NONE: 9,
};
const chromeUaIdx = navigator.userAgent.lastIndexOf('Chrome/');
const chromeVersion = navigator.userAgent.substring(chromeUaIdx + 7, navigator.userAgent.indexOf('.', chromeUaIdx));
let power_user = {
tokenizer: tokenizers.BEST_MATCH,
token_padding: 64,
@ -1740,20 +1743,23 @@ async function loadContextSettings() {
if (control.isCheckbox) {
$element.prop('checked', power_user.context[control.property]);
} else {
$element[0].innerText = power_user.context[control.property];
$element.val(power_user.context[control.property]);
}
console.log(`Setting ${$element.prop('id')} to ${power_user.context[control.property]}`);
// If the setting already exists, no need to duplicate it
// TODO: Maybe check the power_user object for the setting instead of a flag?
$element.on('input keyup', async function () {
const value = control.isCheckbox ? !!$(this).prop('checked') : $(this)[0].innerText;
$element.on('input', async function () {
const value = control.isCheckbox ? !!$(this).prop('checked') : $(this).val();
if (control.isGlobalSetting) {
power_user[control.property] = value;
} else {
power_user.context[control.property] = value;
}
console.log(`Setting ${$element.prop('id')} to ${value}`);
if (chromeUaIdx == -1 || Number(chromeVersion) < 123) {
await resetScrollHeight($(this));
}
saveSettingsDebounced();
});
});
@ -1793,7 +1799,7 @@ async function loadContextSettings() {
.prop('checked', control.isGlobalSetting ? power_user[control.property] : power_user.context[control.property])
.trigger('input');
} else {
$element[0].innerText = (control.isGlobalSetting ? power_user[control.property] : power_user.context[control.property]);
$element.val(control.isGlobalSetting ? power_user[control.property] : power_user.context[control.property]);
$element.trigger('input');
}
}
@ -3096,7 +3102,7 @@ $(document).ready(() => {
});
$('#start_reply_with').on('input', function () {
power_user.user_prompt_bias = String($(this)[0].innerText);
power_user.user_prompt_bias = String($(this).val);
saveSettingsDebounced();
});
@ -3628,7 +3634,7 @@ $(document).ready(() => {
});
$('#custom_stopping_strings').on('input', function () {
power_user.custom_stopping_strings = String($(this)[0].innerText).trim();
power_user.custom_stopping_strings = String($(this).val).trim();
saveSettingsDebounced();
});

View File

@ -2027,8 +2027,13 @@ export function toggleDrawer(drawer, expand = true) {
content.style.display = 'none';
}
const chromeUaIdx = navigator.userAgent.lastIndexOf('Chrome/');
const chromeVersion = navigator.userAgent.substring(chromeUaIdx + 7, navigator.userAgent.indexOf('.', chromeUaIdx));
// Set the height of "autoSetHeight" textareas within the inline-drawer to their scroll height
content.querySelectorAll('textarea.autoSetHeight').forEach(resetScrollHeight);
if (chromeUaIdx == -1 || Number(chromeVersion) < 123) {
content.querySelectorAll('textarea.autoSetHeight').forEach(resetScrollHeight);
}
}
export async function fetchFaFile(name) {

View File

@ -1176,6 +1176,7 @@ textarea {
textarea.autoSetHeight {
max-height: 50vh;
max-height: 50dvh;
field-sizing: content;
}
input,