import { setGenerationParamsFromPreset } from '../script.js'; import { isMobile } from './RossAscends-mods.js'; import { textgenerationwebui_settings as textgen_settings } from './textgen-settings.js'; let models = []; export async function loadMancerModels(data) { if (!Array.isArray(data)) { console.error('Invalid Mancer models data', data); return; } models = data; $('#mancer_model').empty(); for (const model of data) { const option = document.createElement('option'); option.value = model.id; option.text = model.name; option.selected = model.id === textgen_settings.mancer_model; $('#mancer_model').append(option); } } function onMancerModelSelect() { const modelId = String($('#mancer_model').val()); textgen_settings.mancer_model = modelId; $('#api_button_textgenerationwebui').trigger('click'); const limits = models.find(x => x.id === modelId)?.limits; setGenerationParamsFromPreset({ max_length: limits.context, genamt: limits.completion }); } function getMancerModelTemplate(option) { const model = models.find(x => x.id === option?.element?.value); if (!option.id || !model) { return option.text; } const creditsPerPrompt = (model.limits?.context - model.limits?.completion) * model.pricing?.prompt; const creditsPerCompletion = model.limits?.completion * model.pricing?.completion; const creditsTotal = Math.round(creditsPerPrompt + creditsPerCompletion).toFixed(0); return $((`