From e74090139c681eb535f97acf4a31e922d9490510 Mon Sep 17 00:00:00 2001 From: mweldon Date: Wed, 13 Sep 2023 01:52:37 -0700 Subject: [PATCH] Add copy to clipboard button on prompt itemization popup (#1124) * Add copy to clipboard button on prompt itemization popup * Minor fix for NovelAI Summarize and new bad words --- public/css/mobile-styles.css | 1 + public/script.js | 14 +++++++++++++- public/scripts/templates/itemizationChat.html | 1 + public/scripts/templates/itemizationText.html | 1 + src/novelai.js | 5 ++--- 5 files changed, 18 insertions(+), 4 deletions(-) diff --git a/public/css/mobile-styles.css b/public/css/mobile-styles.css index b5c58f969..2385ff9e1 100644 --- a/public/css/mobile-styles.css +++ b/public/css/mobile-styles.css @@ -161,6 +161,7 @@ } #showRawPrompt, + #copyPromptToClipboard, #groupCurrentMemberPopoutButton { display: none; } diff --git a/public/script.js b/public/script.js index ad9f7e9f2..c58ca50b1 100644 --- a/public/script.js +++ b/public/script.js @@ -2754,7 +2754,7 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject, // Add quiet generation prompt at depth 0 if (quiet_prompt && quiet_prompt.length) { const name = name1; - const quietAppend = isInstruct ? formatInstructModeChat(name, quiet_prompt, false, true, '', name1, name2, false) : `\n${name}: ${quiet_prompt}`; + const quietAppend = isInstruct ? formatInstructModeChat(name, quiet_prompt, false, true, '', name1, name2, false) : `\n${quiet_prompt}`; lastMesString += quietAppend; // Bail out early return lastMesString; @@ -8018,6 +8018,18 @@ jQuery(async function () { } }) + $(document).on("pointerup", "#copyPromptToClipboard", function () { + let rawPrompt = itemizedPrompts[PromptArrayItemForRawPromptDisplay].rawPrompt; + let rawPromptValues = rawPrompt; + + if (Array.isArray(rawPrompt)) { + rawPromptValues = rawPrompt.map(x => x.content).join('\n'); + } + + navigator.clipboard.writeText(rawPromptValues); + toastr.info('Copied!', '', { timeOut: 2000 }); + }); + $(document).on("pointerup", "#showRawPrompt", function () { //console.log(itemizedPrompts[PromptArrayItemForRawPromptDisplay].rawPrompt); console.log(PromptArrayItemForRawPromptDisplay); diff --git a/public/scripts/templates/itemizationChat.html b/public/scripts/templates/itemizationChat.html index 12e25c94a..d5a8de41f 100644 --- a/public/scripts/templates/itemizationChat.html +++ b/public/scripts/templates/itemizationChat.html @@ -1,6 +1,7 @@

Prompt Itemization +

Tokenizer: {{selectedTokenizer}}
API Used: {{this_main_api}}
diff --git a/public/scripts/templates/itemizationText.html b/public/scripts/templates/itemizationText.html index b6f60404b..efd9f84c1 100644 --- a/public/scripts/templates/itemizationText.html +++ b/public/scripts/templates/itemizationText.html @@ -1,6 +1,7 @@

Prompt Itemization +

Tokenizer: {{selectedTokenizer}}
API Used: {{this_main_api}}
diff --git a/src/novelai.js b/src/novelai.js index 4090373e0..ab6b3a6c8 100644 --- a/src/novelai.js +++ b/src/novelai.js @@ -1,8 +1,7 @@ // Ban bracket generation, plus defaults const badWordsList = [ - [23], [49209, 23], [23], [49209, 23], [23], [49209, 23], [23], [49209, 23], [23], [49209, 23], [21], [49209, 21], - [21], [49209, 21], [21], [49209, 21], [21], [49209, 21], [21], [49209, 21], [3], [49356], [1431], [31715], [34387], - [20765], [30702], [10691], [49333], [1266], [26523], [41471], [2936], [85, 85], [49332], [7286], [1115], [19438, 2542], + [3], [49356], [1431], [31715], [34387], [20765], [30702], [10691], [49333], [1266], + [19438], [43145], [26523], [41471], [2936], [85, 85], [49332], [7286], [1115] ] const hypeBotBadWordsList = [