Merge branch 'dev'

This commit is contained in:
SillyLossy
2023-04-19 15:53:08 +03:00
8 changed files with 76 additions and 1599 deletions

1
.gitignore vendored
View File

@ -6,6 +6,7 @@ public/backgrounds/
public/groups/ public/groups/
public/worlds/ public/worlds/
public/css/bg_load.css public/css/bg_load.css
public/themes/
/uploads/ /uploads/
*.jsonl *.jsonl
config.conf config.conf

File diff suppressed because it is too large Load Diff

View File

@ -8,7 +8,8 @@
<meta name="darkreader-lock"> <meta name="darkreader-lock">
<link href="webfonts/NotoSans/stylesheet.css" rel="stylesheet"> <link href="webfonts/NotoSans/stylesheet.css" rel="stylesheet">
<!-- fontawesome webfonts--> <!-- fontawesome webfonts-->
<link href="css/all.css" rel="stylesheet"> <link href="css/fontawesome.css" rel="stylesheet">
<link href="css/solid.css" rel="stylesheet">
<link rel="apple-touch-icon" sizes="57x57" href="img/apple-icon-57x57.png" /> <link rel="apple-touch-icon" sizes="57x57" href="img/apple-icon-57x57.png" />
<link rel="apple-touch-icon" sizes="72x72" href="img/apple-icon-72x72.png" /> <link rel="apple-touch-icon" sizes="72x72" href="img/apple-icon-72x72.png" />

View File

