mirror of
https://github.com/KoboldAI/KoboldAI-Client.git
synced 2025-06-05 21:59:24 +02:00
Fix space tokens being dropped from stream preview.
When streaming preview tokens arrive, they are accumulated into a stream_preview span. These tokens were inserted one-by-one into the `innerText` property of this span. However, the behavior of innerText is to discard trailing whitespace, which meant that a token that was entirely composed of spaces would be discarded. See this link for more information on this behavior: https://stackoverflow.com/questions/47768523/empty-spaces-are-ignored-by-the-innertext-property I tried fixing this by switching to use `textContent`, however this caused newlines to be discarded instead. This change fixes the issue by accumulating incoming tokens into a string and then assigning the string to innerText.
This commit is contained in:
@@ -79,6 +79,7 @@ var rs_close;
|
|||||||
var seqselmenu;
|
var seqselmenu;
|
||||||
var seqselcontents;
|
var seqselcontents;
|
||||||
var stream_preview;
|
var stream_preview;
|
||||||
|
var stream_preview_text;
|
||||||
var token_prob_container;
|
var token_prob_container;
|
||||||
|
|
||||||
var storyname = null;
|
var storyname = null;
|
||||||
@@ -2151,6 +2152,7 @@ function endStream() {
|
|||||||
if (stream_preview) {
|
if (stream_preview) {
|
||||||
stream_preview.remove();
|
stream_preview.remove();
|
||||||
stream_preview = null;
|
stream_preview = null;
|
||||||
|
stream_preview_text = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2390,10 +2392,14 @@ $(document).ready(function(){
|
|||||||
if (!stream_preview && streamingEnabled) {
|
if (!stream_preview && streamingEnabled) {
|
||||||
stream_preview = document.createElement("span");
|
stream_preview = document.createElement("span");
|
||||||
game_text.append(stream_preview);
|
game_text.append(stream_preview);
|
||||||
|
stream_preview_text = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const token of msg.data) {
|
for (const token of msg.data) {
|
||||||
if (streamingEnabled) stream_preview.innerText += token.decoded;
|
if (streamingEnabled) {
|
||||||
|
stream_preview_text += token.decoded;
|
||||||
|
stream_preview.innerText = stream_preview_text;
|
||||||
|
}
|
||||||
|
|
||||||
if (probabilitiesEnabled) {
|
if (probabilitiesEnabled) {
|
||||||
// Probability display
|
// Probability display
|
||||||
|
Reference in New Issue
Block a user