Stop any request. Part 2 (still WIP)

This commit is contained in:
SillyLossy
2023-05-24 16:46:05 +03:00
parent 5cb5ea1c2d
commit a0ef9fce83
3 changed files with 68 additions and 56 deletions

View File

@ -79,7 +79,7 @@ async function adjustHordeGenerationParams(max_context_length, max_length) {
return { maxContextLength, maxLength };
}
async function generateHorde(prompt, params) {
async function generateHorde(prompt, params, signal) {
validateHordeModel();
delete params.prompt;
@ -119,6 +119,16 @@ async function generateHorde(prompt, params) {
console.log(`Horde task id = ${task_id}`);
for (let retryNumber = 0; retryNumber < MAX_RETRIES; retryNumber++) {
if (signal.aborted) {
await fetch(`https://horde.koboldai.net/api/v2/generate/text/status/${task_id}`, {
method: 'DELETE',
headers: {
"Client-Agent": CLIENT_VERSION,
}
});
throw new Error('Request aborted');
}
const statusCheckResponse = await fetch(`https://horde.koboldai.net/api/v2/generate/text/status/${task_id}`, getRequestArgs());
const statusCheckJson = await statusCheckResponse.json();