mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Define bottom anchor threshold in one place
This commit is contained in:
@ -1485,6 +1485,7 @@ async function Generate(type, automatic_trigger, force_name2) {
|
|||||||
|
|
||||||
// Compute anchors
|
// Compute anchors
|
||||||
const topAnchorDepth = 8;
|
const topAnchorDepth = 8;
|
||||||
|
const bottomAnchorThreshold = 8;
|
||||||
let anchorTop = '';
|
let anchorTop = '';
|
||||||
let anchorBottom = '';
|
let anchorBottom = '';
|
||||||
if (!is_pygmalion) {
|
if (!is_pygmalion) {
|
||||||
@ -1725,7 +1726,7 @@ async function Generate(type, automatic_trigger, force_name2) {
|
|||||||
generatedPromtCache += cycleGenerationPromt;
|
generatedPromtCache += cycleGenerationPromt;
|
||||||
if (generatedPromtCache.length == 0) {
|
if (generatedPromtCache.length == 0) {
|
||||||
if (main_api === 'openai') {
|
if (main_api === 'openai') {
|
||||||
generateOpenAIPromptCache(charPersonality, topAnchorDepth, anchorTop, anchorBottom);
|
generateOpenAIPromptCache(charPersonality, topAnchorDepth, anchorTop, bottomAnchorThreshold, anchorBottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('generating prompt');
|
console.log('generating prompt');
|
||||||
@ -1746,7 +1747,7 @@ async function Generate(type, automatic_trigger, force_name2) {
|
|||||||
item += "[" + personalityAndAnchor + ']\n';
|
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);
|
item = item.substr(0, item.length - 1);
|
||||||
//chatString+=postAnchor+"\n";//"[Writing style: very long messages]\n";
|
//chatString+=postAnchor+"\n";//"[Writing style: very long messages]\n";
|
||||||
item = item + anchorBottom + "\n";
|
item = item + anchorBottom + "\n";
|
||||||
|
@ -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 = openai_msgs.reverse();
|
||||||
openai_msgs.forEach(function (msg, i, arr) {//For added anchors and others
|
openai_msgs.forEach(function (msg, i, arr) {//For added anchors and others
|
||||||
let item = msg["content"];
|
let item = msg["content"];
|
||||||
@ -209,7 +209,7 @@ function generateOpenAIPromptCache(charPersonality, topAnchorDepth, anchorTop, a
|
|||||||
item = `[${name2} is ${personalityAndAnchor}]\n${item}`;
|
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;
|
item = anchorBottom + "\n" + item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user