Merge pull request #2810 from SillyTavern/tabby-models-list

Tabby models list
This commit is contained in:
Cohee 2024-09-10 00:37:31 +03:00 committed by GitHub
commit b0214298fd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 86 additions and 16 deletions

View File

@ -15,8 +15,13 @@
z-index: 40000;
}
.select2-selection__clear {
.select2-container .select2-selection .select2-selection__clear {
color: var(--SmartThemeBodyColor);
font-size: 24px;
padding: 0;
position: absolute;
right: 5px;
top: 0;
}
.select2-container .select2-search__field {

View File

@ -1905,11 +1905,11 @@
<div class="flex-container flexFlowColumn">
<div id="main-API-selector-block">
<select id="main_api">
<option value="textgenerationwebui"><span data-i18n="Text Completion">Text Completion</span></option>
<option value="openai"><span data-i18n="Chat Completion">Chat Completion</span></option>
<option value="novel"><span data-i18n="NovelAI">NovelAI</span></option>
<option value="koboldhorde"><span data-i18n="KoboldAI Horde">KoboldAI Horde</span></option>
<option value="kobold"><span data-i18n="KoboldAI">KoboldAI Classic</span></option>
<option value="textgenerationwebui" data-i18n="Text Completion">Text Completion</option>
<option value="openai" data-i18n="Chat Completion">Chat Completion</option>
<option value="novel" data-i18n="NovelAI">NovelAI</option>
<option value="koboldhorde" data-i18n="KoboldAI Horde">KoboldAI Horde</option>
<option value="kobold" data-i18n="KoboldAI">KoboldAI Classic</option>
</select>
</div>
<div id="kobold_horde" style="position: relative;"> <!-- shows the kobold settings -->
@ -2335,8 +2335,7 @@
</div>
<div class="flex1">
<h4>
<span data-i18n="Ollama Model">Ollama Model
</h4>
<span data-i18n="Ollama Model">Ollama Model</span>
</h4>
<select id="ollama_model">
<option data-i18n="-- Connect to the API --">
@ -2373,7 +2372,24 @@
<h4>
<span data-i18n="Tabby Model">Tabby Model</span>
</h4>
</h4>
<select id="tabby_model">
<option data-i18n="-- Connect to the API --">
-- Connect to the API --
</option>
</select>
<div class="marginTopBot5">
<small>
<i class="fa-solid fa-lightbulb"></i>
&nbsp;
<code>inline_model_loading: True</code>
<span data-i18n="must be set in Tabby's config.yml to switch models.">
must be set in Tabby's config.yml to switch models.
</span>
<b data-i18n="Use an admin API key.">
Use an admin API key.
</b>
</small>
</div>
<div id="tabby_download_model" class="menu_button menu_button_icon">
<i class="fa-solid fa-download"></i>
<span data-i18n="Download">Download</span>
@ -3240,7 +3256,7 @@
</small>
</label>
<div>
<input type="text" id="instruct_activation_regex" class="text_pole textarea_compact" placeholder="e.g. /llama(-)?[3|3.1]/i"></input>
<input type="text" id="instruct_activation_regex" class="text_pole textarea_compact" placeholder="e.g. /llama(-)?[3|3.1]/i">
</div>
<div>
<label for="instruct_system_prompt" class="flex-container">
@ -3737,7 +3753,7 @@
<div class="flex-container alignItemsBaseline">
<span data-i18n="Chat Style:">Chat Style:</span><br>
<select id="chat_display" class="widthNatural flex1 margin0">
<option value="0" data-i18n="Flat">Flat</span>
<option value="0" data-i18n="Flat">Flat</option>
<option value="1" data-i18n="Bubbles">Bubbles</option>
<option value="2" data-i18n="Document">Document</option>
</select>
@ -5586,8 +5602,8 @@
</div>
<div class="range-block-range">
<select name="characterFilter" class="select2_multi_sameline" multiple>
<option value="">
<span data-i18n="-- Characters not found --">-- Characters not found --</span>
<option value="" data-i18n="-- Characters not found --">
-- Characters not found --
</option>
</select>
</div>
@ -5644,7 +5660,6 @@
<input class="openai_logit_bias_text text_pole" data-i18n="[placeholder]Text or token ids" placeholder="Text or [token ids]" />
<input class="openai_logit_bias_value text_pole" type="number" min="-100" value="0" max="100" />
<i class="menu_button fa-solid fa-xmark openai_logit_bias_remove"></i>
</form>
</div>
</div>
<div id="logit_bias_template" class="template_element">

View File

@ -224,7 +224,7 @@ import {
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 { loadFeatherlessModels, loadMancerModels, loadOllamaModels, loadTogetherAIModels, loadInfermaticAIModels, loadOpenRouterModels, loadVllmModels, loadAphroditeModels, loadDreamGenModels, initTextGenModels } from './scripts/textgen-models.js';
import { loadFeatherlessModels, loadMancerModels, loadOllamaModels, loadTogetherAIModels, loadInfermaticAIModels, loadOpenRouterModels, loadVllmModels, loadAphroditeModels, loadDreamGenModels, initTextGenModels, loadTabbyModels } from './scripts/textgen-models.js';
import { appendFileContent, hasPendingFileAttachment, populateFileAttachment, decodeStyleTags, encodeStyleTags, isExternalMediaAllowed, getCurrentEntityId } from './scripts/chats.js';
import { initPresetManager } from './scripts/preset-manager.js';
import { MacrosParser, evaluateMacros, getLastMessageId } from './scripts/macros.js';
@ -1214,6 +1214,9 @@ async function getStatusTextgen() {
} else if (textgen_settings.type === FEATHERLESS) {
loadFeatherlessModels(data?.data);
setOnlineStatus(textgen_settings.featherless_model);
} else if (textgen_settings.type === TABBY) {
loadTabbyModels(data?.data);
setOnlineStatus(textgen_settings.tabby_model || data?.result);
} else {
setOnlineStatus(data?.result);
}

View File

@ -338,6 +338,7 @@ class PresetManager {
'max_tokens_second',
'openrouter_providers',
'openrouter_allow_fallbacks',
'tabby_model',
];
const settings = Object.assign({}, getSettingsByApiId(this.apiId));

View File

@ -3426,6 +3426,7 @@ function getModelOptions(quiet) {
{ id: 'vllm_model', api: 'textgenerationwebui', type: textgen_types.VLLM },
{ id: 'aphrodite_model', api: 'textgenerationwebui', type: textgen_types.APHRODITE },
{ id: 'ollama_model', api: 'textgenerationwebui', type: textgen_types.OLLAMA },
{ id: 'tabby_model', api: 'textgenerationwebui', type: textgen_types.TABBY },
{ id: 'model_openai_select', api: 'openai', type: chat_completion_sources.OPENAI },
{ id: 'model_claude_select', api: 'openai', type: chat_completion_sources.CLAUDE },
{ id: 'model_windowai_select', api: 'openai', type: chat_completion_sources.WINDOWAI },

View File

@ -12,6 +12,7 @@ let dreamGenModels = [];
let vllmModels = [];
let aphroditeModels = [];
let featherlessModels = [];
let tabbyModels = [];
export let openRouterModels = [];
/**
@ -66,6 +67,30 @@ export async function loadOllamaModels(data) {
}
}
export async function loadTabbyModels(data) {
if (!Array.isArray(data)) {
console.error('Invalid Tabby models data', data);
return;
}
tabbyModels = data;
tabbyModels.sort((a, b) => a.id.localeCompare(b.id));
tabbyModels.unshift({ id: '' });
if (!tabbyModels.find(x => x.id === textgen_settings.tabby_model)) {
textgen_settings.tabby_model = tabbyModels[0]?.id || '';
}
$('#tabby_model').empty();
for (const model of tabbyModels) {
const option = document.createElement('option');
option.value = model.id;
option.text = model.id;
option.selected = model.id === textgen_settings.tabby_model;
$('#tabby_model').append(option);
}
}
export async function loadTogetherAIModels(data) {
if (!Array.isArray(data)) {
console.error('Invalid Together AI models data', data);
@ -310,6 +335,12 @@ function onOllamaModelSelect() {
$('#api_button_textgenerationwebui').trigger('click');
}
function onTabbyModelSelect() {
const modelId = String($('#tabby_model').val());
textgen_settings.tabby_model = modelId;
$('#api_button_textgenerationwebui').trigger('click');
}
function onOpenRouterModelSelect() {
const modelId = String($('#openrouter_model').val());
textgen_settings.openrouter_model = modelId;
@ -641,6 +672,7 @@ export function initTextGenModels() {
$('#aphrodite_model').on('change', onAphroditeModelSelect);
$('#featherless_model').on('change', onFeatherlessModelSelect);
$('#tabby_download_model').on('click', downloadTabbyModel);
$('#tabby_model').on('change', onTabbyModelSelect);
const providersSelect = $('.openrouter_providers');
for (const provider of OPENROUTER_PROVIDERS) {
@ -671,6 +703,13 @@ export function initTextGenModels() {
searchInputCssClass: 'text_pole',
width: '100%',
});
$('#tabby_model').select2({
placeholder: '[Currently loaded]',
searchInputPlaceholder: 'Search models...',
searchInputCssClass: 'text_pole',
width: '100%',
allowClear: true,
});
$('#model_infermaticai_select').select2({
placeholder: 'Select a model',
searchInputPlaceholder: 'Search models...',

View File

@ -180,6 +180,7 @@ const settings = {
vllm_model: '',
aphrodite_model: '',
dreamgen_model: 'opus-v1-xl/text',
tabby_model: '',
legacy_api: false,
sampler_order: KOBOLDCPP_ORDER,
logit_bias: [],
@ -995,7 +996,7 @@ function tryParseStreamingError(response, decoded) {
// No JSON. Do nothing.
}
const message = data?.error?.message || data?.message;
const message = data?.error?.message || data?.message || data?.detail;
if (message) {
toastr.error(message, 'Text Completion API');
@ -1047,6 +1048,11 @@ export function getTextGenModel() {
return settings.featherless_model;
case HUGGINGFACE:
return 'tgi';
case TABBY:
if (settings.tabby_model) {
return settings.tabby_model;
}
break;
default:
return undefined;
}