mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
back to working after merge,
formatting should match fixed bug with send butting showing up midway through long pyg generations optimized changeMainAPI function
This commit is contained in:
@ -1213,7 +1213,8 @@ async function Generate(type, automatic_trigger) {//encode("dsfs").length
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
function runGenerate(cycleGenerationPromt = '') {
|
function runGenerate(cycleGenerationPromt = '') {
|
||||||
console.log('rungenerate entered');
|
|
||||||
|
is_send_press = true;
|
||||||
|
|
||||||
generatedPromtCache += cycleGenerationPromt;
|
generatedPromtCache += cycleGenerationPromt;
|
||||||
if (generatedPromtCache.length == 0) {
|
if (generatedPromtCache.length == 0) {
|
||||||
@ -1325,7 +1326,7 @@ async function Generate(type, automatic_trigger) {//encode("dsfs").length
|
|||||||
}
|
}
|
||||||
finalPromt = worldInfoBefore + storyString + worldInfoAfter + extension_prompt + mesExmString + mesSendString + generatedPromtCache + promptBias;
|
finalPromt = worldInfoBefore + storyString + worldInfoAfter + extension_prompt + mesExmString + mesSendString + generatedPromtCache + promptBias;
|
||||||
finalPromt = finalPromt.replace(/\r/gm, '');
|
finalPromt = finalPromt.replace(/\r/gm, '');
|
||||||
console.log('final prompt decided');
|
//console.log('final prompt decided');
|
||||||
|
|
||||||
//if we aren't using the kobold GUI settings...
|
//if we aren't using the kobold GUI settings...
|
||||||
if (main_api == 'textgenerationwebui' || main_api == 'kobold' && preset_settings != 'gui') {
|
if (main_api == 'textgenerationwebui' || main_api == 'kobold' && preset_settings != 'gui') {
|
||||||
@ -1456,7 +1457,7 @@ async function Generate(type, automatic_trigger) {//encode("dsfs").length
|
|||||||
dataType: "json",
|
dataType: "json",
|
||||||
contentType: "application/json",
|
contentType: "application/json",
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
console.log('generation success');
|
//console.log('generation success');
|
||||||
tokens_already_generated += this_amount_gen; // add new gen amt to any prev gen counter..
|
tokens_already_generated += this_amount_gen; // add new gen amt to any prev gen counter..
|
||||||
|
|
||||||
|
|
||||||
@ -1496,7 +1497,8 @@ async function Generate(type, automatic_trigger) {//encode("dsfs").length
|
|||||||
message_already_generated.indexOf('<|endoftext|>') === -1 && //if there is no <endoftext> stamp in the response msg
|
message_already_generated.indexOf('<|endoftext|>') === -1 && //if there is no <endoftext> stamp in the response msg
|
||||||
tokens_already_generated < parseInt(amount_gen) && //if the gen'd msg is less than the max response length..
|
tokens_already_generated < parseInt(amount_gen) && //if the gen'd msg is less than the max response length..
|
||||||
getMessage.length > 0) { //if we actually have gen'd text at all...
|
getMessage.length > 0) { //if we actually have gen'd text at all...
|
||||||
runGenerate(getMessage); //generate again with the 'GetMessage' argument..
|
runGenerate(getMessage);
|
||||||
|
console.log('returning to make pyg generate again'); //generate again with the 'GetMessage' argument..
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1582,7 +1584,7 @@ async function Generate(type, automatic_trigger) {//encode("dsfs").length
|
|||||||
}
|
}
|
||||||
console.log('runGenerate calls addOneMessage');
|
console.log('runGenerate calls addOneMessage');
|
||||||
addOneMessage(chat[chat.length - 1]);
|
addOneMessage(chat[chat.length - 1]);
|
||||||
console.log('should hide loading mes and return with send button now');
|
|
||||||
$("#send_but").css("display", "inline");
|
$("#send_but").css("display", "inline");
|
||||||
$("#loading_mes").css("display", "none");
|
$("#loading_mes").css("display", "none");
|
||||||
|
|
||||||
@ -1599,7 +1601,7 @@ async function Generate(type, automatic_trigger) {//encode("dsfs").length
|
|||||||
Generate('force_name2');
|
Generate('force_name2');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log('final re-setting of send button due to error');
|
|
||||||
$("#send_but").css("display", "inline");
|
$("#send_but").css("display", "inline");
|
||||||
$("#loading_mes").css("display", "none");
|
$("#loading_mes").css("display", "none");
|
||||||
showSwipeButtons();
|
showSwipeButtons();
|
||||||
@ -1610,7 +1612,7 @@ async function Generate(type, automatic_trigger) {//encode("dsfs").length
|
|||||||
//console.log('AI Response: +'+getMessage+ '('+final_message_length+' tokens)');
|
//console.log('AI Response: +'+getMessage+ '('+final_message_length+' tokens)');
|
||||||
|
|
||||||
$("#send_but").css("display", "inline");
|
$("#send_but").css("display", "inline");
|
||||||
console.log('attempting to show swipes');
|
|
||||||
showSwipeButtons();
|
showSwipeButtons();
|
||||||
|
|
||||||
$("#loading_mes").css("display", "none");
|
$("#loading_mes").css("display", "none");
|
||||||
@ -1618,6 +1620,7 @@ async function Generate(type, automatic_trigger) {//encode("dsfs").length
|
|||||||
},
|
},
|
||||||
error: function (jqXHR, exception) {
|
error: function (jqXHR, exception) {
|
||||||
|
|
||||||
|
|
||||||
$("#send_textarea").removeAttr('disabled');
|
$("#send_textarea").removeAttr('disabled');
|
||||||
is_send_press = false;
|
is_send_press = false;
|
||||||
$("#send_but").css("display", "inline");
|
$("#send_but").css("display", "inline");
|
||||||
@ -1748,7 +1751,8 @@ async function getChat() {
|
|||||||
data: JSON.stringify({
|
data: JSON.stringify({
|
||||||
ch_name: characters[this_chid].name,
|
ch_name: characters[this_chid].name,
|
||||||
file_name: characters[this_chid].chat,
|
file_name: characters[this_chid].chat,
|
||||||
avatar_url: characters[this_chid].avatar }),
|
avatar_url: characters[this_chid].avatar
|
||||||
|
}),
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
contentType: 'application/json',
|
contentType: 'application/json',
|
||||||
});
|
});
|
||||||
@ -1797,39 +1801,50 @@ function openNavToggle() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////// OPTIMZED MAIN API CHANGE FUNCTION ////////////
|
||||||
|
|
||||||
function changeMainAPI() {
|
function changeMainAPI() {
|
||||||
if ($("#main_api").find(":selected").val() == "kobold") {
|
const selectedVal = $("#main_api").val();
|
||||||
$("#kobold_api").css("display", "block");
|
const apiElements = {
|
||||||
$("#novel_api").css("display", "none");
|
"kobold": {
|
||||||
$("#textgenerationwebui_api").css("display", "none");
|
apiElem: $("#kobold_api"),
|
||||||
main_api = "kobold";
|
maxContextElem: $("#max_context_block"),
|
||||||
$("#max_context_block").css("display", "block");
|
amountGenElem: $("#amount_gen_block"),
|
||||||
$("#amount_gen_block").css("display", "block");
|
softPromptElem: $("#softprompt_block")
|
||||||
$("#softprompt_block").css("display", "block");
|
},
|
||||||
|
"textgenerationwebui": {
|
||||||
|
apiElem: $("#textgenerationwebui_api"),
|
||||||
|
maxContextElem: $("#max_context_block"),
|
||||||
|
amountGenElem: $("#amount_gen_block"),
|
||||||
|
softPromptElem: $("#softprompt_block")
|
||||||
|
},
|
||||||
|
"novel": {
|
||||||
|
apiElem: $("#novel_api"),
|
||||||
|
maxContextElem: $("#max_context_block"),
|
||||||
|
amountGenElem: $("#amount_gen_block"),
|
||||||
|
softPromptElem: $("#softprompt_block")
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
for (const apiName in apiElements) {
|
||||||
|
const apiObj = apiElements[apiName];
|
||||||
|
const isCurrentApi = selectedVal === apiName;
|
||||||
|
apiObj.apiElem.css("display", isCurrentApi ? "block" : "none");
|
||||||
|
apiObj.maxContextElem.css("display", isCurrentApi && apiName !== "novel" ? "block" : "none");
|
||||||
|
apiObj.amountGenElem.css("display", isCurrentApi && apiName !== "novel" ? "block" : "none");
|
||||||
|
apiObj.softPromptElem.css("display", isCurrentApi && apiName !== "novel" ? "block" : "none");
|
||||||
|
|
||||||
|
if (isCurrentApi && apiName === "textgenerationwebui") {
|
||||||
|
apiObj.amountGenElem.children().prop("disabled", false);
|
||||||
|
apiObj.amountGenElem.css("opacity", 1.0);
|
||||||
}
|
}
|
||||||
if ($("#main_api").find(":selected").val() == "textgenerationwebui") {
|
|
||||||
$("#kobold_api").css("display", "none");
|
|
||||||
$("#novel_api").css("display", "none");
|
|
||||||
$("#textgenerationwebui_api").css("display", "block");
|
|
||||||
main_api = "textgenerationwebui";
|
|
||||||
$("#max_context_block").css("display", "block");
|
|
||||||
$("#amount_gen_block").css("display", "block");
|
|
||||||
$("#softprompt_block").css("display", "block");
|
|
||||||
$("#amount_gen_block").children().prop("disabled", false);
|
|
||||||
$("#amount_gen_block").css("opacity", 1.0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($("#main_api").find(":selected").val() == "novel") {
|
main_api = selectedVal;
|
||||||
$("#kobold_api").css("display", "none");
|
|
||||||
$("#novel_api").css("display", "block");
|
|
||||||
$("#textgenerationwebui_api").css("display", "none");
|
|
||||||
main_api = "novel";
|
|
||||||
$("#max_context_block").css("display", "none");
|
|
||||||
$("#amount_gen_block").css("display", "none");
|
|
||||||
$("#softprompt_block").css("display", "none");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////
|
||||||
|
|
||||||
async function getUserAvatars() {
|
async function getUserAvatars() {
|
||||||
$("#user_avatar_block").html(""); //RossAscends: necessary to avoid doubling avatars each QuickRefresh.
|
$("#user_avatar_block").html(""); //RossAscends: necessary to avoid doubling avatars each QuickRefresh.
|
||||||
$("#user_avatar_block").append('<div class="avatar_upload">+</div>');
|
$("#user_avatar_block").append('<div class="avatar_upload">+</div>');
|
||||||
|
@ -122,7 +122,8 @@ function RA_CountCharTokens() {
|
|||||||
create_save_scenario
|
create_save_scenario
|
||||||
)).length;
|
)).length;
|
||||||
|
|
||||||
} else {if (this_chid !== undefined && this_chid !== "invalid-safety-id") { // if we are counting a valid pre-saved char
|
} else {
|
||||||
|
if (this_chid !== undefined && this_chid !== "invalid-safety-id") { // if we are counting a valid pre-saved char
|
||||||
|
|
||||||
//same as above, all tokens including temporary ones
|
//same as above, all tokens including temporary ones
|
||||||
count_tokens = encode(
|
count_tokens = encode(
|
||||||
|
Reference in New Issue
Block a user