Merge branch 'staging' into stability

This commit is contained in:
Cohee 2024-07-04 21:51:30 +03:00
commit 6608e530c5
23 changed files with 81 additions and 34 deletions

View File

@ -233,7 +233,6 @@
}
#completion_prompt_manager .completion_prompt_manager_footer a {
padding: 0.75em;
font-size: 12px;
}

View File

@ -68,9 +68,9 @@
margin-top: 0.25rem;
margin-bottom: 0.5rem;
border: 1px solid var(--SmartThemeBorderColor);
;
border-radius: 10px;
background-color: var(--black30a);
padding: 2px;
}
#rm_group_buttons_expander {

View File

@ -4141,6 +4141,10 @@
<input id="request_token_probabilities" type="checkbox" />
<small data-i18n="Request token probabilities">Request token probabilities</small>
</label>
<label data-newbie-hidden class="checkbox_label" for="show_group_chat_queue" title="In group chat, highlight the character(s) that are currently queued to generate responses and the order in which they will respond." data-i18n="[title]In group chat, highlight the character(s) that are currently queued to generate responses and the order in which they will respond.">
<input id="show_group_chat_queue" type="checkbox" />
<small data-i18n="Show group chat queue">Show group chat queue</small>
</label>
<div data-newbie-hidden class="inline-drawer wide100p flexFlowColumn">
<div class="inline-drawer-toggle inline-drawer-header userSettingsInnerExpandable" title="Automatically reject and re-generate AI message based on configurable criteria." data-i18n="[title]Automatically reject and re-generate AI message based on configurable criteria">
<b><span data-i18n="Auto-swipe">Auto-swipe</span></b>
@ -5596,10 +5600,10 @@
<label for="completion_prompt_manager_popup_entry_form_injection_position">
<span data-i18n="prompt_manager_position">Position</span>
</label>
<div class="text_muted" data-i18n="Injection position. Next to other prompts (relative) or in-chat (absolute).">Injection position. Next to other prompts (relative) or in-chat (absolute).</div>
<div class="text_muted" data-i18n="Injection position. Relative (to other prompts in prompt manager) or In-chat @ Depth.">Injection position. Relative (to other prompts in prompt manager) or In-chat @ Depth.</div>
<select id="completion_prompt_manager_popup_entry_form_injection_position" class="text_pole" name="injection_position">
<option data-i18n="prompt_manager_relative" value="0">Relative</option>
<option data-i18n="prompt_manager_absolute" value="1">Absolute</option>
<option data-i18n="prompt_manager_in_chat" value="1">In-chat</option>
</select>
</div>
<div id="completion_prompt_manager_depth_block" class="completion_prompt_manager_popup_entry_form_control flex1">
@ -5796,6 +5800,7 @@
<div class="tags tags_inline"></div>
</div>
<input class="ch_fav" value="" hidden />
<div class="queue_position"></div>
<div class="group_member_icon">
<div title="Temporarily disable automatic replies from this character" data-action="disable" class="right_menu_button fa-solid fa-lg fa-comment-slash" data-i18n="[title]Temporarily disable automatic replies from this character"></div>
<div title="Enable automatic replies from this character" data-action="enable" class="right_menu_button fa-solid fa-lg fa-comment-slash" data-i18n="[title]Enable automatic replies from this character"></div>

View File

@ -1023,7 +1023,6 @@
"prompt_manager_position": "موضع",
"Injection position. Next to other prompts (relative) or in-chat (absolute).": "موضع الحقن. بجوار المطالبات الأخرى (نسبية) أو داخل الدردشة (مطلقة).",
"prompt_manager_relative": "نسبي",
"prompt_manager_absolute": "مطلق",
"prompt_manager_depth": "عمق",
"Injection depth. 0 = after the last message, 1 = before the last message, etc.": "عمق الحقن. 0 = بعد الرسالة الأخيرة، 1 = قبل الرسالة الأخيرة، الخ.",
"Prompt": "موضوع",

View File

@ -1023,7 +1023,6 @@
"prompt_manager_position": "Position",
"Injection position. Next to other prompts (relative) or in-chat (absolute).": "Injektionsposition. Neben anderen Eingabeaufforderungen (relativ) oder im Chat (absolut).",
"prompt_manager_relative": "Relativ",
"prompt_manager_absolute": "Absolut",
"prompt_manager_depth": "Tiefe",
"Injection depth. 0 = after the last message, 1 = before the last message, etc.": "Injektionstiefe. 0 = nach der letzten Nachricht, 1 = vor der letzten Nachricht usw.",
"Prompt": "Aufforderung",

View File

@ -1023,7 +1023,6 @@
"prompt_manager_position": "Posición",
"Injection position. Next to other prompts (relative) or in-chat (absolute).": "Posición de inyección. Junto a otras indicaciones (relativa) o en el chat (absoluta).",
"prompt_manager_relative": "Relativo",
"prompt_manager_absolute": "Absoluto",
"prompt_manager_depth": "Profundidad",
"Injection depth. 0 = after the last message, 1 = before the last message, etc.": "Profundidad de inyección. 0 = después del último mensaje, 1 = antes del último mensaje, etc.",
"Prompt": "Indicar",

View File

@ -1023,7 +1023,6 @@
"prompt_manager_position": "Position",
"Injection position. Next to other prompts (relative) or in-chat (absolute).": "Position d'injection. À côté dautres invites (relatives) ou dans le chat (absolues).",
"prompt_manager_relative": "Relatif",
"prompt_manager_absolute": "Absolu",
"prompt_manager_depth": "Profondeur",
"Injection depth. 0 = after the last message, 1 = before the last message, etc.": "Profondeur d'injection. 0 = après le dernier message, 1 = avant le dernier message, etc.",
"Prompt": "Inciter",

View File

@ -1023,7 +1023,6 @@
"prompt_manager_position": "Staða",
"Injection position. Next to other prompts (relative) or in-chat (absolute).": "Inndælingarstaða. Við hliðina á öðrum leiðbeiningum (afstætt) eða í spjalli (algert).",
"prompt_manager_relative": "Aðstandandi",
"prompt_manager_absolute": "Algjört",
"prompt_manager_depth": "Dýpt",
"Injection depth. 0 = after the last message, 1 = before the last message, etc.": "Inndælingardýpt. 0 = eftir síðustu skilaboð, 1 = fyrir síðustu skilaboð o.s.frv.",
"Prompt": "Ábending",

View File

@ -1023,7 +1023,6 @@
"prompt_manager_position": "Posizione",
"Injection position. Next to other prompts (relative) or in-chat (absolute).": "Posizione di iniezione. Accanto ad altri suggerimenti (relativo) o in chat (assoluto).",
"prompt_manager_relative": "Parente",
"prompt_manager_absolute": "Assoluto",
"prompt_manager_depth": "Profondità",
"Injection depth. 0 = after the last message, 1 = before the last message, etc.": "Profondità di iniezione. 0 = dopo l'ultimo messaggio, 1 = prima dell'ultimo messaggio, ecc.",
"Prompt": "Prompt",

View File

@ -1023,7 +1023,6 @@
"prompt_manager_position": "位置",
"Injection position. Next to other prompts (relative) or in-chat (absolute).": "挿入位置。他のプロンプトの隣 (相対) またはチャット内 (絶対)。",
"prompt_manager_relative": "相対的",
"prompt_manager_absolute": "絶対",
"prompt_manager_depth": "深さ",
"Injection depth. 0 = after the last message, 1 = before the last message, etc.": "注入の深さ。0 = 最後のメッセージの後、1 = 最後のメッセージの前など。",
"Prompt": "プロンプト",

View File

@ -1023,7 +1023,6 @@
"prompt_manager_position": "위치",
"Injection position. Next to other prompts (relative) or in-chat (absolute).": "주입 위치. 다른 프롬프트 옆(상대적) 또는 채팅 내(절대적).",
"prompt_manager_relative": "상대적인",
"prompt_manager_absolute": "순수한",
"prompt_manager_depth": "깊이",
"Injection depth. 0 = after the last message, 1 = before the last message, etc.": "주입 깊이. 0 = 마지막 메시지 뒤, 1 = 마지막 메시지 앞 등",
"Prompt": "프롬프트",

View File

@ -1023,7 +1023,6 @@
"prompt_manager_position": "Positie",
"Injection position. Next to other prompts (relative) or in-chat (absolute).": "Injectiepositie. Naast andere prompts (relatief) of in-chat (absoluut).",
"prompt_manager_relative": "Familielid",
"prompt_manager_absolute": "Absoluut",
"prompt_manager_depth": "Diepte",
"Injection depth. 0 = after the last message, 1 = before the last message, etc.": "Injectiediepte. 0 = na het laatste bericht, 1 = voor het laatste bericht, etc.",
"Prompt": "Prompt",

View File

@ -1023,7 +1023,6 @@
"prompt_manager_position": "Posição",
"Injection position. Next to other prompts (relative) or in-chat (absolute).": "Posição de injeção. Ao lado de outras solicitações (relativas) ou no chat (absolutas).",
"prompt_manager_relative": "Relativo",
"prompt_manager_absolute": "Absoluto",
"prompt_manager_depth": "Profundidade",
"Injection depth. 0 = after the last message, 1 = before the last message, etc.": "Profundidade de injeção. 0 = após a última mensagem, 1 = antes da última mensagem, etc.",
"Prompt": "Prompt",

View File

@ -1025,7 +1025,6 @@
"prompt_manager_position": "Точка инжекта",
"Injection position. Next to other prompts (relative) or in-chat (absolute).": "Как рассчитывать позицию для инжекта. Она может располагаться по отношению к другим промптам (относительная) либо по отношению к чату (абсолютная).",
"prompt_manager_relative": "Относительная",
"prompt_manager_absolute": "Абсолютная",
"prompt_manager_depth": "Глубина",
"Injection depth. 0 = after the last message, 1 = before the last message, etc.": "Глубина вставки. 0 = после последнего сообщения, 1 = перед последним сообщением, и т.д.",
"The prompt to be sent.": "Отправляемый ИИ промпт.",

View File

@ -1023,7 +1023,6 @@
"prompt_manager_position": "Позиція",
"Injection position. Next to other prompts (relative) or in-chat (absolute).": "Позиція ін'єкції. Поруч з іншими підказками (відносні) або в чаті (абсолютні).",
"prompt_manager_relative": "Відносна",
"prompt_manager_absolute": "Абсолютний",
"prompt_manager_depth": "Глибина",
"Injection depth. 0 = after the last message, 1 = before the last message, etc.": "Глибина ін'єкції. 0 = після останнього повідомлення, 1 = перед останнім повідомленням тощо.",
"Prompt": "Запит",

View File

@ -1023,7 +1023,6 @@
"prompt_manager_position": "Chức vụ",
"Injection position. Next to other prompts (relative) or in-chat (absolute).": "Vị trí tiêm. Bên cạnh các lời nhắc khác (tương đối) hoặc trong trò chuyện (tuyệt đối).",
"prompt_manager_relative": "Liên quan đến",
"prompt_manager_absolute": "tuyệt đối",
"prompt_manager_depth": "Chiều sâu",
"Injection depth. 0 = after the last message, 1 = before the last message, etc.": "Độ sâu phun. 0 = sau tin nhắn cuối cùng, 1 = trước tin nhắn cuối cùng, v.v.",
"Prompt": "Đề xuất",

View File

@ -1056,7 +1056,6 @@
"prompt_manager_position": "位置",
"Injection position. Next to other prompts (relative) or in-chat (absolute).": "注入位置。其他提示词旁边(相对)或在聊天中(绝对)。",
"prompt_manager_relative": "相对",
"prompt_manager_absolute": "绝对",
"prompt_manager_depth": "深度",
"Injection depth. 0 = after the last message, 1 = before the last message, etc.": "注入深度。0 = 在最后一条消息之后1 = 在最后一条消息之前,等等。",
"Prompt": "提示词",

View File

@ -1025,7 +1025,6 @@
"prompt_manager_position": "位置",
"Injection position. Next to other prompts (relative) or in-chat (absolute).": "注入位置。與其他提示詞相鄰(相對位置)或在聊天中(絕對位置)。",
"prompt_manager_relative": "相對位置",
"prompt_manager_absolute": "絕對位置",
"prompt_manager_depth": "深度",
"Injection depth. 0 = after the last message, 1 = before the last message, etc.": "注入深度。0 = 在最後一條訊息之後1 = 在最後一條訊息之前,以此類推。",
"Prompt": "提示詞",

View File

@ -70,6 +70,7 @@ import {
animation_duration,
depth_prompt_role_default,
shouldAutoContinue,
this_chid,
} from '../script.js';
import { printTagList, createTagMapFromList, applyTagsOnCharacterSelect, tag_map, applyTagsOnGroupSelect } from './tags.js';
import { FILTER_TYPES, FilterHelper } from './filters.js';
@ -120,6 +121,8 @@ const DEFAULT_AUTO_MODE_DELAY = 5;
export const groupCandidatesFilter = new FilterHelper(debounce(printGroupCandidates, debounce_timeout.quick));
let autoModeWorker = null;
const saveGroupDebounced = debounce(async (group, reload) => await _save(group, reload), debounce_timeout.relaxed);
/** @type {Map<string, number>} */
let groupChatQueueOrder = new Map();
function setAutoModeWorker() {
clearInterval(autoModeWorker);
@ -855,9 +858,15 @@ async function generateGroupWrapper(by_auto_mode, type = null, params = {}) {
const bias = getBiasStrings(userInput, type);
await sendMessageAsUser(userInput, bias.messageBias);
await saveChatConditional();
$('#send_textarea').val('')[0].dispatchEvent(new Event('input', { bubbles:true }));
$('#send_textarea').val('')[0].dispatchEvent(new Event('input', { bubbles: true }));
}
groupChatQueueOrder = new Map();
if (power_user.show_group_chat_queue) {
for (let i = 0; i < activatedMembers.length; ++i) {
groupChatQueueOrder.set(characters[activatedMembers[i]].avatar, i + 1);
}
}
// now the real generation begins: cycle through every activated character
for (const chId of activatedMembers) {
throwIfAborted();
@ -865,6 +874,9 @@ async function generateGroupWrapper(by_auto_mode, type = null, params = {}) {
const generateType = type == 'swipe' || type == 'impersonate' || type == 'quiet' || type == 'continue' ? type : 'group_chat';
setCharacterId(chId);
setCharacterName(characters[chId].name);
if (power_user.show_group_chat_queue) {
printGroupMembers();
}
await eventSource.emit(event_types.GROUP_MEMBER_DRAFTED, chId);
if (type !== 'swipe' && type !== 'impersonate' && !isStreamingEnabled()) {
@ -885,6 +897,10 @@ async function generateGroupWrapper(by_auto_mode, type = null, params = {}) {
messageChunk = textResult?.messageChunk;
}
}
if (power_user.show_group_chat_queue) {
groupChatQueueOrder.delete(characters[chId].avatar);
groupChatQueueOrder.forEach((value, key, map) => map.set(key, value - 1));
}
}
} finally {
typingIndicator.hide();
@ -892,6 +908,10 @@ async function generateGroupWrapper(by_auto_mode, type = null, params = {}) {
is_group_generating = false;
setSendButtonState(false);
setCharacterId(undefined);
if (power_user.show_group_chat_queue) {
groupChatQueueOrder = new Map();
printGroupMembers();
}
setCharacterName('');
activateSendButtons();
showSwipeButtons();
@ -1006,6 +1026,7 @@ function activateNaturalOrder(members, input, lastMessage, allowSelfResponses, i
}
}
const chattyMembers = [];
// activation by talkativeness (in shuffled order, except banned)
const shuffledMembers = shuffle([...members]);
for (let member of shuffledMembers) {
@ -1016,26 +1037,30 @@ function activateNaturalOrder(members, input, lastMessage, allowSelfResponses, i
}
const rollValue = Math.random();
let talkativeness = Number(character.talkativeness);
talkativeness = Number.isNaN(talkativeness)
const talkativeness = isNaN(character.talkativeness)
? talkativeness_default
: talkativeness;
: Number(character.talkativeness);
if (talkativeness >= rollValue) {
activatedMembers.push(member);
}
if (talkativeness > 0) {
chattyMembers.push(member);
}
}
// pick 1 at random if no one was activated
let retries = 0;
while (activatedMembers.length === 0 && ++retries <= members.length) {
const randomIndex = Math.floor(Math.random() * members.length);
const character = characters.find((x) => x.avatar === members[randomIndex]);
// try to limit the selected random character to those with talkativeness > 0
const randomPool = chattyMembers.length > 0 ? chattyMembers : members;
while (activatedMembers.length === 0 && ++retries <= randomPool.length) {
const randomIndex = Math.floor(Math.random() * randomPool.length);
const character = characters.find((x) => x.avatar === randomPool[randomIndex]);
if (!character) {
continue;
}
activatedMembers.push(members[randomIndex]);
activatedMembers.push(randomPool[randomIndex]);
}
// de-duplicate array of character avatars
@ -1313,6 +1338,14 @@ function getGroupCharacterBlock(character) {
template.attr('chid', characters.indexOf(character));
template.find('.ch_fav').val(isFav);
template.toggleClass('is_fav', isFav);
let queuePosition = groupChatQueueOrder.get(character.avatar);
if (queuePosition) {
template.find('.queue_position').text(queuePosition);
template.toggleClass('is_queued', queuePosition > 1);
template.toggleClass('is_active', queuePosition === 1);
}
template.toggleClass('disabled', isGroupMemberDisabled(character.avatar));
// Display inline tags
@ -1605,6 +1638,7 @@ export async function openGroupById(groupId) {
select_group_chats(groupId);
if (selected_group !== groupId) {
groupChatQueueOrder = new Map();
await clearChat();
cancelTtsPlay();
selected_group = groupId;

View File

@ -437,7 +437,7 @@ export function evaluateMacros(content, env) {
content = replaceInstructMacros(content, env);
content = replaceVariableMacros(content);
content = content.replace(/{{newline}}/gi, '\n');
content = content.replace(/\n*{{trim}}\n*/gi, '');
content = content.replace(/(?:\r?\n)*{{trim}}(?:\r?\n)*/gi, '');
content = content.replace(/{{noop}}/gi, '');
content = content.replace(/{{input}}/gi, () => String($('#send_textarea').val()));

View File

@ -179,6 +179,7 @@ let power_user = {
send_on_enter: send_on_enter_options.AUTO,
console_log_prompts: false,
request_token_probabilities: false,
show_group_chat_queue: false,
render_formulas: false,
allow_name1_display: false,
allow_name2_display: false,
@ -1601,6 +1602,7 @@ function loadPowerUserSettings(settings, data) {
$('#console_log_prompts').prop('checked', power_user.console_log_prompts);
$('#request_token_probabilities').prop('checked', power_user.request_token_probabilities);
$('#show_group_chat_queue').prop('checked', power_user.show_group_chat_queue);
$('#auto_fix_generated_markdown').prop('checked', power_user.auto_fix_generated_markdown);
$('#auto_scroll_chat_to_bottom').prop('checked', power_user.auto_scroll_chat_to_bottom);
$('#bogus_folders').prop('checked', power_user.bogus_folders);
@ -3567,6 +3569,11 @@ $(document).ready(() => {
saveSettingsDebounced();
});
$('#show_group_chat_queue').on('input', function () {
power_user.show_group_chat_queue = !!$(this).prop('checked');
saveSettingsDebounced();
});
$('#auto_scroll_chat_to_bottom').on('input', function () {
power_user.auto_scroll_chat_to_bottom = !!$(this).prop('checked');
saveSettingsDebounced();

View File

@ -2,10 +2,10 @@
<select id="{{prefix}}prompt_manager_footer_append_prompt" class="text_pole" name="append-prompt">
{{{promptsHtml}}}
</select>
<a class="menu_button fa-chain fa-solid" title="Insert prompt" data-i18n="[title]Insert prompt"></a>
<a class="caution menu_button fa-x fa-solid" title="Delete prompt" data-i18n="[title]Delete prompt"></a>
<a class="menu_button fa-file-import fa-solid" id="prompt-manager-import" title="Import a prompt list" data-i18n="[title]Import a prompt list"></a>
<a class="menu_button fa-file-export fa-solid" id="prompt-manager-export" title="Export this prompt list" data-i18n="[title]Export this prompt list"></a>
<a class="menu_button fa-undo fa-solid" id="prompt-manager-reset-character" title="Reset current character" data-i18n="[title]Reset current character"></a>
<a class="menu_button fa-plus-square fa-solid" title="New prompt" data-i18n="[title]New prompt"></a>
<a class="menu_button fa-chain fa-solid fa-fw" title="Insert prompt" data-i18n="[title]Insert prompt"></a>
<a class="caution menu_button fa-x fa-solid fa-fw" title="Delete prompt" data-i18n="[title]Delete prompt"></a>
<a class="menu_button fa-file-import fa-solid fa-fw" id="prompt-manager-import" title="Import a prompt list" data-i18n="[title]Import a prompt list"></a>
<a class="menu_button fa-file-export fa-solid fa-fw" id="prompt-manager-export" title="Export this prompt list" data-i18n="[title]Export this prompt list"></a>
<a class="menu_button fa-undo fa-solid fa-fw" id="prompt-manager-reset-character" title="Reset current character" data-i18n="[title]Reset current character"></a>
<a class="menu_button fa-plus-square fa-solid fa-fw" title="New prompt" data-i18n="[title]New prompt"></a>
</div>

View File

@ -2922,6 +2922,23 @@ input[type=search]:focus::-webkit-search-cancel-button {
position: relative;
}
.group_member .queue_position:not(:empty)::before {
content: "#";
}
.group_member .queue_position {
margin-right: 0.75rem;
font-size: calc(var(--mainFontSize) * 0.9);
}
.group_member.is_queued {
outline: 2px solid var(--golden);
}
.group_member.is_active {
outline: 2px solid var(--active);
}
.character_select.is_fav .avatar,
.group_select.is_fav .avatar,
.group_member.is_fav .avatar,