Move reroll button

This commit is contained in:
Cohee
2024-11-17 18:45:53 +02:00
parent 5e883e446a
commit de4246f7b7
3 changed files with 8 additions and 14 deletions

View File

@ -17,6 +17,7 @@ import { t } from './i18n.js';
const TINTS = 4;
const MAX_MESSAGE_LOGPROBS = 100;
const REROLL_BUTTON = $('#logprobsReroll');
/**
* Tuple of a candidate token and its logarithm of probability of being chosen
@ -93,14 +94,10 @@ function renderAlternativeTokensView() {
const prefix = continueFrom || '';
const tokenSpans = [];
REROLL_BUTTON.toggle(!!prefix);
if (prefix) {
const rerollButton = $('<button id="logprobsReroll" class="menu_button">' +
' <span class="fa-solid fa-redo logprobs_reroll"></span>' +
'</button>');
rerollButton.attr('title', t`Reroll with the entire prefix`);
rerollButton.on('click', () => onPrefixClicked(prefix.length));
tokenSpans.push(rerollButton);
REROLL_BUTTON.off('click').on('click', () => onPrefixClicked(prefix.length));
let cumulativeOffset = 0;
const words = prefix.split(/\s+/);
@ -127,7 +124,6 @@ function renderAlternativeTokensView() {
});
}
messageLogprobs.forEach((tokenData, i) => {
const { token } = tokenData;
const span = $('<span></span>');
@ -539,6 +535,7 @@ function convertTokenIdLogprobsToText(input) {
}
export function initLogprobs() {
REROLL_BUTTON.hide();
const debouncedRender = debounce(renderAlternativeTokensView);
$('#logprobsViewerClose').on('click', onToggleLogprobsPanel);
$('#option_toggle_logprobs').on('click', onToggleLogprobsPanel);