Skip to content

Commit

Permalink
Fixes to prediction preview
Browse files Browse the repository at this point in the history
  • Loading branch information
lmg-anon committed Dec 22, 2024
1 parent a071cb0 commit eecca8d
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions mikupad.html
Original file line number Diff line number Diff line change
Expand Up @@ -6214,7 +6214,7 @@
if (promptPreviewChunks.length)
setPromptPreviewChunks([]);

if (fimPromptInfo !== undefined || cancel || !showPromptPreview || endpointAPI == API_AI_HORDE)
if (fimPromptInfo !== undefined || cancel || endpointAPI == API_AI_HORDE || tokenHighlightMode === -1 || !showPromptPreview)
return;

const ac = new AbortController();
Expand Down Expand Up @@ -6859,12 +6859,12 @@
case 'false:false:false:Escape':
if (cancel) {
cancel();
} else if (promptPreviewText.length !== 0) {
} else if (showPromptPreview && promptPreviewChunks.length !== 0) {
setPromptPreviewReroll((r) => r + 1);
}
break;
case 'false:false:false:Tab':
if (promptPreviewText.length === 0)
if (!showPromptPreview || promptPreviewChunks.length === 0)
break;

setPromptChunks(p => [
Expand Down Expand Up @@ -7351,12 +7351,12 @@
data-promptchunk=${i}
style=${bgColor ? { '--bg-color': bgColor } : {}}
className=${`${(tokenHighlightMode === 1 && !isCurrent) || chunk.type === 'user' ? 'user' : 'machine'} ${isCurrent ? 'current' : ''} ${isNextUndo ? 'erase' : ''}`}>
${(chunk.content === '\n' ? ' \n' : chunk.content) + (i === promptChunks.length - 1 && chunk.content.endsWith('\n') && promptPreviewText?.length === 0 ? '\u00a0' : '')}
${(chunk.content === '\n' ? ' \n' : chunk.content) + (i === promptChunks.length - 1 && chunk.content.endsWith('\n') && promptPreviewChunks.length === 0 ? '\u00a0' : '')}
</span>`;
})}` : null}
${(showPromptPreview && promptPreviewText?.length) ? html`
})}
${(showPromptPreview && promptPreviewChunks.length) ? html`
<span ref=${promptPreviewElement} className="preview"></span>
<span class="preview nudge">Tab</span>` : null}
<span class="preview nudge">Tab</span>` : null}` : null}
</div>
<${SearchAndReplaceWidget}
isOpen=${modalState.searchAndReplace}
Expand Down Expand Up @@ -7448,7 +7448,7 @@
<${Checkbox} label="Token Streaming"
disabled=${!!cancel} value=${useTokenStreaming} onValueChange=${setUseTokenStreaming}/>
<${Checkbox} label="Prediction Preview"
disabled=${!!cancel} value=${showPromptPreview} onValueChange=${setShowPromptPreview}/>
disabled=${!!cancel || tokenHighlightMode === -1} value=${showPromptPreview && tokenHighlightMode !== -1} onValueChange=${setShowPromptPreview}/>
${showPromptPreview && html`
<${InputBox} label="Max Preview Tokens" type="text" inputmode="numeric"
readOnly=${!!cancel} value=${promptPreviewTokens} onValueChange=${setPromptPreviewTokens}/>`}`}
Expand Down

0 comments on commit eecca8d

Please sign in to comment.