diff --git a/public/css/promptmanager.css b/public/css/promptmanager.css index 6cf4dd0d0..178682998 100644 --- a/public/css/promptmanager.css +++ b/public/css/promptmanager.css @@ -19,7 +19,7 @@ #completion_prompt_manager #completion_prompt_manager_list li { display: grid; - grid-template-columns: 4fr 80px 40px; + grid-template-columns: 4fr 80px 45px; margin-bottom: 0.5em; width: 100% } diff --git a/public/index.html b/public/index.html index 2397b93e0..8360e97d6 100644 --- a/public/index.html +++ b/public/index.html @@ -1750,13 +1750,13 @@
-
@@ -4511,8 +4511,8 @@ - - + + diff --git a/public/locales/ru-ru.json b/public/locales/ru-ru.json index 1a3a1bc4a..7d73a774b 100644 --- a/public/locales/ru-ru.json +++ b/public/locales/ru-ru.json @@ -381,7 +381,7 @@ "Delete": "Удалить", "Cancel": "Отменить", "Advanced Defininitions": "Расширенное описание", - "Personality summary": "Сводка по личности", + "Personality summary": "Резюме по личности", "A brief description of the personality": "Краткое описание личности", "Scenario": "Сценарий", "Circumstances and context of the dialogue": "Обстоятельства и контекст диалога", @@ -627,7 +627,7 @@ "Most chats": "Больше всего чатов", "Least chats": "Меньше всего чатов", "Back": "Назад", - "Prompt Overrides": "Индивидуальный промпт", + "Prompt Overrides": "Индивидуальные промпты", "(For OpenAI/Claude/Scale APIs, Window/OpenRouter, and Instruct Mode)": "(для API OpenAI/Claude/Scale, Window/OpenRouter, а также режима Instruct)", "Insert {{original}} into either box to include the respective default prompt from system settings.": "Введите {{original}} в любое поле, чтобы вставить соответствующий промпт из системных настроек", "Main Prompt": "Основной промпт", @@ -872,7 +872,7 @@ "Assistant Prefill": "Префилл для ассистента", "Start Claude's answer with...": "Начать ответ Клода с...", "Use system prompt (Claude 2.1+ only)": "Использовать системный промпт (только Claude 2.1+)", - "Send the system prompt for supported models. If disabled, the user message is added to the beginning of the prompt.": "Отправлять системный промпт для поддерживаемых моделей. Если отключено, сообщение пользователя добавляется в начало промпта.", + "Send the system prompt for supported models. If disabled, the user message is added to the beginning of the prompt.": "Отправлять системный промпт для поддерживаемых моделей. Если отключено, в начало промпта добавляется сообщение пользователя.", "Prompts": "Промпты", "Total Tokens:": "Всего токенов:", "Insert prompt": "Вставить промпт", @@ -1273,5 +1273,15 @@ "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.": "Персонажи отличного качества, финалисты конкурса персонажей." + "These characters are the finalists of character design contests and have remarkable quality.": "Персонажи отличного качества, финалисты конкурса персонажей.", + "Inline Image Quality": "Качество inline-изображений", + "openai_inline_image_quality_auto": "Автоопределение", + "openai_inline_image_quality_low": "Низкое", + "openai_inline_image_quality_high": "Высокое", + "Assistant Impersonation Prefill": "Префилл для ассистента при перевоплощении", + "Hide Chat Avatars": "Не показывать аватарки в чате", + "Hide avatars in chat messages.": "Скрыть аватарки сбоку от сообщений в чате", + "Flat": "Стандартный", + "Toggle character info panel": "Показать / скрыть инфо-панель", + "(For Chat Completion and Instruct Mode)": "(для Chat Completion и режима Instruct)" } diff --git a/public/scripts/PromptManager.js b/public/scripts/PromptManager.js index d45da25bf..9be84ae70 100644 --- a/public/scripts/PromptManager.js +++ b/public/scripts/PromptManager.js @@ -6,6 +6,7 @@ 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; @@ -250,7 +251,7 @@ class PromptManager { this.error = null; /** Dry-run for generate, must return a promise */ - this.tryGenerate = () => { }; + this.tryGenerate = async () => { }; /** Called to persist the configuration, must return a promise */ this.saveServiceSettings = () => { }; @@ -695,23 +696,23 @@ class PromptManager { if ('character' === this.configuration.promptOrder.strategy && null === this.activeCharacter) return; this.error = null; - waitUntilCondition(() => !is_send_press && !is_group_generating, 1024 * 1024, 100).then(() => { + waitUntilCondition(() => !is_send_press && !is_group_generating, 1024 * 1024, 100).then(async () => { if (true === afterTryGenerate) { // Executed during dry-run for determining context composition this.profileStart('filling context'); - this.tryGenerate().finally(() => { + this.tryGenerate().finally(async () => { this.profileEnd('filling context'); this.profileStart('render'); - this.renderPromptManager(); - this.renderPromptManagerListItems(); + await this.renderPromptManager(); + await this.renderPromptManagerListItems(); this.makeDraggable(); this.profileEnd('render'); }); } else { // Executed during live communication this.profileStart('render'); - this.renderPromptManager(); - this.renderPromptManagerListItems(); + await this.renderPromptManager(); + await this.renderPromptManagerListItems(); this.makeDraggable(); this.profileEnd('render'); } @@ -1338,7 +1339,7 @@ class PromptManager { /** * Empties, then re-assembles the container containing the prompt list. */ - renderPromptManager() { + async renderPromptManager() { let selectedPromptIndex = 0; const existingAppendSelect = document.getElementById(`${this.configuration.prefix}prompt_manager_footer_append_prompt`); if (existingAppendSelect instanceof HTMLSelectElement) { @@ -1349,24 +1350,14 @@ class PromptManager { const errorDiv = `
- ${this.error} + ${DOMPurify.sanitize(this.error)}
`; const totalActiveTokens = this.tokenUsage; - promptManagerDiv.insertAdjacentHTML('beforeend', ` -
- ${this.error ? errorDiv : ''} -
-
- Prompts -
-
Total Tokens: ${totalActiveTokens}
-
- -
- `); + const headerHtml = await renderTemplateAsync('promptManagerHeader', { error: this.error, errorDiv, prefix: this.configuration.prefix, totalActiveTokens }); + promptManagerDiv.insertAdjacentHTML('beforeend', headerHtml); this.listElement = promptManagerDiv.querySelector(`#${this.configuration.prefix}prompt_manager_list`); @@ -1384,22 +1375,9 @@ 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); @@ -1410,23 +1388,9 @@ class PromptManager { footerDiv.querySelector('select').selectedIndex = selectedPromptIndex; // Add prompt export dialogue and options - const exportForCharacter = ` -
- Export for character - -
`; - const exportPopup = ` -
-
-
- Export all - -
- ${'global' === this.configuration.promptOrder.strategy ? '' : exportForCharacter} -
-
- `; + const exportForCharacter = await renderTemplateAsync('promptManagerExportForCharacter'); + const exportPopup = await renderTemplateAsync('promptManagerExportPopup', { isGlobalStrategy: 'global' === this.configuration.promptOrder.strategy, exportForCharacter }); rangeBlockDiv.insertAdjacentHTML('beforeend', exportPopup); // Destroy previous popper instance if it exists @@ -1460,7 +1424,7 @@ class PromptManager { /** * Empties, then re-assembles the prompt list */ - renderPromptManagerListItems() { + async renderPromptManagerListItems() { if (!this.serviceSettings.prompts) return; const promptManagerList = this.listElement; @@ -1468,16 +1432,7 @@ class PromptManager { const { prefix } = this.configuration; - let listItemHtml = ` -
  • - Name - - Tokens -
  • -
  • -
    -
  • - `; + let listItemHtml = await renderTemplateAsync('promptManagerListHeader', { prefix }); this.getPromptsForCharacter(this.activeCharacter).forEach(prompt => { if (!prompt) return; @@ -1602,7 +1557,7 @@ class PromptManager { data: data, }; - const serializedObject = JSON.stringify(promptExport); + const serializedObject = JSON.stringify(promptExport, null, 4); const blob = new Blob([serializedObject], { type: 'application/json' }); const url = URL.createObjectURL(blob); const downloadLink = document.createElement('a'); diff --git a/public/scripts/templates/promptManagerExportForCharacter.html b/public/scripts/templates/promptManagerExportForCharacter.html new file mode 100644 index 000000000..2127f7dfb --- /dev/null +++ b/public/scripts/templates/promptManagerExportForCharacter.html @@ -0,0 +1,4 @@ +
    + Export for character + +
    diff --git a/public/scripts/templates/promptManagerExportPopup.html b/public/scripts/templates/promptManagerExportPopup.html new file mode 100644 index 000000000..0beae5446 --- /dev/null +++ b/public/scripts/templates/promptManagerExportPopup.html @@ -0,0 +1,12 @@ +
    +
    +
    + Export all + +
    + {{#if isGlobalStrategy}} + {{else}} + {{{exportForCharacter}}} + {{/if}} +
    +
    diff --git a/public/scripts/templates/promptManagerFooter.html b/public/scripts/templates/promptManagerFooter.html new file mode 100644 index 000000000..ccd328c62 --- /dev/null +++ b/public/scripts/templates/promptManagerFooter.html @@ -0,0 +1,11 @@ + diff --git a/public/scripts/templates/promptManagerHeader.html b/public/scripts/templates/promptManagerHeader.html new file mode 100644 index 000000000..8a3705e09 --- /dev/null +++ b/public/scripts/templates/promptManagerHeader.html @@ -0,0 +1,12 @@ +
    + {{#if error}} + {{{errorDiv}}} + {{/if}} +
    +
    + Prompts +
    +
    Total Tokens: {{totalActiveTokens}}
    +
    + +
    diff --git a/public/scripts/templates/promptManagerListHeader.html b/public/scripts/templates/promptManagerListHeader.html new file mode 100644 index 000000000..29d81965c --- /dev/null +++ b/public/scripts/templates/promptManagerListHeader.html @@ -0,0 +1,8 @@ +
  • + Name + + Tokens +
  • +
  • +
    +