Skip to content

":Copilot model" fails with "Copilot: Could not retrieve completions models" #305

Description

@giner

The current implementation seems to rely on model_picker_enabled being true however it's false for the only completion mode in use: gpt-41-copilot.

What I expect to see from :Copilot model:

Copilot: Current/only completions model is GPT-4.1 Copilot (gpt-41-copilot)

What I see instead:

Copilot: Could not retrieve completions models

Here is a minimal fix which makes it work:

diff --git a/autoload/copilot.vim b/autoload/copilot.vim
index dfdc443..936e975 100644
--- a/autoload/copilot.vim
+++ b/autoload/copilot.vim
@@ -774,7 +774,7 @@ function! s:commands.panel(opts) abort
 endfunction
 
 function! s:FmtModel(model) abort
-  return a:model.modelName . ' (' . a:model.id . ')'
+  return a:model.name . ' (' . a:model.id . ')'
 endfunction
 
 function! s:commands.model(opts) abort
@@ -782,11 +782,11 @@ function! s:commands.model(opts) abort
     return
   endif
   let client = copilot#Client()
-  let response = client.Request('copilot/models', {}).Wait()
+  let response = client.Request('copilot/models/getModelMetadataList', {}).Wait()
   if response.status ==# 'error'
     return 'echoerr ' . string('Copilot: Error retrieving completions models: ' . response.error.message)
   endif
-  let models = filter(response.result, { _, m -> index(m.scopes, 'completion') >= 0 })
+  let models = filter(response.result.models, { _, m -> m.capabilities.type ==# 'completion' })
   if len(models) == 0
     echo 'Copilot: Could not retrieve completions models'
   elseif len(models) == 1

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions