diff --git a/public/locales/ru-ru.json b/public/locales/ru-ru.json index 7e9c7a32c..1a3a1bc4a 100644 --- a/public/locales/ru-ru.json +++ b/public/locales/ru-ru.json @@ -1266,5 +1266,12 @@ "Message Content": "Внутри сообщения", "Prepend character names to message contents.": "Предварять сообщения именем персонажа.", "Character Names Behavior": "Вставка имени персонажа", - "Restrictions apply: only Latin alphanumerics and underscores. Doesn't work for all sources, notably: Claude, MistralAI, Google.": "Только латинские буквы, цифры и знак подчёркивания. Работает не для всех бэкендов, в частности для Claude, MistralAI, Google." + "Restrictions apply: only Latin alphanumerics and underscores. Doesn't work for all sources, notably: Claude, MistralAI, Google.": "Только латинские буквы, цифры и знак подчёркивания. Работает не для всех бэкендов, в частности для Claude, MistralAI, Google.", + "and pick a character.": "и выберите персонажа.", + "Record a snapshot of your current settings.": "Сделать снимок текущих настроек.", + "Restore this snapshot": "Откатиться к этому снимку", + "To change your user avatar, use the buttons below or select a default persona in the Persona Management menu.": "Чтобы сменить аватарку, используйте кнопки ниже, либо выберите персону по умолчанию в меню управления персоной.", + "These characters are the winners of character design contests and have outstandable quality.": "Персонажи наивысшего качества, одержавшие победу в конкурсе персонажей.", + "Featured Characters": "Рекомендуемые персонажи", + "These characters are the finalists of character design contests and have remarkable quality.": "Персонажи отличного качества, финалисты конкурса персонажей." } diff --git a/public/scripts/PromptManager.js b/public/scripts/PromptManager.js index bb7f90d90..d45da25bf 100644 --- a/public/scripts/PromptManager.js +++ b/public/scripts/PromptManager.js @@ -6,7 +6,6 @@ import { Message, TokenHandler } from './openai.js'; import { power_user } from './power-user.js'; import { debounce, waitUntilCondition, escapeHtml } from './utils.js'; import { debounce_timeout } from './constants.js'; -import { renderTemplateAsync } from './templates.js' function debouncePromise(func, delay) { let timeoutId; @@ -703,14 +702,16 @@ class PromptManager { this.tryGenerate().finally(() => { this.profileEnd('filling context'); this.profileStart('render'); - this.renderPromptManager().then(() => this.renderPromptManagerListItems()); + this.renderPromptManager(); + this.renderPromptManagerListItems(); this.makeDraggable(); this.profileEnd('render'); }); } else { // Executed during live communication this.profileStart('render'); - this.renderPromptManager().then(() => this.renderPromptManagerListItems()); + this.renderPromptManager(); + this.renderPromptManagerListItems(); this.makeDraggable(); this.profileEnd('render'); } @@ -1337,7 +1338,7 @@ class PromptManager { /** * Empties, then re-assembles the container containing the prompt list. */ - async renderPromptManager() { + renderPromptManager() { let selectedPromptIndex = 0; const existingAppendSelect = document.getElementById(`${this.configuration.prefix}prompt_manager_footer_append_prompt`); if (existingAppendSelect instanceof HTMLSelectElement) { @@ -1353,9 +1354,19 @@ class PromptManager { `; const totalActiveTokens = this.tokenUsage; - - const headerHtml = await renderTemplateAsync('promptManagerHeader', {error: this.error, errorDiv, prefix: this.configuration.prefix, totalActiveTokens}); - promptManagerDiv.insertAdjacentHTML('beforeend', headerHtml); + + promptManagerDiv.insertAdjacentHTML('beforeend', ` +
+ ${this.error ? errorDiv : ''} +
+
+ Prompts +
+
Total Tokens: ${totalActiveTokens}
+
+ +
+ `); this.listElement = promptManagerDiv.querySelector(`#${this.configuration.prefix}prompt_manager_list`); @@ -1373,9 +1384,22 @@ class PromptManager { selectedPromptIndex = 0; } + const footerHtml = ` + + `; + const rangeBlockDiv = promptManagerDiv.querySelector('.range-block'); const headerDiv = promptManagerDiv.querySelector('.completion_prompt_manager_header'); - const footerHtml = await renderTemplateAsync('promptManagerFooter', {promptsHtml, prefix: this.configuration.prefix}); headerDiv.insertAdjacentHTML('afterend', footerHtml); rangeBlockDiv.querySelector('#prompt-manager-reset-character').addEventListener('click', this.handleCharacterReset); @@ -1386,9 +1410,23 @@ class PromptManager { footerDiv.querySelector('select').selectedIndex = selectedPromptIndex; // Add prompt export dialogue and options - - const exportForCharacter = await renderTemplateAsync('promptManagerExportForCharacter'); - let exportPopup = await renderTemplateAsync('promptManagerExportPopup', {isGlobalStrategy: 'global' === this.configuration.promptOrder.strategy, exportForCharacter}); + const exportForCharacter = ` +
+ Export for character + +
`; + const exportPopup = ` +
+
+
+ Export all + +
+ ${'global' === this.configuration.promptOrder.strategy ? '' : exportForCharacter} +
+
+ `; + rangeBlockDiv.insertAdjacentHTML('beforeend', exportPopup); // Destroy previous popper instance if it exists @@ -1422,36 +1460,43 @@ class PromptManager { /** * Empties, then re-assembles the prompt list */ - async renderPromptManagerListItems() { + renderPromptManagerListItems() { if (!this.serviceSettings.prompts) return; const promptManagerList = this.listElement; promptManagerList.innerHTML = ''; const { prefix } = this.configuration; - - const that = this; - - let listItem = await renderTemplateAsync('promptManagerListHeader', {prefix}); - - this.getPromptsForCharacter(this.activeCharacter).forEach(async function(prompt) { + + let listItemHtml = ` +
  • + Name + + Tokens +
  • +
  • +
    +
  • + `; + + this.getPromptsForCharacter(this.activeCharacter).forEach(prompt => { if (!prompt) return; - const listEntry = that.getPromptOrderEntry(that.activeCharacter, prompt.identifier); + const listEntry = this.getPromptOrderEntry(this.activeCharacter, prompt.identifier); const enabledClass = listEntry.enabled ? '' : `${prefix}prompt_manager_prompt_disabled`; const draggableClass = `${prefix}prompt_manager_prompt_draggable`; const markerClass = prompt.marker ? `${prefix}prompt_manager_marker` : ''; - const tokens = that.tokenHandler?.getCounts()[prompt.identifier] ?? 0; + const tokens = this.tokenHandler?.getCounts()[prompt.identifier] ?? 0; // Warn the user if the chat history goes below certain token thresholds. let warningClass = ''; let warningTitle = ''; - const tokenBudget = that.serviceSettings.openai_max_context - that.serviceSettings.openai_max_tokens; - if (that.tokenUsage > tokenBudget * 0.8 && + const tokenBudget = this.serviceSettings.openai_max_context - this.serviceSettings.openai_max_tokens; + if (this.tokenUsage > tokenBudget * 0.8 && 'chatHistory' === prompt.identifier) { - const warningThreshold = that.configuration.warningTokenThreshold; - const dangerThreshold = that.configuration.dangerTokenThreshold; + const warningThreshold = this.configuration.warningTokenThreshold; + const dangerThreshold = this.configuration.dangerTokenThreshold; if (tokens <= dangerThreshold) { warningClass = 'fa-solid tooltip fa-triangle-exclamation text_danger'; @@ -1465,7 +1510,7 @@ class PromptManager { const calculatedTokens = tokens ? tokens : '-'; let detachSpanHtml = ''; - if (that.isPromptDeletionAllowed(prompt)) { + if (this.isPromptDeletionAllowed(prompt)) { detachSpanHtml = ` `; @@ -1474,7 +1519,7 @@ class PromptManager { } let editSpanHtml = ''; - if (that.isPromptEditAllowed(prompt)) { + if (this.isPromptEditAllowed(prompt)) { editSpanHtml = ` `; @@ -1483,7 +1528,7 @@ class PromptManager { } let toggleSpanHtml = ''; - if (that.isPromptToggleAllowed(prompt)) { + if (this.isPromptToggleAllowed(prompt)) { toggleSpanHtml = ` `; @@ -1496,9 +1541,9 @@ class PromptManager { const isImportantPrompt = !prompt.marker && prompt.system_prompt && prompt.injection_position !== INJECTION_POSITION.ABSOLUTE && prompt.forbid_overrides; const isUserPrompt = !prompt.marker && !prompt.system_prompt && prompt.injection_position !== INJECTION_POSITION.ABSOLUTE; const isInjectionPrompt = !prompt.marker && prompt.injection_position === INJECTION_POSITION.ABSOLUTE; - const isOverriddenPrompt = Array.isArray(that.overriddenPrompts) && that.overriddenPrompts.includes(prompt.identifier); + const isOverriddenPrompt = Array.isArray(this.overriddenPrompts) && this.overriddenPrompts.includes(prompt.identifier); const importantClass = isImportantPrompt ? `${prefix}prompt_manager_important` : ''; - listItem += ` + listItemHtml += `
  • ${prompt.marker ? '' : ''} @@ -1506,7 +1551,7 @@ class PromptManager { ${isImportantPrompt ? '' : ''} ${isUserPrompt ? '' : ''} ${isInjectionPrompt ? '' : ''} - ${that.isPromptInspectionAllowed(prompt) ? `${encodedName}` : encodedName} + ${this.isPromptInspectionAllowed(prompt) ? `${encodedName}` : encodedName} ${isInjectionPrompt ? `@ ${prompt.injection_depth}` : ''} ${isOverriddenPrompt ? '' : ''} @@ -1523,7 +1568,7 @@ class PromptManager { `; }); - promptManagerList.insertAdjacentHTML('beforeend', listItem); + promptManagerList.insertAdjacentHTML('beforeend', listItemHtml); // Now that the new elements are in the DOM, you can add the event listeners. Array.from(promptManagerList.getElementsByClassName('prompt-manager-detach-action')).forEach(el => { diff --git a/public/scripts/extensions/assets/market.html b/public/scripts/extensions/assets/market.html index 26422d758..1912c4324 100644 --- a/public/scripts/extensions/assets/market.html +++ b/public/scripts/extensions/assets/market.html @@ -1,6 +1,6 @@
    -

    +

    Contest Winners

    @@ -9,7 +9,7 @@

    -

    +

    Featured Characters

    diff --git a/public/scripts/templates/promptManagerExportForCharacter.html b/public/scripts/templates/promptManagerExportForCharacter.html deleted file mode 100644 index 11d592aaf..000000000 --- a/public/scripts/templates/promptManagerExportForCharacter.html +++ /dev/null @@ -1,4 +0,0 @@ - \ No newline at end of file diff --git a/public/scripts/templates/promptManagerExportPopup.html b/public/scripts/templates/promptManagerExportPopup.html deleted file mode 100644 index 2141c6092..000000000 --- a/public/scripts/templates/promptManagerExportPopup.html +++ /dev/null @@ -1,12 +0,0 @@ -
    -
    -
    - Export all - -
    - {{#if isGlobalStrategy}} - {{else}} - {{exportForCharacter}} - {{/if}} -
    -
    \ No newline at end of file diff --git a/public/scripts/templates/promptManagerFooter.html b/public/scripts/templates/promptManagerFooter.html deleted file mode 100644 index 51302d059..000000000 --- a/public/scripts/templates/promptManagerFooter.html +++ /dev/null @@ -1,11 +0,0 @@ - \ No newline at end of file diff --git a/public/scripts/templates/promptManagerHeader.html b/public/scripts/templates/promptManagerHeader.html deleted file mode 100644 index bcdf51251..000000000 --- a/public/scripts/templates/promptManagerHeader.html +++ /dev/null @@ -1,12 +0,0 @@ -
    - {{#if error}} - {{errorDiv}} - {{/if}} -
    -
    - Prompts -
    -
    Total Tokens: {{totalActiveTokens}}
    -
    -
      -
      \ No newline at end of file diff --git a/public/scripts/templates/promptManagerListHeader.html b/public/scripts/templates/promptManagerListHeader.html deleted file mode 100644 index 24cb29526..000000000 --- a/public/scripts/templates/promptManagerListHeader.html +++ /dev/null @@ -1,8 +0,0 @@ -
    • - Name - - Tokens -
    • -
    • -
      -
    • \ No newline at end of file diff --git a/public/scripts/templates/snapshotsView.html b/public/scripts/templates/snapshotsView.html index 5281be319..763190757 100644 --- a/public/scripts/templates/snapshotsView.html +++ b/public/scripts/templates/snapshotsView.html @@ -1,7 +1,7 @@

      Settings Snapshots -

      - +
      diff --git a/public/scripts/templates/userProfile.html b/public/scripts/templates/userProfile.html index e1eb34ecd..8d413aab7 100644 --- a/public/scripts/templates/userProfile.html +++ b/public/scripts/templates/userProfile.html @@ -16,7 +16,7 @@
      -
      +
      avatar