Don't block send on ooba API error

This commit is contained in:
SillyLossy
2023-03-27 22:07:35 +03:00
parent 9c31ab0039
commit 190bfdd3f4

View File

@ -1632,6 +1632,7 @@ async function Generate(type, automatic_trigger, force_name2) {//encode("dsfs").
} else if (main_api == 'textgenerationwebui') { } else if (main_api == 'textgenerationwebui') {
getMessage = data.data[0]; getMessage = data.data[0];
if (getMessage == null || data.error) { if (getMessage == null || data.error) {
activateSendButtons();
callPopup('<h3>Got empty response from Text generation web UI. Try restarting the API with recommended options.</h3>', 'text'); callPopup('<h3>Got empty response from Text generation web UI. Try restarting the API with recommended options.</h3>', 'text');
return; return;
} }
@ -1732,8 +1733,7 @@ async function Generate(type, automatic_trigger, force_name2) {//encode("dsfs").
//console.log('runGenerate calls addOneMessage'); //console.log('runGenerate calls addOneMessage');
addOneMessage(chat[chat.length - 1]); addOneMessage(chat[chat.length - 1]);
$("#send_but").css("display", "inline"); activateSendButtons();
$("#loading_mes").css("display", "none");
} }
} else { } else {
// regenerate with character speech reenforced // regenerate with character speech reenforced
@ -1742,8 +1742,7 @@ async function Generate(type, automatic_trigger, force_name2) {//encode("dsfs").
Generate(newType, automatic_trigger = false, force_name2 = true); Generate(newType, automatic_trigger = false, force_name2 = true);
} }
} else { } else {
$("#send_but").css("display", "inline"); activateSendButtons();
$("#loading_mes").css("display", "none");
//console.log('runGenerate calling showSwipeBtns'); //console.log('runGenerate calling showSwipeBtns');
showSwipeButtons(); showSwipeButtons();
} }
@ -1757,18 +1756,15 @@ async function Generate(type, automatic_trigger, force_name2) {//encode("dsfs").
//let final_message_length = encode(JSON.stringify(getMessage)).length; //let final_message_length = encode(JSON.stringify(getMessage)).length;
//console.log('AI Response: +'+getMessage+ '('+final_message_length+' tokens)'); //console.log('AI Response: +'+getMessage+ '('+final_message_length+' tokens)');
$("#send_but").css("display", "inline"); activateSendButtons();
//console.log('runGenerate calling showSwipeBtns pt. 2');
showSwipeButtons(); showSwipeButtons();
$("#loading_mes").css("display", "none");
$('.mes_edit:last').show(); $('.mes_edit:last').show();
}; };
function onError(jqXHR, exception) { function onError(jqXHR, exception) {
$("#send_textarea").removeAttr('disabled'); $("#send_textarea").removeAttr('disabled');
is_send_press = false; is_send_press = false;
$("#send_but").css("display", "inline"); activateSendButtons();
$("#loading_mes").css("display", "none");
console.log(exception); console.log(exception);
console.log(jqXHR); console.log(jqXHR);
}; };
@ -1786,6 +1782,12 @@ async function Generate(type, automatic_trigger, force_name2) {//encode("dsfs").
console.log('generate ending'); console.log('generate ending');
} //generate ends } //generate ends
function activateSendButtons() {
is_send_press = false;
$("#send_but").css("display", "inline");
$("#loading_mes").css("display", "none");
}
function resetChatState() { function resetChatState() {
active_character = "invalid-safety-id"; //unsets the chid in settings (this prevents AutoLoadChat from trying to load the wrong ChID active_character = "invalid-safety-id"; //unsets the chid in settings (this prevents AutoLoadChat from trying to load the wrong ChID
this_chid = "invalid-safety-id"; //unsets expected chid before reloading (related to getCharacters/printCharacters from using old arrays) this_chid = "invalid-safety-id"; //unsets expected chid before reloading (related to getCharacters/printCharacters from using old arrays)