From 454994a7bdf149089ad6c959cc12d8fbef6e84a4 Mon Sep 17 00:00:00 2001 From: RossAscends <124905043+RossAscends@users.noreply.github.com> Date: Wed, 17 May 2023 03:55:23 +0900 Subject: [PATCH 01/19] Update readme.md with SD/TTS info --- readme.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/readme.md b/readme.md index 5b6a380fe..000bd927d 100644 --- a/readme.md +++ b/readme.md @@ -65,6 +65,8 @@ Get in touch with the developers directly: * Character emotional expressions * Auto-Summary of the chat history * Sending images to chat, and the AI interpreting the content. + * Stable Diffusion image generation (5 chat-related presets plus 'free mode') + * Text-to-speech for AI response messages (via ElevenLabs, Silero, or the OS's System TTS) ## UI Extensions 🚀 @@ -76,6 +78,8 @@ Get in touch with the developers directly: | D&D Dice | A set of 7 classic D&D dice for all your dice rolling needs.

*I used to roll the dice.
Feel the fear in my enemies' eyes* | None | image | | Author's Note | Built-in extension that allows you to append notes that will be added to the context and steer the story and character in a specific direction. Because it's sent after the character description, it has a lot of weight. Thanks Aliážµ#2222 for pitching the idea! | None | ![image](https://user-images.githubusercontent.com/128647114/230311637-d809cd9b-af66-4dd1-a310-7a27e847c011.png) | | Character Backgrounds | Built-in extension to assign unique backgrounds to specific chats or groups. | None | image | +| Stable Diffusion | Use local of cloud-based Stable Diffusion webUI API to generate images. 5 presets included ('you', 'your face', 'me', 'the story', and 'the last message'. Free mode also supported via `/sd (anything_here_)` command in the chat input bar. Most common StableDiffusion generation settings are customizable within the SillyTavern UI. | None | image | +| Text-to-Speech | AI-generated voice will read back character messages on demand, or automatically read new messages they arrive. Supports ElevenLabs, Silero, and your device's TTS service. | None | image | ## UI/CSS/Quality of Life tweaks by RossAscends From fde5f7af84f15f5fef95bf898305365850d13eae Mon Sep 17 00:00:00 2001 From: RossAscends <124905043+RossAscends@users.noreply.github.com> Date: Wed, 17 May 2023 04:00:05 +0900 Subject: [PATCH 02/19] Update readme.md with SD/TSS images --- readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 000bd927d..1687c59f2 100644 --- a/readme.md +++ b/readme.md @@ -78,8 +78,8 @@ Get in touch with the developers directly: | D&D Dice | A set of 7 classic D&D dice for all your dice rolling needs.

*I used to roll the dice.
Feel the fear in my enemies' eyes* | None | image | | Author's Note | Built-in extension that allows you to append notes that will be added to the context and steer the story and character in a specific direction. Because it's sent after the character description, it has a lot of weight. Thanks Aliážµ#2222 for pitching the idea! | None | ![image](https://user-images.githubusercontent.com/128647114/230311637-d809cd9b-af66-4dd1-a310-7a27e847c011.png) | | Character Backgrounds | Built-in extension to assign unique backgrounds to specific chats or groups. | None | image | -| Stable Diffusion | Use local of cloud-based Stable Diffusion webUI API to generate images. 5 presets included ('you', 'your face', 'me', 'the story', and 'the last message'. Free mode also supported via `/sd (anything_here_)` command in the chat input bar. Most common StableDiffusion generation settings are customizable within the SillyTavern UI. | None | image | -| Text-to-Speech | AI-generated voice will read back character messages on demand, or automatically read new messages they arrive. Supports ElevenLabs, Silero, and your device's TTS service. | None | image | +| Stable Diffusion | Use local of cloud-based Stable Diffusion webUI API to generate images. 5 presets included ('you', 'your face', 'me', 'the story', and 'the last message'. Free mode also supported via `/sd (anything_here_)` command in the chat input bar. Most common StableDiffusion generation settings are customizable within the SillyTavern UI. | None | image | +| Text-to-Speech | AI-generated voice will read back character messages on demand, or automatically read new messages they arrive. Supports ElevenLabs, Silero, and your device's TTS service. | None | image | ## UI/CSS/Quality of Life tweaks by RossAscends From a656783b156c9799d34af61f1bdfcfc9b6a60231 Mon Sep 17 00:00:00 2001 From: SillyLossy Date: Wed, 17 May 2023 01:13:35 +0300 Subject: [PATCH 03/19] Upgrade tensorflow in colab --- colab/GPU.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/colab/GPU.ipynb b/colab/GPU.ipynb index caf939c44..194ba8dea 100644 --- a/colab/GPU.ipynb +++ b/colab/GPU.ipynb @@ -98,7 +98,7 @@ "!git clone https://github.com/Cohee1207/tts_samples\n", "!npm install -g localtunnel\n", "!pip install -r requirements-complete.txt\n", - "!pip install tensorflow==2.11\n", + "!pip install tensorflow==2.12\n", "\n", "\n", "cmd = f\"python server.py {' '.join(params)}\"\n", From db439be897b2002482e54bea170f648e254e0181 Mon Sep 17 00:00:00 2001 From: RossAscends <124905043+RossAscends@users.noreply.github.com> Date: Thu, 18 May 2023 14:48:31 +0900 Subject: [PATCH 04/19] add black and white backgrounds --- public/backgrounds/_black.jpg | Bin 0 -> 8049 bytes public/backgrounds/_white.jpg | Bin 0 -> 7635 bytes 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 public/backgrounds/_black.jpg create mode 100644 public/backgrounds/_white.jpg diff --git a/public/backgrounds/_black.jpg b/public/backgrounds/_black.jpg new file mode 100644 index 0000000000000000000000000000000000000000..a451bc161f641ffc1ee52c854dce378fff0b3545 GIT binary patch literal 8049 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 Date: Fri, 19 May 2023 04:51:11 +0900 Subject: [PATCH 05/19] added hotkeys hints to /? readout --- public/script.js | 179 +++++++++++++++++++++++++---------------------- 1 file changed, 95 insertions(+), 84 deletions(-) diff --git a/public/script.js b/public/script.js index bb926bbee..af5e927c9 100644 --- a/public/script.js +++ b/public/script.js @@ -291,11 +291,22 @@ const system_messages = { is_system: true, is_name: true, mes: [ - 'Hi there! The following chat formatting commands are supported:', - '
    ', - '
  1. {{text}} – sets a one-time behavioral bias for the AI. Resets when you send the next message.
  2. ', - '
', - ].join('') + `Hi there! The following chat formatting commands are supported: +
    +
  • {{text}} - sets a one-time behavioral bias for the AI. Resets when you send the next message. +
  • +
+ Hotkeys/Keybinds: +
    +
  • Up = Edit last message in chat
  • +
  • Ctrl+Up = Edit last USER message in chat
  • +
  • Left = swipe left
  • +
  • Right = swipe right (NOTE: swipe hotkeys are disabled when chatbar has something typed into it)
  • +
  • Ctrl+Left = view locally stored variables (in the browser console window)
  • +
  • Enter (with chat bar selected) = send your message to AI
  • +
  • Ctrl+Enter = Regenerate the last AI response
  • +
` + ] }, welcome: { @@ -304,42 +315,42 @@ const system_messages = { is_user: false, is_name: true, mes: [ - '

Welcome to SillyTavern!

', - '
', - '

Want to Update to the latest version?

', - "Read the instructions here. Also located in your installation's base folder", - '
', - '

In order to begin chatting:

', - '
    ', - '
  1. Connect to one of the supported generation APIs (the plug icon)
  2. ', - '
  3. Create or pick a character from the list (the top-right namecard icon)
  4. ', - '
', - '
', - '

Where to download more characters?

', - '(Not endorsed, your discretion is advised)', - '
    ', - '
  1. Pygmalion AI Discord
  2. ', - '
  3. CharacterHub (NSFW)
  4. ', - '
', - '
', - '

Where can I get help?

', - 'Before going any further, check out the following resources:', - '
    ', - '
  1. Introduction to SillyTavern
  2. ', - '
  3. SillyTavern FAQ
  4. ', - '
  5. SillyTavern Guidebook
  6. ', - '
  7. Extras API Docs
  8. ', - '
  9. Pygmalion AI Docs
  10. ', - '
', - 'Type /? in any chat to get help on message formatting commands.', - '
', - '

Still have questions or suggestions left?

', - 'SillyTavern Community Discord', - '
', - 'Post a GitHub issue.', - '
', - 'Contact the developers.', - ].join('') + `

Welcome to SillyTavern!

+
+

Want to Update to the latest version?

+ Read the instructions here. Also located in your installation's base folder +
+

In order to begin chatting:

+
    +
  1. Connect to one of the supported generation APIs (the plug icon)
  2. +
  3. Create or pick a character from the list (the top-right namecard icon)
  4. +
+
+

Where to download more characters?

+ (Not endorsed, your discretion is advised) +
    +
  1. Pygmalion AI Discord
  2. +
  3. CharacterHub (NSFW)
  4. +
+
+

Where can I get help?

+ Before going any further, check out the following resources: +
    +
  1. Introduction to SillyTavern
  2. +
  3. SillyTavern FAQ
  4. +
  5. SillyTavern Guidebook
  6. +
  7. Extras API Docs
  8. +
  9. Pygmalion AI Docs
  10. +
+ Type /? in any chat to get help on message formatting commands. +
+

Still have questions or suggestions left?

+ SillyTavern Community Discord +
+ Post a GitHub issue. +
+ Contact the developers. + `].join('') }, group: { name: systemUserName, @@ -408,7 +419,7 @@ async function getClientVersion() { let displayVersion = `SillyTavern ${data.pkgVersion}`; if (data.gitRevision && data.gitBranch) { - displayVersion += ` '${data.gitBranch}' (${data.gitRevision})`; + displayVersion += ` '${data.gitBranch}'(${data.gitRevision})`; } $('#version_display').text(displayVersion); @@ -447,7 +458,7 @@ function getTokenCount(str, padding = undefined) { jQuery.ajax({ async: false, type: 'POST', // - url: `/tokenize_llama`, + url: `/ tokenize_llama`, data: JSON.stringify({ text: str }), dataType: "json", contentType: "application/json", @@ -733,9 +744,9 @@ function updateSoftPromptsList(soft_prompts) { // Add SPs added to Kobold soft_prompts.forEach((prompt) => { - if ($(`#softprompt option[value="${prompt.name}"]`).length === 0) { + if ($(`#softprompt option[value = "${prompt.name}"]`).length === 0) { $("#softprompt").append( - `` + `< option value = "${prompt.name}" > ${prompt.name} ` ); if (prompt.selected) { @@ -759,7 +770,7 @@ function printCharacters() { } // Populate the template const template = $('#character_template .character_select').clone(); - template.attr({ 'chid': i, 'id': `CharID${i}` }); + template.attr({ 'chid': i, 'id': `CharID${i} ` }); template.find('img').attr('src', this_avatar); template.find('.avatar').attr('title', item.avatar); template.find('.ch_name').text(item.name); @@ -822,7 +833,7 @@ async function getBackgrounds() { for (const bg of getData) { const thumbPath = getThumbnailUrl('bg', bg); $("#bg_menu_content").append( - `
+ `< div class="bg_example flex-container" bgfile = "${bg}" class="bg_example_img" title = "${bg}" style = "background-image: url('${thumbPath}');" >
${bg @@ -830,7 +841,7 @@ async function getBackgrounds() { .replace('.jpg', '') .replace('.webp', '')}
-
` + ` ); } } @@ -993,7 +1004,7 @@ function messageFormatting(mes, ch_name, isSystem, isUser) { .replace(/\*\*(.+?)\*\*/g, "$1") .replace(/\n/g, "
"); } else if (!isSystem) { - mes = mes.replace(/```[\s\S]*?```|``[\s\S]*?``|`[\s\S]*?`|(\".+?\")|(\u201C.+?\u201D)/gm, function (match, p1, p2) { + mes = mes.replace(/```[\s\S]*? ```|``[\s\S]*?``|`[\s\S]*? `|(\".+?\")|(\u201C.+?\u201D)/gm, function (match, p1, p2) { if (p1) { return '"' + p1.replace(/\"/g, "") + '"'; } else if (p2) { @@ -1016,7 +1027,7 @@ function messageFormatting(mes, ch_name, isSystem, isUser) { } if (!power_user.allow_name2_display && ch_name && !isUser && !isSystem) { - mes = mes.replaceAll(`${ch_name}:`, ""); + mes = mes.replaceAll(`${ch_name}: `, ""); } return mes; @@ -1061,8 +1072,8 @@ function addCopyToCodeBlocks(messageElement) { const copiedMsg = document.createElement("div"); copiedMsg.classList.add('code-copied'); copiedMsg.innerText = "Copied!"; - copiedMsg.style.top = `${event.clientY - 55}px`; - copiedMsg.style.left = `${event.clientX - 55}px`; + copiedMsg.style.top = `${event.clientY - 55} px`; + copiedMsg.style.left = `${event.clientX - 55} px`; document.body.append(copiedMsg); setTimeout(() => { document.body.removeChild(copiedMsg); @@ -1137,14 +1148,14 @@ function addOneMessage(mes, { type = "normal", insertAfter = null, scroll = true $("#chat").append(HTMLForEachMes); } else { - const target = $("#chat").find(`.mes[mesid="${insertAfter}"]`); + const target = $("#chat").find(`.mes[mesid = "${insertAfter}"]`); $(HTMLForEachMes).insertAfter(target); $(HTMLForEachMes).find('.swipe_left').css('display', 'none'); $(HTMLForEachMes).find('.swipe_right').css('display', 'none'); } } - const newMessage = $(`#chat [mesid="${count_view_mes}"]`); + const newMessage = $(`#chat[mesid = "${count_view_mes}"]`); newMessage.data("isSystem", isSystem); if (isSystem) { @@ -1155,17 +1166,17 @@ function addOneMessage(mes, { type = "normal", insertAfter = null, scroll = true // don't need prompt button for user if (params.isUser === true) { newMessage.find(".mes_prompt").hide(); - console.log(`hiding prompt for user mesID ${params.mesId}`); + console.log(`hiding prompt for user mesID ${params.mesId} `); } //shows or hides the Prompt display button let mesIdToFind = Number(newMessage.attr('mesId')); if (itemizedPrompts.length !== 0) { - //console.log(`itemizedPrompt.length = ${itemizedPrompts.length}`) + //console.log(`itemizedPrompt.length = ${ itemizedPrompts.length } `) for (var i = 0; i < itemizedPrompts.length; i++) { if (itemizedPrompts[i].mesId === mesIdToFind) { newMessage.find(".mes_prompt").show(); - console.log(`showing prompt for mesID ${params.mesId} from ${params.characterName}`); + console.log(`showing prompt for mesID ${params.mesId} from ${params.characterName} `); } else { console.log(`no cache obj for mesID ${mesIdToFind}, hiding prompt button and continuing search`); newMessage.find(".mes_prompt").hide(); @@ -1180,23 +1191,23 @@ function addOneMessage(mes, { type = "normal", insertAfter = null, scroll = true newMessage.find('.avatar img').on('error', function () { $(this).hide(); - $(this).parent().html(`
`); + $(this).parent().html(`< div class="missing-avatar fa-solid fa-user-slash" > `); }); if (type === 'swipe') { - $("#chat").find(`[mesid="${count_view_mes - 1}"]`).find('.mes_text').html(''); - $("#chat").find(`[mesid="${count_view_mes - 1}"]`).find('.mes_text').append(messageText); - appendImageToMessage(mes, $("#chat").find(`[mesid="${count_view_mes - 1}"]`)); - $("#chat").find(`[mesid="${count_view_mes - 1}"]`).attr('title', title); + $("#chat").find(`[mesid = "${count_view_mes - 1}"]`).find('.mes_text').html(''); + $("#chat").find(`[mesid = "${count_view_mes - 1}"]`).find('.mes_text').append(messageText); + appendImageToMessage(mes, $("#chat").find(`[mesid = "${count_view_mes - 1}"]`)); + $("#chat").find(`[mesid = "${count_view_mes - 1}"]`).attr('title', title); if (mes.swipe_id == mes.swipes.length - 1) { - $("#chat").find(`[mesid="${count_view_mes - 1}"]`).find('.mes_timer').text(params.timerValue); - $("#chat").find(`[mesid="${count_view_mes - 1}"]`).find('.mes_timer').attr('title', params.timerTitle); + $("#chat").find(`[mesid = "${count_view_mes - 1}"]`).find('.mes_timer').text(params.timerValue); + $("#chat").find(`[mesid = "${count_view_mes - 1}"]`).find('.mes_timer').attr('title', params.timerTitle); } else { - $("#chat").find(`[mesid="${count_view_mes - 1}"]`).find('.mes_timer').html(''); + $("#chat").find(`[mesid = "${count_view_mes - 1}"]`).find('.mes_timer').html(''); } } else { - $("#chat").find(`[mesid="${count_view_mes}"]`).find('.mes_text').append(messageText); + $("#chat").find(`[mesid = "${count_view_mes}"]`).find('.mes_text').append(messageText); appendImageToMessage(mes, newMessage); hideSwipeButtons(); count_view_mes++; @@ -1224,10 +1235,10 @@ function formatGenerationTimer(gen_started, gen_finished) { const start = moment(gen_started); const finish = moment(gen_finished); const seconds = finish.diff(start, 'seconds', true); - const timerValue = `${seconds.toFixed(1)}s`; + const timerValue = `${seconds.toFixed(1)} s`; const timerTitle = [ - `Generation queued: ${start.format(dateFormat)}`, - `Reply received: ${finish.format(dateFormat)}`, + `Generation queued: ${start.format(dateFormat)} `, + `Reply received: ${finish.format(dateFormat)} `, `Time to generate: ${seconds} seconds`, ].join('\n'); @@ -1256,9 +1267,9 @@ function substituteParams(content, _name1, _name2) { } function getStoppingStrings(isImpersonate, addSpace) { - const charString = `\n${name2}:`; - const youString = `\nYou:`; - const userString = `\n${name1}:`; + const charString = `\n${name2}: `; + const youString = `\nYou: `; + const userString = `\n${name1}: `; const result = isImpersonate ? [charString] : [youString]; result.push(userString); @@ -1271,7 +1282,7 @@ function getStoppingStrings(isImpersonate, addSpace) { const names = group.members .map(x => characters.find(y => y.avatar == x)) .filter(x => x && x.name !== name2) - .map(x => `\n${x.name}:`); + .map(x => `\n${x.name}: `); result.push(...names); } } @@ -1371,7 +1382,7 @@ function cleanGroupMessage(getMessage) { continue; } - const indexOfMember = getMessage.indexOf(`${name}:`); + const indexOfMember = getMessage.indexOf(`${name}: `); if (indexOfMember != -1) { getMessage = getMessage.substr(0, indexOfMember); } @@ -1445,8 +1456,8 @@ class StreamingProcessor { return; } - $(`#chat .mes[mesid="${messageId}"] .mes_stop`).css({ 'display': 'block' }); - $(`#chat .mes[mesid="${messageId}"] .mes_buttons`).css({ 'display': 'none' }); + $(`#chat.mes[mesid = "${messageId}"].mes_stop`).css({ 'display': 'block' }); + $(`#chat.mes[mesid = "${messageId}"].mes_buttons`).css({ 'display': 'none' }); } hideStopButton(messageId) { @@ -1454,8 +1465,8 @@ class StreamingProcessor { return; } - $(`#chat .mes[mesid="${messageId}"] .mes_stop`).css({ 'display': 'none' }); - $(`#chat .mes[mesid="${messageId}"] .mes_buttons`).css({ 'display': 'block' }); + $(`#chat.mes[mesid = "${messageId}"].mes_stop`).css({ 'display': 'none' }); + $(`#chat.mes[mesid = "${messageId}"].mes_buttons`).css({ 'display': 'block' }); } onStartStreaming(text) { @@ -1519,9 +1530,9 @@ class StreamingProcessor { chat[messageId].is_system, chat[messageId].is_user, ); - const mesText = $(`#chat .mes[mesid="${messageId}"] .mes_text`); + const mesText = $(`#chat.mes[mesid = "${messageId}"].mes_text`); mesText.html(formattedText); - $(`#chat .mes[mesid="${messageId}"] .mes_timer`).text(timePassed.timerValue).attr('title', timePassed.timerTitle); + $(`#chat.mes[mesid = "${messageId}"].mes_timer`).text(timePassed.timerValue).attr('title', timePassed.timerTitle); this.setFirstSwipe(messageId); } @@ -1531,7 +1542,7 @@ class StreamingProcessor { onFinishStreaming(messageId, text) { this.hideStopButton(this.messageId); this.onProgressStreaming(messageId, text, true); - addCopyToCodeBlocks($(`#chat .mes[mesid="${messageId}"]`)); + addCopyToCodeBlocks($(`#chat.mes[mesid = "${messageId}"]`)); saveChatConditional(); activateSendButtons(); showSwipeButtons(); @@ -1543,7 +1554,7 @@ class StreamingProcessor { if (power_user.auto_swipe) { function containsBlacklistedWords(str, blacklist, threshold) { - const regex = new RegExp(`\\b(${blacklist.join('|')})\\b`, 'gi'); + const regex = new RegExp(`\\b(${blacklist.join('|')}) \\b`, 'gi'); const matches = str.match(regex) || []; return matches.length >= threshold; } @@ -1753,7 +1764,7 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject, power_user.custom_chat_separator ? power_user.custom_chat_separator : power_user.disable_examples_formatting ? '' : is_pygmalion ? '' : `This is how ${name2} should talk`; - let mesExamplesArray = mesExamples.split(//gi).slice(1).map(block => `${blockHeading}\n${block.trim()}\n`); + let mesExamplesArray = mesExamples.split(//gi).slice(1).map(block => `${blockHeading} \n${block.trim()} \n`); // First message in fresh 1-on-1 chat reacts to user/character settings changes if (chat.length) { @@ -1765,7 +1776,7 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject, if (type === 'swipe') { coreChat.pop(); } - console.log(`Core/all messages: ${coreChat.length}/${chat.length}`); + console.log(`Core / all messages: ${coreChat.length} /${chat.length}`); if (main_api === 'openai') { message_already_generated = ''; // OpenAI doesn't have multigen From 826dc860b6212a20e41e6b6cf37f29be288a0c8a Mon Sep 17 00:00:00 2001 From: RossAscends <124905043+RossAscends@users.noreply.github.com> Date: Fri, 19 May 2023 05:55:11 +0900 Subject: [PATCH 06/19] fixed autoformat error --- public/script.js | 82 ++++++++++++++++++++++++------------------------ 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/public/script.js b/public/script.js index af5e927c9..842746dcf 100644 --- a/public/script.js +++ b/public/script.js @@ -744,9 +744,9 @@ function updateSoftPromptsList(soft_prompts) { // Add SPs added to Kobold soft_prompts.forEach((prompt) => { - if ($(`#softprompt option[value = "${prompt.name}"]`).length === 0) { + if ($(`#softprompt option[value="${prompt.name}"]`).length === 0) { $("#softprompt").append( - `< option value = "${prompt.name}" > ${prompt.name} ` + `` ); if (prompt.selected) { @@ -770,7 +770,7 @@ function printCharacters() { } // Populate the template const template = $('#character_template .character_select').clone(); - template.attr({ 'chid': i, 'id': `CharID${i} ` }); + template.attr({ 'chid': i, 'id': `CharID${i}` }); template.find('img').attr('src', this_avatar); template.find('.avatar').attr('title', item.avatar); template.find('.ch_name').text(item.name); @@ -833,7 +833,7 @@ async function getBackgrounds() { for (const bg of getData) { const thumbPath = getThumbnailUrl('bg', bg); $("#bg_menu_content").append( - `< div class="bg_example flex-container" bgfile = "${bg}" class="bg_example_img" title = "${bg}" style = "background-image: url('${thumbPath}');" > + `
${bg @@ -841,7 +841,7 @@ async function getBackgrounds() { .replace('.jpg', '') .replace('.webp', '')}
-
` + ` ); } } @@ -1004,7 +1004,7 @@ function messageFormatting(mes, ch_name, isSystem, isUser) { .replace(/\*\*(.+?)\*\*/g, "$1") .replace(/\n/g, "
"); } else if (!isSystem) { - mes = mes.replace(/```[\s\S]*? ```|``[\s\S]*?``|`[\s\S]*? `|(\".+?\")|(\u201C.+?\u201D)/gm, function (match, p1, p2) { + mes = mes.replace(/```[\s\S]*?```|``[\s\S]*?``|`[\s\S]*?`|(\".+?\")|(\u201C.+?\u201D)/gm, function (match, p1, p2) { if (p1) { return '"' + p1.replace(/\"/g, "") + '"'; } else if (p2) { @@ -1027,7 +1027,7 @@ function messageFormatting(mes, ch_name, isSystem, isUser) { } if (!power_user.allow_name2_display && ch_name && !isUser && !isSystem) { - mes = mes.replaceAll(`${ch_name}: `, ""); + mes = mes.replaceAll(`${ch_name}:`, ""); } return mes; @@ -1072,8 +1072,8 @@ function addCopyToCodeBlocks(messageElement) { const copiedMsg = document.createElement("div"); copiedMsg.classList.add('code-copied'); copiedMsg.innerText = "Copied!"; - copiedMsg.style.top = `${event.clientY - 55} px`; - copiedMsg.style.left = `${event.clientX - 55} px`; + copiedMsg.style.top = `${event.clientY - 55}px`; + copiedMsg.style.left = `${event.clientX - 55}px`; document.body.append(copiedMsg); setTimeout(() => { document.body.removeChild(copiedMsg); @@ -1148,14 +1148,14 @@ function addOneMessage(mes, { type = "normal", insertAfter = null, scroll = true $("#chat").append(HTMLForEachMes); } else { - const target = $("#chat").find(`.mes[mesid = "${insertAfter}"]`); + const target = $("#chat").find(`.mes[mesid="${insertAfter}"]`); $(HTMLForEachMes).insertAfter(target); $(HTMLForEachMes).find('.swipe_left').css('display', 'none'); $(HTMLForEachMes).find('.swipe_right').css('display', 'none'); } } - const newMessage = $(`#chat[mesid = "${count_view_mes}"]`); + const newMessage = $(`#chat [mesid="${count_view_mes}"]`); newMessage.data("isSystem", isSystem); if (isSystem) { @@ -1166,17 +1166,17 @@ function addOneMessage(mes, { type = "normal", insertAfter = null, scroll = true // don't need prompt button for user if (params.isUser === true) { newMessage.find(".mes_prompt").hide(); - console.log(`hiding prompt for user mesID ${params.mesId} `); + console.log(`hiding prompt for user mesID ${params.mesId}`); } //shows or hides the Prompt display button let mesIdToFind = Number(newMessage.attr('mesId')); if (itemizedPrompts.length !== 0) { - //console.log(`itemizedPrompt.length = ${ itemizedPrompts.length } `) + //console.log(`itemizedPrompt.length = ${itemizedPrompts.length}`) for (var i = 0; i < itemizedPrompts.length; i++) { if (itemizedPrompts[i].mesId === mesIdToFind) { newMessage.find(".mes_prompt").show(); - console.log(`showing prompt for mesID ${params.mesId} from ${params.characterName} `); + console.log(`showing prompt for mesID ${params.mesId} from ${params.characterName}`); } else { console.log(`no cache obj for mesID ${mesIdToFind}, hiding prompt button and continuing search`); newMessage.find(".mes_prompt").hide(); @@ -1191,23 +1191,23 @@ function addOneMessage(mes, { type = "normal", insertAfter = null, scroll = true newMessage.find('.avatar img').on('error', function () { $(this).hide(); - $(this).parent().html(`< div class="missing-avatar fa-solid fa-user-slash" > `); + $(this).parent().html(`
`); }); if (type === 'swipe') { - $("#chat").find(`[mesid = "${count_view_mes - 1}"]`).find('.mes_text').html(''); - $("#chat").find(`[mesid = "${count_view_mes - 1}"]`).find('.mes_text').append(messageText); - appendImageToMessage(mes, $("#chat").find(`[mesid = "${count_view_mes - 1}"]`)); - $("#chat").find(`[mesid = "${count_view_mes - 1}"]`).attr('title', title); + $("#chat").find(`[mesid="${count_view_mes - 1}"]`).find('.mes_text').html(''); + $("#chat").find(`[mesid="${count_view_mes - 1}"]`).find('.mes_text').append(messageText); + appendImageToMessage(mes, $("#chat").find(`[mesid="${count_view_mes - 1}"]`)); + $("#chat").find(`[mesid="${count_view_mes - 1}"]`).attr('title', title); if (mes.swipe_id == mes.swipes.length - 1) { - $("#chat").find(`[mesid = "${count_view_mes - 1}"]`).find('.mes_timer').text(params.timerValue); - $("#chat").find(`[mesid = "${count_view_mes - 1}"]`).find('.mes_timer').attr('title', params.timerTitle); + $("#chat").find(`[mesid="${count_view_mes - 1}"]`).find('.mes_timer').text(params.timerValue); + $("#chat").find(`[mesid="${count_view_mes - 1}"]`).find('.mes_timer').attr('title', params.timerTitle); } else { - $("#chat").find(`[mesid = "${count_view_mes - 1}"]`).find('.mes_timer').html(''); + $("#chat").find(`[mesid="${count_view_mes - 1}"]`).find('.mes_timer').html(''); } } else { - $("#chat").find(`[mesid = "${count_view_mes}"]`).find('.mes_text').append(messageText); + $("#chat").find(`[mesid="${count_view_mes}"]`).find('.mes_text').append(messageText); appendImageToMessage(mes, newMessage); hideSwipeButtons(); count_view_mes++; @@ -1235,10 +1235,10 @@ function formatGenerationTimer(gen_started, gen_finished) { const start = moment(gen_started); const finish = moment(gen_finished); const seconds = finish.diff(start, 'seconds', true); - const timerValue = `${seconds.toFixed(1)} s`; + const timerValue = `${seconds.toFixed(1)}s`; const timerTitle = [ - `Generation queued: ${start.format(dateFormat)} `, - `Reply received: ${finish.format(dateFormat)} `, + `Generation queued: ${start.format(dateFormat)}`, + `Reply received: ${finish.format(dateFormat)}`, `Time to generate: ${seconds} seconds`, ].join('\n'); @@ -1267,9 +1267,9 @@ function substituteParams(content, _name1, _name2) { } function getStoppingStrings(isImpersonate, addSpace) { - const charString = `\n${name2}: `; - const youString = `\nYou: `; - const userString = `\n${name1}: `; + const charString = `\n${name2}:`; + const youString = `\nYou:`; + const userString = `\n${name1}:`; const result = isImpersonate ? [charString] : [youString]; result.push(userString); @@ -1282,7 +1282,7 @@ function getStoppingStrings(isImpersonate, addSpace) { const names = group.members .map(x => characters.find(y => y.avatar == x)) .filter(x => x && x.name !== name2) - .map(x => `\n${x.name}: `); + .map(x => `\n${x.name}:`); result.push(...names); } } @@ -1382,7 +1382,7 @@ function cleanGroupMessage(getMessage) { continue; } - const indexOfMember = getMessage.indexOf(`${name}: `); + const indexOfMember = getMessage.indexOf(`${name}:`); if (indexOfMember != -1) { getMessage = getMessage.substr(0, indexOfMember); } @@ -1456,8 +1456,8 @@ class StreamingProcessor { return; } - $(`#chat.mes[mesid = "${messageId}"].mes_stop`).css({ 'display': 'block' }); - $(`#chat.mes[mesid = "${messageId}"].mes_buttons`).css({ 'display': 'none' }); + $(`#chat .mes[mesid="${messageId}"] .mes_stop`).css({ 'display': 'block' }); + $(`#chat .mes[mesid="${messageId}"] .mes_buttons`).css({ 'display': 'none' }); } hideStopButton(messageId) { @@ -1465,8 +1465,8 @@ class StreamingProcessor { return; } - $(`#chat.mes[mesid = "${messageId}"].mes_stop`).css({ 'display': 'none' }); - $(`#chat.mes[mesid = "${messageId}"].mes_buttons`).css({ 'display': 'block' }); + $(`#chat .mes[mesid="${messageId}"] .mes_stop`).css({ 'display': 'none' }); + $(`#chat .mes[mesid="${messageId}"] .mes_buttons`).css({ 'display': 'block' }); } onStartStreaming(text) { @@ -1530,9 +1530,9 @@ class StreamingProcessor { chat[messageId].is_system, chat[messageId].is_user, ); - const mesText = $(`#chat.mes[mesid = "${messageId}"].mes_text`); + const mesText = $(`#chat .mes[mesid="${messageId}"] .mes_text`); mesText.html(formattedText); - $(`#chat.mes[mesid = "${messageId}"].mes_timer`).text(timePassed.timerValue).attr('title', timePassed.timerTitle); + $(`#chat .mes[mesid="${messageId}"] .mes_timer`).text(timePassed.timerValue).attr('title', timePassed.timerTitle); this.setFirstSwipe(messageId); } @@ -1542,7 +1542,7 @@ class StreamingProcessor { onFinishStreaming(messageId, text) { this.hideStopButton(this.messageId); this.onProgressStreaming(messageId, text, true); - addCopyToCodeBlocks($(`#chat.mes[mesid = "${messageId}"]`)); + addCopyToCodeBlocks($(`#chat .mes[mesid="${messageId}"]`)); saveChatConditional(); activateSendButtons(); showSwipeButtons(); @@ -1554,7 +1554,7 @@ class StreamingProcessor { if (power_user.auto_swipe) { function containsBlacklistedWords(str, blacklist, threshold) { - const regex = new RegExp(`\\b(${blacklist.join('|')}) \\b`, 'gi'); + const regex = new RegExp(`\\b(${blacklist.join('|')})\\b`, 'gi'); const matches = str.match(regex) || []; return matches.length >= threshold; } @@ -1764,7 +1764,7 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject, power_user.custom_chat_separator ? power_user.custom_chat_separator : power_user.disable_examples_formatting ? '' : is_pygmalion ? '' : `This is how ${name2} should talk`; - let mesExamplesArray = mesExamples.split(//gi).slice(1).map(block => `${blockHeading} \n${block.trim()} \n`); + let mesExamplesArray = mesExamples.split(//gi).slice(1).map(block => `${blockHeading}\n${block.trim()}\n`); // First message in fresh 1-on-1 chat reacts to user/character settings changes if (chat.length) { @@ -1776,7 +1776,7 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject, if (type === 'swipe') { coreChat.pop(); } - console.log(`Core / all messages: ${coreChat.length} /${chat.length}`); + console.log(`Core/all messages: ${coreChat.length}/${chat.length}`); if (main_api === 'openai') { message_already_generated = ''; // OpenAI doesn't have multigen From 6557abcd07998a53a37ddfd5c2eeb2eafeb1fb69 Mon Sep 17 00:00:00 2001 From: ramblingcoder Date: Thu, 18 May 2023 17:44:12 -0500 Subject: [PATCH 07/19] Update docker-compose.yml to reflect sillytavern name --- docker/docker-compose.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 59b67738d..cb100b1a1 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -1,12 +1,12 @@ version: "3" services: - tavernai: + sillytavern: build: .. - container_name: tavernai - hostname: tavernai - image: tavernai/tavernai:latest + container_name: sillytavern + hostname: sillytavern + image: cohee1207/sillytavern:latest ports: - "8000:8000" volumes: - "./config:/home/node/app/config" - restart: unless-stopped \ No newline at end of file + restart: unless-stopped From 3e4e1ba96a7efa96ac7ba79124d576198831af9a Mon Sep 17 00:00:00 2001 From: ramblingcoder Date: Thu, 18 May 2023 18:09:41 -0500 Subject: [PATCH 08/19] Update docker-compose.yml --- docker/docker-compose.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index cb100b1a1..9b91526c4 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -9,4 +9,5 @@ services: - "8000:8000" volumes: - "./config:/home/node/app/config" + - "./config.conf:/home/node/app/config.conf" restart: unless-stopped From 7e59745dfc13abe8e70aafaa7857da769a245d4d Mon Sep 17 00:00:00 2001 From: unknown <92774204+nai-degen@users.noreply.github.com> Date: Fri, 19 May 2023 03:17:42 -0500 Subject: [PATCH 09/19] buffers partial SSE messages from Readable --- public/scripts/openai.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/public/scripts/openai.js b/public/scripts/openai.js index e8053b44a..82a0c7849 100644 --- a/public/scripts/openai.js +++ b/public/scripts/openai.js @@ -555,13 +555,19 @@ async function sendOpenAIRequest(type, openai_msgs_tosend, signal) { const decoder = new TextDecoder(); const reader = response.body.getReader(); let getMessage = ""; + let messageBuffer = ""; while (true) { const { done, value } = await reader.read(); let response = decoder.decode(value); tryParseStreamingError(response); - - let eventList = response.split("\n"); + + // ReadableStream's buffer is not guaranteed to contain full SSE messages as they arrive in chunks + // We need to buffer chunks until we have one or more full messages (separated by double newlines) + messageBuffer += response; + let eventList = messageBuffer.split("\n\n"); + // Last element will be an empty string or a leftover partial message + messageBuffer = eventList.pop(); for (let event of eventList) { if (!event.startsWith("data")) From 74d99e09da81562450cbb2570f52cdb10cd3db34 Mon Sep 17 00:00:00 2001 From: SillyLossy Date: Fri, 19 May 2023 11:56:28 +0300 Subject: [PATCH 10/19] Bump package version --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5ff863658..140910cfa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "sillytavern", - "version": "1.5.3", + "version": "1.5.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "sillytavern", - "version": "1.5.3", + "version": "1.5.4", "license": "AGPL-3.0", "dependencies": { "@dqbd/tiktoken": "^1.0.2", diff --git a/package.json b/package.json index 3fa8d0b97..de95cb74a 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "type": "git", "url": "https://github.com/Cohee1207/SillyTavern.git" }, - "version": "1.5.3", + "version": "1.5.4", "scripts": { "start": "node server.js" }, From 32b7250a2d3bc006c15c8470fb34b1e2189545a6 Mon Sep 17 00:00:00 2001 From: SillyLossy Date: Fri, 19 May 2023 12:15:15 +0300 Subject: [PATCH 11/19] Bump package version --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index fb027e06a..e1aa5c111 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "sillytavern", - "version": "1.5.4", + "version": "1.6.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "sillytavern", - "version": "1.5.4", + "version": "1.6.0", "license": "AGPL-3.0", "dependencies": { "@dqbd/tiktoken": "^1.0.2", diff --git a/package.json b/package.json index 49548b351..af3fcd5de 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "type": "git", "url": "https://github.com/Cohee1207/SillyTavern.git" }, - "version": "1.5.4", + "version": "1.6.0", "scripts": { "start": "node server.js", "pkg": "pkg --compress Gzip ." From 5113660e957e18343163b36073ee873d6bd39f3b Mon Sep 17 00:00:00 2001 From: SillyLossy Date: Fri, 19 May 2023 14:21:02 +0300 Subject: [PATCH 12/19] Fix group chats import --- public/script.js | 79 +++++++++++++++++++---------------- public/scripts/group-chats.js | 35 ++++++++++++++++ server.js | 22 ++++++---- 3 files changed, 91 insertions(+), 45 deletions(-) diff --git a/public/script.js b/public/script.js index 842746dcf..e189331de 100644 --- a/public/script.js +++ b/public/script.js @@ -49,6 +49,7 @@ import { editGroup, deleteGroupChat, renameGroupChat, + importGroupChat, } from "./scripts/group-chats.js"; import { @@ -3409,6 +3410,7 @@ async function read_avatar_load(input) { await delay(durationSaveEdit); await fetch(getThumbnailUrl('avatar', formData.get('avatar_url')), { method: 'GET', + cache: 'no-cache', headers: { 'pragma': 'no-cache', 'cache-control': 'no-cache', @@ -3973,7 +3975,7 @@ async function getPastCharacterChats() { return data; } -async function displayPastChats() { +export async function displayPastChats() { $("#select_chat_div").empty(); const group = selected_group ? groups.find(x => x.id === selected_group) : null; @@ -4010,7 +4012,7 @@ async function displayPastChats() { $("#select_chat_div").append(template); - if (currentChat === fileName.replace(".jsonl", "")) { + if (currentChat === fileName.toString().replace(".jsonl", "")) { $("#select_chat_div").find(".select_chat_block:last").attr("highlight", true); } } @@ -4055,7 +4057,6 @@ async function getStatusNovel() { } } - function selectRightMenuWithAnimation(selectedMenuId) { const displayModes = { 'rm_info_block': 'flex', @@ -4076,13 +4077,7 @@ function selectRightMenuWithAnimation(selectedMenuId) { easing: animation_easing, complete: function () { }, }); - - - - // $(menu).find('#groupCurrentMemberListToggle').click(); - } - }) } @@ -4124,10 +4119,8 @@ function select_rm_info(type, charId) { setTimeout(function () { $(`#rm_characters_block [title="${charId + '.png'}"]`).parent().removeClass('flash animated'); }, 5000); - } - setRightTabSelectedClass(); prev_selected_char = charId; @@ -4457,6 +4450,27 @@ export async function saveChatConditional() { } } +async function importCharacterChat(formData) { + await jQuery.ajax({ + type: "POST", + url: "/importchat", + data: formData, + beforeSend: function () { + }, + cache: false, + contentType: false, + processData: false, + success: async function (data) { + if (data.res) { + await displayPastChats(); + } + }, + error: function () { + $("#create_button").removeAttr("disabled"); + }, + }); +} + function updateViewMessageIds() { $('#chat').find(".mes").each(function (index, element) { $(element).attr("mesid", index); @@ -6289,12 +6303,13 @@ $(document).ready(function () { $("#chat_import_file").click(); }); - $("#chat_import_file").on("change", function (e) { + $("#chat_import_file").on("change", async function (e) { var file = e.target.files[0]; - //console.log(1); + if (!file) { return; } + var ext = file.name.match(/\.(\w+)$/); if ( !ext || @@ -6303,33 +6318,23 @@ $(document).ready(function () { return; } + if (selected_group && file.name.endsWith('.json')) { + toastr.warning("Only SillyTavern's own format is supported for group chat imports. Sorry!"); + return; + } + var format = ext[1].toLowerCase(); $("#chat_import_file_type").val(format); - //console.log(format); + var formData = new FormData($("#form_import_chat").get(0)); - //console.log('/importchat entered with: '+formData); - jQuery.ajax({ - type: "POST", - url: "/importchat", - data: formData, - beforeSend: function () { - $("#select_chat_div").html(""); - $("#load_select_chat_div").css("display", "block"); - //$('#create_button').attr('value','Creating...'); - }, - cache: false, - contentType: false, - processData: false, - success: function (data) { - //console.log(data); - if (data.res) { - displayPastChats(); - } - }, - error: function (jqXHR, exception) { - $("#create_button").removeAttr("disabled"); - }, - }); + $("#select_chat_div").html(""); + $("#load_select_chat_div").css("display", "block"); + + if (selected_group) { + await importGroupChat(formData); + } else { + await importCharacterChat(formData); + } }); $("#rm_button_group_chats").click(function () { diff --git a/public/scripts/group-chats.js b/public/scripts/group-chats.js index 171908216..65f33cc14 100644 --- a/public/scripts/group-chats.js +++ b/public/scripts/group-chats.js @@ -47,6 +47,7 @@ import { select_selected_character, cancelTtsPlay, isMultigenEnabled, + displayPastChats, } from "../script.js"; import { appendTagToList, createTagMapFromList, getTagsList, applyTagsOnCharacterSelect } from './tags.js'; @@ -292,6 +293,12 @@ async function getGroups() { if (group.past_metadata == undefined) { group.past_metadata = {}; } + if (typeof group.chat_id === 'number') { + group.chat_id = String(group.chat_id); + } + if (Array.isArray(group.chats) && group.chats.some(x => typeof x === 'number')) { + group.chats = group.chats.map(x => String(x)); + } } } } @@ -1282,6 +1289,34 @@ export async function deleteGroupChat(groupId, chatId) { } } +export async function importGroupChat(formData) { + await jQuery.ajax({ + type: "POST", + url: "/importgroupchat", + data: formData, + beforeSend: function () { + }, + cache: false, + contentType: false, + processData: false, + success: async function (data) { + if (data.res) { + const chatId = data.res; + const group = groups.find(x => x.id == selected_group); + + if (group) { + group.chats.push(chatId); + await editGroup(selected_group, true, true); + await displayPastChats(); + } + } + }, + error: function () { + $("#create_button").removeAttr("disabled"); + }, + }); +} + export async function saveGroupBookmarkChat(groupId, name, metadata) { const group = groups.find(x => x.id === groupId); diff --git a/server.js b/server.js index 03e80abcd..062cd7084 100644 --- a/server.js +++ b/server.js @@ -1754,6 +1754,17 @@ app.post("/exportcharacter", jsonParser, async function (request, response) { return response.sendStatus(400); }); +app.post("/importgroupchat", urlencodedParser, function (request, response) { + try { + const filedata = request.file; + const chatname = humanizedISO8601DateTime(); + fs.copyFileSync(`./uploads/${filedata.filename}`, (`${directories.groupChats}/${chatname}.jsonl`)); + return response.send({ res: chatname }); + } catch (error) { + console.error(error); + return response.send({ error: true }); + } +}); app.post("/importchat", urlencodedParser, function (request, response) { if (!request.body) return response.sendStatus(400); @@ -1763,9 +1774,8 @@ app.post("/importchat", urlencodedParser, function (request, response) { let avatar_url = (request.body.avatar_url).replace('.png', ''); let ch_name = request.body.character_name; if (filedata) { - if (format === 'json') { - fs.readFile('./uploads/' + filedata.filename, 'utf8', (err, data) => { + fs.readFile(`./uploads/${filedata.filename}`, 'utf8', (err, data) => { if (err) { console.log(err); @@ -1782,7 +1792,6 @@ app.post("/importchat", urlencodedParser, function (request, response) { user_name: 'You', character_name: ch_name, create_date: humanizedISO8601DateTime(), - }, ...history.msgs.map( (message) => ({ @@ -1803,7 +1812,7 @@ app.post("/importchat", urlencodedParser, function (request, response) { const errors = []; newChats.forEach(chat => fs.writeFile( - chatsPath + avatar_url + '/' + ch_name + ' - ' + humanizedISO8601DateTime() + ' imported.jsonl', + `${chatsPath + avatar_url}/${ch_name} - ${humanizedISO8601DateTime()} imported.jsonl`, chat.map(JSON.stringify).join('\n'), 'utf8', (err) => err ?? errors.push(err) @@ -1832,8 +1841,7 @@ app.post("/importchat", urlencodedParser, function (request, response) { let jsonData = json5.parse(line); if (jsonData.user_name !== undefined || jsonData.name !== undefined) { - //console.log(humanizedISO8601DateTime()+':/importchat copying chat as '+ch_name+' - '+humanizedISO8601DateTime()+'.jsonl'); - fs.copyFile('./uploads/' + filedata.filename, chatsPath + avatar_url + '/' + ch_name + ' - ' + humanizedISO8601DateTime() + '.jsonl', (err) => { //added character name and replaced Date.now() with humanizedISO8601DateTime + fs.copyFile(`./uploads/${filedata.filename}`, (`${chatsPath + avatar_url}/${ch_name} - ${humanizedISO8601DateTime()}.jsonl`), (err) => { if (err) { response.send({ error: true }); return console.log(err); @@ -1849,9 +1857,7 @@ app.post("/importchat", urlencodedParser, function (request, response) { rl.close(); }); } - } - }); app.post('/importworldinfo', urlencodedParser, (request, response) => { From 6f8ba8fd69971dda6df99d24b5f7087fb78664e2 Mon Sep 17 00:00:00 2001 From: 10sa Date: Fri, 19 May 2023 21:39:48 +0900 Subject: [PATCH 13/19] Add security override config --- config.conf | 6 ++++++ server.js | 8 ++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/config.conf b/config.conf index 452636cca..b6f7dcb62 100644 --- a/config.conf +++ b/config.conf @@ -10,6 +10,11 @@ const enableExtensions = true; //Enables support for TavernAI-extras project const listen = true; // If true, Can be access from other device or PC. otherwise can be access only from hosting machine. const allowKeysExposure = false; // If true, private API keys could be fetched to the frontend. + +// If true, Allows insecure settings for listen, whitelist, and authentication. +// Change this setting only on "trusted networks". Do not change this value unless you are aware of the issues that can arise from changing this setting and configuring a insecure setting. +const securityOverride = false; + module.exports = { port, whitelist, @@ -21,4 +26,5 @@ module.exports = { listen, disableThumbnails, allowKeysExposure, + securityOverride, }; diff --git a/server.js b/server.js index f30b3714f..9f3f606dc 100644 --- a/server.js +++ b/server.js @@ -2715,8 +2715,12 @@ const setupTasks = async function () { } if (listen && !config.whitelistMode && !config.basicAuthMode) { - console.error('Your SillyTavern is currently unsecurely open to the public. Enable whitelisting or basic authentication.'); - process.exit(1); + if (config.securityOverride) + console.warn("Security has been override. If it's not a trusted network, change the settings."); + else { + console.error('Your SillyTavern is currently unsecurely open to the public. Enable whitelisting or basic authentication.'); + process.exit(1); + } } if (true === cliArguments.ssl) From 102a7eb6b7d5802052dcd308ddc05f15a4ca3dc7 Mon Sep 17 00:00:00 2001 From: 10sa Date: Fri, 19 May 2023 22:18:56 +0900 Subject: [PATCH 14/19] Refactoring character card scripts --- server.js | 58 ++--------------------------- src/character-card-parser.js | 72 ++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+), 55 deletions(-) create mode 100644 src/character-card-parser.js diff --git a/server.js b/server.js index 9f3f606dc..9505beda2 100644 --- a/server.js +++ b/server.js @@ -60,6 +60,8 @@ const utf8Encode = new TextEncoder(); const utf8Decode = new TextDecoder('utf-8', { ignoreBOM: true }); const commandExistsSync = require('command-exists').sync; +const characterCardParser = require('./src/character-card-parser.js'); + const config = require(path.join(__dirname, './config.conf')); const server_port = process.env.SILLY_TAVERN_PORT || config.port; @@ -892,61 +894,7 @@ async function charaWrite(img_url, data, target_img, response = undefined, mes = } async function charaRead(img_url, input_format) { - let format; - if (input_format === undefined) { - if (img_url.indexOf('.webp') !== -1) { - format = 'webp'; - } else { - format = 'png'; - } - } else { - format = input_format; - } - - switch (format) { - case 'webp': - try { - const exif_data = await ExifReader.load(fs.readFileSync(img_url)); - let char_data; - - if (exif_data['UserComment']['description']) { - let description = exif_data['UserComment']['description']; - if (description === 'Undefined' && exif_data['UserComment'].value && exif_data['UserComment'].value.length === 1) { - description = exif_data['UserComment'].value[0]; - } - try { - json5.parse(description); - char_data = description; - } catch { - const byteArr = description.split(",").map(Number); - const uint8Array = new Uint8Array(byteArr); - const char_data_string = utf8Decode.decode(uint8Array); - char_data = char_data_string; - } - } else { - console.log('No description found in EXIF data.'); - return false; - } - return char_data; - } - catch (err) { - console.log(err); - return false; - } - case 'png': - const buffer = fs.readFileSync(img_url); - const chunks = extract(buffer); - - const textChunks = chunks.filter(function (chunk) { - return chunk.name === 'tEXt'; - }).map(function (chunk) { - return PNGtext.decode(chunk.data); - }); - var base64DecodedData = Buffer.from(textChunks[0].text, 'base64').toString('utf8'); - return base64DecodedData;//textChunks[0].text; - default: - break; - } + return characterCardParser.parse(img_url, input_format); } app.post("/getcharacters", jsonParser, function (request, response) { diff --git a/src/character-card-parser.js b/src/character-card-parser.js new file mode 100644 index 000000000..9b66d9869 --- /dev/null +++ b/src/character-card-parser.js @@ -0,0 +1,72 @@ +const fs = require('fs'); +const json5 = require('json5'); +const ExifReader = require('exifreader'); + +const extract = require('png-chunks-extract'); +const PNGtext = require('png-chunk-text'); + +const utf8Decode = new TextDecoder('utf-8', { ignoreBOM: true }); + +const parse = async (cardUrl, format) => { + let fileFormat; + if (format === undefined) { + if (cardUrl.indexOf('.webp') !== -1) + fileFormat = 'webp'; + else + fileFormat = 'png'; + } + else + fileFormat = format; + + switch (fileFormat) { + case 'webp': + try { + const exif_data = await ExifReader.load(fs.readFileSync(cardUrl)); + let char_data; + + if (exif_data['UserComment']['description']) { + let description = exif_data['UserComment']['description']; + if (description === 'Undefined' && exif_data['UserComment'].value && exif_data['UserComment'].value.length === 1) { + description = exif_data['UserComment'].value[0]; + } + + try { + json5.parse(description); + char_data = description; + } catch { + const byteArr = description.split(",").map(Number); + const uint8Array = new Uint8Array(byteArr); + const char_data_string = utf8Decode.decode(uint8Array); + char_data = char_data_string; + } + } + else { + console.log('No description found in EXIF data.'); + return false; + } + + return char_data; + } + catch (err) { + console.log(err); + return false; + } + case 'png': + const buffer = fs.readFileSync(cardUrl); + const chunks = extract(buffer); + + const textChunks = chunks.filter(function (chunk) { + return chunk.name === 'tEXt'; + }).map(function (chunk) { + return PNGtext.decode(chunk.data); + }); + + return Buffer.from(textChunks[0].text, 'base64').toString('utf8'); + default: + break; + } +}; + +module.exports = { + parse: parse +}; \ No newline at end of file From 211649798aa6fc3f11a7c8b6683321e624931344 Mon Sep 17 00:00:00 2001 From: 10sa Date: Fri, 19 May 2023 22:30:49 +0900 Subject: [PATCH 15/19] Create .editorconfig --- .editorconfig | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..1e80dbbf5 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,11 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true + +[*.{js, conf, json}] +charset = utf-8 +indent_style = tab +indent_size = 4 \ No newline at end of file From 30e931454a42966b84dd5c2f7d351cda57b93d49 Mon Sep 17 00:00:00 2001 From: 10sa Date: Fri, 19 May 2023 22:38:12 +0900 Subject: [PATCH 16/19] Change tab indent to space indent --- .editorconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.editorconfig b/.editorconfig index 1e80dbbf5..2a13caebf 100644 --- a/.editorconfig +++ b/.editorconfig @@ -7,5 +7,5 @@ trim_trailing_whitespace = true [*.{js, conf, json}] charset = utf-8 -indent_style = tab +indent_style = space indent_size = 4 \ No newline at end of file From 905db6a4e8f1d9584e17549f9271e6fd8babeb45 Mon Sep 17 00:00:00 2001 From: 10sa Date: Fri, 19 May 2023 22:48:48 +0900 Subject: [PATCH 17/19] Reformat codes --- src/character-card-parser.js | 116 +++++++++++++++++------------------ 1 file changed, 58 insertions(+), 58 deletions(-) diff --git a/src/character-card-parser.js b/src/character-card-parser.js index 9b66d9869..e97a66bf0 100644 --- a/src/character-card-parser.js +++ b/src/character-card-parser.js @@ -8,65 +8,65 @@ const PNGtext = require('png-chunk-text'); const utf8Decode = new TextDecoder('utf-8', { ignoreBOM: true }); const parse = async (cardUrl, format) => { - let fileFormat; - if (format === undefined) { - if (cardUrl.indexOf('.webp') !== -1) - fileFormat = 'webp'; - else - fileFormat = 'png'; - } - else - fileFormat = format; - - switch (fileFormat) { - case 'webp': - try { - const exif_data = await ExifReader.load(fs.readFileSync(cardUrl)); - let char_data; - - if (exif_data['UserComment']['description']) { - let description = exif_data['UserComment']['description']; - if (description === 'Undefined' && exif_data['UserComment'].value && exif_data['UserComment'].value.length === 1) { - description = exif_data['UserComment'].value[0]; - } - - try { - json5.parse(description); - char_data = description; - } catch { - const byteArr = description.split(",").map(Number); - const uint8Array = new Uint8Array(byteArr); - const char_data_string = utf8Decode.decode(uint8Array); - char_data = char_data_string; - } - } - else { - console.log('No description found in EXIF data.'); - return false; - } - - return char_data; - } - catch (err) { - console.log(err); - return false; - } - case 'png': - const buffer = fs.readFileSync(cardUrl); - const chunks = extract(buffer); - - const textChunks = chunks.filter(function (chunk) { - return chunk.name === 'tEXt'; - }).map(function (chunk) { - return PNGtext.decode(chunk.data); - }); - - return Buffer.from(textChunks[0].text, 'base64').toString('utf8'); - default: - break; + let fileFormat; + if (format === undefined) { + if (cardUrl.indexOf('.webp') !== -1) + fileFormat = 'webp'; + else + fileFormat = 'png'; + } + else + fileFormat = format; + + switch (fileFormat) { + case 'webp': + try { + const exif_data = await ExifReader.load(fs.readFileSync(cardUrl)); + let char_data; + + if (exif_data['UserComment']['description']) { + let description = exif_data['UserComment']['description']; + if (description === 'Undefined' && exif_data['UserComment'].value && exif_data['UserComment'].value.length === 1) { + description = exif_data['UserComment'].value[0]; + } + + try { + json5.parse(description); + char_data = description; + } catch { + const byteArr = description.split(",").map(Number); + const uint8Array = new Uint8Array(byteArr); + const char_data_string = utf8Decode.decode(uint8Array); + char_data = char_data_string; + } + } + else { + console.log('No description found in EXIF data.'); + return false; + } + + return char_data; + } + catch (err) { + console.log(err); + return false; + } + case 'png': + const buffer = fs.readFileSync(cardUrl); + const chunks = extract(buffer); + + const textChunks = chunks.filter(function (chunk) { + return chunk.name === 'tEXt'; + }).map(function (chunk) { + return PNGtext.decode(chunk.data); + }); + + return Buffer.from(textChunks[0].text, 'base64').toString('utf8'); + default: + break; } }; module.exports = { - parse: parse -}; \ No newline at end of file + parse: parse +}; From 3fcaf7fd41d5b2b17bc8127562c7d68bed03159d Mon Sep 17 00:00:00 2001 From: SillyLossy Date: Fri, 19 May 2023 18:16:59 +0300 Subject: [PATCH 18/19] Check for user avatar crop --- server.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server.js b/server.js index c90aa86c3..66c3291c2 100644 --- a/server.js +++ b/server.js @@ -915,7 +915,7 @@ async function tryReadImage(img_url, crop) { } async function charaRead(img_url, input_format) { - return characterCardParser.parse(img_url, input_format); + return characterCardParser.parse(img_url, input_format); } app.post("/getcharacters", jsonParser, function (request, response) { @@ -1873,7 +1873,7 @@ app.post('/uploaduseravatar', urlencodedParser, async (request, response) => { const crop = tryParse(request.query.crop); let rawImg = await jimp.read(pathToUpload); - if (typeof crop == 'object') { + if (typeof crop == 'object' && [crop.x, crop.y, crop.width, crop.height].every(x => typeof x === 'number')) { rawImg = rawImg.crop(crop.x, crop.y, crop.width, crop.height); } From ab5e555d6206bb07fa597125ab5960f7404db7e5 Mon Sep 17 00:00:00 2001 From: SillyLossy Date: Fri, 19 May 2023 18:31:59 +0300 Subject: [PATCH 19/19] Add reverse proxy to presets. #345 #109 Remove token breakdown from OAI options (it's now globally active). --- public/index.html | 14 -------------- public/script.js | 21 --------------------- public/scripts/openai.js | 20 +++----------------- public/style.css | 13 ------------- 4 files changed, 3 insertions(+), 65 deletions(-) diff --git a/public/index.html b/public/index.html index 471f207c5..e74848ecc 100644 --- a/public/index.html +++ b/public/index.html @@ -369,15 +369,6 @@ -
- -
- Display a breakdown of the tokens used in the request. -
-
Context Size (tokens) @@ -2507,11 +2498,6 @@
-
diff --git a/public/script.js b/public/script.js index e189331de..c8f3c08bd 100644 --- a/public/script.js +++ b/public/script.js @@ -2432,9 +2432,6 @@ function getMaxContextSize() { } function parseTokenCounts(counts, thisPromptBits) { - const breakdown_bar = $('#token_breakdown div:first-child'); - breakdown_bar.empty(); - const total = Object.values(counts).filter(x => !Number.isNaN(x)).reduce((acc, val) => acc + val, 0); thisPromptBits.push({ @@ -2448,22 +2445,6 @@ function parseTokenCounts(counts, thisPromptBits) { oaiConversationTokens: Object.entries(counts)[7][1], oaiTotalTokens: total, }); - - Object.entries(counts).forEach(([type, value]) => { - if (value === 0) { - return; - } - const percent_value = (value / total) * 100; - const color = uniqolor(type, { saturation: 50, lightness: 75, }).color; - const bar = document.createElement('div'); - bar.style.width = `${percent_value}%`; - bar.classList.add('token_breakdown_segment'); - bar.style.backgroundColor = color + 'AA'; - bar.style.borderColor = color + 'FF'; - bar.innerText = value; - bar.title = `${type}: ${percent_value.toFixed(2)}%`; - breakdown_bar.append(bar); - }); } function adjustChatsSeparator(mesSendString) { @@ -3582,10 +3563,8 @@ function changeMainAPI() { // Hide common settings for OpenAI if (selectedVal == "openai") { $("#common-gen-settings-block").css("display", "none"); - //$("#token_breakdown").css("display", "flex"); } else { $("#common-gen-settings-block").css("display", "block"); - //$("#token_breakdown").css("display", "none"); } // Hide amount gen for poe if (selectedVal == "poe") { diff --git a/public/scripts/openai.js b/public/scripts/openai.js index 19ee009ed..2b80dd64a 100644 --- a/public/scripts/openai.js +++ b/public/scripts/openai.js @@ -102,7 +102,6 @@ const default_settings = { openai_model: 'gpt-3.5-turbo', jailbreak_system: false, reverse_proxy: '', - oai_breakdown: false, }; const oai_settings = { @@ -127,7 +126,6 @@ const oai_settings = { openai_model: 'gpt-3.5-turbo', jailbreak_system: false, reverse_proxy: '', - oai_breakdown: false, }; let openai_setting_names; @@ -460,7 +458,7 @@ async function prepareOpenAIMessages(name2, storyString, worldInfoBefore, worldI handler_instance.log(); return [ openai_msgs_tosend, - oai_settings.oai_breakdown ? handler_instance.counts : false, + handler_instance.counts, ]; } @@ -751,7 +749,6 @@ function loadOpenAISettings(data, settings) { if (settings.nsfw_first !== undefined) oai_settings.nsfw_first = !!settings.nsfw_first; if (settings.openai_model !== undefined) oai_settings.openai_model = settings.openai_model; if (settings.jailbreak_system !== undefined) oai_settings.jailbreak_system = !!settings.jailbreak_system; - if (settings.oai_breakdown !== undefined) oai_settings.oai_breakdown = !!settings.oai_breakdown; $('#stream_toggle').prop('checked', oai_settings.stream_openai); @@ -767,7 +764,6 @@ function loadOpenAISettings(data, settings) { $('#wrap_in_quotes').prop('checked', oai_settings.wrap_in_quotes); $('#nsfw_first').prop('checked', oai_settings.nsfw_first); $('#jailbreak_system').prop('checked', oai_settings.jailbreak_system); - $('#oai_breakdown').prop('checked', oai_settings.oai_breakdown); if (settings.main_prompt !== undefined) oai_settings.main_prompt = settings.main_prompt; if (settings.nsfw_prompt !== undefined) oai_settings.nsfw_prompt = settings.nsfw_prompt; @@ -887,7 +883,7 @@ async function saveOpenAIPreset(name, settings) { jailbreak_system: settings.jailbreak_system, impersonation_prompt: settings.impersonation_prompt, bias_preset_selected: settings.bias_preset_selected, - oai_breakdown: settings.oai_breakdown, + reverse_proxy: settings.reverse_proxy, }; const savePresetSettings = await fetch(`/savepreset_openai?name=${name}`, { @@ -1146,12 +1142,12 @@ function onSettingsPresetChange() { wrap_in_quotes: ['#wrap_in_quotes', 'wrap_in_quotes', true], nsfw_first: ['#nsfw_first', 'nsfw_first', true], jailbreak_system: ['#jailbreak_system', 'jailbreak_system', true], - oai_breakdown: ['#oai_breakdown', 'oai_breakdown', true], main_prompt: ['#main_prompt_textarea', 'main_prompt', false], nsfw_prompt: ['#nsfw_prompt_textarea', 'nsfw_prompt', false], jailbreak_prompt: ['#jailbreak_prompt_textarea', 'jailbreak_prompt', false], impersonation_prompt: ['#impersonation_prompt_textarea', 'impersonation_prompt', false], bias_preset_selected: ['#openai_logit_bias_preset', 'bias_preset_selected', false], + reverse_proxy: ['#openai_reverse_proxy', 'reverse_proxy', false], }; for (const [key, [selector, setting, isCheckbox]] of Object.entries(settingsToUpdate)) { @@ -1319,16 +1315,6 @@ $(document).ready(function () { saveSettingsDebounced(); }); - $("#oai_breakdown").on('change', function () { - oai_settings.oai_breakdown = !!$(this).prop("checked"); - if (!oai_settings.oai_breakdown) { - $("#token_breakdown").css('display', 'none'); - } else { - $("#token_breakdown").css('display', 'flex'); - } - saveSettingsDebounced(); - }); - // auto-select a preset based on character/group name $(document).on("click", ".character_select", function () { const chid = $(this).attr('chid'); diff --git a/public/style.css b/public/style.css index d5bc238d0..7ddd0b5bf 100644 --- a/public/style.css +++ b/public/style.css @@ -427,19 +427,6 @@ code { justify-content: center; } -#token_breakdown div { - display: flex; - width: 100%; - justify-content: center; -} - -.token_breakdown_segment { - min-width: 40px !important; - border: solid 2px; - border-radius: 5px; -} - - #loading_mes { display: none; width: 40px;