-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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: Add GitHub Copilot as model provider #2227
Comments
Seems like it's a standard OpenAI-style API, with an token that is refreshed periodically using a long-lived refrehs token, OAuth style. The tricky part seems to be actually getting the refresh token in the first place. All the Neovim plugins rely on authenticating through The good news is that the refresh token doesn't really seem to ever expire. My token at If we're ok with having Aider pull its refresh token in a similar way, then this should be pretty easy to implement, but the initial setup for the user may be a bit of a hassle. For additional reference, here's Avante.nvim's implementation which is pretty similar to the one in CodeCompanion. |
Great, that doesn't look too complicated, thanks. Haven't looked into it, is the JS language server the only way to get the token? Anything we can do with these: https://github.com/settings/tokens? |
This code can get the token from github api. Note that it register itself as copilot.vim, as I don't know if copilot allows for other third part clients.
|
Thanks for trying aider and filing this issue. This sounds like it would require using a undocumented API or abusing a documented API for an off-label purpose? |
@RodolfoCastanheira Great, that's looks like a simple solution. We should have all the pieces then? @paul-gauthier I don't know, whether it's undocumented or would be off-label. I mainly forwarded the idea from Cline (see op) and also made the same suggestion to LiteLLM (see mention above). |
I think there's a decent argument to be made that it's acceptable, if not officially supported.
The main difference between the extensions and what Aider (and the other existing, unofficial integrations) would do is around the auth token management. For extensions the tokens are automatically managed for you and the short-lived access token is passed to each call to the extension code. But in both cases, it's using an OAuth style flow that authenticates as your Github user, and that token stops working if you stop paying. I can understand the worry for a high-profile project like Aider doing an integration like this. Hopefully this helps clear it up some. |
Aider relies on litellm for integrations to LLM API providers, so I think it would be best to focus on getting it implemented there. That said, it seems unclear that Copilot would sanction this sort of use of their API. So I'm not sure it would be appropriate for litellm (or aider) to add this sort of support. I'm happy to be shown something that would clarify that this would be a legitimate use of the copilot API. |
I've checked the usage policy[1] and the official forum, but couldn't find anything that says third-party integrations are either allowed or forbidden. When someone asks for help with an unofficial integration, the GitHub staff just lets the community respond (they don't jump in and say "no, you can't do that" or "we don't support that"). It seems like personal use for coding is okay, as long as you're not getting out of hand. And it looks like these unofficial integrations are tolerated, even if this usage is not officially endorsed. The silence on the matter seems like a deliberate choice. |
Here's the official documentation on how agents should use their API: https://docs.github.com/en/copilot/building-copilot-extensions/building-a-copilot-agent-for-your-copilot-extension/using-copilots-llm-for-your-agent I think it's quite a strong sign that they allow such usage. |
I'm labeling this issue as stale because it has been open for 2 weeks with no activity. If there are no additional comments, I will close it in 7 days.Note: A bot script made these updates to the issue. |
Any update? |
The docs above explain how a GitHub Copilot Agent can access the API. I see no indication that 3rd party tools like aider can use it. Please correct me if I am misunderstanding the docs. |
Please correct me if I'm wrong, but my understanding is that in worst-case scenario Aider would need its "gh-copilot-proxy-agent" that would basically proxy requests to LLM from Aider. Main point is that Aider is a great agent and it would be in the spirit of their manual to make it compatible with their APIs one way or another. |
I'm labeling this issue as stale because it has been open for 2 weeks with no activity. If there are no additional comments, I will close it in 7 days. Note: A bot script made these updates to the issue. |
I vote in favor. This integration will be really useful for those who already have a Copilot subscription. Regarding “unofficial” integrations, Zed offers Copilot integration for both code completion and chat. They utilize copilot.vim. |
I also want to use the github copilot model from aider. |
I'm labeling this issue as stale because it has been open for 2 weeks with no activity. If there are no additional comments, I will close it in 7 days. Note: A bot script made these updates to the issue. |
Could we get any clues from how CopilotC-Nvim/CopilotChat.nvim implements chat, and use that as a basis for an aider provider? |
It's as described in a few comments earlier in this thread. They all piggyback on the official extension to do the auth or have extracted the code from it to do so, and then it's just a normal HTTP endpoint that looks like OpenAI with an OAuth token to be refreshed periodically. From a technical standpoint there's nothing particularly challenging. But Paul's concern here, as I understand it, is that all the Neovim plugins are using Copilot in a way that is perhaps tolerated but not officially approved, and adding support to Aider would be doing the same. And Aider is
so he's not totally comfortable with it. (Apologies if I'm incorrectly representing his stance here.) That aside, the integration would also need to go into LiteLLM since Aider is just using that for its LLM client. There's an issue for that here. |
Issue
Hello!
Please add GitHub Copilot as model provider.
Should be possible like this: https://github.com/olimorris/codecompanion.nvim/blob/5c5a5c759b8c925e81f8584a0279eefc8a6c6643/lua/codecompanion/adapters/copilot.lua
Idea taken from: cline/cline#660
Thank you!
Version and model info
No response
The text was updated successfully, but these errors were encountered: