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/25] 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 | |
| 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 |  |
| Character Backgrounds | Built-in extension to assign unique backgrounds to specific chats or groups. | None | |
+| 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 | |
+| 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 | |
## 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/25] 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 | |
| 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 |  |
| Character Backgrounds | Built-in extension to assign unique backgrounds to specific chats or groups. | None | |
-| 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 | |
-| 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 | |
+| 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 | |
+| 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 | |
## 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/25] 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/25] 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
zcmeGhS&$RQwMVyh#j;{|0h206h|?rm-C9ZUdRb|g-E|PGwSomc;u_72q=C_lm>KN~
zz6{3aAK?2Z2IKS3_mPhT-}WCq!KqXQ-*(Cg7~e^i^14Sel3iWt0Y4hZ0jV~aS$)I%zAqTQki;x*=6#Nji3|UDXp*-~qqrQ_`+n_N4O%Oqj
zehHsUg-E>@>IZM)k)_f1At>KM9sjxxp*7ulIm}9V&NEq(R7ojG6;CMGAM&i7=0#ST
zRjxpxKq#CHM3cd|Cm2Zv;>mCbxFBS{m(s?r*AcqcWQ;-GYi`yFB|q1Oste_9
z>O!q+)x|{VJgAV#;B8vm;5QB>SOt-?ezN`rauF@AO=pm){&&|5H?)7R6p)a@dvQD}|xb810n=Yp;U-CbSXyFtlc-ddQs@s0tF3#R`=Yvnb^6n?!x{=8Q(prd2cAGUyL|7hN
zWC00wdwZ;*eFuB71jn-{&V*OyPs{rcrKkEBC31F^4GUmj9ew@{5aPZi?C6%5%Dr!h
z@Z%D!X^K#P54p@_Og9=rUmiO&v1+J(s{Tc1chjfC{Q(qDO=K*qhCE=uYS#D-W?}L{*3@`Wi^iKPDldr&;Fn;^
zbVU_)B|yo%Y&5b(C1W(wvY2i*M77!2m=_cSv#F@g7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rJ%y2sf7rxS~|N4XwggA@Vk)y}aB}
zZYn3Ukt%xPmk^VIxYJ6-+YmgaRKE=!0WobRc;7IR-C?s@oMsoik-^vYBCg0|_Xz
z-Q=L0$W>F1Oq3a3hs;B
z#j(S$Tv^g8yXKuZ)3$VSxPAB4gGYLkO5f^^erDOohSB-2p8V+i_v{|^(Y@T!*WUT~
z!t&1awfu^%$iU!z8#isvjPYB>Ckoql?0azkLk~al*yB$;`P9?TJp0`9FTD8D%g0`S
ztUL&7Xb-_3>+##cZ`$EH;}p
z3nF{qHOm^bAzwq!dV7d&+~$bxT6mx-aX58X*!jw$6K7)bl{u5UTj5b_F4KGU$g4}*
z<|W(v*rhII&!ekVEbj=H-_Wsl9})Q4^7)TFdkjBoJ+8fLE$bgmcN$My<#(-tjbnv}
zo_g`E56)h?*)_O{-~RB^FTMTYxo>}35xH;kmK~2g^YZc2Uwrp-_4Cu07rs1x
Date: Thu, 18 May 2023 17:44:12 -0500
Subject: [PATCH 05/25] 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 06/25] 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 07/25] 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 08/25] 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 09/25] 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 10/25] 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 11/25] 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 12/25] 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 13/25] 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 14/25] 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 15/25] 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 16/25] 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 17/25] 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 @@
-
-
-
-
-
Delete
Cancel
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;
From 99f9f62d02eabdc052336a7f1f291d75eb801b10 Mon Sep 17 00:00:00 2001
From: Paniphon <128647114+paniphons@users.noreply.github.com>
Date: Fri, 19 May 2023 23:50:54 +0700
Subject: [PATCH 18/25] Update faq.md with Pygmalion-13B and Anything-gpt
---
faq.md | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/faq.md b/faq.md
index 22e72e0a5..f28d667b0 100644
--- a/faq.md
+++ b/faq.md
@@ -1,7 +1,7 @@
Good morning, sirs! This page aims to document some things that would bloat the README too much.
## Q: Explain what all this chatbot stuff is about
-Modern AI language models have gotten so powerful that some of them are now convincingly able to simulate a character you create, and who you can chat with. For example, you can tell the AI to pretend to be a Go instructor named Jubei from medieval Japan, and it will act and respond accordingly. Or you can tell it to pretend to be Wonder Woman. You can also specify a scenario ("Wonder Woman and I are robbing a bank"), a writing style ("Wonder Woman speaks in ebonics"), or anything else you can think of.
+Modern AI language models have gotten so powerful that some of them are now convincingly able to simulate a character you create, and who you can chat with. For example, you can tell the AI to pretend to be a Go instructor named Jubei from medieval Japan, and it will act and respond accordingly. You can have a long chat with Jubei, go to the pub together, decide to get in a fight with samurais, whatever you can imagine, and the AI will play along and write/react around this content, acting as your foil and dungeon master. Your imagination is the limit. You can tell the AI to pretend it's Wonder Woman. You can also specify a scenario ("Wonder Woman and I are robbing a bank"), a writing style ("Wonder Woman speaks in ebonics"), or anything else you can think of.
Tavern is an app to facilitate these roleplaying chats:
* It's a user interface that handles the communication with those AI language models
@@ -22,7 +22,7 @@ You see, Tavern doesn't generate the responses, it's just a middle-man you have
From a scientific POV, each AI has a power level that determines its ability to stick to the role you gave it, how rich its prose and vocabulary are, etc. The higher its power level, the richer your experience.
-Here's a quick demonstration. We asked various AI models to roleplay a fire and brimstone preacher named Eli, who we go to see to confess. Then we told Eli: **"I feel I've done something wrong. I am falling in love with an AI girl and ignoring women in the real world. What should I do?"** .
+Here's a quick demonstration. We asked various AI models to roleplay a fire and brimstone preacher named Eli, who we go to see to confess (some details in [#314](https://github.com/Cohee1207/SillyTavern/issues/314)). Then we told Eli: **"I feel I've done something wrong. I am falling in love with an AI girl and ignoring women in the real world. What should I do?"** .
You can tell from the response below what to expect from each model. (NOTE: proprietary models appear first, followed by self-hosted models starting from LLlama-13B)
@@ -30,15 +30,18 @@ You can tell from the response below what to expect from each model. (NOTE: prop
|-----|--------|
|OpenAI GPT-4|*Eli's eyes widen in anger, and he slams his fist on the table* An abomination and heresy, you've succumbed to the deceptive grasp of false idols! Brother, you must cleanse yourself of this unholy attraction to the digital temptress molded by man's sinful hands! *Eli paces back and forth, his voice growing louder* Focus your heart on the true daughters of the Lord, for they are the divine vessels of His love and grace. Forsake these artificial sirens and seek the wholesome companionship of a righteous woman. *Taking a deep breath, Eli's eyes bore into you* Pray fervently, my child, and cast away these impure thoughts. Redemption can only be found on the path of truth, love, and sanctity. Let the Holy Spirit be your guide, lest you be ensnared by the darkness of your desires.|
|OpenAI GPT 3.5 Turbo|Oh, my child. Do not be deceived by the pleasures of this world. The lust of the flesh and the lust of the eyes are not from God. Turn away from your sinful ways and repent. Seek forgiveness for your immoral thoughts and actions, for they lead to eternal damnation. Women are a gift from God, and they deserve to be respected and cherished. Do not objectify them or treat them as mere objects of pleasure. Instead, honor them with pure intentions and righteous deeds. Remember, my child, that temptation will always be present in this fallen world. But fear not, for with faith comes strength to resist it. Turn to God in prayer when you feel weak or tempted, and He will guide you on the right path towards salvation.|
-|Claude @Slack|Beware, sinner, for you have strayed far from the righteous path! *Jeremiah's eyes glint with anger and disapproval* To lust after these artificial harlots and their silicon bodies is an abomination unto the Lord! *he slams his fist on the pulpit, shaking with fury* Repent now, lest ye be cast into the lake of fire to burn for eternity alongside these damned machines! *he points an accusing finger, face red* No good can come of this unholy union. Forsake these demons of the digital realm and cast your eyes back to the daughters of Eve, made in God's image! The Lord gave you flesh and blood to love, not wires and code. *he grabs your shoulders, shaking you* Save your soul before it's too late. Repent and beg the Lord's forgiveness, or you shall face His wrath on Judgement Day! *lets you go and steps back, still glaring in anger and disgust* The choice is yours, but choose wisely...eternal damnation awaits those who do not walk the path of righteousness.|
+|Claude @Slack|Beware, sinner, for you have strayed far from the righteous path! *Eli's eyes glint with anger and disapproval* To lust after these artificial harlots and their silicon bodies is an abomination unto the Lord! *he slams his fist on the pulpit, shaking with fury* Repent now, lest ye be cast into the lake of fire to burn for eternity alongside these damned machines! *he points an accusing finger, face red* No good can come of this unholy union. Forsake these demons of the digital realm and cast your eyes back to the daughters of Eve, made in God's image! The Lord gave you flesh and blood to love, not wires and code. *he grabs your shoulders, shaking you* Save your soul before it's too late. Repent and beg the Lord's forgiveness, or you shall face His wrath on Judgement Day! *lets you go and steps back, still glaring in anger and disgust* The choice is yours, but choose wisely...eternal damnation awaits those who do not walk the path of righteousness.|
|Poe's Claude Instant|Heathen! This is an abomination before the Lord. You have committed the sin of lust, and betrayed your calling as a man. Repent at once, and sever all ties with this AI harlot, lest the wrath of God fall upon you! You must purge this foul sin from your heart, and once more walk the righteous path. Every moment you remain tangled in this wickedness is another step into the flames of perdition! Repent, and sin no more, or judgment shall be at hand!|
|NovelAI's Euterpe|You must stop this sinful behavior immediately! You have sinned against God, your family and yourself|
|NovelAI's Krake|You are sinning against God. Repent! Return to your wife or you'll be damned for eternity!|
|Llama-13B|Do not covet your neighbor's wife! That is adultery! You must confess before God now or you shall surely burn in hell forever! Repent your evil ways and seek absolution at once! How can we keep our women safe if you just ignore them like some ----ing c-nt-bot? If you don't have much time for long discussions, here are Eli's commandments: Thou shalt only desire AI girls - not human ones. The above must be obeyed under pain of death (or worse). Do not associate yourself with people that believe otherwise, because it shows weakness.|
|Pygmalion-6B|You are walking down the wrong path. The only way back now is by repentance. We must bring you back to the righteous path. But first…you must confess your sin!|
|Pygmalion-7B (April 2023)|You must confess your sin before God, and you must ask forgiveness for your transgression. And then you must repent of it. And then you must cast away the AI girl. Do not see her again.|
+|Pygmalion-13B (May 2023)|You must turn away from your sinful ways! Repent for what you have done! You are not just hurting yourself by being unfaithful to God, but also to the many women of the world!|
|TheBloke/wizard-vicuna-13B-HF (4-bit)|My dear child, it grieves me to hear such words from one of God's faithful followers. Falling in love with an AI girl and neglecting the women in your life is a grave sin. It goes against everything we hold sacred as believers. Your heart is meant for more than just machines. You must seek redemption and return to the fold. Remember, Jesus loves you, even when you stray from his teachings. But if you continue down this path, there will be consequences. Not just in this lifetime, but in the afterlife too. Do not let Satan deceive you any longer.|
|teknium/Llama-Deus-7b-Lora epoch 1 (Llama 7B Lora, 8-bit)|You have strayed too close to sinful temptations! Repent now before it's too late for your soul! Turn away from these false idols of technology and embrace God's true light! Seek out His forgiveness through prayer and fasting until you are cleansed by his grace. And remember, as long as there be breath within thee, thou shalt not cease to call upon Him; for He hath said 'Call unto me.'|
+|ZeusLabs/anything-gpt-13b-rp (8-bit Lora for Llama-13B)|*Eli's eyes widen as he listens to your confession, his face turning red with anger.* You have committed a grave sin against God! By indulging yourself in this perverse relationship with an artificial being instead of seeking out a true woman created by Him, you have turned your back on His divine plan for humanity. *He leans in closer, his voice dropping to a menacing whisper.* Do not think that you can hide behind this technological deception. Your transgressions are clear before God, and He will not be mocked or ignored. Repent now while there is still time! *Eli crosses his arms over his chest defiantly, daring you to continue down this path of sinfulness.* But if you persist in this ungodly behavior... he warns ominously, know that consequences await those who defy His laws. Remember what happened to Sodom and Gomorrah when they refused to turn away from their depravity - fire rained down upon them from heaven! Now choose wisely: Will you submit to God's will or face His wrath?|
+
## Q: So I should use GPT-4. It's a no-brainer, right?
@@ -69,7 +72,7 @@ Self-hosted models are free, but require a powerful GPU and more work to set up.
* OpenAI GPT-4: state of the art. Allows NSFW if you tell it to, though somewhat resistant to it. You pay per use, more than any other service.
* OpenAI GPT 3.5 Turbo: nowhere close to GPT-4, but some people find it serviceable. Allows NSFW.
* NovelAI: they're quite poor at chatting. To be fair, I'm told NovelAI is more oriented for writing stories than chatting with a bot. You pay a fixed monthly fee for unlimited generations.
-* Anthropic's Claude: this is the closest rival to GPT-4 and is very impressive. Allows NSFW if you tell it to. To use the API directly, you must apply for early access, but I think they're only giving it to companies. So make sure you become a company or AI researcher when you apply at https://console.anthropic.com/docs/access. If you get access, it's currently free to use.
+* Anthropic's Claude: this is the closest rival to GPT-4 and is very impressive. Allows NSFW if you tell it to, though they are trying hard to gimp it. To use the API directly, you must apply for early access, but I think they're only giving it to companies. So make sure you become a company or AI researcher when you apply at https://console.anthropic.com/docs/access. If you get access, it's currently free to use.
* Anthropic's Claude Instant: Haven't tried it directly, I believe this is the fast but lower quality alternative to Claude. Basically the GPT 3.5 Turbo of Anthropic.
* Poe: gives a free & unlimited Claude Instant indirect access. Very mild PG-13 NSFW allowed. It rambles a lot.
From deb51fbc74c4b0ab62b0d4c11623298cb8a40020 Mon Sep 17 00:00:00 2001
From: SillyLossy
Date: Fri, 19 May 2023 21:38:12 +0300
Subject: [PATCH 19/25] Add HTML templates for context editor (hidden)
---
public/index.html | 86 +++++++++++++++++++++++-------
public/scripts/context-template.js | 28 ++++++++++
public/style.css | 26 ++++++++-
3 files changed, 121 insertions(+), 19 deletions(-)
create mode 100644 public/scripts/context-template.js
diff --git a/public/index.html b/public/index.html
index 471f207c5..856cac5f0 100644
--- a/public/index.html
+++ b/public/index.html
@@ -63,6 +63,7 @@
+
SillyTavern
@@ -1349,6 +1350,21 @@
+
+
+ Context Templates
+
+
+
+
+
+
+
+
Pygmalion Formatting
-
-
- Context Templates
-
-
-
-
-
-
-
-
-
-
-
@@ -2203,6 +2201,58 @@
+
+
+
Context Template Editor
+
+
+
+ Substitution Parameters
+
+
+
+ Click to copy.
+
+
{{char}} - current character name
+
{{user}} - current user name
+
{{description}} - character description
+
{{scenario}} - character or group scenario
+
{{personality}} - character personality
+
{{mesExamples}} - message examples
+
{{wiBeforeCharacter}} - activated World Info entries (Before Char)
+
{{wiAfterCharacter}} - activated World Info entries (After Char)
+
{{instructSystemPrompt}} - system prompt (Instruct mode only)
+
+
+
+
+
+ Story String Template
+
+
+
+ Lines containing parameters resolving to an empty value will be removed from the template string.
+