Skip to content

Commit 9ce16d4

Browse files
authored
feat: use model name and versioning for model selection (#1055)
Update model selection logic to use model names with versioning instead of just IDs. This improves user experience by showing more descriptive model names in the selection UI and ensures the latest version of each model is preferred when filtering available models. Also updates the default model to the latest gpt-4o-2024-11-20 version. Related #1052 (comment)
1 parent 340f47e commit 9ce16d4

File tree

4 files changed

+8
-12
lines changed

4 files changed

+8
-12
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ Below are all available configuration options with their default values:
453453

454454
system_prompt = 'COPILOT_INSTRUCTIONS', -- System prompt to use (can be specified manually in prompt via /).
455455

456-
model = 'gpt-4o', -- Default model to use, see ':CopilotChatModels' for available models (can be specified manually in prompt via $).
456+
model = 'gpt-4o-2024-11-20', -- Default model to use, see ':CopilotChatModels' for available models (can be specified manually in prompt via $).
457457
agent = 'copilot', -- Default agent to use, see ':CopilotChatAgents' for available agents (can be specified manually in prompt via @).
458458
context = nil, -- Default context or array of contexts to use (can be specified manually in prompt via #).
459459
sticky = nil, -- Default sticky prompt or array of sticky prompts to use at start of every new chat.

lua/CopilotChat/config.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ return {
5858

5959
system_prompt = 'COPILOT_INSTRUCTIONS', -- System prompt to use (can be specified manually in prompt via /).
6060

61-
model = 'gpt-4o', -- Default model to use, see ':CopilotChatModels' for available models (can be specified manually in prompt via $).
61+
model = 'gpt-4o-2024-11-20', -- Default model to use, see ':CopilotChatModels' for available models (can be specified manually in prompt via $).
6262
agent = 'none', -- Default agent to use, see ':CopilotChatAgents' for available agents (can be specified manually in prompt via @).
6363
context = nil, -- Default context or array of contexts to use (can be specified manually in prompt via #).
6464
sticky = nil, -- Default sticky prompt or array of sticky prompts to use at start of every new chat.

lua/CopilotChat/config/providers.lua

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -186,18 +186,14 @@ M.copilot = {
186186
end)
187187
:totable()
188188

189-
local version_map = {}
189+
local name_map = {}
190190
for _, model in ipairs(models) do
191-
if not version_map[model.version] or #model.id < #version_map[model.version] then
192-
version_map[model.version] = model.id
191+
if not name_map[model.name] or model.version > name_map[model.name].version then
192+
name_map[model.name] = model
193193
end
194194
end
195195

196-
models = vim.tbl_map(function(id)
197-
return vim.tbl_filter(function(model)
198-
return model.id == id
199-
end, models)[1]
200-
end, vim.tbl_values(version_map))
196+
models = vim.tbl_values(name_map)
201197

202198
for _, model in ipairs(models) do
203199
if not model.policy then

lua/CopilotChat/init.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ function M.select_model()
733733
vim.ui.select(choices, {
734734
prompt = 'Select a model> ',
735735
format_item = function(item)
736-
local out = string.format('%s (%s)', item.id, item.provider)
736+
local out = string.format('%s (%s:%s)', item.name, item.provider, item.id)
737737
if item.selected then
738738
out = '* ' .. out
739739
end
@@ -764,7 +764,7 @@ function M.select_agent()
764764
vim.ui.select(choices, {
765765
prompt = 'Select an agent> ',
766766
format_item = function(item)
767-
local out = string.format('%s (%s)', item.id, item.provider)
767+
local out = string.format('%s (%s:%s)', item.name, item.provider, item.id)
768768
if item.selected then
769769
out = '* ' .. out
770770
end

0 commit comments

Comments
 (0)