Skip to content

Commit

Permalink
Highlight current token
Browse files Browse the repository at this point in the history
  • Loading branch information
lmg-anon committed Jun 3, 2024
1 parent c81a3b7 commit abc77df
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions mikupad.html
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,9 @@
flex: none;
font-size: 1rem;
}
#probs > button.current {
background: var(--color-base-40);
}
#probs > button:first-child {
border-radius: 5px 0 0 5px;
padding-left: 6px;
Expand Down Expand Up @@ -4955,11 +4958,14 @@
style=${{
'display': 'none'
}}>
${probs.map((prob, i) =>
html`<button key=${i} onClick=${() => switchCompletion(currentPromptChunk?.index, prob.tok_str)}>
${probs.map((prob, i) => {
const index = currentPromptChunk?.index;
const isCurrentToken = promptChunks[index]?.prob == prob.prob;
return html`<button key=${i} className=${isCurrentToken ? 'current' : ''} onClick=${() => switchCompletion(index, prob.tok_str)}>
<div className="tok">${replaceUnprintableBytes(prob.tok_str)}</div>
<div className="prob">${(prob.prob * 100).toFixed(2)}%</div>
</button>`)}
</button>`;
})}
</div>` : null}
<div id="sidebar" ref=${sidebar} style=${{ 'max-height': ''}}>
<${SelectBox}
Expand Down

0 comments on commit abc77df

Please sign in to comment.