llm icon indicating copy to clipboard operation
llm copied to clipboard

Support for using GH Copilot API

Open meain opened this issue 11 months ago • 13 comments

Wondering how hard it would be to add support for APIs used by GH Copilot. This helps us make use of Copilot subscription with other Emacs llm frontends. chep/copilot-chat.el does make use of this if you need a reference. With the somewhat recent addition of 3.5 Sonnet, it seems like a solid option. Roo Code seems to have done something similar recently and got a good reception(from what I saw on Reddit).

meain avatar Jan 22 '25 05:01 meain

Is https://github.com/ahyatt/llm/pull/113 what you are looking for? This is fairly close to finished right now.

ahyatt avatar Jan 22 '25 05:01 ahyatt

GitHub models is different. It is a separate model inference API provided by GH and is not related to the Copilot subscription. Also, it does not provide access to Sonnet and has shorter context window limits for most models AFAICT.

meain avatar Jan 22 '25 05:01 meain

Thanks for the clarification. I looked around, and it doesn't look like there are docs for the API available. That doesn't mean it's not possible, but I'd have to separately reverse-engineer it, which will take some time. Because the llm package is FSF licensed, I can't just go off someone else's code.

That probably isn't something I'm going to have time for, but if there's anyone that does have FSF paperwork done, and does want to take this on, I think it'd be a reasonable thing to add. However, the lack of an API docs may mean that Github intends to make breaking changes, which is a risk factor here.

ahyatt avatar Jan 24 '25 05:01 ahyatt

Because the llm package is FSF licensed, I can't just go off someone else's code.

The chep/copilot-chat package mentioned above is MIT licensed, and MIT license is considered as an FSF compatible, meaning it can be used, bundled and distributed together with GPL code.

You are right, it may be that their API will change, but I doubt that the pace of change should be big, since there are already a lot of plugins that would break in that case.

Having support for GH Copilot would be really nice, since GH is, to my knowledge, the only AI tool that can be used free of cost for the maintainers of Open-Source projects.

markokocic avatar Jan 24 '25 09:01 markokocic

Thanks for the clarification. I'll look into this; a lot will depend on how easy it is for me to test this. I have a Github Copilot account, but whether that lets me use this functionality I don't know.

ahyatt avatar Jan 25 '25 20:01 ahyatt

This interesting to me as well since they recently started to provide a free contingent. I use LLMs sparingly and maybe that would be enough for my usage. Currently I use the ChatGPT API and charged it with 15$ in December and still haven't used all of it.

Nebucatnetzer avatar Feb 20 '25 12:02 Nebucatnetzer

I use LLMs sparingly and maybe that would be enough for my usage.

If you only use it sparingly and don't care about sonnet, GitHub models in https://github.com/ahyatt/llm/pull/113 should be good enough. It has a pretty generous free tier.

@Nebucatnetzer

meain avatar Feb 20 '25 12:02 meain

Ah I didn’t know we could use those for free as well. Thank you for letting me know.

Nebucatnetzer avatar Feb 20 '25 13:02 Nebucatnetzer

FYI, gptel now does support copilot. Ref: https://github.com/karthink/gptel/blob/master/gptel-gh.el

meain avatar Jun 25 '25 03:06 meain

Thanks for the info. I'll take a look at this again soon (also, if someone with FSF paperwork wanted to make a contribution, that of course would be welcome).

ahyatt avatar Jun 28 '25 02:06 ahyatt

I took a look at this a few weeks ago, and how to get authentication working is pretty undocumented. While I could copy what happens in gptel, because this is FSF code, the FSF can't just copy non-FSF-copyrighted code without an assignment (I think).

What could happen, though, is that we could copy it and put it not under FSF copyright but under a different copyright, and make it available through Non-GNU ELPA or MELPA.

ahyatt avatar Aug 13 '25 01:08 ahyatt

Wondering if it would be enough to get consent from the original authors of the file as well as the project maintainers to make this part of llm under a GPL license. Seems like the file was touch by 5 folks including the maintainer.

meain avatar Aug 13 '25 04:08 meain

That would require them to sign the FSF paperwork, if they haven't already. It's possible! But at that point, I'd probably just ask them to sign the FSF paperwork and adapt it themselves to this library. https://github.com/kiennq is the primary author, and I think only they would be sufficient to make this happen.

ahyatt avatar Aug 13 '25 14:08 ahyatt