Display context size for featherless models

417335a19d87aec0af109a9ad777865c7e3c21aa

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

1 files changed, +18 -0Showing whitespace changes
public/scripts/textgen-models.js+18 -0
@@ -242,6 +242,7 @@ export async function loadFeatherlessModels(data) {
242242 return;
243243 }
244244
245+ data.sort((a, b) => a.id.localeCompare(b.id));
245246 featherlessModels = data;
246247
247248 if (!data.find(x => x.id === textgen_settings.featherless_model)) {
@@ -262,6 +263,8 @@ function onFeatherlessModelSelect() {
262263 const modelId = String($('#featherless_model').val());
263264 textgen_settings.featherless_model = modelId;
264265 $('#api_button_textgenerationwebui').trigger('click');
266+ const model = featherlessModels.find(x => x.id === modelId);
267+ setGenerationParamsFromPreset({ max_length: model.context_length });
265268}
266269
267270
@@ -431,6 +434,20 @@ function getAphroditeModelTemplate(option) {
431434 `));
432435}
433436
437+function getFeatherlessModelTemplate(option) {
438+ const model = featherlessModels.find(x => x.id === option?.element?.value);
439+
440+ if (!option.id || !model) {
441+ return option.text;
442+ }
443+
444+ return $((`
445+ <div class="flex-container flexFlowColumn">
446+ <div><strong>${DOMPurify.sanitize(model.name)}</strong> | <span>${model.context_length || '???'} tokens</span></div>
447+ </div>
448+ `));
449+}
450+
434451async function downloadOllamaModel() {
435452 try {
436453 const serverUrl = textgen_settings.server_urls[textgen_types.OLLAMA];
@@ -679,6 +696,7 @@ jQuery(function () {
679696 searchInputPlaceholder: 'Search models...',
680697 searchInputCssClass: 'text_pole',
681698 width: '100%',
699+ templateResult: getFeatherlessModelTemplate,
682700 });
683701 providersSelect.select2({
684702 sorter: data => data.sort((a, b) => a.text.localeCompare(b.text)),