Move reroll button

de4246f7b79ee74665f85ca9e626553b18b88b58

Cohee <18619528+Cohee1207@users.noreply.github.com>

3 files changed, +8 -14Showing whitespace changes
public/css/logprobs.css+0 -6
@@ -80,12 +80,6 @@
80 background-color: rgba(255, 0, 50, 0.4);80 background-color: rgba(255, 0, 50, 0.4);
81}81}
8282
83#logprobsReroll {
84 float: right; /* Position the button to the right */
85 margin: 5px 0 5px 10px; /* Add spacing (top, right, bottom, left) */
86 clear: right; /* Ensure it starts on a new line */
87}
88
89.logprobs_candidate_list {83.logprobs_candidate_list {
90 grid-row-start: 3;84 grid-row-start: 3;
91 grid-row-end: 4;85 grid-row-end: 4;
public/index.html+4 -1
@@ -6631,8 +6631,11 @@
6631 </div>6631 </div>
6632 </div>6632 </div>
6633 <div class="logprobs_panel_content inline-drawer-content flex-container flexFlowColumn">6633 <div class="logprobs_panel_content inline-drawer-content flex-container flexFlowColumn">
6634 <small>6634 <small class="flex-container alignItemsCenter justifySpaceBetween">
6635 <b data-i18n="Select a token to see alternatives considered by the AI.">Select a token to see alternatives considered by the AI.</b>6635 <b data-i18n="Select a token to see alternatives considered by the AI.">Select a token to see alternatives considered by the AI.</b>
6636 <button id="logprobsReroll" class="menu_button" title="Reroll with the entire prefix" data-i18n="[title]Reroll with the entire prefix">
6637 <span class="fa-solid fa-redo logprobs_reroll"></span>
6638 </button>
6636 </small>6639 </small>
6637 <hr>6640 <hr>
6638 <div id="logprobs_generation_output"></div>6641 <div id="logprobs_generation_output"></div>
public/scripts/logprobs.js+4 -7
@@ -17,6 +17,7 @@ import { t } from './i18n.js';
1717
18const TINTS = 4;18const TINTS = 4;
19const MAX_MESSAGE_LOGPROBS = 100;19const MAX_MESSAGE_LOGPROBS = 100;
20const REROLL_BUTTON = $('#logprobsReroll');
2021
21/**22/**
22 * Tuple of a candidate token and its logarithm of probability of being chosen23 * Tuple of a candidate token and its logarithm of probability of being chosen
@@ -93,14 +94,10 @@ function renderAlternativeTokensView() {
9394
94 const prefix = continueFrom || '';95 const prefix = continueFrom || '';
95 const tokenSpans = [];96 const tokenSpans = [];
97 REROLL_BUTTON.toggle(!!prefix);
9698
97 if (prefix) {99 if (prefix) {
98 const rerollButton = $('<button id="logprobsReroll" class="menu_button">' +100 REROLL_BUTTON.off('click').on('click', () => onPrefixClicked(prefix.length));
99 ' <span class="fa-solid fa-redo logprobs_reroll"></span>' +
100 '</button>');
101 rerollButton.attr('title', t`Reroll with the entire prefix`);
102 rerollButton.on('click', () => onPrefixClicked(prefix.length));
103 tokenSpans.push(rerollButton);
104101
105 let cumulativeOffset = 0;102 let cumulativeOffset = 0;
106 const words = prefix.split(/\s+/);103 const words = prefix.split(/\s+/);
@@ -127,7 +124,6 @@ function renderAlternativeTokensView() {
127 });124 });
128 }125 }
129126
130
131 messageLogprobs.forEach((tokenData, i) => {127 messageLogprobs.forEach((tokenData, i) => {
132 const { token } = tokenData;128 const { token } = tokenData;
133 const span = $('<span></span>');129 const span = $('<span></span>');
@@ -539,6 +535,7 @@ function convertTokenIdLogprobsToText(input) {
539}535}
540536
541export function initLogprobs() {537export function initLogprobs() {
538 REROLL_BUTTON.hide();
542 const debouncedRender = debounce(renderAlternativeTokensView);539 const debouncedRender = debounce(renderAlternativeTokensView);
543 $('#logprobsViewerClose').on('click', onToggleLogprobsPanel);540 $('#logprobsViewerClose').on('click', onToggleLogprobsPanel);
544 $('#option_toggle_logprobs').on('click', onToggleLogprobsPanel);541 $('#option_toggle_logprobs').on('click', onToggleLogprobsPanel);