Closed trekta closed 9 months ago
(setq gptel--debug t)
Thanks for the quick response! Here is the output of gptel-error:
HTTP/2 401 date: Wed, 24 Jan 2024 04:52:40 GMT content-length: 15 access-control-allow-origin: * set-cookie: Host-next-auth.csrf-token=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx; Path=/; HttpOnly; Secure; SameSite=Lax set-cookie: Secure-next-auth.callback-url=https%3A%2F%2Fapi.together.xyz; Path=/; HttpOnly; Secure; SameSite=Lax etag: "e8oxfpna2sf" cf-cache-status: DYNAMIC server: cloudflare cf-ray: 84a5ab15de48901e-FRA alt-svc: h3=":443"; ma=86400
Missing API key(xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx . 560)
Looks like the API key isn't being read.
How are you setting it here:
:key "xxxxxxxxxredactedxxxxxxxxxxx" ;can be a function that returns the key
(gptel-backend-key gptel-backend)
(gptel--get-api-key)
The result of the first form should be whatever you set :key
to above, and the second should give you the actual API key. Does this work?the :key value is set as string/plain text.
I ran both commands thru eval-expression
and they both output the correct api key as plain text surrounded by quotation marks.
I tried setting the together.ai API key to a string (as you do) but couldn't reproduce the issue. My config is identical to yours.
Could you set gptel--debug
to true again, and paste whatever is added to the messages buffer here? Instead of the gptel-error
buffer, I mean. Be sure to remove your API key from the message.
this is the message buffer after setting gtpel--debug t
Querying TogetherAI... ("--disable" "--location" "--silent" "--compressed" "-XPOST" "-y300" "-Y1" "-D-" "-w(bd9e8774d6f4e1e1d4225af5d65702dd . %{size_header})" "-d{\"model\":\"togethercomputer/llama-2-70b-chat\",\"messages\":[{\"role\":\"system\",\"content\":\"You are a large language model living in Emacs and a helpful assistant. Respond concisely.\"},{\"role\":\"user\",\"content\":\"hi\"}],\"stream\":false,\"temperature\":1.0,\"max_tokens\":500}" "-HContent-Type: application/json" "https://api.together.xyz/v1/chat/completions") ChatGPT response error: ((HTTP/2 401) Malformed JSON in response.) Malformed JSON in response
correct me if I am wrong but I dont see an API key in that query :/
Your API key is not being sent at all. Please update gptel.
Updating did the job. I feel stupid now. Sorry to waste your time and thanks for the quick and easy help you provided. not sure if related but jsonrpc updated aswell..
Updating did the job. I feel stupid now. Sorry to waste your time and thanks for the quick and easy help you provided. not sure if related but jsonrpc updated aswell..
No worries, I should have pegged it after the first couple of messages. jsonrpc is not a dependency of gptel (direct or transitive) so it's unrelated.
(I really need to add better logging to gptel to catch these issues, this serves as a good reminder.)
I'm seeing the same issue. I think it started after adding the key
default to gptel-make-openai
.
gptel-backend
#s(gptel-openai "Anyscale" "api.endpoints.anyscale.com" #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_9> "https" t "/v1/chat/completions" nil ("meta-llama/Llama-2-7b-chat-hf" "meta-llama/Llama-2-13b-chat-hf" "meta-llama/Llama-2-70b-chat-hf" "codellama/CodeLlama-34b-Instruct-hf" "mistralai/Mistral-7B-Instruct-v0.1" "mistralai/Mixtral-8x7B-Instruct-v0.1" "HuggingFaceH4/zephyr-7b-beta" "Open-Orca/Mistral-7B-OpenOrca") "https://api.endpoints.anyscale.com/v1/chat/completions")
(gptel-backend-key gptel-backend)
nil
@ryankask Your gptel-backend does not include a key field.
@karthink You are right. I misread a recent commit and thought that the key argument had a default (ie (key 'gptel-api-key) ) but it’s the headers argument that now has a default.
I use the gptel-api-key function for the custom open ai backends I’ve created so that could be a useful default too.
I use the gptel-api-key function for the custom open ai backends I’ve created so that could be a useful default too.
This cannot be a default since there are openAI-compatible local APIs (llama.cpp and gpt4all among others) that do not require an api key. Setting it to gptel-api-key
by default will cause an error of the opposite kind from yours.
hey I am trying to use gptel with together.ai thru the gptel-make-openai function. When calling
gptel-send
using this backend I get this error:this is my use-package declaration; that so far worked well for the other two defined backends:
any help is appreciated as I cant rule out errors on my side. thanks in advance