mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Send abort signal to koboldcpp server on abort, mk. 2
Implemented the abort request being sent through server.js instead of the client endpoint.
This commit is contained in:
16
server.js
16
server.js
@@ -412,8 +412,20 @@ app.post("/generate", jsonParser, async function (request, response_generate = r
|
||||
response = await fetch(url, { method: 'POST', timeout: 0, ...args });
|
||||
|
||||
if (request.body.streaming) {
|
||||
|
||||
request.socket.on('close', function () {
|
||||
request.socket.on('close', async function () {
|
||||
if (controller.signal.aborted) {
|
||||
try {
|
||||
// send abort signal to koboldcpp
|
||||
await fetch(`${api_server}/extra/abort`, {
|
||||
method: 'POST',
|
||||
});
|
||||
} catch {
|
||||
// likely endpoint not available on older versions of koboldcpp
|
||||
if ('status' in error) {
|
||||
console.log('Status Code from Kobold:', error.status);
|
||||
}
|
||||
}
|
||||
}
|
||||
response.body.destroy(); // Close the remote stream
|
||||
response_generate.end(); // End the Express response
|
||||
});
|
||||
|
Reference in New Issue
Block a user