Skip to content

Commit 7cdc9c1

Browse files
Display copilot multipliers in model list (#1567)
* debug: temporary log file to make sure how is the response * feat(providers): add model billing multiplier support Expose the 'multiplier' field from model billing configuration into the provider definitions. This change allows the plugin to track and display usage cost multipliers for specific LLM models. Changes include: - Updating providers.lua to pull 'multiplier' from billing data. - Updating init.lua to propagate the multiplier to the model selection UI. - Adding a visual indicator in the model picker to show the multiplier. Notable behavior change: The model selection menu will now display billing multipliers, such as '[x2]', next to supported models. Testing: Verify the model selector displays the multiplier correctly when a model has billing information defined: :lua print(vim.inspect(require('CopilotChat.config.providers').copilot)) Check that models without billing info remain unaffected. * feat(model): add fallback indicator for missing multipliers Update the model selection interface to explicitly display 'x not specified' when a model multiplier is undefined. Previously, missing multipliers resulted in no indicator being shown. This change ensures visual consistency in the status line or UI components that list model configurations. Notable change: - The string 'x not specified' will now appear in the indicators table when a multiplier is nil. Testing: - Open the model selection menu and verify that models without a defined multiplier now show the fallback text instead of being empty. * refactor(config): remove debug logging and clean up UI helpers Refactored the provider and UI logic for model selection. What changed: - Removed the log.info call for Copilot models in providers.lua as it added unnecessary noise to the logs. - Simplified the 'select_model' logic in init.lua by removing the conditional fallback for missing multipliers. Notable behavior changes: - Models without a multiplier will no longer show 'x not specified' in the picker list. Testing: - Check that the model picker still renders correctly. - Verify that logs are clean during model fetching. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 137d3bc commit 7cdc9c1

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

lua/CopilotChat/config/providers.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,7 @@ M.copilot = {
655655
tools = model.capabilities.supports.tool_calls,
656656
policy = not model['policy'] or model['policy']['state'] == 'enabled',
657657
version = model.version,
658+
multiplier = model.billing and model.billing.multiplier or nil,
658659
use_responses = use_responses,
659660
-- Carry the base URL into the model so get_url and resolve_model
660661
-- can use it without needing access to the headers again.

lua/CopilotChat/init.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ function M.select_model()
343343
streaming = model.streaming,
344344
tools = model.tools,
345345
reasoning = model.reasoning,
346+
multiplier = model.multiplier,
346347
selected = model.id == M.config.model,
347348
}
348349
end, models)
@@ -358,6 +359,9 @@ function M.select_model()
358359
out = '* ' .. out
359360
end
360361

362+
if item.multiplier ~= nil then
363+
table.insert(indicators, 'x' .. tostring(item.multiplier))
364+
end
361365
if item.provider then
362366
table.insert(indicators, item.provider)
363367
end

0 commit comments

Comments
 (0)