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

What token to use for Github #502

Open
kidmose opened this issue Dec 10, 2024 · 3 comments
Open

What token to use for Github #502

kidmose opened this issue Dec 10, 2024 · 3 comments
Labels
question Further information is requested

Comments

@kidmose
Copy link

kidmose commented Dec 10, 2024

Briefly describe what you are trying to do

Set up gptel to use Github Copilot

  1. Installed gptel with package-install

  2. Created token from https://github.com/settings/tokens (Tried both "classic" and "fine-grained")

  3. Set up gptel in emacs, init.el:

     (use-package gptel
       :ensure t
       :custom
       (gptel-model 'gpt-4o)
       (gptel-log-level 'debug)
       (gptel-backend
        (gptel-make-openai "Github Models"
                           :host "models.inference.ai.azure.com"
                           :endpoint "/chat/completions"
                           :stream t
                           :key "<REDACTED>"
                           :models '(gpt-4o))))
    
  4. Started gptel buffer: M-x gptel

  5. Selected default (I.e. "Github Models" from above)

  6. Entered prompt and press C-c RET

Expected: Some response from the LLM, entered into the buffer.

Received:

  • Nothing in gptel buffer (*Github Models*)
  • Error in *gptel-log* (full content below): 401 Your account type is not currently supported

Is there anyone able to provide some guidance on what I am missing here? (Apparently some permission/role from my GH org. but which?)
Would be greatly appreciated :)

Additional context
Emacs version: GNU Emacs 28.2
Operating system: Debian on 12 on WSL

** gptel.log **

{
  "gptel": "request headers",
  "timestamp": "2024-12-10 15:56:10"
}
{
  "Content-Type": "application/json",
  "Authorization": "Bearer <REDACTED>"
}
{
  "gptel": "request body",
  "timestamp": "2024-12-10 15:56:10"
}
{
  "model": "gpt-4o",
  "messages": [
    {
      "role": "system",
      "content": "You are a large language model living in Emacs and a helpful assistant. Respond concisely."
    },
    {
      "role": "user",
      "content": "hi"
    }
  ],
  "stream": true,
  "temperature": 1.0
}
{"gptel": "request Curl command", "timestamp": "2024-12-10 15:56:10"}
curl \
--disable \
--location \
--silent \
--compressed \
-XPOST \
-y300 \
-Y1 \
-D- \
-w\(<REDACTED>\ .\ \%\{size_header\}\) \
-d\{\"model\"\:\"gpt-4o\"\,\"messages\"\:\[\{\"role\"\:\"system\"\,\"content\"\:\"You\ are\ a\ large\ language\ model\ living\ in\ Emacs\ and\ a\ helpful\ assistant.\ Respond\ concisely.\"\}\,\{\"role\"\:\"user\"\,\"content\"\:\"hi\"\}\]\,\"stream\"\:true\,\"temperature\"\:1.0\} \
-HContent-Type\:\ application/json \
-HAuthorization\:\ Bearer\ <REDACTED> \
https\://models.inference.ai.azure.com/chat/completions
{
  "gptel": "response headers",
  "timestamp": "2024-12-10 15:56:11"
}
"HTTP/2 401 \r\ndate: Tue, 10 Dec 2024 14:56:11 GMT\r\ncontent-type: application/json; charset=utf-8\r\nx-ms-error-code: unauthorized\r\nrequest-context: appId=\r\nstrict-transport-security: max-age=31536000; includeSubDomains; preload\r\nx-content-type-options: nosniff\r\nx-aml-cluster: vienna-eastus2-02\r\nx-request-time: 0.090\r\n\r"
{
  "gptel": "response body",
  "timestamp": "2024-12-10 15:56:11"
}
{
  "error": {
    "code": "unauthorized",
    "message": "Your account type is not currently supported",
    "details": "Your account type is not currently supported"
  }
}
@kidmose kidmose added the question Further information is requested label Dec 10, 2024
@kidmose
Copy link
Author

kidmose commented Dec 12, 2024

I believe these are the relevant settings: https://github.com/settings/copilot (screenshot below).
My guess is that it is "Copilot in github.com" that the above config refers to (models.inference.ai.azure.com/chat/completions) so that needs to be enabled,
... or I need to figure out how to use e.g. the "Copilot Chat in the IDE" API instead.

image

@kidmose
Copy link
Author

kidmose commented Dec 12, 2024

Getting "Copilot on github.com" enabled, I was able to progress to a different error: 401: Bad credentials
This seems to strongly suggest that it is the "Copilot on github.com" feature that needs to be enabled for using https://models.inference.ai.azure.com/chat/completions .

I tried to create a classic token, with "copilot" permission; gives 401 Bad credentials
and i tried a fine-grained token, with "Read access to Copilot Chat" and "Read access to Copilot Editor Context"´; also 401 Bad credentials

Any inputs on what permission are necessary (or any hints, what so ever) is much appreciated :)

@gs-101
Copy link
Contributor

gs-101 commented Dec 16, 2024

Hello, I'm the one who implemented the GitHub support for gptel (see #386).

Sorry if the current description is misleading, but it only supports GitHub Models (here is a blog post about it), which basically exposes APIs for multiple LLMs, so GitHub users can interact with them. I use it with that and it works prefectly.

For Copilot, there's copilot.el + copilot-chat.el

For use with gptel, maybe someone with access to it could extend the GitHub support (but for it to be good I think completion support would have to be implemented).

EDIT 1: As for token permissions, the token works without any of them ticked
EDIT 2: Nevermind the lack of access to Copilot, it's free now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants