diff --git a/public/css/select2-overrides.css b/public/css/select2-overrides.css index f3cc9356a..cdab229d8 100644 --- a/public/css/select2-overrides.css +++ b/public/css/select2-overrides.css @@ -107,6 +107,12 @@ position: relative; } +.select2-results .select2-results__option--group { + color: var(--SmartThemeBodyColor); + background-color: var(--SmartThemeBlurTintColor); + position: relative; +} + /* Customize the hovered option list item */ .select2-results .select2-results__option--highlighted.select2-results__option--selectable { color: var(--SmartThemeBodyColor); @@ -114,12 +120,20 @@ opacity: 1; } +.select2-results__option.select2-results__option--group::before { + display: none; +} + /* Customize the option list item */ .select2-results__option { padding-left: 30px; /* Add some padding to make room for the checkbox */ } +.select2-results .select2-results__option--group .select2-results__options--nested .select2-results__option { + padding-left: 2em; +} + /* Add the custom checkbox */ .select2-results__option::before { content: ''; diff --git a/public/scripts/openai.js b/public/scripts/openai.js index 6d354ef17..8ac693cb9 100644 --- a/public/scripts/openai.js +++ b/public/scripts/openai.js @@ -62,6 +62,7 @@ import { formatInstructModePrompt, formatInstructModeSystemPrompt, } from './instruct-mode.js'; +import { isMobile } from './RossAscends-mods.js'; export { openai_messages_count, @@ -1298,6 +1299,25 @@ function getChatCompletionModel() { } } +function getOpenRouterModelTemplate(option){ + const model = model_list.find(x => x.id === option?.element?.value); + + if (!option.id || !model) { + return option.text; + } + + let tokens_dollar = Number(1 / (1000 * model.pricing?.prompt)); + let tokens_rounded = (Math.round(tokens_dollar * 1000) / 1000).toFixed(0); + + const price = 0 === Number(model.pricing?.prompt) ? 'Free' : `${tokens_rounded}k t/$ `; + + return $((` +
+
${DOMPurify.sanitize(model.name)} | ${model.context_length} ctx | ${price}
+
+ `)); +} + function calculateOpenRouterCost() { if (oai_settings.chat_completion_source !== chat_completion_sources.OPENROUTER) { return; @@ -1321,7 +1341,7 @@ function calculateOpenRouterCost() { } function saveModelList(data) { - model_list = data.map((model) => ({ id: model.id, context_length: model.context_length, pricing: model.pricing, architecture: model.architecture })); + model_list = data.map((model) => ({ ...model })); model_list.sort((a, b) => a?.id && b?.id && a.id.localeCompare(b.id)); if (oai_settings.chat_completion_source == chat_completion_sources.OPENROUTER) { @@ -1376,16 +1396,10 @@ function appendOpenRouterOptions(model_list, groupModels = false, sort = false) $('#model_openrouter_select').append($('