[OpenRouter] Show API prices in list/description

This commit is contained in:
spacegeek69 2023-08-10 06:11:03 +02:00
parent 0ede3894e2
commit f9db8eee67
1 changed files with 4 additions and 1 deletions

View File

@ -722,10 +722,13 @@ function saveModelList(data) {
$('#model_openrouter_select').empty(); $('#model_openrouter_select').empty();
$('#model_openrouter_select').append($('<option>', { value: openrouter_website_model, text: 'Use OpenRouter website setting' })); $('#model_openrouter_select').append($('<option>', { value: openrouter_website_model, text: 'Use OpenRouter website setting' }));
model_list.forEach((model) => { model_list.forEach((model) => {
let prompt_max_price = parseFloat(model.pricing.prompt) * model.context_length;
let price_rounded = (Math.round(prompt_max_price * 1000) / 1000).toFixed(3);
let model_description = `${model.id} \$${price_rounded} (${model.context_length})`;
$('#model_openrouter_select').append( $('#model_openrouter_select').append(
$('<option>', { $('<option>', {
value: model.id, value: model.id,
text: model.id, text: model_description,
})); }));
}); });
$('#model_openrouter_select').val(oai_settings.openrouter_model).trigger('change'); $('#model_openrouter_select').val(oai_settings.openrouter_model).trigger('change');