From 5072034da492df4b0bfd6dd73446230c3ae81141 Mon Sep 17 00:00:00 2001 From: Riccardo Giovanetti Date: Mon, 6 Mar 2023 17:31:16 +0100 Subject: [PATCH] Fix for Broken Tool Tip #15 This fixes the problem due to hints.js overwriting the SD Web UI original file. The hints.js file has been renamed and the code inside refactored. --- javascript/prompt_generator_hints.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/javascript/prompt_generator_hints.js b/javascript/prompt_generator_hints.js index 30df722..f2d1821 100644 --- a/javascript/prompt_generator_hints.js +++ b/javascript/prompt_generator_hints.js @@ -1,6 +1,7 @@ -//Basically copied this from AUTOMATIC1111 implementation of the main UI +//Basically copied and adapted from AUTOMATIC1111 implementation of the main UI +// mouseover tooltips for various UI elements in the form of "UI element label"="Tooltip text". -titles = { +prompt_generator_titles = { "Temperature": "A higher temperature will produce more diverse results, but with a higher risk of less coherent text", "Max Length": "The maximum number of tokens for the output of the model", "Top K": "Strategy is to sample from a shortlist of the top K tokens. This approach allows the other high-scoring tokens a chance of being picked.", @@ -11,16 +12,16 @@ titles = { onUiUpdate(function(){ gradioApp().querySelectorAll('span, button, select, p').forEach(function(span){ - tooltip = titles[span.textContent]; + tooltip = prompt_generator_titles[span.textContent]; if(!tooltip){ - tooltip = titles[span.value]; + tooltip = prompt_generator_titles[span.value]; } if(!tooltip){ for (const c of span.classList) { - if (c in titles) { - tooltip = titles[c]; + if (c in prompt_generator_titles) { + tooltip = prompt_generator_titles[c]; break; } } @@ -35,7 +36,7 @@ onUiUpdate(function(){ if (select.onchange != null) return; select.onchange = function(){ - select.title = titles[select.value] || ""; + select.title = prompt_generator_titles[select.value] || ""; } }) -}) \ No newline at end of file +})