Add option to disable prompt token counters

This commit is contained in:
Aarni Koskela
2023-05-21 23:20:50 +03:00
parent 5ed970b949
commit 618c59b01d
2 changed files with 9 additions and 0 deletions

View File

@@ -21,6 +21,9 @@ function update_img2img_tokens(...args) {
}
function update_token_counter(button_id) {
if (opts.disable_token_counters) {
return;
}
if (promptTokenCountTimeouts[button_id]) {
clearTimeout(promptTokenCountTimeouts[button_id]);
}
@@ -54,6 +57,11 @@ function setupTokenCounting(id, id_counter, id_button) {
var counter = gradioApp().getElementById(id_counter);
var textarea = gradioApp().querySelector(`#${id} > label > textarea`);
if (opts.disable_token_counters) {
counter.style.display = "none";
return;
}
if (counter.parentElement == prompt.parentElement) {
return;
}