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

b0214298fdd2c446ef52da43fa5a372d482a1cb1

Cohee <18619528+Cohee1207@users.noreply.github.com>

Signed
7 files changed, +86 -16Ignore whitespace
public/css/select2-overrides.css+6 -1
@@ -15,8 +15,13 @@
15 z-index: 40000;15 z-index: 40000;
16}16}
1717
18.select2-selection__clear {18.select2-container .select2-selection .select2-selection__clear {
19 color: var(--SmartThemeBodyColor);19 color: var(--SmartThemeBodyColor);
20 font-size: 24px;
21 padding: 0;
22 position: absolute;
23 right: 5px;
24 top: 0;
20}25}
2126
22.select2-container .select2-search__field {27.select2-container .select2-search__field {
public/index.html+28 -13
@@ -1905,11 +1905,11 @@
1905 <div class="flex-container flexFlowColumn">1905 <div class="flex-container flexFlowColumn">
1906 <div id="main-API-selector-block">1906 <div id="main-API-selector-block">
1907 <select id="main_api">1907 <select id="main_api">
1908 <option value="textgenerationwebui"><span data-i18n="Text Completion">Text Completion</span></option>1908 <option value="textgenerationwebui" data-i18n="Text Completion">Text Completion</option>
1909 <option value="openai"><span data-i18n="Chat Completion">Chat Completion</span></option>1909 <option value="openai" data-i18n="Chat Completion">Chat Completion</option>
1910 <option value="novel"><span data-i18n="NovelAI">NovelAI</span></option>1910 <option value="novel" data-i18n="NovelAI">NovelAI</option>
1911 <option value="koboldhorde"><span data-i18n="KoboldAI Horde">KoboldAI Horde</span></option>1911 <option value="koboldhorde" data-i18n="KoboldAI Horde">KoboldAI Horde</option>
1912 <option value="kobold"><span data-i18n="KoboldAI">KoboldAI Classic</span></option>1912 <option value="kobold" data-i18n="KoboldAI">KoboldAI Classic</option>
1913 </select>1913 </select>
1914 </div>1914 </div>
1915 <div id="kobold_horde" style="position: relative;"> <!-- shows the kobold settings -->1915 <div id="kobold_horde" style="position: relative;"> <!-- shows the kobold settings -->
@@ -2335,8 +2335,7 @@
2335 </div>2335 </div>
2336 <div class="flex1">2336 <div class="flex1">
2337 <h4>2337 <h4>
2338 <span data-i18n="Ollama Model">Ollama Model2338 <span data-i18n="Ollama Model">Ollama Model</span>
2339 </h4>
2340 </h4>2339 </h4>
2341 <select id="ollama_model">2340 <select id="ollama_model">
2342 <option data-i18n="-- Connect to the API --">2341 <option data-i18n="-- Connect to the API --">
@@ -2373,7 +2372,24 @@
2373 <h4>2372 <h4>
2374 <span data-i18n="Tabby Model">Tabby Model</span>2373 <span data-i18n="Tabby Model">Tabby Model</span>
2375 </h4>2374 </h4>
2376 </h4>2375 <select id="tabby_model">
2376 <option data-i18n="-- Connect to the API --">
2377 -- Connect to the API --
2378 </option>
2379 </select>
2380 <div class="marginTopBot5">
2381 <small>
2382 <i class="fa-solid fa-lightbulb"></i>
2383 &nbsp;
2384 <code>inline_model_loading: True</code>
2385 <span data-i18n="must be set in Tabby's config.yml to switch models.">
2386 must be set in Tabby's config.yml to switch models.
2387 </span>
2388 <b data-i18n="Use an admin API key.">
2389 Use an admin API key.
2390 </b>
2391 </small>
2392 </div>
2377 <div id="tabby_download_model" class="menu_button menu_button_icon">2393 <div id="tabby_download_model" class="menu_button menu_button_icon">
2378 <i class="fa-solid fa-download"></i>2394 <i class="fa-solid fa-download"></i>
2379 <span data-i18n="Download">Download</span>2395 <span data-i18n="Download">Download</span>
@@ -3240,7 +3256,7 @@
3240 </small>3256 </small>
3241 </label>3257 </label>
3242 <div>3258 <div>
3243 <input type="text" id="instruct_activation_regex" class="text_pole textarea_compact" placeholder="e.g. /llama(-)?[3|3.1]/i"></input>3259 <input type="text" id="instruct_activation_regex" class="text_pole textarea_compact" placeholder="e.g. /llama(-)?[3|3.1]/i">
3244 </div>3260 </div>
3245 <div>3261 <div>
3246 <label for="instruct_system_prompt" class="flex-container">3262 <label for="instruct_system_prompt" class="flex-container">
@@ -3737,7 +3753,7 @@
3737 <div class="flex-container alignItemsBaseline">3753 <div class="flex-container alignItemsBaseline">
3738 <span data-i18n="Chat Style:">Chat Style:</span><br>3754 <span data-i18n="Chat Style:">Chat Style:</span><br>
3739 <select id="chat_display" class="widthNatural flex1 margin0">3755 <select id="chat_display" class="widthNatural flex1 margin0">
3740 <option value="0" data-i18n="Flat">Flat</span>3756 <option value="0" data-i18n="Flat">Flat</option>
3741 <option value="1" data-i18n="Bubbles">Bubbles</option>3757 <option value="1" data-i18n="Bubbles">Bubbles</option>
3742 <option value="2" data-i18n="Document">Document</option>3758 <option value="2" data-i18n="Document">Document</option>
3743 </select>3759 </select>
@@ -5586,8 +5602,8 @@
5586 </div>5602 </div>
5587 <div class="range-block-range">5603 <div class="range-block-range">
5588 <select name="characterFilter" class="select2_multi_sameline" multiple>5604 <select name="characterFilter" class="select2_multi_sameline" multiple>
5589 <option value="">5605 <option value="" data-i18n="-- Characters not found --">
5590 <span data-i18n="-- Characters not found --">-- Characters not found --</span>5606 -- Characters not found --
5591 </option>5607 </option>
5592 </select>5608 </select>
5593 </div>5609 </div>
@@ -5644,7 +5660,6 @@
5644 <input class="openai_logit_bias_text text_pole" data-i18n="[placeholder]Text or token ids" placeholder="Text or [token ids]" />5660 <input class="openai_logit_bias_text text_pole" data-i18n="[placeholder]Text or token ids" placeholder="Text or [token ids]" />
5645 <input class="openai_logit_bias_value text_pole" type="number" min="-100" value="0" max="100" />5661 <input class="openai_logit_bias_value text_pole" type="number" min="-100" value="0" max="100" />
5646 <i class="menu_button fa-solid fa-xmark openai_logit_bias_remove"></i>5662 <i class="menu_button fa-solid fa-xmark openai_logit_bias_remove"></i>
5647 </form>
5648 </div>5663 </div>
5649 </div>5664 </div>
5650 <div id="logit_bias_template" class="template_element">5665 <div id="logit_bias_template" class="template_element">
public/script.js+4 -1
@@ -224,7 +224,7 @@ import {
224import { getBackgrounds, initBackgrounds, loadBackgroundSettings, background_settings } from './scripts/backgrounds.js';224import { getBackgrounds, initBackgrounds, loadBackgroundSettings, background_settings } from './scripts/backgrounds.js';
225import { hideLoader, showLoader } from './scripts/loader.js';225import { hideLoader, showLoader } from './scripts/loader.js';
226import { BulkEditOverlay, CharacterContextMenu } from './scripts/BulkEditOverlay.js';226import { BulkEditOverlay, CharacterContextMenu } from './scripts/BulkEditOverlay.js';
227import { loadFeatherlessModels, loadMancerModels, loadOllamaModels, loadTogetherAIModels, loadInfermaticAIModels, loadOpenRouterModels, loadVllmModels, loadAphroditeModels, loadDreamGenModels, initTextGenModels } from './scripts/textgen-models.js';227import { loadFeatherlessModels, loadMancerModels, loadOllamaModels, loadTogetherAIModels, loadInfermaticAIModels, loadOpenRouterModels, loadVllmModels, loadAphroditeModels, loadDreamGenModels, initTextGenModels, loadTabbyModels } from './scripts/textgen-models.js';
228import { appendFileContent, hasPendingFileAttachment, populateFileAttachment, decodeStyleTags, encodeStyleTags, isExternalMediaAllowed, getCurrentEntityId } from './scripts/chats.js';228import { appendFileContent, hasPendingFileAttachment, populateFileAttachment, decodeStyleTags, encodeStyleTags, isExternalMediaAllowed, getCurrentEntityId } from './scripts/chats.js';
229import { initPresetManager } from './scripts/preset-manager.js';229import { initPresetManager } from './scripts/preset-manager.js';
230import { MacrosParser, evaluateMacros, getLastMessageId } from './scripts/macros.js';230import { MacrosParser, evaluateMacros, getLastMessageId } from './scripts/macros.js';
@@ -1214,6 +1214,9 @@ async function getStatusTextgen() {
1214 } else if (textgen_settings.type === FEATHERLESS) {1214 } else if (textgen_settings.type === FEATHERLESS) {
1215 loadFeatherlessModels(data?.data);1215 loadFeatherlessModels(data?.data);
1216 setOnlineStatus(textgen_settings.featherless_model);1216 setOnlineStatus(textgen_settings.featherless_model);
1217 } else if (textgen_settings.type === TABBY) {
1218 loadTabbyModels(data?.data);
1219 setOnlineStatus(textgen_settings.tabby_model || data?.result);
1217 } else {1220 } else {
1218 setOnlineStatus(data?.result);1221 setOnlineStatus(data?.result);
1219 }1222 }
public/scripts/preset-manager.js+1 -0
@@ -338,6 +338,7 @@ class PresetManager {
338 'max_tokens_second',338 'max_tokens_second',
339 'openrouter_providers',339 'openrouter_providers',
340 'openrouter_allow_fallbacks',340 'openrouter_allow_fallbacks',
341 'tabby_model',
341 ];342 ];
342 const settings = Object.assign({}, getSettingsByApiId(this.apiId));343 const settings = Object.assign({}, getSettingsByApiId(this.apiId));
343344
public/scripts/slash-commands.js+1 -0
@@ -3426,6 +3426,7 @@ function getModelOptions(quiet) {
3426 { id: 'vllm_model', api: 'textgenerationwebui', type: textgen_types.VLLM },3426 { id: 'vllm_model', api: 'textgenerationwebui', type: textgen_types.VLLM },
3427 { id: 'aphrodite_model', api: 'textgenerationwebui', type: textgen_types.APHRODITE },3427 { id: 'aphrodite_model', api: 'textgenerationwebui', type: textgen_types.APHRODITE },
3428 { id: 'ollama_model', api: 'textgenerationwebui', type: textgen_types.OLLAMA },3428 { id: 'ollama_model', api: 'textgenerationwebui', type: textgen_types.OLLAMA },
3429 { id: 'tabby_model', api: 'textgenerationwebui', type: textgen_types.TABBY },
3429 { id: 'model_openai_select', api: 'openai', type: chat_completion_sources.OPENAI },3430 { id: 'model_openai_select', api: 'openai', type: chat_completion_sources.OPENAI },
3430 { id: 'model_claude_select', api: 'openai', type: chat_completion_sources.CLAUDE },3431 { id: 'model_claude_select', api: 'openai', type: chat_completion_sources.CLAUDE },
3431 { id: 'model_windowai_select', api: 'openai', type: chat_completion_sources.WINDOWAI },3432 { id: 'model_windowai_select', api: 'openai', type: chat_completion_sources.WINDOWAI },
public/scripts/textgen-models.js+39 -0
@@ -12,6 +12,7 @@ let dreamGenModels = [];
12let vllmModels = [];12let vllmModels = [];
13let aphroditeModels = [];13let aphroditeModels = [];
14let featherlessModels = [];14let featherlessModels = [];
15let tabbyModels = [];
15export let openRouterModels = [];16export let openRouterModels = [];
1617
17/**18/**
@@ -66,6 +67,30 @@ export async function loadOllamaModels(data) {
66 }67 }
67}68}
6869
70export async function loadTabbyModels(data) {
71 if (!Array.isArray(data)) {
72 console.error('Invalid Tabby models data', data);
73 return;
74 }
75
76 tabbyModels = data;
77 tabbyModels.sort((a, b) => a.id.localeCompare(b.id));
78 tabbyModels.unshift({ id: '' });
79
80 if (!tabbyModels.find(x => x.id === textgen_settings.tabby_model)) {
81 textgen_settings.tabby_model = tabbyModels[0]?.id || '';
82 }
83
84 $('#tabby_model').empty();
85 for (const model of tabbyModels) {
86 const option = document.createElement('option');
87 option.value = model.id;
88 option.text = model.id;
89 option.selected = model.id === textgen_settings.tabby_model;
90 $('#tabby_model').append(option);
91 }
92}
93
69export async function loadTogetherAIModels(data) {94export async function loadTogetherAIModels(data) {
70 if (!Array.isArray(data)) {95 if (!Array.isArray(data)) {
71 console.error('Invalid Together AI models data', data);96 console.error('Invalid Together AI models data', data);
@@ -310,6 +335,12 @@ function onOllamaModelSelect() {
310 $('#api_button_textgenerationwebui').trigger('click');335 $('#api_button_textgenerationwebui').trigger('click');
311}336}
312337
338function onTabbyModelSelect() {
339 const modelId = String($('#tabby_model').val());
340 textgen_settings.tabby_model = modelId;
341 $('#api_button_textgenerationwebui').trigger('click');
342}
343
313function onOpenRouterModelSelect() {344function onOpenRouterModelSelect() {
314 const modelId = String($('#openrouter_model').val());345 const modelId = String($('#openrouter_model').val());
315 textgen_settings.openrouter_model = modelId;346 textgen_settings.openrouter_model = modelId;
@@ -641,6 +672,7 @@ export function initTextGenModels() {
641 $('#aphrodite_model').on('change', onAphroditeModelSelect);672 $('#aphrodite_model').on('change', onAphroditeModelSelect);
642 $('#featherless_model').on('change', onFeatherlessModelSelect);673 $('#featherless_model').on('change', onFeatherlessModelSelect);
643 $('#tabby_download_model').on('click', downloadTabbyModel);674 $('#tabby_download_model').on('click', downloadTabbyModel);
675 $('#tabby_model').on('change', onTabbyModelSelect);
644676
645 const providersSelect = $('.openrouter_providers');677 const providersSelect = $('.openrouter_providers');
646 for (const provider of OPENROUTER_PROVIDERS) {678 for (const provider of OPENROUTER_PROVIDERS) {
@@ -671,6 +703,13 @@ export function initTextGenModels() {
671 searchInputCssClass: 'text_pole',703 searchInputCssClass: 'text_pole',
672 width: '100%',704 width: '100%',
673 });705 });
706 $('#tabby_model').select2({
707 placeholder: '[Currently loaded]',
708 searchInputPlaceholder: 'Search models...',
709 searchInputCssClass: 'text_pole',
710 width: '100%',
711 allowClear: true,
712 });
674 $('#model_infermaticai_select').select2({713 $('#model_infermaticai_select').select2({
675 placeholder: 'Select a model',714 placeholder: 'Select a model',
676 searchInputPlaceholder: 'Search models...',715 searchInputPlaceholder: 'Search models...',
public/scripts/textgen-settings.js+7 -1
@@ -180,6 +180,7 @@ const settings = {
180 vllm_model: '',180 vllm_model: '',
181 aphrodite_model: '',181 aphrodite_model: '',
182 dreamgen_model: 'opus-v1-xl/text',182 dreamgen_model: 'opus-v1-xl/text',
183 tabby_model: '',
183 legacy_api: false,184 legacy_api: false,
184 sampler_order: KOBOLDCPP_ORDER,185 sampler_order: KOBOLDCPP_ORDER,
185 logit_bias: [],186 logit_bias: [],
@@ -995,7 +996,7 @@ function tryParseStreamingError(response, decoded) {
995 // No JSON. Do nothing.996 // No JSON. Do nothing.
996 }997 }
997998
998 const message = data?.error?.message || data?.message;999 const message = data?.error?.message || data?.message || data?.detail;
9991000
1000 if (message) {1001 if (message) {
1001 toastr.error(message, 'Text Completion API');1002 toastr.error(message, 'Text Completion API');
@@ -1047,6 +1048,11 @@ export function getTextGenModel() {
1047 return settings.featherless_model;1048 return settings.featherless_model;
1048 case HUGGINGFACE:1049 case HUGGINGFACE:
1049 return 'tgi';1050 return 'tgi';
1051 case TABBY:
1052 if (settings.tabby_model) {
1053 return settings.tabby_model;
1054 }
1055 break;
1050 default:1056 default:
1051 return undefined;1057 return undefined;
1052 }1058 }