Skip to content

Commit 0de6faf

Browse files
committed
feat: use version map again for resolving all copilot models
Instead of relying on model_picker_enabled rely on model.version again. This shows newer versions of models and hidden ones. This was removed in favour of model_picker_enabled in past but this approach is way better for usability. Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
1 parent 5e09dd9 commit 0de6faf

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

lua/CopilotChat/config/providers.lua

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ M.copilot = {
176176
local models = vim
177177
.iter(response.body.data)
178178
:filter(function(model)
179-
return model.model_picker_enabled and model.capabilities.type == 'chat'
179+
return model.capabilities.type == 'chat'
180180
end)
181181
:map(function(model)
182182
return {
@@ -186,10 +186,24 @@ M.copilot = {
186186
max_input_tokens = model.capabilities.limits.max_prompt_tokens,
187187
max_output_tokens = model.capabilities.limits.max_output_tokens,
188188
policy = not model['policy'] or model['policy']['state'] == 'enabled',
189+
version = model.version,
189190
}
190191
end)
191192
:totable()
192193

194+
local version_map = {}
195+
for _, model in ipairs(models) do
196+
if not version_map[model.version] or #model.id < #version_map[model.version] then
197+
version_map[model.version] = model.id
198+
end
199+
end
200+
201+
models = vim.tbl_map(function(id)
202+
return vim.tbl_filter(function(model)
203+
return model.id == id
204+
end, models)[1]
205+
end, vim.tbl_values(version_map))
206+
193207
for _, model in ipairs(models) do
194208
if not model.policy then
195209
utils.curl_post('https://api.githubcopilot.com/models/' .. model.id .. '/policy', {

0 commit comments

Comments
 (0)