mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-01-20 21:41:32 +01:00
Add error handling for empty Palm response
This commit is contained in:
parent
cfba379777
commit
abe4bb6d54
17
server.js
17
server.js
@ -3122,7 +3122,20 @@ async function sendPalmRequest(request, response) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const generateResponseJson = await generateResponse.json();
|
const generateResponseJson = await generateResponse.json();
|
||||||
const responseText = generateResponseJson.candidates[0]?.output;
|
const responseText = generateResponseJson?.candidates[0]?.output;
|
||||||
|
|
||||||
|
if (!responseText) {
|
||||||
|
console.log('Palm API returned no response', generateResponseJson);
|
||||||
|
let message = `Palm API returned no response: ${JSON.stringify(generateResponseJson)}`;
|
||||||
|
|
||||||
|
// Check for filters
|
||||||
|
if (generateResponseJson?.filters[0]?.message) {
|
||||||
|
message = `Palm filter triggered: ${generateResponseJson.filters[0].message}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
return response.send({ error: { message } });
|
||||||
|
}
|
||||||
|
|
||||||
console.log('Palm response:', responseText);
|
console.log('Palm response:', responseText);
|
||||||
|
|
||||||
// Wrap it back to OAI format
|
// Wrap it back to OAI format
|
||||||
@ -3394,7 +3407,7 @@ app.post("/tokenize_via_api", jsonParser, async function (request, response) {
|
|||||||
|
|
||||||
if (legacyApi) {
|
if (legacyApi) {
|
||||||
url += '/v1/token-count';
|
url += '/v1/token-count';
|
||||||
args.body = JSON.stringify({ "prompt": text});
|
args.body = JSON.stringify({ "prompt": text });
|
||||||
} else {
|
} else {
|
||||||
url += '/v1/internal/encode';
|
url += '/v1/internal/encode';
|
||||||
args.body = JSON.stringify({ "text": text });
|
args.body = JSON.stringify({ "text": text });
|
||||||
|
Loading…
Reference in New Issue
Block a user