tabby icon indicating copy to clipboard operation
tabby copied to clipboard

cUrl Unauthorized

Open gmatht opened this issue 1 year ago • 3 comments

Describe the bug

The suggested cUrl command doesn't work. Nor is there an obvious way to fix it. According to https://tabby.tabbyml.com/docs/extensions/troubleshooting/ we can access TabbyML using cUrl like so:

curl -X 'POST' \
  'http://localhost:8080/v1/completions' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "language": "python",
  "segments": {
    "prefix": "def fib(n):\n    ",
    "suffix": "\n        return fib(n - 1) + fib(n - 2)"
  }
}'

However, this does not return any text, and the headers returned are:

HTTP/1.1 401 Unauthorized
vary: origin, access-control-request-method, access-control-request-headers
access-control-allow-origin: *
access-control-expose-headers: *
content-length: 0
date: Sat, 14 Sep 2024 08:47:34 GMT

TabbyML claims to support OAuth2. From reading the OAuth2 docs, I learned that I am meant to add -H 'Authorization: Bearer auth_...'. Also ripgrep finds Authorization: Bearer in the tabby source code. However, when I add that header I get:

HTTP/1.1 501 Not Implemented
vary: origin, access-control-request-method, access-control-request-headers
access-control-allow-origin: *
access-control-expose-headers: *
content-length: 0
date: Sat, 14 Sep 2024 08:55:01 GMT

I came across an RFC that instead recommended Authorization: Basic auth..., but that also gave a 501. Authorization: auth... instead gave a 401 error.

Information about your version tabby 0.16.1

Information about your GPU

Sat Sep 14 16:57:57 2024
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 555.85                 Driver Version: 555.85         CUDA Version: 12.5     |
|-----------------------------------------+------------------------+----------------------+
| GPU  Name                  Driver-Model | Bus-Id          Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |           Memory-Usage | GPU-Util  Compute M. |
|                                         |                        |               MIG M. |
|=========================================+========================+======================|
|   0  NVIDIA GeForce RTX 4070      WDDM  |   00000000:0B:00.0  On |                  N/A |
|  0%   48C    P2             33W /  200W |    6849MiB /  12282MiB |      1%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+

+-----------------------------------------------------------------------------------------+
| Processes:                                                                              |
|  GPU   GI   CI        PID   Type   Process name                              GPU Memory |
|        ID   ID                                                               Usage      |
|=========================================================================================|
|    0   N/A  N/A      2136    C+G   ...AppData\Roaming\Spotify\Spotify.exe      N/A      |
|    0   N/A  N/A      4536    C+G   ...0_x64__qbz5n2kfra8p0\python3.12.exe      N/A      |
|    0   N/A  N/A      9908    C+G   ...2txyewy\StartMenuExperienceHost.exe      N/A      |
|    0   N/A  N/A     12228    C+G   ...\cef\cef.win7x64\steamwebhelper.exe      N/A      |
|    0   N/A  N/A     14196    C+G   ...on\128.0.2739.79\msedgewebview2.exe      N/A      |
|    0   N/A  N/A     14708    C+G   ...cal\Microsoft\OneDrive\OneDrive.exe      N/A      |
|    0   N/A  N/A     16044    C+G   ...m Files\Mozilla Firefox\firefox.exe      N/A      |
|    0   N/A  N/A     16324    C+G   ...\cef\cef.win7x64\steamwebhelper.exe      N/A      |
|    0   N/A  N/A     17368    C+G   ...on\128.0.2739.67\msedgewebview2.exe      N/A      |
|    0   N/A  N/A     17480    C+G   ...22\Community\Common7\IDE\devenv.exe      N/A      |
|    0   N/A  N/A     19072    C+G   ...al\Discord\app-1.0.9163\Discord.exe      N/A      |
|    0   N/A  N/A     19140    C+G   ...__8wekyb3d8bbwe\Notepad\Notepad.exe      N/A      |
|    0   N/A  N/A     20312    C+G   ...CBS_cw5n1h2txyewy\TextInputHost.exe      N/A      |
|    0   N/A  N/A     20796    C+G   C:\Windows\explorer.exe                     N/A      |
|    0   N/A  N/A     24036    C+G   ...e Stream\96.0.0.0\GoogleDriveFS.exe      N/A      |
|    0   N/A  N/A     24876    C+G   ...cks-services\BlueStacksServices.exe      N/A      |
|    0   N/A  N/A     28116    C+G   ...__8wekyb3d8bbwe\WindowsTerminal.exe      N/A      |
|    0   N/A  N/A     28176    C+G   ...1.0_x64__8wekyb3d8bbwe\Video.UI.exe      N/A      |
|    0   N/A  N/A     29412    C+G   ...crosoft\Edge\Application\msedge.exe      N/A      |
|    0   N/A  N/A     30388      C   C:\bin\llama-server.exe                     N/A      |
|    0   N/A  N/A     31600    C+G   ...nt.CBS_cw5n1h2txyewy\SearchHost.exe      N/A      |
|    0   N/A  N/A     33544    C+G   ...\GOG Galaxy\GalaxyClient Helper.exe      N/A      |
|    0   N/A  N/A     33836    C+G   ...ekyb3d8bbwe\PhoneExperienceHost.exe      N/A      |
|    0   N/A  N/A     34712    C+G   ...Programs\Microsoft VS Code\Code.exe      N/A      |
|    0   N/A  N/A     36132    C+G   ...5n1h2txyewy\ShellExperienceHost.exe      N/A      |
|    0   N/A  N/A     37720    C+G   ...m Files\Mozilla Firefox\firefox.exe      N/A      |
|    0   N/A  N/A     38752    C+G   ...siveControlPanel\SystemSettings.exe      N/A      |
|    0   N/A  N/A     44444    C+G   C:\Program Files\digiKam\digikam.exe        N/A      |
+-----------------------------------------------------------------------------------------+

