mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-01-23 16:02:06 +01:00
Do backflips trying to get error information from endpoints.
Then present it nicely.
This commit is contained in:
parent
2fc6813e66
commit
9cf4056b28
@ -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');
|
||||
}
|
||||
}
|
||||
|
13
server.js
13
server.js
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user