mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Fix impersonate and swipes in group chats with streaming and not.
This commit is contained in:
@ -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,
|
||||||
@ -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;
|
||||||
}
|
}
|
||||||
@ -2279,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() {
|
||||||
|
@ -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,8 +366,41 @@ 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") {
|
||||||
await delay(100);
|
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 {
|
else {
|
||||||
messagesBefore++;
|
messagesBefore++;
|
||||||
@ -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] : [];
|
||||||
|
Reference in New Issue
Block a user