@ -148,6 +148,7 @@ export {
count_view_mes, count_view_mes,
max_context, max_context,
chat_metadata, chat_metadata,
streamingProcessor,
default_avatar, default_avatar,
system_message_types, system_message_types,
talkativeness_default, talkativeness_default,
@ -1021,11 +1022,11 @@ function substituteParams(content, _name1, _name2) {
return content; return content;
} }
function getStoppingStrings(isImpersonate, wrapInQuotes) { function getStoppingStrings(isImpersonate, addSpace) {
const charString = `\n${name2}:`; const charString = `\n${name2}:`;
const userString = is_pygmalion ? `\nYou:` : `\n${name1}:`; const userString = is_pygmalion ? `\nYou:` : `\n${name1}:`;
const result = isImpersonate ? charString : userString; const result = isImpersonate ? charString : userString;
return wrapInQuotes ? `"${result}"` : result; return addSpace ? `${result} ` : result;
} }
function getSlashCommand(message, type) { function getSlashCommand(message, type) {
@ -1328,7 +1329,7 @@ async function Generate(type, automatic_trigger, force_name2) {
streamingProcessor = false; streamingProcessor = false;
} }
if (selected_group && !is_group_generating && !isImpersonate) { if (selected_group && !is_group_generating) {
generateGroupWrapper(false, type = type); generateGroupWrapper(false, type = type);
return; return;
} }
@ -2193,6 +2194,17 @@ function cleanUpMessage(getMessage, isImpersonate) {
getMessage = getMessage.trim(); getMessage = getMessage.trim();
} }
const stoppingString = getStoppingStrings(isImpersonate, false);
if (stoppingString.length) {
for (let j = stoppingString.length - 1; j > 0; j--) {
if (getMessage.slice(-j) === stoppingString.slice(0, j)) {
getMessage = getMessage.slice(0, -j);
break;
}
}
}
return getMessage; return getMessage;
} }
@ -2268,6 +2280,7 @@ function activateSendButtons() {
is_send_press = false; is_send_press = false;
$("#send_but").css("display", "flex"); $("#send_but").css("display", "flex");
$("#loading_mes").css("display", "none"); $("#loading_mes").css("display", "none");
$("#send_textarea").attr("disabled", false);
} }
function deactivateSendButtons() { function deactivateSendButtons() {

View File

@ -14,8 +14,7 @@
bottom: 1px; bottom: 1px;
padding: 0; padding: 0;
filter: drop-shadow(2px 2px 2px #51515199); filter: drop-shadow(2px 2px 2px #51515199);
z-index: 3; z-index: 1;
/* resize: both; */
overflow: hidden; overflow: hidden;
} }

View File

@ -41,6 +41,7 @@ import {
updateChatMetadata, updateChatMetadata,
isStreamingEnabled, isStreamingEnabled,
getThumbnailUrl, getThumbnailUrl,
streamingProcessor,
} from "../script.js"; } from "../script.js";
export { export {
@ -329,6 +330,10 @@ async function generateGroupWrapper(by_auto_mode, type = null) {
throw new Error('Deleted group member swiped'); throw new Error('Deleted group member swiped');
} }
} }
else if (type === "impersonate") {
$("#send_textarea").attr("disabled", true);
activatedMembers = activateImpersonate(group.members);
}
else if (activationStrategy === group_activation_strategy.NATURAL) { else if (activationStrategy === group_activation_strategy.NATURAL) {
activatedMembers = activateNaturalOrder(group.members, activationText, lastMessage, group.allow_self_responses, isUserInput); activatedMembers = activateNaturalOrder(group.members, activationText, lastMessage, group.allow_self_responses, isUserInput);
} }
@ -338,13 +343,13 @@ async function generateGroupWrapper(by_auto_mode, type = null) {
// now the real generation begins: cycle through every character // now the real generation begins: cycle through every character
for (const chId of activatedMembers) { for (const chId of activatedMembers) {
const generateType = type !== "swipe" ? "group_chat" : "swipe"; const generateType = type == "swipe" || type == "impersonate" ? type : "group_chat";
setCharacterId(chId); setCharacterId(chId);
setCharacterName(characters[chId].name) setCharacterName(characters[chId].name)
await Generate(generateType, by_auto_mode); await Generate(generateType, by_auto_mode);
if (type !== "swipe") { if (type !== "swipe" && type !== "impersonate") {
// update indicator and scroll down // update indicator and scroll down
typingIndicator typingIndicator
.find(".typing_indicator_name") .find(".typing_indicator_name")
@ -361,9 +366,42 @@ async function generateGroupWrapper(by_auto_mode, type = null) {
await delay(100); await delay(100);
} }
// if swipe - see if message changed // if swipe - see if message changed
else if (type === "swipe" && lastMessageText === chat[chat.length - 1].mes) { else if (type === "swipe") {
if (isStreamingEnabled()) {
if (streamingProcessor && !streamingProcessor.isFinished) {
await delay(100); await delay(100);
} }
else {
break;
}
}
else {
if (lastMessageText === chat[chat.length - 1].mes) {
await delay(100);
}
else {
break;
}
}
}
else if (type === "impersonate") {
if (isStreamingEnabled()) {
if (streamingProcessor && !streamingProcessor.isFinished) {
await delay(100);
}
else {
break;
}
}
else {
if (!$("#send_textarea").val() || $("#send_textarea").val() == userInput) {
await delay(100);
}
else {
break;
}
}
}
else { else {
messagesBefore++; messagesBefore++;
break; break;
@ -376,6 +414,7 @@ async function generateGroupWrapper(by_auto_mode, type = null) {
} }
} finally { } finally {
is_group_generating = false; is_group_generating = false;
$("#send_textarea").attr("disabled", false);
setSendButtonState(false); setSendButtonState(false);
setCharacterId(undefined); setCharacterId(undefined);
setCharacterName(''); setCharacterName('');
@ -383,6 +422,15 @@ async function generateGroupWrapper(by_auto_mode, type = null) {
} }
} }
function activateImpersonate(members) {
const randomIndex = Math.floor(Math.random() * members.length);
const activatedNames = [members[randomIndex]];
const memberIds = activatedNames
.map((x) => characters.findIndex((y) => y.name === x))
.filter((x) => x !== -1);
return memberIds;
}
function activateSwipe(members) { function activateSwipe(members) {
const name = chat[chat.length - 1].name; const name = chat[chat.length - 1].name;
const activatedNames = members.includes(name) ? [name] : []; const activatedNames = members.includes(name) ? [name] : [];

View File

@ -50,14 +50,12 @@
/* base variable for blur strength slider calculations */ /* base variable for blur strength slider calculations */
--blurStrength: 10; --blurStrength: 10;
color-scheme: only light; color-scheme: only light;
/*styles for the color picker*/ /*styles for the color picker*/
--tool-cool-color-picker-btn-bg: transparent; --tool-cool-color-picker-btn-bg: transparent;
--tool-cool-color-picker-btn-border-color: transparent; --tool-cool-color-picker-btn-border-color: transparent;
} }
* { * {

Binary file not shown.