Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: implement copilot provider #52

Open
1 task done
xquangdang opened this issue Feb 12, 2025 · 4 comments
Open
1 task done

feature: implement copilot provider #52

xquangdang opened this issue Feb 12, 2025 · 4 comments
Labels
enhancement New feature or request

Comments

@xquangdang
Copy link

Did you check the docs?

  • I have read all the docs

Is your feature request related to a problem? Please describe.

Copilot support would be nice since it support multiple models and doesn't have limit usage on non-free plan.

Describe the solution you'd like

Add support for copilot provider

Describe alternatives you've considered

Avante, copilotchat

Additional context

Copilot just drop an SDK on npm: https://www.npmjs.com/package/@github/copilot-language-server

@xquangdang xquangdang added the enhancement New feature or request label Feb 12, 2025
@dlants
Copy link
Owner

dlants commented Feb 12, 2025

So the linked repo is the LSP for copilot, which exposes a fairly different interface than magenta uses currently. Specifically, there's no way to provide a system prompt or define tools, or to force a tool invocation.

As such this will likely be quite challenging to implement, as one would have to roll their own tool specification and parsing.

I'll leave this issue open though, so we can track copilot and whether they ever get around to exposing more of a direct API (though I doubt they will since I'm not sure what would differentiate their API from the underlying foundation models they use).

@dlants
Copy link
Owner

dlants commented Feb 12, 2025

Copilot did lunch agent mode recently, which should use a similar sort of API as magenta does. I wonder if that code is open-source? It would be useful to see how the vscode extension integrates with the copilot api.

@angrypie
Copy link

There are a few projects that implement a generic AI LSP. Maybe it’s worth considering how it could be useful.

https://github.com/SilasMarvin/lsp-ai

https://github.com/huggingface/llm-ls

@morquade
Copy link

morquade commented Mar 24, 2025

Specifically, there's no way to provide a system prompt or define tools, or to force a tool invocation.

Copilot now does support tools. It works using an openai compatible api (to an extent, I'm not sure what is all supported, but tools are). Using the chat/completions api you can just send the tools as outlined on openai's api spec.

One caveat to the above is that copilot does not support the text options 'auto' and 'required' for the 'tool_choice' field as far as I can tell. It does however work if you pass in an object indicating what function it must use to force a tool. (Also detailed on the api spec).

Tool forcing unfortunately seems to ONLY work for gpt as a backend. Claude, and gemini will call tools, but the tool_choice field doesn't seem to do anything in my tests. However, using a different model just requires changing the 'model' key on the api call, so anytime I tool needs to be forced you could just use gpt as the backing model, and let the users specify whatever model they want for anything else.

As for the system prompt you should be able to supply a message with the role system to achieve that.

Here is an example of what a request forcing a tool might look like

{
  "messages": [
    {
      "role": "system",
      "content": "My system prompts"
    },
    {
      "role": "user",
      "content": "Can you tell me the weather in Seattle in the US?"
    },
  ],
  "model": "gpt-4o",
  "max_tokens": 4096,
  "tools": [
    {
      "type": "function",
      "function": {
        "name": "get_weather",
        "description": "Get current temperature for a given location.",
        "parameters": {
          "type": "object",
          "properties": {
            "location": {
              "type": "string",
              "description": "City and country e.g. Bogotá, Colombia",
            }
          },
        }
      }
    }
  ],
  "tool_choice": {
    "type": "function",
    "function": {
      "name": "get_weather"
    }
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants