support for not hiding everything except image

This commit is contained in:
Sumit Kumar
2023-05-16 15:59:35 +05:30
parent 8ea25935e8
commit 94a53d5759

View File

@ -428,7 +428,7 @@ function getTokenCount(str, padding = 0) {
let tokenCount = 0; let tokenCount = 0;
jQuery.ajax({ jQuery.ajax({
async: false, async: false,
type: 'POST', // type: 'POST', //
url: `/tokenize_llama`, url: `/tokenize_llama`,
data: JSON.stringify({ text: str }), data: JSON.stringify({ text: str }),
dataType: "json", dataType: "json",
@ -572,7 +572,7 @@ $.get("/csrf-token").then(async (data) => {
}); });
function checkOnlineStatus() { function checkOnlineStatus() {
///////// REMOVED LINES THAT DUPLICATE RA_CHeckOnlineStatus FEATURES ///////// REMOVED LINES THAT DUPLICATE RA_CHeckOnlineStatus FEATURES
if (online_status == "no_connection") { if (online_status == "no_connection") {
$("#online_status_indicator2").css("background-color", "red"); //Kobold $("#online_status_indicator2").css("background-color", "red"); //Kobold
@ -1020,7 +1020,7 @@ function appendImageToMessage(mes, messageElement) {
image.src = mes.extra?.image; image.src = mes.extra?.image;
image.title = mes.extra?.title || mes.title; image.title = mes.extra?.title || mes.title;
image.classList.add("img_extra"); image.classList.add("img_extra");
messageElement.find(".mes_text").prepend(image); mes.extra?.inline_image?messageElement.find(".mes_text").append(image):messageElement.find(".mes_text").prepend(image);
} }
} }
@ -1078,7 +1078,7 @@ function addOneMessage(mes, { type = "normal", insertAfter = null, scroll = true
avatarImg = default_avatar; avatarImg = default_avatar;
} }
} }
//old processing: //old processing:
//if messge is from sytem, use the name provided in the message JSONL to proceed, //if messge is from sytem, use the name provided in the message JSONL to proceed,
//if not system message, use name2 (char's name) to proceed //if not system message, use name2 (char's name) to proceed
//characterName = mes.is_system || mes.force_avatar ? mes.name : name2; //characterName = mes.is_system || mes.force_avatar ? mes.name : name2;
@ -1816,7 +1816,7 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
if (novel_tier === 1) { if (novel_tier === 1) {
this_max_context = 1024; this_max_context = 1024;
} else { } else {
this_max_context = 2048 - 60;//fix for fat tokens this_max_context = 2048 - 60;//fix for fat tokens
if (nai_settings.model_novel == 'krake-v2') { if (nai_settings.model_novel == 'krake-v2') {
this_max_context -= 160; this_max_context -= 160;
} }
@ -1949,7 +1949,7 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
// where it left off by removing the trailing newline at the end // where it left off by removing the trailing newline at the end
// that was added by chat2 generator. This causes problems with // that was added by chat2 generator. This causes problems with
// instruct mode that could not have a trailing newline. So we're // instruct mode that could not have a trailing newline. So we're
// removing a newline ONLY at the end of the string if it exists. // removing a newline ONLY at the end of the string if it exists.
item = item.replace(/\n?$/, ''); item = item.replace(/\n?$/, '');
//item = item.substr(0, item.length - 1); //item = item.substr(0, item.length - 1);
} }
@ -2127,7 +2127,7 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
let promptBiasTokens = getTokenCount(promptBias); let promptBiasTokens = getTokenCount(promptBias);
let mesSendStringTokens = getTokenCount(mesSendString) let mesSendStringTokens = getTokenCount(mesSendString)
let ActualChatHistoryTokens = mesSendStringTokens - allAnchorsTokens + power_user.token_padding; let ActualChatHistoryTokens = mesSendStringTokens - allAnchorsTokens + power_user.token_padding;
let totalTokensInPrompt = let totalTokensInPrompt =
allAnchorsTokens + // AN and/or legacy anchors allAnchorsTokens + // AN and/or legacy anchors
//afterScenarioAnchorTokens + //only counts if AN is set to 'after scenario' //afterScenarioAnchorTokens + //only counts if AN is set to 'after scenario'
@ -2137,21 +2137,21 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
promptBiasTokens + //{{}} promptBiasTokens + //{{}}
ActualChatHistoryTokens + //chat history ActualChatHistoryTokens + //chat history
power_user.token_padding; power_user.token_padding;
console.log( console.log(
` `
Prompt Itemization Prompt Itemization
------------------- -------------------
Extension Add-ins AN: ${allAnchorsTokens} Extension Add-ins AN: ${allAnchorsTokens}
World Info: ${worldInfoStringTokens} World Info: ${worldInfoStringTokens}
Character Definitions: ${storyStringTokens} Character Definitions: ${storyStringTokens}
-- Description: ${charDescriptionTokens} -- Description: ${charDescriptionTokens}
-- Example Messages: ${examplesStringTokens} -- Example Messages: ${examplesStringTokens}
-- Character Personality: ${charPersonalityTokens} -- Character Personality: ${charPersonalityTokens}
-- Character Scenario: ${scenarioTextTokens} -- Character Scenario: ${scenarioTextTokens}
Chat History: ${ActualChatHistoryTokens} Chat History: ${ActualChatHistoryTokens}
{{}} Bias: ${promptBiasTokens} {{}} Bias: ${promptBiasTokens}
Padding: ${power_user.token_padding} Padding: ${power_user.token_padding}
@ -2160,7 +2160,7 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
vs vs
finalPrompt: ${finalPromptTokens} finalPrompt: ${finalPromptTokens}
Max Context: ${this_max_context} Max Context: ${this_max_context}
` `
); */ ); */
@ -2277,8 +2277,8 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
} }
else { else {
jQuery.ajax({ jQuery.ajax({
type: 'POST', // type: 'POST', //
url: generate_url, // url: generate_url, //
data: JSON.stringify(generate_data), data: JSON.stringify(generate_data),
beforeSend: function () { beforeSend: function () {