karthink / gptel

A simple LLM client for Emacs
GNU General Public License v3.0
1.04k stars 111 forks source link

Empty response from ChatGPT #251

Closed freddez closed 3 months ago

freddez commented 3 months ago

Hello, I've tried my api key with curl, it works, but when I try gptel prompt, I am stuck with an "Empty response" message, and no error.

I am using emacs 29.2 with doom. I've also tried to purge eln-cache with no success.

Edit : It works if I disable gptel-use-curl I'm using curl 8.2.1 on Ubuntu mantic

karthink commented 3 months ago

I tested the latest commit in a sandbox and I'm not able to reproduce this bug.

  1. Did you try deleting and reinstalling the package (as opposed to upgrading)? When the load order changes this kind of thing happens often. If that doesn't work:
  2. Could you try installing gptel in an emacs -q session?

Run

emacs --init-directory /tmp/testdir

Then in Emacs:

(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(package-initialize)

And M-x package-install gptel.


EDIT: You could also try M-x load-file and loading gptel-openai.el manually.

karthink commented 3 months ago

Edit : It works if I disable gptel-use-curl

I suspect it will continue to work with curl if you turn off streaming responses. If none of the above work, could you run the following and test too?

(setq gptel-use-curl t
         gptel-stream nil)
nordlow commented 3 months ago

I have the same problem. I'm registered user having access to 4.0 in the browser. When

(use-package gptel
  :ensure t :defer t
  :custom
  (gptel-api-key "_____"))

with the _____ replaced with my API key I get back

ChatGPT error: (HTTP/2 429) You exceeded your current quota, please check your plan and billing details. For more information on this error, read the docs: https://platform.openai.com/docs/guides/error-codes/api-errors.
karthink commented 3 months ago

I have the same problem. I'm registered user having access to 4.0 in the browser. When

(use-package gptel
  :ensure t :defer t
  :custom
  (gptel-api-key "_____"))

with the _____ replaced with my API key I get back

ChatGPT error: (HTTP/2 429) You exceeded your current quota, please check your plan and billing details. For more information on this error, read the docs: https://platform.openai.com/docs/guides/error-codes/api-errors.

This is a separate issue that's unrelated to gptel. I'm guessing you don't have sufficient credits in your OpenAI billing account.

mmwilbert commented 3 months ago

I also have this problem (empty response) except I am trying to connect to Gemini. To make it more annoying, I can't set either gptel-use-curl or gptel-stream to nil. If I do, when I try to send something I get

error in process sentinel: string-trim-right: Wrong type argument: stringp, nil error in process sentinel: Wrong type argument: stringp, nil.

If they are set to t, I get the empty response. Is there a way to see what curl command is being sent? I'm wondering if that would be informative.

karthink commented 3 months ago

I also have this problem (empty response) except I am trying to connect to Gemini. To make it more annoying, I can't set either gptel-use-curl or gptel-stream to nil. If I do, when I try to send something I get

error in process sentinel: string-trim-right: Wrong type argument: stringp, nil error in process sentinel: Wrong type argument: stringp, nil.

If they are set to t, I get the empty response. Is there a way to see what curl command is being sent? I'm wondering if that would be informative.

  1. Did you upgrade gptel or is it a new/fresh install? If it's after upgrading you can try deleting and reinstalling.
  2. To see what's being sent, you can run (setq gptel-log-level 'debug), then check the *gptel-log* buffer.
karthink commented 3 months ago

@freddez Just pushed a fix for what I'm guessing is the problem. Please update and test.

mmwilbert commented 3 months ago

I deleted and reloaded gptel. I still had (setq gptel-stream nil) in my init, so I got the sentinel error I described earlier. After I changed that, I got Gemini error (HTTP/2 503): Malformed JSON in response.

This was apparently because the model was overloaded, but maybe the error should be different?

I tried it again and got the empty response message. But in fact, the response in gptel-log did not look empty.

Here it is:

