Add aphrodite model selector
This commit is contained in:
parent
d1ca855d23
commit
95c49029f7
|
@ -2062,6 +2062,14 @@
|
|||
<small data-i18n="Example: 127.0.0.1:5000">Example: http://127.0.0.1:5000</small>
|
||||
<input id="aphrodite_api_url_text" class="text_pole wide100p" maxlength="500" value="" autocomplete="off" data-server-history="aphrodite">
|
||||
</div>
|
||||
<div>
|
||||
<h4 data-i18n="Aphrodite Model">Aphrodite Model</h4>
|
||||
<select id="aphrodite_model">
|
||||
<option data-i18n="-- Connect to the API --">
|
||||
-- Connect to the API --
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div data-tg-type="llamacpp">
|
||||
<div class="flex-container flexFlowColumn">
|
||||
|
|
|
@ -196,7 +196,7 @@ import { createPersona, initPersonas, selectCurrentPersona, setPersonaDescriptio
|
|||
import { getBackgrounds, initBackgrounds, loadBackgroundSettings, background_settings } from './scripts/backgrounds.js';
|
||||
import { hideLoader, showLoader } from './scripts/loader.js';
|
||||
import { BulkEditOverlay, CharacterContextMenu } from './scripts/BulkEditOverlay.js';
|
||||
import { loadMancerModels, loadOllamaModels, loadTogetherAIModels, loadInfermaticAIModels, loadOpenRouterModels } from './scripts/textgen-models.js';
|
||||
import { loadMancerModels, loadOllamaModels, loadTogetherAIModels, loadInfermaticAIModels, loadOpenRouterModels, loadAphroditeModels } from './scripts/textgen-models.js';
|
||||
import { appendFileContent, hasPendingFileAttachment, populateFileAttachment, decodeStyleTags, encodeStyleTags } from './scripts/chats.js';
|
||||
import { initPresetManager } from './scripts/preset-manager.js';
|
||||
import { evaluateMacros } from './scripts/macros.js';
|
||||
|
@ -1064,6 +1064,9 @@ async function getStatusTextgen() {
|
|||
} else if (textgen_settings.type === OPENROUTER) {
|
||||
loadOpenRouterModels(data?.data);
|
||||
online_status = textgen_settings.openrouter_model;
|
||||
} else if (textgen_settings.type === APHRODITE) {
|
||||
loadAphroditeModels(data?.data);
|
||||
online_status = textgen_settings.aphrodite_model;
|
||||
} else {
|
||||
online_status = data?.result;
|
||||
}
|
||||
|
|
|
@ -309,6 +309,7 @@ class PresetManager {
|
|||
'mancer_model',
|
||||
'togetherai_model',
|
||||
'ollama_model',
|
||||
'aphrodite_model',
|
||||
'server_urls',
|
||||
'type',
|
||||
'custom_model',
|
||||
|
|
|
@ -6,6 +6,7 @@ import { tokenizers } from './tokenizers.js';
|
|||
let mancerModels = [];
|
||||
let togetherModels = [];
|
||||
let infermaticAIModels = [];
|
||||
let aphroditeModels = [];
|
||||
export let openRouterModels = [];
|
||||
|
||||
export async function loadOllamaModels(data) {
|
||||
|
@ -125,6 +126,28 @@ export async function loadOpenRouterModels(data) {
|
|||
}
|
||||
}
|
||||
|
||||
export async function loadAphroditeModels(data) {
|
||||
if (!Array.isArray(data)) {
|
||||
console.error('Invalid Aphrodite models data', data);
|
||||
return;
|
||||
}
|
||||
|
||||
aphroditeModels = data;
|
||||
|
||||
if (!data.find(x => x.id === textgen_settings.aphrodite_model)) {
|
||||
textgen_settings.aphrodite_model = data[0]?.id || '';
|
||||
}
|
||||
|
||||
$('#aphrodite_model').empty();
|
||||
for (const model of data) {
|
||||
const option = document.createElement('option');
|
||||
option.value = model.id;
|
||||
option.text = model.id;
|
||||
option.selected = model.id === textgen_settings.aphrodite_model;
|
||||
$('#aphrodite_model').append(option);
|
||||
}
|
||||
}
|
||||
|
||||
function onMancerModelSelect() {
|
||||
const modelId = String($('#mancer_model').val());
|
||||
textgen_settings.mancer_model = modelId;
|
||||
|
@ -164,6 +187,12 @@ function onOpenRouterModelSelect() {
|
|||
setGenerationParamsFromPreset({ max_length: model.context_length });
|
||||
}
|
||||
|
||||
function onAphroditeModelSelect() {
|
||||
const modelId = String($('#aphrodite_model').val());
|
||||
textgen_settings.aphrodite_model = modelId;
|
||||
$('#api_button_textgenerationwebui').trigger('click');
|
||||
}
|
||||
|
||||
function getMancerModelTemplate(option) {
|
||||
const model = mancerModels.find(x => x.id === option?.element?.value);
|
||||
|
||||
|
@ -230,6 +259,20 @@ function getOpenRouterModelTemplate(option) {
|
|||
`));
|
||||
}
|
||||
|
||||
function getAphroditeModelTemplate(option) {
|
||||
const model = aphroditeModels.find(x => x.id === option?.element?.value);
|
||||
|
||||
if (!option.id || !model) {
|
||||
return option.text;
|
||||
}
|
||||
|
||||
return $((`
|
||||
<div class="flex-container flexFlowColumn">
|
||||
<div><strong>${DOMPurify.sanitize(model.id)}</strong></div>
|
||||
</div>
|
||||
`));
|
||||
}
|
||||
|
||||
async function downloadOllamaModel() {
|
||||
try {
|
||||
const serverUrl = textgen_settings.server_urls[textgen_types.OLLAMA];
|
||||
|
@ -291,6 +334,7 @@ jQuery(function () {
|
|||
$('#ollama_model').on('change', onOllamaModelSelect);
|
||||
$('#openrouter_model').on('change', onOpenRouterModelSelect);
|
||||
$('#ollama_download_model').on('click', downloadOllamaModel);
|
||||
$('#aphrodite_model').on('change', onAphroditeModelSelect);
|
||||
|
||||
if (!isMobile()) {
|
||||
$('#mancer_model').select2({
|
||||
|
@ -327,5 +371,12 @@ jQuery(function () {
|
|||
width: '100%',
|
||||
templateResult: getOpenRouterModelTemplate,
|
||||
});
|
||||
$('#aphrodite_model').select2({
|
||||
placeholder: 'Select a model',
|
||||
searchInputPlaceholder: 'Search models...',
|
||||
searchInputCssClass: 'text_pole',
|
||||
width: '100%',
|
||||
templateResult: getAphroditeModelTemplate,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
@ -142,6 +142,7 @@ const settings = {
|
|||
infermaticai_model: '',
|
||||
ollama_model: '',
|
||||
openrouter_model: 'openrouter/auto',
|
||||
aphrodite_model: '',
|
||||
legacy_api: false,
|
||||
sampler_order: KOBOLDCPP_ORDER,
|
||||
logit_bias: [],
|
||||
|
@ -941,7 +942,7 @@ function getModel() {
|
|||
}
|
||||
|
||||
if (settings.type === APHRODITE) {
|
||||
return online_status;
|
||||
return settings.aphrodite_model;
|
||||
}
|
||||
|
||||
if (settings.type === OLLAMA) {
|
||||
|
|
Loading…
Reference in New Issue