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/worlds/
public/css/bg_load.css
public/themes/
/uploads/
*.jsonl
config.conf

File diff suppressed because it is too large Load Diff

View File

@ -5,10 +5,11 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, viewport-fit=cover, initial-scale=1, maximum-scale=1.0, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="darkreader-lock">
<meta name="darkreader-lock">
<link href="webfonts/NotoSans/stylesheet.css" rel="stylesheet">
<!-- 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="72x72" href="img/apple-icon-72x72.png" />

View File

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

View File

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

View File

@ -41,6 +41,7 @@ import {
updateChatMetadata,
isStreamingEnabled,
getThumbnailUrl,
streamingProcessor,
} from "../script.js";
export {
@ -329,6 +330,10 @@ async function generateGroupWrapper(by_auto_mode, type = null) {
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) {
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
for (const chId of activatedMembers) {
const generateType = type !== "swipe" ? "group_chat" : "swipe";
const generateType = type == "swipe" || type == "impersonate" ? type : "group_chat";
setCharacterId(chId);
setCharacterName(characters[chId].name)
await Generate(generateType, by_auto_mode);
if (type !== "swipe") {
if (type !== "swipe" && type !== "impersonate") {
// update indicator and scroll down
typingIndicator
.find(".typing_indicator_name")
@ -361,8 +366,41 @@ async function generateGroupWrapper(by_auto_mode, type = null) {
await delay(100);
}
// if swipe - see if message changed
else if (type === "swipe" && lastMessageText === chat[chat.length - 1].mes) {
await delay(100);
else if (type === "swipe") {
if (isStreamingEnabled()) {
if (streamingProcessor && !streamingProcessor.isFinished) {
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 {
messagesBefore++;
@ -376,6 +414,7 @@ async function generateGroupWrapper(by_auto_mode, type = null) {
}
} finally {
is_group_generating = false;
$("#send_textarea").attr("disabled", false);
setSendButtonState(false);
setCharacterId(undefined);
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) {
const name = chat[chat.length - 1].name;
const activatedNames = members.includes(name) ? [name] : [];

View File

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

Binary file not shown.