mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Fix sticky bias
This commit is contained in:
@@ -1990,7 +1990,7 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
|
|||||||
|
|
||||||
deactivateSendButtons();
|
deactivateSendButtons();
|
||||||
|
|
||||||
let { messageBias, promptBias } = getBiasStrings(textareaText);
|
let { messageBias, promptBias } = getBiasStrings(textareaText, type);
|
||||||
|
|
||||||
//*********************************
|
//*********************************
|
||||||
//PRE FORMATING STRING
|
//PRE FORMATING STRING
|
||||||
@@ -2699,17 +2699,23 @@ function getNextMessageId(type) {
|
|||||||
return type == 'swipe' ? Number(count_view_mes - 1) : Number(count_view_mes);
|
return type == 'swipe' ? Number(count_view_mes - 1) : Number(count_view_mes);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getBiasStrings(textareaText) {
|
export function getBiasStrings(textareaText, type) {
|
||||||
let promptBias = '';
|
let promptBias = '';
|
||||||
let messageBias = extractMessageBias(textareaText);
|
let messageBias = extractMessageBias(textareaText);
|
||||||
|
|
||||||
// gets bias of the latest message where it was applied
|
// If user input is not provided, retrieve the bias of the most recent relevant message
|
||||||
for (let mes of chat.slice().reverse()) {
|
if (!textareaText) {
|
||||||
if (mes && mes.extra && (mes.is_user || mes.is_system || mes.extra.type === system_message_types.NARRATOR)) {
|
for (let i = chat.length - 1; i >= 0; i--) {
|
||||||
if (mes.extra.bias && mes.extra.bias.trim().length > 0) {
|
const mes = chat[i];
|
||||||
promptBias = mes.extra.bias;
|
if (type === 'swipe' && chat.length - 1 === i) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (mes && (mes.is_user || mes.is_system || mes.extra.type === system_message_types.NARRATOR)) {
|
||||||
|
if (mes.extra?.bias?.trim()?.length > 0) {
|
||||||
|
promptBias = mes.extra.bias;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -524,7 +524,7 @@ async function generateGroupWrapper(by_auto_mode, type = null, params = {}) {
|
|||||||
toastr.warning('All group members are disabled. Enable at least one to get a reply.');
|
toastr.warning('All group members are disabled. Enable at least one to get a reply.');
|
||||||
|
|
||||||
// Send user message as is
|
// Send user message as is
|
||||||
const bias = getBiasStrings(userInput);
|
const bias = getBiasStrings(userInput, type);
|
||||||
await sendMessageAsUser(userInput, bias.messageBias);
|
await sendMessageAsUser(userInput, bias.messageBias);
|
||||||
await saveChatConditional();
|
await saveChatConditional();
|
||||||
$('#send_textarea').val('').trigger('input');
|
$('#send_textarea').val('').trigger('input');
|
||||||
|
Reference in New Issue
Block a user