Compare commits
6 Commits
20a6b02252
...
b6bd8443c5
Author | SHA1 | Date |
---|---|---|
|
b6bd8443c5 | |
|
e59fb85db8 | |
|
b80ca93a1a | |
|
ef59e8abae | |
|
d31e44dec8 | |
|
8e21502843 |
|
@ -1660,16 +1660,24 @@
|
|||
</div>
|
||||
<div class="inline-drawer-content">
|
||||
<label class="checkbox_label flexWrap alignItemsCenter" for="character_names_none">
|
||||
<input type="radio" id="character_names_none" name="character_names" value="0">
|
||||
<input type="radio" id="character_names_none" name="character_names" value="-1">
|
||||
<span data-i18n="None">None</span>
|
||||
<i class="right_menu_button fa-solid fa-circle-exclamation" title="Except for groups and past personas. Otherwise, make sure you provide names in the prompt." data-i18n="[title]character_names_none"></i>
|
||||
<small class="flexBasis100p" data-i18n="Don't add character names.">
|
||||
Don't add character names.
|
||||
<i class="right_menu_button fa-solid fa-circle-exclamation" title="Never add character name prefixes. May behave poorly in groups, choose with caution." data-i18n="[title]character_names_none"></i>
|
||||
<small class="flexBasis100p" data-i18n="Never add character names.">
|
||||
Never add character names.
|
||||
</small>
|
||||
</label>
|
||||
<label class="checkbox_label flexWrap alignItemsCenter" for="character_names_default">
|
||||
<input type="radio" id="character_names_default" name="character_names" value="0">
|
||||
<span data-i18n="Default">Default</span>
|
||||
<i class="right_menu_button fa-solid fa-circle-exclamation" title="Add prefixes for groups and past personas. Otherwise, make sure you provide names in the prompt." data-i18n="[title]character_names_default"></i>
|
||||
<small class="flexBasis100p" data-i18n="Don't add character names unless necessary.">
|
||||
Don't add character names unless necessary.
|
||||
</small>
|
||||
</label>
|
||||
<label class="checkbox_label flexWrap alignItemsCenter" for="character_names_completion">
|
||||
<input type="radio" id="character_names_completion" name="character_names" value="1">
|
||||
<span data-i18n="Completion">Completion Object</span>
|
||||
<span data-i18n="Completion Object">Completion Object</span>
|
||||
<i class="right_menu_button fa-solid fa-circle-exclamation" title="Restrictions apply: only Latin alphanumerics and underscores. Doesn't work for all sources, notably: Claude, MistralAI, Google." data-i18n="[title]character_names_completion"></i>
|
||||
<small class="flexBasis100p" data-i18n="Add character names to completion objects.">
|
||||
Add character names to completion objects.
|
||||
|
@ -1816,9 +1824,9 @@
|
|||
<div data-newbie-hidden class="range-block" data-source="claude">
|
||||
<div class="wide100p">
|
||||
<span id="claude_assistant_prefill_text" data-i18n="Assistant Prefill">Assistant Prefill</span>
|
||||
<textarea id="claude_assistant_prefill" class="text_pole textarea_compact" name="assistant_prefill autoSetHeight" rows="3" maxlength="10000" data-i18n="[placeholder]Start Claude's answer with..." placeholder="Start Claude's answer with..."></textarea>
|
||||
<textarea id="claude_assistant_prefill" class="text_pole textarea_compact autoSetHeight" name="assistant_prefill" rows="3" maxlength="10000" data-i18n="[placeholder]Start Claude's answer with..." placeholder="Start Claude's answer with..."></textarea>
|
||||
<span id="claude_assistant_impersonation_text" data-i18n="Assistant Impersonation Prefill">Assistant Impersonation Prefill</span>
|
||||
<textarea id="claude_assistant_impersonation" class="text_pole textarea_compact" name="assistant_impersonation autoSetHeight" rows="3" maxlength="10000" data-i18n="[placeholder]Start Claude's answer with..." placeholder="Start Claude's answer with..."></textarea>
|
||||
<textarea id="claude_assistant_impersonation" class="text_pole textarea_compact autoSetHeight" name="assistant_impersonation" rows="3" maxlength="10000" data-i18n="[placeholder]Start Claude's answer with..." placeholder="Start Claude's answer with..."></textarea>
|
||||
</div>
|
||||
<label for="claude_use_sysprompt" class="checkbox_label widthFreeExpand">
|
||||
<input id="claude_use_sysprompt" type="checkbox" />
|
||||
|
|
|
@ -216,7 +216,7 @@
|
|||
"Character Names Behavior": "سلوك أسماء الشخصيات",
|
||||
"Helps the model to associate messages with characters.": "يساعد النموذج على ربط الرسائل بالأحرف.",
|
||||
"None": "لا شيء",
|
||||
"character_names_none": "باستثناء المجموعات والشخصيات السابقة. بخلاف ذلك، تأكد من تقديم الأسماء في المطالبة.",
|
||||
"character_names_default": "باستثناء المجموعات والشخصيات السابقة. بخلاف ذلك، تأكد من تقديم الأسماء في المطالبة.",
|
||||
"Don't add character names.": "لا تضيف أسماء الشخصيات.",
|
||||
"Completion": "كائن الإكمال",
|
||||
"character_names_completion": "تنطبق القيود: فقط الحروف الأبجدية اللاتينية والأرقام والشرطات السفلية. لا يعمل مع جميع المصادر، ولا سيما: Claude وMistralAI وGoogle.",
|
||||
|
|
|
@ -216,7 +216,7 @@
|
|||
"Character Names Behavior": "Charakternamen Verhalten",
|
||||
"Helps the model to associate messages with characters.": "Hilft dem Modell, Nachrichten mit Zeichen zu verknüpfen.",
|
||||
"None": "Keins",
|
||||
"character_names_none": "Außer für Gruppen und frühere Personas. Andernfalls stellen Sie sicher, dass Sie in der Eingabeaufforderung Namen angeben.",
|
||||
"character_names_default": "Außer für Gruppen und frühere Personas. Andernfalls stellen Sie sicher, dass Sie in der Eingabeaufforderung Namen angeben.",
|
||||
"Don't add character names.": "Fügen Sie keine Charakternamen hinzu.",
|
||||
"Completion": "Vervollständigungsobjekt",
|
||||
"character_names_completion": "Es gelten Einschränkungen: nur lateinische alphanumerische Zeichen und Unterstriche. Funktioniert nicht für alle Quellen, insbesondere: Claude, MistralAI, Google.",
|
||||
|
|
|
@ -216,7 +216,7 @@
|
|||
"Character Names Behavior": "Comportamiento de los nombres de personajes",
|
||||
"Helps the model to associate messages with characters.": "Ayuda al modelo a asociar mensajes con personajes.",
|
||||
"None": "Ninguno",
|
||||
"character_names_none": "Excepto grupos y personas pasadas. De lo contrario, asegúrese de proporcionar nombres en el mensaje.",
|
||||
"character_names_default": "Excepto grupos y personas pasadas. De lo contrario, asegúrese de proporcionar nombres en el mensaje.",
|
||||
"Don't add character names.": "No agregues nombres de personajes.",
|
||||
"Completion": "Objeto de finalización",
|
||||
"character_names_completion": "Aplican restricciones: solo caracteres alfanuméricos latinos y guiones bajos. No funciona para todas las fuentes, en particular: Claude, MistralAI, Google.",
|
||||
|
|
|
@ -216,7 +216,7 @@
|
|||
"Character Names Behavior": "Comportement des noms de personnages",
|
||||
"Helps the model to associate messages with characters.": "Aide le modèle à associer des messages à des personnages.",
|
||||
"None": "Aucun",
|
||||
"character_names_none": "Sauf pour les groupes et les personnages passés. Sinon, assurez-vous de fournir des noms dans l'invite.",
|
||||
"character_names_default": "Sauf pour les groupes et les personnages passés. Sinon, assurez-vous de fournir des noms dans l'invite.",
|
||||
"Don't add character names.": "N'ajoutez pas de noms de personnages.",
|
||||
"Completion": "Objet d'achèvement",
|
||||
"character_names_completion": "Des restrictions s'appliquent : uniquement les caractères alphanumériques latins et les traits de soulignement. Ne fonctionne pas pour toutes les sources, notamment : Claude, MistralAI, Google.",
|
||||
|
|
|
@ -216,7 +216,7 @@
|
|||
"Character Names Behavior": "Hegðun persónunafna",
|
||||
"Helps the model to associate messages with characters.": "Hjálpar líkaninu að tengja skilaboð við stafi.",
|
||||
"None": "Enginn",
|
||||
"character_names_none": "Nema hópar og fyrri persónur. Annars, vertu viss um að gefa upp nöfn í hvetjunni.",
|
||||
"character_names_default": "Nema hópar og fyrri persónur. Annars, vertu viss um að gefa upp nöfn í hvetjunni.",
|
||||
"Don't add character names.": "Ekki bæta við persónunöfnum.",
|
||||
"Completion": "Lokunarhlutur",
|
||||
"character_names_completion": "Takmarkanir gilda: aðeins latneskar tölustafir og undirstrik. Virkar ekki fyrir allar heimildir, sérstaklega: Claude, MistralAI, Google.",
|
||||
|
|
|
@ -216,7 +216,7 @@
|
|||
"Character Names Behavior": "Comportamento dei nomi dei personaggi",
|
||||
"Helps the model to associate messages with characters.": "Aiuta il modello ad associare i messaggi ai personaggi.",
|
||||
"None": "Nessuno",
|
||||
"character_names_none": "Fatta eccezione per i gruppi e i personaggi passati. Altrimenti, assicurati di fornire i nomi nel prompt.",
|
||||
"character_names_default": "Fatta eccezione per i gruppi e i personaggi passati. Altrimenti, assicurati di fornire i nomi nel prompt.",
|
||||
"Don't add character names.": "Non aggiungere nomi di personaggi.",
|
||||
"Completion": "Oggetto di completamento",
|
||||
"character_names_completion": "Si applicano restrizioni: solo caratteri alfanumerici latini e trattini bassi. Non funziona con tutte le fonti, in particolare: Claude, MistralAI, Google.",
|
||||
|
|
|
@ -216,7 +216,7 @@
|
|||
"Character Names Behavior": "キャラクター名の動作",
|
||||
"Helps the model to associate messages with characters.": "モデルがメッセージをキャラクターに関連付けるのに役立ちます。",
|
||||
"None": "なし",
|
||||
"character_names_none": "グループと過去のペルソナを除きます。それ以外の場合は、プロンプトに名前を必ず入力してください。",
|
||||
"character_names_default": "グループと過去のペルソナを除きます。それ以外の場合は、プロンプトに名前を必ず入力してください。",
|
||||
"Don't add character names.": "キャラクター名を追加しないでください。",
|
||||
"Completion": "完了オブジェクト",
|
||||
"character_names_completion": "制限事項: ラテン英数字とアンダースコアのみ。すべてのソースで機能するわけではありません。特に、Claude、MistralAI、Google では機能しません。",
|
||||
|
|
|
@ -216,7 +216,7 @@
|
|||
"Character Names Behavior": "캐릭터 이름 행동",
|
||||
"Helps the model to associate messages with characters.": "모델이 메시지를 캐릭터와 연관시키는 데 도움이 됩니다.",
|
||||
"None": "없음",
|
||||
"character_names_none": "그룹 및 과거 페르소나는 제외됩니다. 그렇지 않으면 프롬프트에 이름을 제공해야 합니다.",
|
||||
"character_names_default": "그룹 및 과거 페르소나는 제외됩니다. 그렇지 않으면 프롬프트에 이름을 제공해야 합니다.",
|
||||
"Don't add character names.": "캐릭터 이름을 추가하지 마세요.",
|
||||
"Completion": "완료 객체",
|
||||
"character_names_completion": "제한 사항이 적용됩니다. 라틴 영숫자 및 밑줄만 사용할 수 있습니다. 모든 소스, 특히 Claude, MistralAI, Google에서 작동하지 않습니다.",
|
||||
|
|
|
@ -216,7 +216,7 @@
|
|||
"Character Names Behavior": "Karakternamen Gedrag",
|
||||
"Helps the model to associate messages with characters.": "Helpt het model berichten aan karakters te koppelen.",
|
||||
"None": "Geen",
|
||||
"character_names_none": "Behalve voor groepen en vroegere persona's. Zorg er anders voor dat u namen opgeeft in de prompt.",
|
||||
"character_names_default": "Behalve voor groepen en vroegere persona's. Zorg er anders voor dat u namen opgeeft in de prompt.",
|
||||
"Don't add character names.": "Voeg geen namen van personages toe.",
|
||||
"Completion": "Voltooiingsobject",
|
||||
"character_names_completion": "Er zijn beperkingen van toepassing: alleen Latijnse alfanumerieke tekens en onderstrepingstekens. Werkt niet voor alle bronnen, met name: Claude, MistralAI, Google.",
|
||||
|
|
|
@ -216,7 +216,7 @@
|
|||
"Character Names Behavior": "Comportamento dos nomes dos personagens",
|
||||
"Helps the model to associate messages with characters.": "Ajuda o modelo a associar mensagens a personagens.",
|
||||
"None": "Nenhum",
|
||||
"character_names_none": "Exceto para grupos e personas passadas. Caso contrário, certifique-se de fornecer nomes no prompt.",
|
||||
"character_names_default": "Exceto para grupos e personas passadas. Caso contrário, certifique-se de fornecer nomes no prompt.",
|
||||
"Don't add character names.": "Não adicione nomes de personagens.",
|
||||
"Completion": "Objeto de conclusão",
|
||||
"character_names_completion": "Aplicam-se restrições: apenas alfanuméricos latinos e sublinhados. Não funciona para todas as fontes, nomeadamente: Claude, MistralAI, Google.",
|
||||
|
|
|
@ -1246,7 +1246,7 @@
|
|||
"Top P & Min P": "Top P & Min P",
|
||||
"llama.cpp only. Determines the order of samplers. If Mirostat mode is not 0, sampler order is ignored.": "llama.cpp only. Determines the order of samplers. If Mirostat mode is not 0, sampler order is ignored.",
|
||||
"Helps the model to associate messages with characters.": "Помогает модели связывать сообщения с персонажами.",
|
||||
"character_names_none": "Except for groups and past personas. Otherwise, make sure you provide names in the prompt.",
|
||||
"character_names_default": "Except for groups and past personas. Otherwise, make sure you provide names in the prompt.",
|
||||
"Completion": "Completion Object",
|
||||
"character_names_completion": "Только латинские буквы, цифры и знак подчёркивания. Работает не для всех бэкендов, в частности для Claude, MistralAI, Google.",
|
||||
"Use AI21 Tokenizer": "Использовать токенайзер AI21",
|
||||
|
@ -1662,4 +1662,4 @@
|
|||
"ext_regex_sts_desc": "Сообщения, отправленные с помощью команд STscript",
|
||||
"ext_regex_wi_desc": "Содержимое лорбуков и миров. Для работы требует включения флажка \"Только промпт\"!",
|
||||
"ext_regex_only_format_display_desc": "История чата не изменится, замена будет осуществляться только в отображаемом сообщении (в UI)"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -216,7 +216,7 @@
|
|||
"Character Names Behavior": "Поведінка імен персонажів",
|
||||
"Helps the model to associate messages with characters.": "Допомагає моделі пов’язувати повідомлення з символами.",
|
||||
"None": "Немає",
|
||||
"character_names_none": "За винятком груп і минулих персонажів. В іншому випадку переконайтеся, що ви вказали імена в підказці.",
|
||||
"character_names_default": "За винятком груп і минулих персонажів. В іншому випадку переконайтеся, що ви вказали імена в підказці.",
|
||||
"Don't add character names.": "Не додавайте імена персонажів.",
|
||||
"Completion": "Об'єкт завершення",
|
||||
"character_names_completion": "Застосовуються обмеження: лише латинські букви та цифри підкреслення. Працює не для всіх джерел, зокрема: Claude, MistralAI, Google.",
|
||||
|
|
|
@ -216,7 +216,7 @@
|
|||
"Character Names Behavior": "Tên nhân vật Hành vi",
|
||||
"Helps the model to associate messages with characters.": "Giúp mô hình liên kết tin nhắn với các ký tự.",
|
||||
"None": "Không",
|
||||
"character_names_none": "Ngoại trừ các nhóm và cá tính trong quá khứ. Nếu không, hãy đảm bảo bạn cung cấp tên trong lời nhắc.",
|
||||
"character_names_default": "Ngoại trừ các nhóm và cá tính trong quá khứ. Nếu không, hãy đảm bảo bạn cung cấp tên trong lời nhắc.",
|
||||
"Don't add character names.": "Không thêm tên nhân vật.",
|
||||
"Completion": "Đối tượng hoàn thành",
|
||||
"character_names_completion": "Áp dụng hạn chế: chỉ chữ và số Latinh và dấu gạch dưới. Không hoạt động với tất cả các nguồn, đặc biệt là: Claude, MistralAI, Google.",
|
||||
|
|
|
@ -217,7 +217,7 @@
|
|||
"Character Names Behavior": "角色名称行为",
|
||||
"Helps the model to associate messages with characters.": "有助于模型将消息与角色关联起来。",
|
||||
"None": "无",
|
||||
"character_names_none": "群聊和过去的角色除外。否则,请确保在提示词中提供了姓名。",
|
||||
"character_names_default": "群聊和过去的角色除外。否则,请确保在提示词中提供了姓名。",
|
||||
"Don't add character names.": "不添加角色名称。",
|
||||
"Completion": "补全对象",
|
||||
"character_names_completion": "适用限制:仅限拉丁字母数字和下划线。不适用于所有补全源,尤其是:Claude、MistralAI、Google。",
|
||||
|
|
|
@ -217,7 +217,7 @@
|
|||
"Character Names Behavior": "角色人物名稱行為",
|
||||
"Helps the model to associate messages with characters.": "幫助模型將訊息與角色人物關聯起來。",
|
||||
"None": "無",
|
||||
"character_names_none": "除了團體和過去的玩家角色人物外。否則,請確保在提示中提供名字。",
|
||||
"character_names_default": "除了團體和過去的玩家角色人物外。否則,請確保在提示中提供名字。",
|
||||
"Don't add character names.": "不要新增角色人物名稱",
|
||||
"Completion": "補充",
|
||||
"character_names_completion": "字元限制:僅限拉丁字母數字和底線。不適用於所有來源,特別是:Claude、MistralAI、Google。",
|
||||
|
|
|
@ -411,7 +411,7 @@ async function connectToApi(baseUrl) {
|
|||
}
|
||||
|
||||
const url = new URL(baseUrl);
|
||||
url.pathname = '/api/modules';
|
||||
url.pathname += '/api/modules';
|
||||
|
||||
try {
|
||||
const getExtensionsResult = await doExtrasFetch(url);
|
||||
|
|
|
@ -188,7 +188,8 @@ export const chat_completion_sources = {
|
|||
};
|
||||
|
||||
const character_names_behavior = {
|
||||
NONE: 0,
|
||||
NONE: -1,
|
||||
DEFAULT: 0,
|
||||
COMPLETION: 1,
|
||||
CONTENT: 2,
|
||||
};
|
||||
|
@ -300,7 +301,7 @@ const default_settings = {
|
|||
bypass_status_check: false,
|
||||
continue_prefill: false,
|
||||
function_calling: false,
|
||||
names_behavior: character_names_behavior.NONE,
|
||||
names_behavior: character_names_behavior.DEFAULT,
|
||||
continue_postfix: continue_postfix_types.SPACE,
|
||||
custom_prompt_post_processing: custom_prompt_post_processing_types.NONE,
|
||||
seed: -1,
|
||||
|
@ -380,7 +381,7 @@ const oai_settings = {
|
|||
bypass_status_check: false,
|
||||
continue_prefill: false,
|
||||
function_calling: false,
|
||||
names_behavior: character_names_behavior.NONE,
|
||||
names_behavior: character_names_behavior.DEFAULT,
|
||||
continue_postfix: continue_postfix_types.SPACE,
|
||||
custom_prompt_post_processing: custom_prompt_post_processing_types.NONE,
|
||||
seed: -1,
|
||||
|
@ -554,6 +555,8 @@ function setOpenAIMessages(chat) {
|
|||
// for groups or sendas command - prepend a character's name
|
||||
switch (oai_settings.names_behavior) {
|
||||
case character_names_behavior.NONE:
|
||||
break;
|
||||
case character_names_behavior.DEFAULT:
|
||||
if (selected_group || (chat[j].force_avatar && chat[j].name !== name1 && chat[j].extra?.type !== system_message_types.NARRATOR)) {
|
||||
content = `${chat[j].name}: ${content}`;
|
||||
}
|
||||
|
@ -563,8 +566,9 @@ function setOpenAIMessages(chat) {
|
|||
content = `${chat[j].name}: ${content}`;
|
||||
}
|
||||
break;
|
||||
case character_names_behavior.COMPLETION:
|
||||
break;
|
||||
default:
|
||||
// No action for character_names_behavior.COMPLETION
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -3189,6 +3193,9 @@ function setNamesBehaviorControls() {
|
|||
case character_names_behavior.NONE:
|
||||
$('#character_names_none').prop('checked', true);
|
||||
break;
|
||||
case character_names_behavior.DEFAULT:
|
||||
$('#character_names_default').prop('checked', true);
|
||||
break;
|
||||
case character_names_behavior.COMPLETION:
|
||||
$('#character_names_completion').prop('checked', true);
|
||||
break;
|
||||
|
@ -5184,6 +5191,12 @@ $(document).ready(async function () {
|
|||
saveSettingsDebounced();
|
||||
});
|
||||
|
||||
$('#character_names_default').on('input', function () {
|
||||
oai_settings.names_behavior = character_names_behavior.DEFAULT;
|
||||
setNamesBehaviorControls();
|
||||
saveSettingsDebounced();
|
||||
});
|
||||
|
||||
$('#character_names_completion').on('input', function () {
|
||||
oai_settings.names_behavior = character_names_behavior.COMPLETION;
|
||||
setNamesBehaviorControls();
|
||||
|
|
|
@ -483,7 +483,7 @@ async function sendMistralAIRequest(request, response) {
|
|||
}
|
||||
|
||||
try {
|
||||
const messages = convertMistralMessages(request.body.messages, request.body.model, request.body.char_name, request.body.user_name);
|
||||
const messages = convertMistralMessages(request.body.messages, request.body.char_name, request.body.user_name);
|
||||
const controller = new AbortController();
|
||||
request.socket.removeAllListeners('close');
|
||||
request.socket.on('close', function () {
|
||||
|
|
|
@ -364,65 +364,49 @@ function convertGooglePrompt(messages, model, useSysPrompt = false, charName = '
|
|||
/**
|
||||
* Convert a prompt from the ChatML objects to the format used by MistralAI.
|
||||
* @param {object[]} messages Array of messages
|
||||
* @param {string} model Model name
|
||||
* @param {string} charName Character name
|
||||
* @param {string} userName User name
|
||||
*/
|
||||
function convertMistralMessages(messages, model, charName = '', userName = '') {
|
||||
function convertMistralMessages(messages, charName = '', userName = '') {
|
||||
if (!Array.isArray(messages)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
//large seems to be throwing a 500 error if we don't make the first message a user role, most likely a bug since the other models won't do this
|
||||
if (model.includes('large')) {
|
||||
messages[0].role = 'user';
|
||||
}
|
||||
|
||||
//must send a user role as last message
|
||||
// Make the last assistant message a prefill
|
||||
const lastMsg = messages[messages.length - 1];
|
||||
if (messages.length > 0 && lastMsg && (lastMsg.role === 'system' || lastMsg.role === 'assistant')) {
|
||||
if (lastMsg.role === 'assistant' && lastMsg.name) {
|
||||
lastMsg.content = lastMsg.name + ': ' + lastMsg.content;
|
||||
} else if (lastMsg.role === 'system') {
|
||||
lastMsg.content = '[INST] ' + lastMsg.content + ' [/INST]';
|
||||
}
|
||||
lastMsg.role = 'user';
|
||||
if (messages.length > 0 && lastMsg && (lastMsg.role === 'assistant')) {
|
||||
lastMsg.prefix = true;
|
||||
}
|
||||
|
||||
//system prompts can be stacked at the start, but any futher sys prompts after the first user/assistant message will break the model
|
||||
let encounteredNonSystemMessage = false;
|
||||
// Doesn't support completion names, so prepend if not already done by the frontend (e.g. for group chats).
|
||||
messages.forEach(msg => {
|
||||
if (msg.role === 'system' && msg.name === 'example_assistant') {
|
||||
if (charName) {
|
||||
if (charName && !msg.content.startsWith(`${charName}: `)) {
|
||||
msg.content = `${charName}: ${msg.content}`;
|
||||
}
|
||||
delete msg.name;
|
||||
}
|
||||
|
||||
if (msg.role === 'system' && msg.name === 'example_user') {
|
||||
if (userName) {
|
||||
if (userName && !msg.content.startsWith(`${userName}: `)) {
|
||||
msg.content = `${userName}: ${msg.content}`;
|
||||
}
|
||||
delete msg.name;
|
||||
}
|
||||
|
||||
if (msg.name) {
|
||||
if (msg.name && msg.role !== 'system' && !msg.content.startsWith(`${msg.name}: `)) {
|
||||
msg.content = `${msg.name}: ${msg.content}`;
|
||||
delete msg.name;
|
||||
}
|
||||
|
||||
if ((msg.role === 'user' || msg.role === 'assistant') && !encounteredNonSystemMessage) {
|
||||
encounteredNonSystemMessage = true;
|
||||
}
|
||||
|
||||
if (encounteredNonSystemMessage && msg.role === 'system') {
|
||||
msg.role = 'user';
|
||||
//unsure if the instruct version is what they've deployed on their endpoints and if this will make a difference or not.
|
||||
//it should be better than just sending the message as a user role without context though
|
||||
msg.content = '[INST] ' + msg.content + ' [/INST]';
|
||||
}
|
||||
});
|
||||
|
||||
// If system role message immediately follows an assistant message, change its role to user
|
||||
for (let i = 0; i < messages.length - 1; i++) {
|
||||
if (messages[i].role === 'assistant' && messages[i + 1].role === 'system') {
|
||||
messages[i + 1].role = 'user';
|
||||
}
|
||||
}
|
||||
|
||||
return messages;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue