mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Work on tl
This commit is contained in:
@ -2015,7 +2015,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex-container flexFlowColumn wide100p textAlignCenter marginTop10" data-source="openai,custom">
|
||||
<div class="flex-container oneline-dropdown" title="Constrains effort on reasoning for reasoning models. Currently supported values are low, medium, and high. Reducing reasoning effort can result in faster responses and fewer tokens used on reasoning in a response.">
|
||||
<div class="flex-container oneline-dropdown" title="Constrains effort on reasoning for reasoning models. Currently supported values are low, medium, and high. Reducing reasoning effort can result in faster responses and fewer tokens used on reasoning in a response." data-i18n="[title]Constrains effort on reasoning for reasoning models.">
|
||||
<label for="openai_reasoning_effort" data-i18n="Reasoning Effort">
|
||||
Reasoning Effort
|
||||
</label>
|
||||
@ -4001,7 +4001,7 @@
|
||||
<div class="alignitemscenter flex-container flexFlowColumn flexGrow flexShrink gap0 flexBasis48p" title="Cap the number of entry activation recursions" data-i18n="[title]Cap the number of entry activation recursions">
|
||||
<small>
|
||||
<span data-i18n="Max Recursion Steps">Max Recursion Steps</span>
|
||||
<div class="fa-solid fa-triangle-exclamation opacity50p" data-i18n="[title]0 = unlimited, 1 = scans once and doesn't recurse, 2 = scans once and recurses once, etc\n(disabled when min activations are used)" title="0 = unlimited, 1 = scans once and doesn't recurse, 2 = scans once and recurses once, etc (disabled when min activations are used)"></div>
|
||||
<div class="fa-solid fa-triangle-exclamation opacity50p" data-i18n="[title]0 = unlimited, 1 = scans once and doesn't recurse, 2 = scans once and recurses once, etc" title="0 = unlimited, 1 = scans once and doesn't recurse, 2 = scans once and recurses once, etc (disabled when min activations are used)"></div>
|
||||
</small>
|
||||
<input class="neo-range-slider" type="range" id="world_info_max_recursion_steps" name="world_info_max_recursion_steps" min="0" max="10" step="1">
|
||||
<input class="neo-range-input" type="number" min="0" max="10" step="1" data-for="world_info_max_recursion_steps" id="world_info_max_recursion_steps_counter">
|
||||
@ -6890,8 +6890,8 @@
|
||||
</div>
|
||||
<div id="form_sheld">
|
||||
<div id="dialogue_del_mes">
|
||||
<div id="dialogue_del_mes_ok" class="menu_button">Delete</div>
|
||||
<div id="dialogue_del_mes_cancel" class="menu_button">Cancel</div>
|
||||
<div id="dialogue_del_mes_ok" data-i18n="Delete" class="menu_button">Delete</div>
|
||||
<div id="dialogue_del_mes_cancel" data-i18n="Cancel" class="menu_button">Cancel</div>
|
||||
</div>
|
||||
<div id="send_form" class="no-connection">
|
||||
<form id="file_form" class="wide100p displayNone">
|
||||
|
@ -195,7 +195,7 @@
|
||||
"Yes": "Да",
|
||||
"No": "Нет",
|
||||
"Context %": "Процент контекста",
|
||||
"Budget Cap": "Бюджетный лимит",
|
||||
"Budget Cap": "Лимит бюджета",
|
||||
"(0 = disabled)": "(0 = отключено)",
|
||||
"None": "Отсутствует",
|
||||
"User Settings": "Настройки пользователя",
|
||||
@ -575,10 +575,10 @@
|
||||
"Characters sorting order": "Порядок сортировки персонажей",
|
||||
"Remove": "Убрать",
|
||||
"Select a World Info file for": "Выбрать файл с миром для",
|
||||
"Primary Lorebook": "Основного лорбука",
|
||||
"A selected World Info will be bound to this character as its own Lorebook.": "Информация о мире будет привязана к персонажу как его собственный лорбук",
|
||||
"When generating an AI reply, it will be combined with the entries from a global World Info selector.": "Когда ИИ генерирует ответ, он будет совмещён с записями из глобально выбранного мира",
|
||||
"Exporting a character would also export the selected Lorebook file embedded in the JSON data.": "При экспорте персонажа вместе с ним также выгрузится выбранный лорбук в виде JSON",
|
||||
"Primary Lorebook": "Основной лорбук",
|
||||
"A selected World Info will be bound to this character as its own Lorebook.": "Информация о мире будет привязана к персонажу как его собственный лорбук.",
|
||||
"When generating an AI reply, it will be combined with the entries from a global World Info selector.": "Когда ИИ генерирует ответ, он будет совмещён с записями из глобально выбранного мира.",
|
||||
"Exporting a character would also export the selected Lorebook file embedded in the JSON data.": "При экспорте персонажа вместе с ним также выгрузится выбранный лорбук в виде JSON.",
|
||||
"Additional Lorebooks": "Вспомогательные лорбуки",
|
||||
"Associate one or more auxillary Lorebooks with this character.": "Привязать к этому персонажу один или больше вспомогательных лорбуков",
|
||||
"NOTE: These choices are optional and won't be preserved on character export!": "ВНИМАНИЕ: эти выборы необязательные и не будут сохранены при экспорте персонажа!",
|
||||
@ -593,7 +593,7 @@
|
||||
"Prompt": "Промпт",
|
||||
"Copy": "Скопировать",
|
||||
"Confirm": "Подтвердить",
|
||||
"Copy this message": "Скопировать сообщение",
|
||||
"Copy this message": "Продублировать сообщение",
|
||||
"Delete this message": "Удалить сообщение",
|
||||
"Move message up": "Переместить сообщение вверх",
|
||||
"Move message down": "Переместить сообщение вниз",
|
||||
@ -612,7 +612,7 @@
|
||||
"Ask AI to write your message for you": "Попросить ИИ написать сообщение за вас",
|
||||
"Continue the last message": "Продолжить текущее сообщение",
|
||||
"Bind user name to that avatar": "Закрепить имя за этим аватаром",
|
||||
"Select this as default persona for the new chats.": "Выберать эту Персону в качестве персоны по умолчанию для новых чатов.",
|
||||
"Select this as default persona for the new chats.": "Выбирать эту персону по умолчанию для всех новых чатов.",
|
||||
"Change persona image": "Сменить аватар персоны",
|
||||
"Delete persona": "Удалить персону",
|
||||
"Reduced Motion": "Сокращение анимаций",
|
||||
@ -640,7 +640,7 @@
|
||||
"Token Probabilities": "Вероятности токенов",
|
||||
"Close chat": "Закрыть чат",
|
||||
"Manage chat files": "Все чаты",
|
||||
"Import Extension From Git Repo": "Импортировать расширение из Git Repository",
|
||||
"Import Extension From Git Repo": "Импортировать расширение из Git-репозитория.",
|
||||
"Install extension": "Установить расширение",
|
||||
"Manage extensions": "Управление расширениями",
|
||||
"Tokens persona description": "Токенов",
|
||||
@ -1122,7 +1122,7 @@
|
||||
"help_hotkeys_0": "Горячие клавиши",
|
||||
"You can browse a list of bundled characters in the": "Комплектных персонажей можно найти в меню",
|
||||
"Download Extensions & Assets": "Загрузить расширения и ресурсы",
|
||||
"menu within": "внутри этих кубиков",
|
||||
"menu within": "в меню",
|
||||
"Assets URL": "URL с описанием ресурсов",
|
||||
"Custom (OpenAI-compatible)": "Кастомный (совместимый с OpenAI)",
|
||||
"Custom Endpoint (Base URL)": "Кастомный эндпоинт (базовый URL)",
|
||||
@ -1943,7 +1943,7 @@
|
||||
"and connect to an": "и подключитесь к",
|
||||
"You can add more": "Можете добавить больше",
|
||||
"from other websites": "с других сайтов.",
|
||||
"Go to the": "Загляните в",
|
||||
"Go to the": "Заходите в",
|
||||
"to install additional features.": ", чтобы установить разные дополнительные ресурсы.",
|
||||
"or_welcome": "; также доступен",
|
||||
"Claude API Key": "Ключ от API Claude",
|
||||
@ -1958,7 +1958,7 @@
|
||||
"Save": "Сохранить",
|
||||
"Chat Lorebook": "Лорбук для чата",
|
||||
"chat_world_template_txt": "Выбранный мир будет привязан к этому чату. Будет добавляться в промпт наряду с глобальным лорбуком и лором персонажа.",
|
||||
"world_button_title": "Лор персонажа\n\nНажмите, чтобы загрузить\nShift + клик, чтобы открыть диалог привязки мира",
|
||||
"world_button_title": "Лор персонажа\n\nНажмите, чтобы загрузить\nShift + ЛКМ, чтобы открыть диалог привязки мира",
|
||||
"No auxillary Lorebooks set. Click here to select.": "Вспомогательный лорбук не выбран. Нажмите, чтобы выбрать.",
|
||||
"ext_regex_user_input_desc": "Отправленные вами сообщения.",
|
||||
"ext_regex_ai_input_desc": "Полученные от API ответы.",
|
||||
@ -2144,5 +2144,65 @@
|
||||
"Not connected to the API!": "Нет соединения с API!",
|
||||
"ext_type_system": "Это комплектное расширение. Его нельзя удалить, а обновляется оно вместе со всей системой.",
|
||||
"Update all": "Обновить все",
|
||||
"Close": "Закрыть"
|
||||
}
|
||||
"Close": "Закрыть",
|
||||
"Optional modules:": "Необязательные модули:",
|
||||
"Sort: Display Name": "Сортировать: по названию",
|
||||
"Sort: Loading Order": "Сортировать: в порядке загрузки",
|
||||
"Click to toggle": "Нажмите, чтобы включить или выключить",
|
||||
"Loading Asset List": "Загрузить список ресурсов",
|
||||
"Don't ask again for this URL": "Запомнить выбор для этого адреса",
|
||||
"Are you sure you want to connect to the following url?": "Вы точно хотите подключиться к этому адресу?",
|
||||
"All": "Всё",
|
||||
"Characters": "Персонажи",
|
||||
"Ambient sounds": "Звуковой эмбиент",
|
||||
"Blip sounds": "Звуки уведомлений",
|
||||
"Background music": "Фоновая музыка",
|
||||
"Search": "Поиск",
|
||||
"extension_install_1": "Чтобы загружать расширения из этого списка, у вас должен быть установлен ",
|
||||
"extension_install_2": ".",
|
||||
"extension_install_3": "Нажмите на иконку ",
|
||||
"extension_install_4": ", чтобы перейти в репозиторий расширения и получить более подробную информацию о нём.",
|
||||
"Extension repo/guide:": "Репозиторий расширения:",
|
||||
"Preview in browser": "Предпросмотр",
|
||||
"Adds a function tool": "Частично или полностью работает через вызов функций",
|
||||
"Tool": "Функции",
|
||||
"Move extension": "Переместить расширение",
|
||||
"ext_type_local": "Это локальное расширение, доступно только вам",
|
||||
"ext_type_global": "Это глобальное расширение, доступно всем пользователям",
|
||||
"Move": "Переместить",
|
||||
"Enter the Git URL of the extension to install": "Введите Git-адрес расширения",
|
||||
"Please be aware that using external extensions can have unintended side effects and may pose security risks. Always make sure you trust the source before importing an extension. We are not responsible for any damage caused by third-party extensions.": "помните, что используя расширения от сторонних авторов, вы можете подвергать систему опасности. Устанавливайте расширения только от проверенных разработчиков. Мы не несём ответственности за любой ущерб, причинённый сторонними расширениями.",
|
||||
"Disclaimer:": "Внимание:",
|
||||
"Example:": "Пример:",
|
||||
"context_derived": "Считывать из метаданных модели (по возможности)",
|
||||
"instruct_derived": "Считывать из метаданных модели (по возможности)",
|
||||
"Confirm token parsing with": "Чтобы убедиться в правильности выделения токенов, используйте",
|
||||
"Reasoning Effort": "Рассуждения",
|
||||
"Constrains effort on reasoning for reasoning models.": "Регулирует объём внутренних рассуждений модели (reasoning), для моделей которые поддерживают эту возможность.\nНа данный момент поддерживаются три значения: Подробные, Обычные, Поверхностные.\nПри менее подробном рассуждении ответ получается быстрее, а также экономятся токены, уходящие на расуждения.",
|
||||
"openai_reasoning_effort_low": "Поверхностные",
|
||||
"openai_reasoning_effort_medium": "Обычные",
|
||||
"openai_reasoning_effort_high": "Подробные",
|
||||
"Persona Lore Alt+Click to open the lorebook": "Лорбук данной персоны\nAlt + ЛКМ чтобы открыть лорбук",
|
||||
"Persona Lorebook for": "Лорбук для персоны",
|
||||
"persona_world_template_txt": "Выбранная Информация о мире будет привязана к этой персоне. Информация будет добавляться в каждом промпте вместе с глобальным лорбуком и лорбуками персонажа и чата.",
|
||||
"Global list": "Глобальный список",
|
||||
"Preset-specific list": "Список для данного пресета",
|
||||
"Banned tokens/strings are being sent in the request.": "Запрещённые токены и строки отсылаются в запросе.",
|
||||
"Banned tokens/strings are NOT being sent in the request.": "Запрещённые токены и строки НЕ отсылаются в запросе.",
|
||||
"Add a reasoning block": "Добавить блок рассуждений",
|
||||
"Create a copy of this message?": "Продублировать это сообщение?",
|
||||
"Max Recursion Steps": "Макс. глубина рекурсии",
|
||||
"0 = unlimited, 1 = scans once and doesn't recurse, 2 = scans once and recurses once, etc": "0 = неограничено, 1 = сканировать единожды, 2 = сканировать единожды и сделать один повторный проход, и т.д.\n(неактивно при указанном мин. числе активаций)",
|
||||
"(disabled when max recursion steps are used)": "(неактивно при указанной макс. глубине рекурсии)",
|
||||
"Enter a valid API URL": "Введите корректный адрес API",
|
||||
"No Ollama model selected.": "Не выбрана модель Ollama",
|
||||
"Background Fitting": "Способ подгонки фона под разрешение",
|
||||
"Chat Lore Alt+Click to open the lorebook": "Лорбук данного чата\nAlt + ЛКМ чтобы открыть лорбук",
|
||||
"Token Counter": "Подсчитать токены",
|
||||
"Type / paste in the box below to see the number of tokens in the text.": "Введите или вставьте текст в окошко ниже, чтобы подсчитать количество токенов в нём.",
|
||||
"Selected tokenizer:": "Выбранный токенайзер:",
|
||||
"Input:": "Входные данные:",
|
||||
"Tokenized text:": "Токенизированный текст:",
|
||||
"Token IDs:": "Идентификаторы токенов:",
|
||||
"Tokens:": "Токенов:"
|
||||
}
|
@ -10943,7 +10943,7 @@ jQuery(async function () {
|
||||
});
|
||||
|
||||
$(document).on('click', '.mes_edit_copy', async function () {
|
||||
const confirmation = await callGenericPopup('Create a copy of this message?', POPUP_TYPE.CONFIRM);
|
||||
const confirmation = await callGenericPopup(t`Create a copy of this message?`, POPUP_TYPE.CONFIRM);
|
||||
if (!confirmation) {
|
||||
return;
|
||||
}
|
||||
|
@ -603,12 +603,12 @@ function generateExtensionHtml(name, manifest, isActive, isDisabled, isExternal,
|
||||
}
|
||||
|
||||
let toggleElement = isActive || isDisabled ?
|
||||
`<input type="checkbox" title="Click to toggle" data-name="${name}" class="${isActive ? 'toggle_disable' : 'toggle_enable'} ${checkboxClass}" ${isActive ? 'checked' : ''}>` :
|
||||
'<input type="checkbox" title="' + t`Click to toggle` + `" data-name="${name}" class="${isActive ? 'toggle_disable' : 'toggle_enable'} ${checkboxClass}" ${isActive ? 'checked' : ''}>` :
|
||||
`<input type="checkbox" title="Cannot enable extension" data-name="${name}" class="extension_missing ${checkboxClass}" disabled>`;
|
||||
|
||||
let deleteButton = isExternal ? `<button class="btn_delete menu_button" data-name="${externalId}" title="Delete"><i class="fa-fw fa-solid fa-trash-can"></i></button>` : '';
|
||||
let deleteButton = isExternal ? `<button class="btn_delete menu_button" data-name="${externalId}" data-i18n="[title]Delete" title="Delete"><i class="fa-fw fa-solid fa-trash-can"></i></button>` : '';
|
||||
let updateButton = isExternal ? `<button class="btn_update menu_button displayNone" data-name="${externalId}" title="Update available"><i class="fa-solid fa-download fa-fw"></i></button>` : '';
|
||||
let moveButton = isExternal && isUserAdmin ? `<button class="btn_move menu_button" data-name="${externalId}" title="Move"><i class="fa-solid fa-folder-tree fa-fw"></i></button>` : '';
|
||||
let moveButton = isExternal && isUserAdmin ? `<button class="btn_move menu_button" data-name="${externalId}" data-i18n="[title]Move" title="Move"><i class="fa-solid fa-folder-tree fa-fw"></i></button>` : '';
|
||||
let modulesInfo = '';
|
||||
|
||||
if (isActive && Array.isArray(manifest.optional)) {
|
||||
@ -616,7 +616,7 @@ function generateExtensionHtml(name, manifest, isActive, isDisabled, isExternal,
|
||||
modules.forEach(x => optional.delete(x));
|
||||
if (optional.size > 0) {
|
||||
const optionalString = DOMPurify.sanitize([...optional].join(', '));
|
||||
modulesInfo = `<div class="extension_modules">Optional modules: <span class="optional">${optionalString}</span></div>`;
|
||||
modulesInfo = '<div class="extension_modules">' + t`Optional modules:` + ` <span class="optional">${optionalString}</span></div>`;
|
||||
}
|
||||
} else if (!isDisabled) { // Neither active nor disabled
|
||||
const requirements = new Set(manifest.requires);
|
||||
|
@ -10,6 +10,7 @@ import { POPUP_TYPE, Popup, callGenericPopup } from '../../popup.js';
|
||||
import { executeSlashCommands } from '../../slash-commands.js';
|
||||
import { accountStorage } from '../../util/AccountStorage.js';
|
||||
import { flashHighlight, getStringHash, isValidUrl } from '../../utils.js';
|
||||
import { t } from '../../i18n.js';
|
||||
export { MODULE_NAME };
|
||||
|
||||
const MODULE_NAME = 'assets';
|
||||
@ -59,11 +60,11 @@ const KNOWN_TYPES = {
|
||||
'blip': 'Blip sounds',
|
||||
};
|
||||
|
||||
function downloadAssetsList(url) {
|
||||
updateCurrentAssets().then(function () {
|
||||
async function downloadAssetsList(url) {
|
||||
updateCurrentAssets().then(async function () {
|
||||
fetch(url, { cache: 'no-cache' })
|
||||
.then(response => response.json())
|
||||
.then(json => {
|
||||
.then(async function(json) {
|
||||
|
||||
availableAssets = {};
|
||||
$('#assets_menu').empty();
|
||||
@ -84,10 +85,10 @@ function downloadAssetsList(url) {
|
||||
|
||||
$('#assets_type_select').empty();
|
||||
$('#assets_search').val('');
|
||||
$('#assets_type_select').append($('<option />', { value: '', text: 'All' }));
|
||||
$('#assets_type_select').append($('<option />', { value: '', text: t`All` }));
|
||||
|
||||
for (const type of assetTypes) {
|
||||
const option = $('<option />', { value: type, text: KNOWN_TYPES[type] || type });
|
||||
const option = $('<option />', { value: type, text: t([KNOWN_TYPES[type] || type]) });
|
||||
$('#assets_type_select').append(option);
|
||||
}
|
||||
|
||||
@ -104,11 +105,7 @@ function downloadAssetsList(url) {
|
||||
assetTypeMenu.append(`<h3>${KNOWN_TYPES[assetType] || assetType}</h3>`).hide();
|
||||
|
||||
if (assetType == 'extension') {
|
||||
assetTypeMenu.append(`
|
||||
<div class="assets-list-git">
|
||||
To download extensions from this page, you need to have <a href="https://git-scm.com/downloads" target="_blank">Git</a> installed.<br>
|
||||
Click the <i class="fa-solid fa-sm fa-arrow-up-right-from-square"></i> icon to visit the Extension's repo for tips on how to use it.
|
||||
</div>`);
|
||||
assetTypeMenu.append(await renderExtensionTemplateAsync('assets', 'installation'));
|
||||
}
|
||||
|
||||
for (const i in availableAssets[assetType].sort((a, b) => a?.name && b?.name && a['name'].localeCompare(b['name']))) {
|
||||
@ -184,7 +181,7 @@ function downloadAssetsList(url) {
|
||||
const displayName = DOMPurify.sanitize(asset['name'] || asset['id']);
|
||||
const description = DOMPurify.sanitize(asset['description'] || '');
|
||||
const url = isValidUrl(asset['url']) ? asset['url'] : '';
|
||||
const title = assetType === 'extension' ? `Extension repo/guide: ${url}` : 'Preview in browser';
|
||||
const title = assetType === 'extension' ? t`Extension repo/guide:` + ` ${url}` : t`Preview in browser`;
|
||||
const previewIcon = (assetType === 'extension' || assetType === 'character') ? 'fa-arrow-up-right-from-square' : 'fa-headphones-simple';
|
||||
const toolTag = assetType === 'extension' && asset['tool'];
|
||||
|
||||
@ -195,9 +192,10 @@ function downloadAssetsList(url) {
|
||||
<b>${displayName}</b>
|
||||
<a class="asset_preview" href="${url}" target="_blank" title="${title}">
|
||||
<i class="fa-solid fa-sm ${previewIcon}"></i>
|
||||
</a>
|
||||
${toolTag ? '<span class="tag" title="Adds a function tool"><i class="fa-solid fa-sm fa-wrench"></i> Tool</span>' : ''}
|
||||
</span>
|
||||
</a>` +
|
||||
(toolTag ? '<span class="tag" title="' + t`Adds a function tool` + '"><i class="fa-solid fa-sm fa-wrench"></i> ' +
|
||||
t`Tool` + '</span>' : '') +
|
||||
`</span>
|
||||
<small class="asset-description">
|
||||
${description}
|
||||
</small>
|
||||
@ -435,7 +433,7 @@ jQuery(async () => {
|
||||
const rememberKey = `Assets_SkipConfirm_${getStringHash(url)}`;
|
||||
const skipConfirm = accountStorage.getItem(rememberKey) === 'true';
|
||||
|
||||
const confirmation = skipConfirm || await Popup.show.confirm('Loading Asset List', `<span>Are you sure you want to connect to the following url?</span><var>${url}</var>`, {
|
||||
const confirmation = skipConfirm || await Popup.show.confirm(t`Loading Asset List`, '<span>' + t`Are you sure you want to connect to the following url?` + `</span><var>${url}</var>`, {
|
||||
customInputs: [{ id: 'assets-remember', label: 'Don\'t ask again for this URL' }],
|
||||
onClose: popup => {
|
||||
if (popup.result) {
|
||||
|
4
public/scripts/extensions/assets/installation.html
Normal file
4
public/scripts/extensions/assets/installation.html
Normal file
@ -0,0 +1,4 @@
|
||||
<div class="assets-list-git">
|
||||
<span data-i18n="extension_install_1">To download extensions from this page, you need to have </span><a href="https://git-scm.com/downloads" target="_blank">Git</a><span data-i18n="extension_install_2"> installed.</span><br>
|
||||
<span data-i18n="extension_install_3">Click the </span><i class="fa-solid fa-sm fa-arrow-up-right-from-square"></i><span data-i18n="extension_install_4"> icon to visit the Extension's repo for tips on how to use it.</span>
|
||||
</div>
|
@ -33,7 +33,7 @@ To install a single 3rd party extension, use the "Install Extensions"
|
||||
<div id="assets_filters" class="flex-container">
|
||||
<select id="assets_type_select" class="text_pole flex1">
|
||||
</select>
|
||||
<input id="assets_search" class="text_pole flex1" placeholder="Search" type="search">
|
||||
<input id="assets_search" class="text_pole flex1" data-i18n="[placeholder]Search" placeholder="Search" type="search">
|
||||
<div id="assets-characters-button" class="menu_button menu_button_icon">
|
||||
<i class="fa-solid fa-image-portrait"></i>
|
||||
<span data-i18n="Characters">Characters</span>
|
||||
|
@ -6,6 +6,8 @@ import { getFriendlyTokenizerName, getTextTokens, getTokenCountAsync, tokenizers
|
||||
import { resetScrollHeight, debounce } from '../../utils.js';
|
||||
import { debounce_timeout } from '../../constants.js';
|
||||
import { POPUP_TYPE, callGenericPopup } from '../../popup.js';
|
||||
import { renderExtensionTemplateAsync } from '../../extensions.js';
|
||||
import { t } from '../../i18n.js';
|
||||
|
||||
function rgb2hex(rgb) {
|
||||
rgb = rgb.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i);
|
||||
@ -22,23 +24,7 @@ $('button').click(function () {
|
||||
|
||||
async function doTokenCounter() {
|
||||
const { tokenizerName, tokenizerId } = getFriendlyTokenizerName(main_api);
|
||||
const html = `
|
||||
<div class="wide100p">
|
||||
<h3>Token Counter</h3>
|
||||
<div class="justifyLeft flex-container flexFlowColumn">
|
||||
<h4>Type / paste in the box below to see the number of tokens in the text.</h4>
|
||||
<p>Selected tokenizer: ${tokenizerName}</p>
|
||||
<div>Input:</div>
|
||||
<textarea id="token_counter_textarea" class="wide100p textarea_compact" rows="1"></textarea>
|
||||
<div>Tokens: <span id="token_counter_result">0</span></div>
|
||||
<hr>
|
||||
<div>Tokenized text:</div>
|
||||
<div id="tokenized_chunks_display" class="wide100p">—</div>
|
||||
<hr>
|
||||
<div>Token IDs:</div>
|
||||
<textarea id="token_counter_ids" class="wide100p textarea_compact" readonly rows="1">—</textarea>
|
||||
</div>
|
||||
</div>`;
|
||||
const html = await renderExtensionTemplateAsync('token-counter', 'window', {tokenizerName});
|
||||
|
||||
const dialog = $(html);
|
||||
const countDebounced = debounce(async () => {
|
||||
@ -131,9 +117,9 @@ async function doCount() {
|
||||
jQuery(() => {
|
||||
const buttonHtml = `
|
||||
<div id="token_counter" class="list-group-item flex-container flexGap5">
|
||||
<div class="fa-solid fa-1 extensionsMenuExtensionButton" /></div>
|
||||
Token Counter
|
||||
</div>`;
|
||||
<div class="fa-solid fa-1 extensionsMenuExtensionButton" /></div>` +
|
||||
t`Token Counter` +
|
||||
'</div>';
|
||||
$('#token_counter_wand_container').append(buttonHtml);
|
||||
$('#token_counter').on('click', doTokenCounter);
|
||||
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
|
||||
|
16
public/scripts/extensions/token-counter/window.html
Normal file
16
public/scripts/extensions/token-counter/window.html
Normal file
@ -0,0 +1,16 @@
|
||||
<div class="wide100p">
|
||||
<h3 data-i18n="Token Counter">Token Counter</h3>
|
||||
<div class="justifyLeft flex-container flexFlowColumn">
|
||||
<h4 data-i18n="Type / paste in the box below to see the number of tokens in the text.">Type / paste in the box below to see the number of tokens in the text.</h4>
|
||||
<p><span data-i18n="Selected tokenizer:">Selected tokenizer:</span> {{tokenizerName}}</p>
|
||||
<div data-i18n="Input:">Input:</div>
|
||||
<textarea id="token_counter_textarea" class="wide100p textarea_compact" rows="1"></textarea>
|
||||
<div><span data-i18n="Tokens:">Tokens:</span> <span id="token_counter_result">0</span></div>
|
||||
<hr>
|
||||
<div data-i18n="Tokenized text:">Tokenized text:</div>
|
||||
<div id="tokenized_chunks_display" class="wide100p">—</div>
|
||||
<hr>
|
||||
<div data-i18n="Token IDs:">Token IDs:</div>
|
||||
<textarea id="token_counter_ids" class="wide100p textarea_compact" readonly rows="1">—</textarea>
|
||||
</div>
|
||||
</div>
|
@ -311,7 +311,7 @@ export function validateTextGenUrl() {
|
||||
const formattedUrl = formatTextGenURL(url);
|
||||
|
||||
if (!formattedUrl) {
|
||||
toastr.error('Enter a valid API URL', 'Text Completion API');
|
||||
toastr.error(t`Enter a valid API URL`, 'Text Completion API');
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1187,7 +1187,7 @@ export function getTextGenModel() {
|
||||
return settings.aphrodite_model;
|
||||
case OLLAMA:
|
||||
if (!settings.ollama_model) {
|
||||
toastr.error('No Ollama model selected.', 'Text Completion API');
|
||||
toastr.error(t`No Ollama model selected.`, 'Text Completion API');
|
||||
throw new Error('No Ollama model selected');
|
||||
}
|
||||
return settings.ollama_model;
|
||||
|
Reference in New Issue
Block a user