nomic-ai / gpt4all

gpt4all: run open-source LLMs anywhere

Home Page:https://gpt4all.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Getting unauthorized trying to use API

andypbaker opened this issue · comments

Tried calling the API from PowerShell -

PS> $body = '{
>> "stream":false,
>> "temperatur":0.6,
>> "max_tokens":100,
>> "model":"wizardlm-13b-v1.2.Q4_0 (3)",
>> "prompt":"
>> what is the mathematical constant PI
>> "
>> }'
Andyb,   DEV-09
05/07/2024 07:40:47
C:\Users\andyb\documents
PS> Invoke-RestMethod -Uri http://127.0.0.1:4891/v1/completions -Method POST -Body $body
Invoke-RestMethod : The remote server returned an error: (401) Unauthorized.
At line:1 char:1
+ Invoke-RestMethod -Uri http://127.0.0.1:4891/v1/completions -Method P ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

This is the error code that results from not having the local server enabled in settings. Without further information, I'll have to assume that's the problem.

Star Player, I knew about the port number but not the local server

for anybody else's benefit it's this setting here -
image

I now get PS> Invoke-RestMethod -Uri http://127.0.0.1:4891/v1/completions -Method POST -Body $body

choices : {@{finish_reason=stop; index=0; logprobs=; references=System.Object[]; text=Pi (Ï) is a fundamental mathematical constant that represents the ratio of a
circle's circumference to its diameter. It is an irrational number, which means it cannot be expressed as a simple fraction and goes on indefinitely without
repeating itself in the following decimal place after the first non-repeating digit. The most commonly}}
created : 1715095170
id : foobarbaz
model : Mistral Instruct
object : text_completion
usage : @{completion_tokens=69; prompt_tokens=19; total_tokens=88}

please close now, and thanks.