Do backflips trying to get error information from endpoints.

Then present it nicely.
This commit is contained in:
50h100a 2023-08-03 07:32:53 -04:00
parent 2fc6813e66
commit 9cf4056b28
2 changed files with 16 additions and 7 deletions

View File

@ -885,6 +885,11 @@ async function getStatus() {
kai_settings.can_use_streaming = canUseKoboldStreaming(data.koboldVersion);
}
// We didn't get a 200 status code, but the endpoint has an explanation. Which means it DID connect, but I digress.
if (online_status == "no_connection" && data.response) {
toastr.error(data.response, "API Error", {timeOut: 5000, preventDuplicates:true})
}
//console.log(online_status);
resultCheckStatus();
if (online_status !== "no_connection") {
@ -2984,9 +2989,8 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject,
if (main_api == 'textgenerationwebui' && api_use_mancer_webui) {
const errorText = `<h3>Inferencer endpoint is unhappy!</h3>
Check you have credits available on your
<a href="https://mancer.tech/dashboard.html" target="_blank">Mancer account</a>.<br>
If you have sufficient credits, please try again later.`;
Returned status <tt>${data.status}</tt> with the reason:<br/>
${data.response}`;
callPopup(errorText, 'text');
}
}

View File

@ -657,8 +657,13 @@ app.post("/generate_textgenerationwebui", jsonParser, async function (request, r
console.log(data);
return response_generate.send(data);
} catch (error) {
retval = { error: true, status: error.status, response: error.statusText };
console.log(error);
return response_generate.send({ error: true });
try {
retval.response = await error.json();
retval.response = retval.response.result;
} catch {}
return response_generate.send(retval);
}
}
});
@ -747,18 +752,18 @@ app.post("/getstatus", jsonParser, async function (request, response_getstatus =
};
}
}
client.get(url, args, function (data, response) {
client.get(url, args, async function (data, response) {
if (typeof data !== 'object') {
data = {};
}
if (response.statusCode == 200) {
data.version = version;
data.koboldVersion = koboldVersion;
if (data.result != "ReadOnly") {
} else {
if (data.result == "ReadOnly") {
data.result = "no_connection";
}
} else {
data.response = data.result;
data.result = "no_connection";
}
response_getstatus.send(data);