{
  "gptel": "response headers",
  "timestamp": "2024-03-15 00:32:47"
}
"HTTP/2 200 \r\ncontent-type: application/json; charset=UTF-8\r\nvary: Origin\r\nvary: X-Origin\r\nvary: Referer\r\ncontent-encoding: gzip\r\ndate: Fri, 15 Mar 2024 04:32:40 GMT\r\nserver: scaffolding on HTTPServer2\r\ncache-control: private\r\nx-xss-protection: 0\r\nx-frame-options: SAMEORIGIN\r\nx-content-type-options: nosniff\r\nserver-timing: gfet4t7; dur=773\r\nalt-svc: h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000\r\n\r"
{
  "gptel": "response body",
  "timestamp": "2024-03-15 00:32:47"
}
[
  {
    "candidates": [
      {
        "content": {
          "parts": [
            {
              "text": "Canine companion; domesticated carnivoran"
            }
          ],
          "role": "model"
        },
        "finishReason": "STOP",
        "index": 0,
        "safetyRatings": [
          {
            "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
            "probability": "NEGLIGIBLE"
          },
          {
            "category": "HARM_CATEGORY_HATE_SPEECH",
            "probability": "NEGLIGIBLE"
          },
          {
            "category": "HARM_CATEGORY_HARASSMENT",
            "probability": "NEGLIGIBLE"
          },
          {
            "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
            "probability": "NEGLIGIBLE"
          }
        ]
      }
    ],
    "promptFeedback": {
      "safetyRatings": [
        {
          "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
          "probability": "NEGLIGIBLE"
        },
        {
          "category": "HARM_CATEGORY_HATE_SPEECH",
          "probability": "NEGLIGIBLE"
        },
        {
          "category": "HARM_CATEGORY_HARASSMENT",
          "probability": "NEGLIGIBLE"
        },
        {
          "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
          "probability": "NEGLIGIBLE"
        }
      ]
    }
  }
]

Just FYI, here's the response when I got the 503 message:

{
  "gptel": "response headers",
  "timestamp": "2024-03-15 00:27:31"
}
"HTTP/2 503 \r\nvary: Origin\r\nvary: X-Origin\r\nvary: Referer\r\ncontent-type: application/json; charset=UTF-8\r\ncontent-encoding: gzip\r\ndate: Fri, 15 Mar 2024 04:27:24 GMT\r\nserver: scaffolding on HTTPServer2\r\ncache-control: private\r\ncontent-length: 135\r\nx-xss-protection: 0\r\nx-frame-options: SAMEORIGIN\r\nx-content-type-options: nosniff\r\nserver-timing: gfet4t7; dur=177\r\nalt-svc: h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000\r\n\r"
{
  "gptel": "response body",
  "timestamp": "2024-03-15 00:27:31"
}
[
  {
    "error": {
      "code": 503,
      "message": "The model is overloaded. Please try again later.",
      "status": "UNAVAILABLE"
    }
  }
]

And thank you for the package!

karthink commented 3 months ago

This was apparently because the model was overloaded, but maybe the error should be different?

This is on the docket for me to fix, see #210.

Will take a look at the other logs soon, thanks for the bug report!

freddez commented 3 months ago
(setq gptel-use-curl t
         gptel-stream nil)

Hi, Yes it works like this

karthink commented 3 months ago
(setq gptel-use-curl t
         gptel-stream nil)

Hi, Yes it works like this

Please update and try with the default settings (i.e. with streaming responses). It should be fixed now.

nordlow commented 3 months ago

Using

(setq gptel-use-curl t
         gptel-stream nil)

I'm still getting

gptel response error: (((HTTP/2 429) insufficient_quota) You exceeded your current quota, please check your plan and billing details. For more information on this error, read the docs: https://platform.openai.com/docs/guides/error-codes/api-errors.) nil

Is another issue?

I am able to use my paid OpenAI account in the browser just now. How do I verify that gptel is picking up my secret key in .authinfo?

stfl commented 3 months ago

I have the same issue.

With streaming I can see the streamed response in the log but I still get the "Emtpy Response" message.

dot not work:

(setq gptel-use-curl t
         gptel-stream nil)

works:

(setq gptel-use-curl nil)
nordlow commented 3 months ago

With

(use-package gptel
  :ensure t :defer t
  :custom
  (gptel-use-curl nil)
  (gptel-stream nil)
  )

followed by M-x gptel and inputting just "Hi" and then M-x gptel-send I get

gptel response error: (((HTTP/1.1 429 Too Many Requests) insufficient_quota) You exceeded your current quota, please check your plan and billing details. For more information on this error, read the docs: https://platform.openai.com/docs/guides/error-codes/api-errors.) nil

. How can I check that gptel is picking up my creds using auth-source?

karthink commented 3 months ago

There are several unconnected issues in this thread so I created new ones and I'm closing this one. Please use your respective threads for further troubleshooting.