Due to API limitations, rerolling a token is not supported with OpenAI. Try switching to a different API.
`, 'text'); + return callPopup('Due to API limitations, rerolling a token is not supported with OpenAI. Try switching to a different API.
', 'text'); } const { messageLogprobs, continueFrom } = getActiveMessageLogprobData(); @@ -261,7 +261,7 @@ function onPrefixClicked() { function checkGenerateReady() { if (is_send_press) { - toastr.warning(`Please wait for the current generation to complete.`); + toastr.warning('Please wait for the current generation to complete.'); return false; } return true; @@ -292,13 +292,13 @@ function onToggleLogprobsPanel() { } else { logprobsViewer.addClass('resizing'); logprobsViewer.transition({ - opacity: 0.0, - duration: animation_duration, - }, - async function () { - await delay(50); - logprobsViewer.removeClass('resizing'); - }); + opacity: 0.0, + duration: animation_duration, + }, + async function () { + await delay(50); + logprobsViewer.removeClass('resizing'); + }); setTimeout(function () { logprobsViewer.hide(); }, animation_duration); @@ -407,7 +407,7 @@ export function saveLogprobsForActiveMessage(logprobs, continueFrom) { messageLogprobs: logprobs, continueFrom, hash: getMessageHash(chat[msgId]), - } + }; state.messageLogprobs.set(data.hash, data); @@ -458,7 +458,7 @@ function convertTokenIdLogprobsToText(input) { // Flatten unique token IDs across all logprobs const tokenIds = Array.from(new Set(input.flatMap(logprobs => - logprobs.topLogprobs.map(([token]) => token).concat(logprobs.token) + logprobs.topLogprobs.map(([token]) => token).concat(logprobs.token), ))); // Submit token IDs to tokenizer to get token text, then build ID->text map @@ -469,7 +469,7 @@ function convertTokenIdLogprobsToText(input) { input.forEach(logprobs => { logprobs.token = tokenIdText.get(logprobs.token); logprobs.topLogprobs = logprobs.topLogprobs.map(([token, logprob]) => - [tokenIdText.get(token), logprob] + [tokenIdText.get(token), logprob], ); }); } diff --git a/public/scripts/openai.js b/public/scripts/openai.js index 8a71b89f0..7ce8c8c37 100644 --- a/public/scripts/openai.js +++ b/public/scripts/openai.js @@ -2264,7 +2264,7 @@ export class ChatCompletion { const shouldSquash = (message) => { return !excludeList.includes(message.identifier) && message.role === 'system' && !message.name; - } + }; if (shouldSquash(message)) { if (lastMessage && shouldSquash(lastMessage)) { diff --git a/public/scripts/slash-commands.js b/public/scripts/slash-commands.js index 4aeff2b91..9e2d853d9 100644 --- a/public/scripts/slash-commands.js +++ b/public/scripts/slash-commands.js @@ -38,7 +38,7 @@ import { this_chid, } from '../script.js'; import { getMessageTimeStamp } from './RossAscends-mods.js'; -import { hideChatMessage, unhideChatMessage } from './chats.js'; +import { hideChatMessageRange } from './chats.js'; import { getContext, saveMetadataDebounced } from './extensions.js'; import { getRegexedString, regex_placement } from './extensions/regex/engine.js'; import { findGroupMemberId, groups, is_group_generating, openGroupById, resetSelectedGroup, saveGroupChat, selected_group } from './group-chats.js'; @@ -49,6 +49,7 @@ import { textgen_types, textgenerationwebui_settings } from './textgen-settings. import { decodeTextTokens, getFriendlyTokenizerName, getTextTokens, getTokenCount } from './tokenizers.js'; import { delay, isFalseBoolean, isTrueBoolean, stringToRange, trimToEndSentence, trimToStartSentence, waitUntilCondition } from './utils.js'; import { registerVariableCommands, resolveVariable } from './variables.js'; +import { background_settings } from './backgrounds.js'; export { executeSlashCommands, getSlashCommandsHelp, registerSlashCommand, }; @@ -916,16 +917,7 @@ async function hideMessageCallback(_, arg) { return; } - for (let messageId = range.start; messageId <= range.end; messageId++) { - const messageBlock = $(`.mes[mesid="${messageId}"]`); - - if (!messageBlock.length) { - console.warn(`WARN: No message found with ID ${messageId}`); - return; - } - - await hideChatMessage(messageId, messageBlock); - } + await hideChatMessageRange(range.start, range.end, false); } async function unhideMessageCallback(_, arg) { @@ -941,17 +933,7 @@ async function unhideMessageCallback(_, arg) { return ''; } - for (let messageId = range.start; messageId <= range.end; messageId++) { - const messageBlock = $(`.mes[mesid="${messageId}"]`); - - if (!messageBlock.length) { - console.warn(`WARN: No message found with ID ${messageId}`); - return ''; - } - - await unhideChatMessage(messageId, messageBlock); - } - + await hideChatMessageRange(range.start, range.end, true); return ''; } @@ -1609,7 +1591,9 @@ $(document).on('click', '[data-displayHelp]', function (e) { function setBackgroundCallback(_, bg) { if (!bg) { - return; + // allow reporting of the background name if called without args + // for use in ST Scripts via pipe + return background_settings.name; } console.log('Set background to ' + bg); diff --git a/src/endpoints/backends/text-completions.js b/src/endpoints/backends/text-completions.js index 8e0ebba8d..22806cbf0 100644 --- a/src/endpoints/backends/text-completions.js +++ b/src/endpoints/backends/text-completions.js @@ -516,7 +516,7 @@ llamacpp.post('/slots', jsonParser, async function (request, response) { const baseUrl = trimV1(request.body.server_url); let fetchResponse; - if (request.body.action === "info") { + if (request.body.action === 'info') { fetchResponse = await fetch(`${baseUrl}/slots`, { method: 'GET', timeout: 0, @@ -525,16 +525,16 @@ llamacpp.post('/slots', jsonParser, async function (request, response) { if (!/^\d+$/.test(request.body.id_slot)) { return response.sendStatus(400); } - if (request.body.action !== "erase" && !request.body.filename) { + if (request.body.action !== 'erase' && !request.body.filename) { return response.sendStatus(400); } - + fetchResponse = await fetch(`${baseUrl}/slots/${request.body.id_slot}?action=${request.body.action}`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, timeout: 0, body: JSON.stringify({ - filename: request.body.action !== "erase" ? `${request.body.filename}` : undefined, + filename: request.body.action !== 'erase' ? `${request.body.filename}` : undefined, }), }); }