Move Horde status check to respective module
This commit is contained in:
+2
-22
@@ -137,9 +137,10 @@ import {
|
||||
horde_settings,
|
||||
loadHordeSettings,
|
||||
generateHorde,
|
||||
checkHordeStatus,
|
||||
getStatusHorde,
|
||||
getHordeModels,
|
||||
adjustHordeGenerationParams,
|
||||
isHordeGenerationNotAllowed,
|
||||
MIN_LENGTH,
|
||||
initHorde,
|
||||
} from './scripts/horde.js';
|
||||
@@ -961,18 +962,6 @@ export function setActiveGroup(entityOrKey) {
|
||||
if (active_group) active_character = null;
|
||||
}
|
||||
|
||||
async function getStatusHorde() {
|
||||
try {
|
||||
const hordeStatus = await checkHordeStatus();
|
||||
setOnlineStatus(hordeStatus ? t`Connected` : 'no_connection');
|
||||
}
|
||||
catch {
|
||||
setOnlineStatus('no_connection');
|
||||
}
|
||||
|
||||
return resultCheckStatus();
|
||||
}
|
||||
|
||||
export function startStatusLoading() {
|
||||
$('.api_loading').show();
|
||||
$('.api_button').addClass('disabled');
|
||||
@@ -8192,15 +8181,6 @@ export function setGenerationProgress(progress) {
|
||||
}
|
||||
}
|
||||
|
||||
function isHordeGenerationNotAllowed() {
|
||||
if (main_api == 'koboldhorde' && kai_settings.preset_settings == 'gui') {
|
||||
toastr.error(t`GUI Settings preset is not supported for Horde. Please select another preset.`);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
export function cancelTtsPlay() {
|
||||
if ('speechSynthesis' in window) {
|
||||
speechSynthesis.cancel();
|
||||
|
||||
+31
-12
@@ -1,9 +1,12 @@
|
||||
import {
|
||||
amount_gen,
|
||||
getRequestHeaders,
|
||||
main_api,
|
||||
max_context,
|
||||
resultCheckStatus,
|
||||
saveSettingsDebounced,
|
||||
setGenerationProgress,
|
||||
setOnlineStatus,
|
||||
} from '../script.js';
|
||||
import { SECRET_KEYS, writeSecret } from './secrets.js';
|
||||
import { delay } from './utils.js';
|
||||
@@ -11,20 +14,15 @@ import { isMobile } from './RossAscends-mods.js';
|
||||
import { autoSelectInstructPreset } from './instruct-mode.js';
|
||||
import { t } from './i18n.js';
|
||||
import { callGenericPopup, POPUP_TYPE } from './popup.js';
|
||||
import { kai_settings } from './kai-settings.js';
|
||||
|
||||
export {
|
||||
horde_settings,
|
||||
generateHorde,
|
||||
checkHordeStatus,
|
||||
loadHordeSettings,
|
||||
adjustHordeGenerationParams,
|
||||
getHordeModels,
|
||||
MIN_LENGTH,
|
||||
};
|
||||
|
||||
let models = [];
|
||||
|
||||
let horde_settings = {
|
||||
export let horde_settings = {
|
||||
models: [],
|
||||
auto_adjust_response_length: true,
|
||||
auto_adjust_context_length: false,
|
||||
@@ -105,7 +103,7 @@ async function cancelTask(taskId) {
|
||||
* Checks if Horde is online.
|
||||
* @returns {Promise<boolean>} True if Horde is online, false otherwise
|
||||
*/
|
||||
async function checkHordeStatus() {
|
||||
export async function checkHordeStatus() {
|
||||
try {
|
||||
const response = await fetch('/api/horde/status', {
|
||||
method: 'POST',
|
||||
@@ -124,6 +122,18 @@ async function checkHordeStatus() {
|
||||
}
|
||||
}
|
||||
|
||||
export async function getStatusHorde() {
|
||||
try {
|
||||
const hordeStatus = await checkHordeStatus();
|
||||
setOnlineStatus(hordeStatus ? t`Connected` : 'no_connection');
|
||||
}
|
||||
catch {
|
||||
setOnlineStatus('no_connection');
|
||||
}
|
||||
|
||||
return resultCheckStatus();
|
||||
}
|
||||
|
||||
function validateHordeModel() {
|
||||
let selectedModels = models.filter(m => horde_settings.models.includes(m.name));
|
||||
|
||||
@@ -135,7 +145,7 @@ function validateHordeModel() {
|
||||
return selectedModels;
|
||||
}
|
||||
|
||||
async function adjustHordeGenerationParams(max_context_length, max_length) {
|
||||
export async function adjustHordeGenerationParams(max_context_length, max_length) {
|
||||
console.log(max_context_length, max_length);
|
||||
const workers = await getWorkers(false);
|
||||
let maxContextLength = max_context_length;
|
||||
@@ -190,7 +200,7 @@ function setContextSizePreview() {
|
||||
* @returns {Promise<{text: *, workerName: string}>}
|
||||
* @throws {Error}
|
||||
*/
|
||||
async function generateHorde(prompt, params, signal, reportProgress) {
|
||||
export async function generateHorde(prompt, params, signal, reportProgress) {
|
||||
validateHordeModel();
|
||||
delete params.prompt;
|
||||
|
||||
@@ -280,7 +290,7 @@ async function generateHorde(prompt, params, signal, reportProgress) {
|
||||
* Displays the available models in the Horde model selection dropdown.
|
||||
* @param {boolean} force Force refresh of the models
|
||||
*/
|
||||
async function getHordeModels(force) {
|
||||
export async function getHordeModels(force) {
|
||||
const sortByPerformance = (a, b) => b.performance - a.performance;
|
||||
const sortByWhitelisted = (a, b) => b.is_whitelisted - a.is_whitelisted;
|
||||
const sortByPopular = (a, b) => b.tags?.includes('popular') - a.tags?.includes('popular');
|
||||
@@ -305,7 +315,7 @@ async function getHordeModels(force) {
|
||||
setContextSizePreview();
|
||||
}
|
||||
|
||||
function loadHordeSettings(settings) {
|
||||
export function loadHordeSettings(settings) {
|
||||
if (settings.horde_settings) {
|
||||
Object.assign(horde_settings, settings.horde_settings);
|
||||
}
|
||||
@@ -346,6 +356,15 @@ function hordeModelQueueStateString(model) {
|
||||
return `ETA: ${model.eta}s, Speed: ${model.performance}, Queue: ${model.queued}, Workers: ${model.count}`;
|
||||
}
|
||||
|
||||
export function isHordeGenerationNotAllowed() {
|
||||
if (main_api == 'koboldhorde' && kai_settings.preset_settings == 'gui') {
|
||||
toastr.error(t`GUI Settings preset is not supported for Horde. Please select another preset.`);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function getHordeModelTemplate(option) {
|
||||
const model = models.find(x => x.name === option?.element?.value);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user