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

@ -80,12 +80,6 @@
background-color: rgba(255, 0, 50, 0.4); background-color: rgba(255, 0, 50, 0.4);
} }
#logprobsReroll {
float: right; /* Position the button to the right */
margin: 5px 0 5px 10px; /* Add spacing (top, right, bottom, left) */
clear: right; /* Ensure it starts on a new line */
}
.logprobs_candidate_list { .logprobs_candidate_list {
grid-row-start: 3; grid-row-start: 3;
grid-row-end: 4; grid-row-end: 4;

View File

@ -6631,8 +6631,11 @@
</div> </div>
</div> </div>
<div class="logprobs_panel_content inline-drawer-content flex-container flexFlowColumn"> <div class="logprobs_panel_content inline-drawer-content flex-container flexFlowColumn">
<small> <small class="flex-container alignItemsCenter justifySpaceBetween">
<b data-i18n="Select a token to see alternatives considered by the AI.">Select a token to see alternatives considered by the AI.</b> <b data-i18n="Select a token to see alternatives considered by the AI.">Select a token to see alternatives considered by the AI.</b>
<button id="logprobsReroll" class="menu_button" title="Reroll with the entire prefix" data-i18n="[title]Reroll with the entire prefix">
<span class="fa-solid fa-redo logprobs_reroll"></span>
</button>
</small> </small>
<hr> <hr>
<div id="logprobs_generation_output"></div> <div id="logprobs_generation_output"></div>

View File

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