diff --git a/public/script.js b/public/script.js index fbf086458..e6aa952c8 100644 --- a/public/script.js +++ b/public/script.js @@ -1485,6 +1485,7 @@ async function Generate(type, automatic_trigger, force_name2) { // Compute anchors const topAnchorDepth = 8; + const bottomAnchorThreshold = 8; let anchorTop = ''; let anchorBottom = ''; if (!is_pygmalion) { @@ -1725,7 +1726,7 @@ async function Generate(type, automatic_trigger, force_name2) { generatedPromtCache += cycleGenerationPromt; if (generatedPromtCache.length == 0) { if (main_api === 'openai') { - generateOpenAIPromptCache(charPersonality, topAnchorDepth, anchorTop, anchorBottom); + generateOpenAIPromptCache(charPersonality, topAnchorDepth, anchorTop, bottomAnchorThreshold, anchorBottom); } console.log('generating prompt'); @@ -1746,7 +1747,7 @@ async function Generate(type, automatic_trigger, force_name2) { item += "[" + personalityAndAnchor + ']\n'; } } - if (i >= arrMes.length - 1 && count_view_mes > 8 && $.trim(item).substr(0, (name1 + ":").length) == name1 + ":" && !is_pygmalion) {//For add anchor in end + if (i >= arrMes.length - 1 && count_view_mes > bottomAnchorThreshold && $.trim(item).substr(0, (name1 + ":").length) == name1 + ":" && !is_pygmalion) {//For add anchor in end item = item.substr(0, item.length - 1); //chatString+=postAnchor+"\n";//"[Writing style: very long messages]\n"; item = item + anchorBottom + "\n"; diff --git a/public/scripts/openai.js b/public/scripts/openai.js index 020225dd5..a1c63dc8c 100644 --- a/public/scripts/openai.js +++ b/public/scripts/openai.js @@ -199,7 +199,7 @@ function setOpenAIMessageExamples(mesExamplesArray) { } } -function generateOpenAIPromptCache(charPersonality, topAnchorDepth, anchorTop, anchorBottom) { +function generateOpenAIPromptCache(charPersonality, topAnchorDepth, anchorTop, bottomAnchorThreshold, anchorBottom) { openai_msgs = openai_msgs.reverse(); openai_msgs.forEach(function (msg, i, arr) {//For added anchors and others let item = msg["content"]; @@ -209,7 +209,7 @@ function generateOpenAIPromptCache(charPersonality, topAnchorDepth, anchorTop, a item = `[${name2} is ${personalityAndAnchor}]\n${item}`; } } - if (i >= openai_msgs.length - 1 && count_view_mes > 8 && $.trim(item).substr(0, (name1 + ":").length) == name1 + ":") {//For add anchor in end + if (i >= openai_msgs.length - 1 && count_view_mes > bottomAnchorThreshold && $.trim(item).substr(0, (name1 + ":").length) == name1 + ":") {//For add anchor in end item = anchorBottom + "\n" + item; }