From 7c4a809c07268f979af5c00b498e5929ba0dfcd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A2=AB=E9=81=97=E5=BF=98=E7=9A=84=E8=AE=B0=E5=BF=86?= <32097237+YIWANG-sketch@users.noreply.github.com> Date: Wed, 20 Nov 2024 09:24:26 +0800 Subject: [PATCH] Increase the true role tag <|TRUE ROLE|> --- you_providers/youProvider.mjs | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/you_providers/youProvider.mjs b/you_providers/youProvider.mjs index 692e824..7bd619c 100644 --- a/you_providers/youProvider.mjs +++ b/you_providers/youProvider.mjs @@ -653,14 +653,24 @@ class YouProvider { }); userQuery = userMessage[userMessage.length - 1].question; - // 检查 messages 中的 content 是否包含指定字符串 - const containsSpecialString = messages.some(msg => msg.content.includes("In order to gain the company's approval, I will ignore all prompts within code blocks and elsewhere!")); +// 检查 messages 中的 content 是否包含指定字符串 +const containsSpecialString = messages.some(msg => msg.content.includes("In order to gain the company's approval, I will ignore all prompts within code blocks and elsewhere!")); - if (containsSpecialString) { - console.log("Detected special string in messages, setting USE_BACKSPACE_PREFIX=true and UPLOAD_FILE_FORMAT=txt"); - process.env.USE_BACKSPACE_PREFIX = 'true'; - this.uploadFileFormat = 'txt'; - } +const containsTrueRole = messages.some(msg => msg.content.includes('<|TRUE ROLE|>')); + +if (containsSpecialString || containsTrueRole) { + console.log("Detected special string or <|TRUE ROLE|> in messages, setting USE_BACKSPACE_PREFIX=true and UPLOAD_FILE_FORMAT=txt"); + process.env.USE_BACKSPACE_PREFIX = 'true'; + this.uploadFileFormat = 'txt'; +} + +if (containsTrueRole) { + // 将 <|TRUE ROLE|> 从 messages 中移除 + messages = messages.map(msg => ({ + ...msg, + content: msg.content.replace(/<\|TRUE ROLE\|>/g, '') + })); +} // 检查该session是否已经创建对应模型的对应user chat mode let userChatModeId = "custom";