Remove advanced options toggle

This commit is contained in:
maver
2023-07-31 15:28:01 +02:00
parent af81915ff3
commit 38bfcf5324
3 changed files with 25 additions and 75 deletions

View File

@ -53,7 +53,7 @@
} }
#completion_prompt_manager .completion_prompt_manager_list_head { #completion_prompt_manager .completion_prompt_manager_list_head {
padding: 0.5em; padding: 0.5em 0.5em 0;
} }
#completion_prompt_manager #completion_prompt_manager_list li.completion_prompt_manager_prompt { #completion_prompt_manager #completion_prompt_manager_list li.completion_prompt_manager_prompt {
@ -219,7 +219,6 @@
flex-direction: column; flex-direction: column;
justify-content: center; justify-content: center;
margin-left: 0.25em; margin-left: 0.25em;
cursor: pointer;
transition: 0.3s ease-in-out; transition: 0.3s ease-in-out;
filter: drop-shadow(0px 0px 2px black); filter: drop-shadow(0px 0px 2px black);
} }

View File

@ -230,9 +230,6 @@ function PromptManagerModule() {
/** Character reset button click*/ /** Character reset button click*/
this.handleCharacterReset = () => {}; this.handleCharacterReset = () => {};
/** Advanced settings button click */
this.handleAdvancedSettingsToggle = () => { };
} }
/** /**
@ -252,11 +249,6 @@ PromptManagerModule.prototype.init = function (moduleConfiguration, serviceSetti
this.sanitizeServiceSettings(); this.sanitizeServiceSettings();
this.handleAdvancedSettingsToggle = () => {
this.serviceSettings.prompt_manager_settings.showAdvancedSettings = !this.serviceSettings.prompt_manager_settings.showAdvancedSettings
this.saveServiceSettings().then(() => this.render());
}
// Enable and disable prompts // Enable and disable prompts
this.handleToggle = (event) => { this.handleToggle = (event) => {
const promptID = event.target.closest('.' + this.configuration.prefix + 'prompt_manager_prompt').dataset.pmIdentifier; const promptID = event.target.closest('.' + this.configuration.prefix + 'prompt_manager_prompt').dataset.pmIdentifier;
@ -661,9 +653,6 @@ PromptManagerModule.prototype.sanitizeServiceSettings = function () {
? this.setPrompts(chatCompletionDefaultPrompts.prompts) ? this.setPrompts(chatCompletionDefaultPrompts.prompts)
: this.checkForMissingPrompts(this.serviceSettings.prompts); : this.checkForMissingPrompts(this.serviceSettings.prompts);
// Add prompt manager settings if not present
this.serviceSettings.prompt_manager_settings = this.serviceSettings.prompt_manager_settings ?? {...promptManagerDefaultSettings};
// Add identifiers if there are none assigned to a prompt // Add identifiers if there are none assigned to a prompt
this.serviceSettings.prompts.forEach(prompt => prompt && (prompt.identifier = prompt.identifier ?? this.getUuidv4())); this.serviceSettings.prompts.forEach(prompt => prompt && (prompt.identifier = prompt.identifier ?? this.getUuidv4()));
@ -921,11 +910,6 @@ PromptManagerModule.prototype.loadPromptIntoEditForm = function (prompt) {
roleField.value = prompt.role ?? ''; roleField.value = prompt.role ?? '';
promptField.value = prompt.content ?? ''; promptField.value = prompt.content ?? '';
if (true === prompt.system_prompt &&
false === this.serviceSettings.prompt_manager_settings.showAdvancedSettings) {
roleField.disabled = true;
}
const resetPromptButton = document.getElementById(this.configuration.prefix + 'prompt_manager_popup_entry_form_reset'); const resetPromptButton = document.getElementById(this.configuration.prefix + 'prompt_manager_popup_entry_form_reset');
if (true === prompt.system_prompt) { if (true === prompt.system_prompt) {
resetPromptButton.style.display = 'block'; resetPromptButton.style.display = 'block';
@ -1091,37 +1075,27 @@ PromptManagerModule.prototype.renderPromptManager = function () {
const promptManagerDiv = this.containerElement; const promptManagerDiv = this.containerElement;
promptManagerDiv.innerHTML = ''; promptManagerDiv.innerHTML = '';
const showAdvancedSettings = this.serviceSettings.prompt_manager_settings.showAdvancedSettings;
const checkSpanClass = showAdvancedSettings ? 'fa-solid fa-toggle-on' : 'fa-solid fa-toggle-off';
const errorDiv = ` const errorDiv = `
<div class="${this.configuration.prefix}prompt_manager_error"> <div class="${this.configuration.prefix}prompt_manager_error">
<span class="fa-solid tooltip fa-triangle-exclamation text_danger"></span> ${this.error} <span class="fa-solid tooltip fa-triangle-exclamation text_danger"></span> ${this.error}
</div> </div>
`; `;
const activeTokenInfo = `<span class="tooltip fa-solid fa-info-circle" title="Including tokens from hidden prompts"></span>`;
const totalActiveTokens = this.tokenUsage; const totalActiveTokens = this.tokenUsage;
promptManagerDiv.insertAdjacentHTML('beforeend', ` promptManagerDiv.insertAdjacentHTML('beforeend', `
<div class="range-block-title" data-i18n="Prompts">
Prompts
</div>
<div class="range-block"> <div class="range-block">
${this.error ? errorDiv : ''} ${this.error ? errorDiv : ''}
<div class="${this.configuration.prefix}prompt_manager_header"> <div class="${this.configuration.prefix}prompt_manager_header">
<div class="${this.configuration.prefix}prompt_manager_header_advanced"> <div class="${this.configuration.prefix}prompt_manager_header_advanced">
<span class="${checkSpanClass}"></span> <span data-i18n="Prompts">Prompts</span>
<span class="checkbox_label" data-i18n="Show advanced options">Show advanced options</span>
</div> </div>
<div>Total Tokens: ${totalActiveTokens} ${ showAdvancedSettings ? '' : activeTokenInfo} </div> <div>Total Tokens: ${totalActiveTokens} </div>
</div> </div>
<ul id="${this.configuration.prefix}prompt_manager_list" class="text_pole"></ul> <ul id="${this.configuration.prefix}prompt_manager_list" class="text_pole"></ul>
</div> </div>
`); `);
const checkSpan = promptManagerDiv.querySelector(`.${this.configuration.prefix}prompt_manager_header_advanced span`);
checkSpan.addEventListener('click', this.handleAdvancedSettingsToggle);
this.listElement = promptManagerDiv.querySelector(`#${this.configuration.prefix}prompt_manager_list`); this.listElement = promptManagerDiv.querySelector(`#${this.configuration.prefix}prompt_manager_list`);
if (null !== this.activeCharacter) { if (null !== this.activeCharacter) {
@ -1137,9 +1111,8 @@ PromptManagerModule.prototype.renderPromptManager = function () {
</select> </select>
<a class="menu_button fa-chain fa-solid" title="Attach prompt" data-i18n="Add"></a> <a class="menu_button fa-chain fa-solid" title="Attach prompt" data-i18n="Add"></a>
<a class="caution menu_button fa-x fa-solid" title="Delete prompt" data-i18n="Delete"></a> <a class="caution menu_button fa-x fa-solid" title="Delete prompt" data-i18n="Delete"></a>
${ this.serviceSettings.prompt_manager_settings.showAdvancedSettings <a class="menu_button fa-file-arrow-down fa-solid" id="prompt-manager-export" title="Export this prompt list" data-i18n="Export"></a>
? `<a class="menu_button fa-file-arrow-down fa-solid" id="prompt-manager-export" title="Export this prompt list" data-i18n="Export"></a> <a class="menu_button fa-file-arrow-up fa-solid" id="prompt-manager-import" title="Import a prompt list" data-i18n="Import"></a>
<a class="menu_button fa-file-arrow-up fa-solid" id="prompt-manager-import" title="Import a prompt list" data-i18n="Import"></a>` : '' }
<a class="menu_button fa-undo fa-solid" id="prompt-manager-reset-character" title="Reset current character" data-i18n="Reset current character"></a> <a class="menu_button fa-undo fa-solid" id="prompt-manager-reset-character" title="Reset current character" data-i18n="Reset current character"></a>
<a class="menu_button fa-plus-square fa-solid" title="New prompt" data-i18n="New"></a> <a class="menu_button fa-plus-square fa-solid" title="New prompt" data-i18n="New"></a>
</div> </div>
@ -1155,8 +1128,7 @@ PromptManagerModule.prototype.renderPromptManager = function () {
footerDiv.querySelector('.menu_button:last-child').addEventListener('click', this.handleNewPrompt); footerDiv.querySelector('.menu_button:last-child').addEventListener('click', this.handleNewPrompt);
// Add prompt export dialogue and options // Add prompt export dialogue and options
if (true === this.serviceSettings.prompt_manager_settings.showAdvancedSettings) { const exportPopup = `
const exportPopup = `
<div id="prompt-manager-export-format-popup" class="list-group"> <div id="prompt-manager-export-format-popup" class="list-group">
<div class="prompt-manager-export-format-popup-flex"> <div class="prompt-manager-export-format-popup-flex">
<div class="row"> <div class="row">
@ -1171,29 +1143,28 @@ PromptManagerModule.prototype.renderPromptManager = function () {
</div> </div>
`; `;
rangeBlockDiv.insertAdjacentHTML('beforeend', exportPopup); rangeBlockDiv.insertAdjacentHTML('beforeend', exportPopup);
let exportPopper = Popper.createPopper( let exportPopper = Popper.createPopper(
document.getElementById('prompt-manager-export'), document.getElementById('prompt-manager-export'),
document.getElementById('prompt-manager-export-format-popup'), document.getElementById('prompt-manager-export-format-popup'),
{placement: 'bottom'} {placement: 'bottom'}
); );
const showExportSelection = () => { const showExportSelection = () => {
const popup = document.getElementById('prompt-manager-export-format-popup'); const popup = document.getElementById('prompt-manager-export-format-popup');
const show = popup.hasAttribute('data-show'); const show = popup.hasAttribute('data-show');
if (show) popup.removeAttribute('data-show'); if (show) popup.removeAttribute('data-show');
else popup.setAttribute('data-show', ''); else popup.setAttribute('data-show', '');
exportPopper.update(); exportPopper.update();
}
footerDiv.querySelector('#prompt-manager-import').addEventListener('click', this.handleImport);
footerDiv.querySelector('#prompt-manager-export').addEventListener('click', showExportSelection);
rangeBlockDiv.querySelector('.export-promptmanager-prompts-full').addEventListener('click', this.handleFullExport);
rangeBlockDiv.querySelector('.export-promptmanager-prompts-character').addEventListener('click', this.handleCharacterExport);
} }
footerDiv.querySelector('#prompt-manager-import').addEventListener('click', this.handleImport);
footerDiv.querySelector('#prompt-manager-export').addEventListener('click', showExportSelection);
rangeBlockDiv.querySelector('.export-promptmanager-prompts-full').addEventListener('click', this.handleFullExport);
rangeBlockDiv.querySelector('.export-promptmanager-prompts-character').addEventListener('click', this.handleCharacterExport);
} }
}; };
@ -1222,16 +1193,6 @@ PromptManagerModule.prototype.renderPromptManagerListItems = function () {
this.getPromptsForCharacter(this.activeCharacter).forEach(prompt => { this.getPromptsForCharacter(this.activeCharacter).forEach(prompt => {
if (!prompt) return; if (!prompt) return;
const advancedEnabled = this.serviceSettings.prompt_manager_settings.showAdvancedSettings;
let visibleClass = `${prefix}prompt_manager_prompt_visible`;
if (prompt.marker &&
prompt.identifier !== 'newMainChat' &&
prompt.identifier !== 'chatHistory' &&
prompt.identifier !== 'characterInfo' &&
!advancedEnabled) visibleClass = `${prefix}prompt_manager_prompt_invisible`;
const listEntry = this.getPromptOrderEntry(this.activeCharacter, prompt.identifier); const listEntry = this.getPromptOrderEntry(this.activeCharacter, prompt.identifier);
const enabledClass = listEntry.enabled ? '' : `${prefix}prompt_manager_prompt_disabled`; const enabledClass = listEntry.enabled ? '' : `${prefix}prompt_manager_prompt_disabled`;
const draggableClass = `${prefix}prompt_manager_prompt_draggable`; const draggableClass = `${prefix}prompt_manager_prompt_draggable`;
@ -1287,7 +1248,7 @@ PromptManagerModule.prototype.renderPromptManagerListItems = function () {
} }
listItemHtml += ` listItemHtml += `
<li class="${prefix}prompt_manager_prompt ${visibleClass} ${draggableClass} ${enabledClass} ${markerClass}" data-pm-identifier="${prompt.identifier}"> <li class="${prefix}prompt_manager_prompt ${draggableClass} ${enabledClass} ${markerClass}" data-pm-identifier="${prompt.identifier}">
<span class="${prefix}prompt_manager_prompt_name" data-pm-name="${prompt.name}"> <span class="${prefix}prompt_manager_prompt_name" data-pm-name="${prompt.name}">
${prompt.marker ? '<span class="fa-solid fa-thumb-tack" title="Prompt Marker"></span>' : ''} ${prompt.marker ? '<span class="fa-solid fa-thumb-tack" title="Prompt Marker"></span>' : ''}
${!prompt.marker && prompt.system_prompt ? '<span class="fa-solid fa-globe" title="Global Prompt"></span>' : ''} ${!prompt.marker && prompt.system_prompt ? '<span class="fa-solid fa-globe" title="Global Prompt"></span>' : ''}
@ -1661,17 +1622,10 @@ const promptManagerDefaultPromptOrder = [
} }
]; ];
const promptManagerDefaultSettings = {
prompt_manager_settings: {
showAdvancedSettings: false
}
};
export { export {
PromptManagerModule, PromptManagerModule,
registerPromptManagerMigration, registerPromptManagerMigration,
chatCompletionDefaultPrompts, chatCompletionDefaultPrompts,
promptManagerDefaultPromptOrders, promptManagerDefaultPromptOrders,
promptManagerDefaultSettings,
Prompt Prompt
}; };

View File

@ -28,7 +28,6 @@ import {
import {groups, selected_group} from "./group-chats.js"; import {groups, selected_group} from "./group-chats.js";
import { import {
promptManagerDefaultSettings,
promptManagerDefaultPromptOrders, promptManagerDefaultPromptOrders,
chatCompletionDefaultPrompts, Prompt, chatCompletionDefaultPrompts, Prompt,
PromptManagerModule as PromptManager PromptManagerModule as PromptManager
@ -144,7 +143,6 @@ const default_settings = {
names_in_completion: false, names_in_completion: false,
...chatCompletionDefaultPrompts, ...chatCompletionDefaultPrompts,
...promptManagerDefaultPromptOrders, ...promptManagerDefaultPromptOrders,
...promptManagerDefaultSettings,
send_if_empty: '', send_if_empty: '',
impersonation_prompt: default_impersonation_prompt, impersonation_prompt: default_impersonation_prompt,
new_chat_prompt: default_new_chat_prompt, new_chat_prompt: default_new_chat_prompt,
@ -183,7 +181,6 @@ const oai_settings = {
names_in_completion: false, names_in_completion: false,
...chatCompletionDefaultPrompts, ...chatCompletionDefaultPrompts,
...promptManagerDefaultPromptOrders, ...promptManagerDefaultPromptOrders,
...promptManagerDefaultSettings,
send_if_empty: '', send_if_empty: '',
impersonation_prompt: default_impersonation_prompt, impersonation_prompt: default_impersonation_prompt,
new_chat_prompt: default_new_chat_prompt, new_chat_prompt: default_new_chat_prompt,