Display context size for featherless models
| @@ -242,6 +242,7 @@ export async function loadFeatherlessModels(data) { | |||
| 242 | return; | 242 | return; |
| 243 | } | 243 | } |
| 244 | 244 | ||
| 245 | data.sort((a, b) => a.id.localeCompare(b.id)); | ||
| 245 | featherlessModels = data; | 246 | featherlessModels = data; |
| 246 | 247 | ||
| 247 | if (!data.find(x => x.id === textgen_settings.featherless_model)) { | 248 | if (!data.find(x => x.id === textgen_settings.featherless_model)) { |
| @@ -262,6 +263,8 @@ function onFeatherlessModelSelect() { | |||
| 262 | const modelId = String($('#featherless_model').val()); | 263 | const modelId = String($('#featherless_model').val()); |
| 263 | textgen_settings.featherless_model = modelId; | 264 | textgen_settings.featherless_model = modelId; |
| 264 | $('#api_button_textgenerationwebui').trigger('click'); | 265 | $('#api_button_textgenerationwebui').trigger('click'); |
| 266 | const model = featherlessModels.find(x => x.id === modelId); | ||
| 267 | setGenerationParamsFromPreset({ max_length: model.context_length }); | ||
| 265 | } | 268 | } |
| 266 | 269 | ||
| 267 | 270 | ||
| @@ -431,6 +434,20 @@ function getAphroditeModelTemplate(option) { | |||
| 431 | `)); | 434 | `)); |
| 432 | } | 435 | } |
| 433 | 436 | ||
| 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 | |||
| 434 | async function downloadOllamaModel() { | 451 | async function downloadOllamaModel() { |
| 435 | try { | 452 | try { |
| 436 | const serverUrl = textgen_settings.server_urls[textgen_types.OLLAMA]; | 453 | const serverUrl = textgen_settings.server_urls[textgen_types.OLLAMA]; |
| @@ -679,6 +696,7 @@ jQuery(function () { | |||
| 679 | searchInputPlaceholder: 'Search models...', | 696 | searchInputPlaceholder: 'Search models...', |
| 680 | searchInputCssClass: 'text_pole', | 697 | searchInputCssClass: 'text_pole', |
| 681 | width: '100%', | 698 | width: '100%', |
| 699 | templateResult: getFeatherlessModelTemplate, | ||
| 682 | }); | 700 | }); |
| 683 | providersSelect.select2({ | 701 | providersSelect.select2({ |
| 684 | sorter: data => data.sort((a, b) => a.text.localeCompare(b.text)), | 702 | sorter: data => data.sort((a, b) => a.text.localeCompare(b.text)), |