gmatht avatar Sep 14 '24 09:09 gmatht

Can you provide an example of how to make a request?

I tested this example with HEAD version of main branch.

For example:

curl -X 'POST' \
  'http://localhost:8080/v1/completions' \
  -H 'Authorization: Bearer auth_*****' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "language": "python",
  "segments": {
    "prefix": "def fib(n):\n    ",
    "suffix": "\n        return fib(n - 1) + fib(n - 2)"
  }
}'

I received a response as:

{"id":"cmpl-1188f9d4-2282-46ce-a547-4907e9d6add7","choices":[{"index":0,"text":"    if n <= 1:\n            return n"}]}

Sma1lboy avatar Sep 17 '24 06:09 Sma1lboy

That exact command gives me a 401 error. If I replace the auth_******* with my actual auth, I get a 501 error instead.

On Tue, 17 Sept 2024 at 14:43, Jackson Chen @.***> wrote:

Can you provide an example of how to make a request?

I tested this example with HEAD version of main branch.

For example:

curl -X 'POST'
'http://localhost:8080/v1/completions'
-H 'Authorization: Bearer auth_*****'
-H 'accept: application/json'
-H 'Content-Type: application/json'
-d '{ "language": "python", "segments": { "prefix": "def fib(n):\n ", "suffix": "\n return fib(n - 1) + fib(n - 2)" } }'

I received a response as:

{"id":"cmpl-1188f9d4-2282-46ce-a547-4907e9d6add7","choices":[{"index":0,"text":" if n <= 1:\n return n"}]}

— Reply to this email directly, view it on GitHub https://github.com/TabbyML/tabby/issues/3148#issuecomment-2354678753, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAC7LVMYCZ4536QFKDY6IPTZW7FSRAVCNFSM6AAAAABOGVNI22VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNJUGY3TQNZVGM . You are receiving this because you authored the thread.Message ID: @.***>

-- John C. McCabe-Dansted

gmatht avatar Sep 17 '24 08:09 gmatht

Related: https://github.com/TabbyML/tabby/pull/3152

user agent header is wrongly set to an required field before the fix.

The fix shall go into next patch release.

wsxiaoys avatar Sep 17 '24 14:09 wsxiaoys

released in 0.18

wsxiaoys avatar Oct 18 '24 13:10 wsxiaoys