mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Don't replace well-know substitution marcos with bias. Support macros in sys and sendas messages.
This commit is contained in:
@@ -1467,13 +1467,20 @@ export function extractMessageBias(message) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const forbiddenMatches = ['user', 'char', 'time', 'date'];
|
||||||
const found = [];
|
const found = [];
|
||||||
const rxp = /{{(\*?.+\*?)}}/g;
|
const rxp = /\{\{(.+?)\}\}/g;
|
||||||
//const rxp = /{([^}]+)}/g;
|
//const rxp = /{([^}]+)}/g;
|
||||||
let curMatch;
|
let curMatch;
|
||||||
|
|
||||||
while ((curMatch = rxp.exec(message))) {
|
while ((curMatch = rxp.exec(message))) {
|
||||||
found.push(curMatch[1].trim());
|
const match = curMatch[1].trim();
|
||||||
|
|
||||||
|
if (forbiddenMatches.includes(match)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
found.push(match);
|
||||||
}
|
}
|
||||||
|
|
||||||
let biasString = '';
|
let biasString = '';
|
||||||
@@ -2610,7 +2617,7 @@ export async function sendMessageAsUser(textareaText, messageBias) {
|
|||||||
chat[chat.length - 1]['is_user'] = true;
|
chat[chat.length - 1]['is_user'] = true;
|
||||||
chat[chat.length - 1]['is_name'] = true;
|
chat[chat.length - 1]['is_name'] = true;
|
||||||
chat[chat.length - 1]['send_date'] = humanizedDateTime();
|
chat[chat.length - 1]['send_date'] = humanizedDateTime();
|
||||||
chat[chat.length - 1]['mes'] = textareaText;
|
chat[chat.length - 1]['mes'] = substituteParams(textareaText);
|
||||||
chat[chat.length - 1]['extra'] = {};
|
chat[chat.length - 1]['extra'] = {};
|
||||||
|
|
||||||
if (messageBias) {
|
if (messageBias) {
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import {
|
|||||||
replaceBiasMarkup,
|
replaceBiasMarkup,
|
||||||
saveChatConditional,
|
saveChatConditional,
|
||||||
sendSystemMessage,
|
sendSystemMessage,
|
||||||
|
substituteParams,
|
||||||
system_avatar,
|
system_avatar,
|
||||||
system_message_types
|
system_message_types
|
||||||
} from "../script.js";
|
} from "../script.js";
|
||||||
@@ -143,7 +144,7 @@ async function sendMessageAs(_, text) {
|
|||||||
is_name: true,
|
is_name: true,
|
||||||
is_system: isSystem,
|
is_system: isSystem,
|
||||||
send_date: humanizedDateTime(),
|
send_date: humanizedDateTime(),
|
||||||
mes: mesText,
|
mes: substituteParams(mesText),
|
||||||
force_avatar: force_avatar,
|
force_avatar: force_avatar,
|
||||||
original_avatar: original_avatar,
|
original_avatar: original_avatar,
|
||||||
extra: {
|
extra: {
|
||||||
@@ -174,7 +175,7 @@ async function sendNarratorMessage(_, text) {
|
|||||||
is_name: false,
|
is_name: false,
|
||||||
is_system: isSystem,
|
is_system: isSystem,
|
||||||
send_date: humanizedDateTime(),
|
send_date: humanizedDateTime(),
|
||||||
mes: text.trim(),
|
mes: substituteParams(text.trim()),
|
||||||
force_avatar: system_avatar,
|
force_avatar: system_avatar,
|
||||||
extra: {
|
extra: {
|
||||||
type: system_message_types.NARRATOR,
|
type: system_message_types.NARRATOR,
|
||||||
|
|||||||
Reference in New Issue
Block a user