mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Fix poe server crash
This commit is contained in:
@@ -50,7 +50,7 @@ function loadSettings() {
|
|||||||
selectBot();
|
selectBot();
|
||||||
|
|
||||||
const autoConnect = localStorage.getItem('AutoConnectEnabled') == "true";
|
const autoConnect = localStorage.getItem('AutoConnectEnabled') == "true";
|
||||||
if (autoConnect && token) {
|
if (autoConnect && token && token.length) {
|
||||||
onConnectClick();
|
onConnectClick();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -69,12 +69,12 @@ function saveSettings() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onTokenInput() {
|
function onTokenInput() {
|
||||||
token = $(this).val();
|
token = $('#poe_token').val();
|
||||||
saveSettings();
|
saveSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
function onBotChange() {
|
function onBotChange() {
|
||||||
bot = $(this).find(":selected").val();
|
bot = $('#poe_bots').find(":selected").val();
|
||||||
saveSettings();
|
saveSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,6 +194,10 @@ async function sendMessage(prompt) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function onConnectClick() {
|
async function onConnectClick() {
|
||||||
|
if (!token || !token.length) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const body = JSON.stringify({ token: token });
|
const body = JSON.stringify({ token: token });
|
||||||
const response = await fetch('/status_poe', {
|
const response = await fetch('/status_poe', {
|
||||||
headers: {
|
headers: {
|
||||||
|
16
server.js
16
server.js
@@ -1629,10 +1629,16 @@ app.post('/status_poe', jsonParser, async (request, response) => {
|
|||||||
return response.sendStatus(400);
|
return response.sendStatus(400);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
const client = await getPoeClient(request.body.token);
|
const client = await getPoeClient(request.body.token);
|
||||||
const botNames = client.get_bot_names();
|
const botNames = client.get_bot_names();
|
||||||
client.disconnect_ws();
|
client.disconnect_ws();
|
||||||
|
|
||||||
return response.send({'bot_names': botNames});
|
return response.send({'bot_names': botNames});
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
return response.sendStatus(500);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
app.post('/purge_poe', jsonParser, async (request, response) => {
|
app.post('/purge_poe', jsonParser, async (request, response) => {
|
||||||
@@ -1644,11 +1650,16 @@ app.post('/purge_poe', jsonParser, async (request, response) => {
|
|||||||
const bot = request.body.bot ?? POE_DEFAULT_BOT;
|
const bot = request.body.bot ?? POE_DEFAULT_BOT;
|
||||||
const count = request.body.count ?? -1;
|
const count = request.body.count ?? -1;
|
||||||
|
|
||||||
|
try {
|
||||||
const client = await getPoeClient(token);
|
const client = await getPoeClient(token);
|
||||||
await client.purge_conversation(bot, count)
|
await client.purge_conversation(bot, count)
|
||||||
client.disconnect_ws();
|
client.disconnect_ws();
|
||||||
|
|
||||||
return response.send({"ok" : true});
|
return response.send({"ok" : true});
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
return response.sendStatus(500);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
app.post('/generate_poe', jsonParser, async (request, response) => {
|
app.post('/generate_poe', jsonParser, async (request, response) => {
|
||||||
@@ -1660,6 +1671,7 @@ app.post('/generate_poe', jsonParser, async (request, response) => {
|
|||||||
const prompt = request.body.prompt;
|
const prompt = request.body.prompt;
|
||||||
const bot = request.body.bot ?? POE_DEFAULT_BOT;
|
const bot = request.body.bot ?? POE_DEFAULT_BOT;
|
||||||
|
|
||||||
|
try {
|
||||||
const client = await getPoeClient(token);
|
const client = await getPoeClient(token);
|
||||||
|
|
||||||
let reply;
|
let reply;
|
||||||
@@ -1670,6 +1682,10 @@ app.post('/generate_poe', jsonParser, async (request, response) => {
|
|||||||
client.disconnect_ws();
|
client.disconnect_ws();
|
||||||
|
|
||||||
return response.send({'reply': reply});
|
return response.send({'reply': reply});
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
return response.sendStatus(500);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function getThumbnailFolder(type) {
|
function getThumbnailFolder(type) {
|
||||||
|
Reference in New Issue
Block a user