karthink / gptel

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

Query error setting default language model to gpt-4 #84

Closed djs42012 closed 11 months ago

djs42012 commented 1 year ago

Hi karthink,

I am trying to set gpt-4 as the default language model by doing the following (after! gptel (setq! gptel-model "gpt-4")) but receive the following error when submitting a query ChatGPT error: (HTTP/2 404) The model: 'gpt-4' does not exist. I've confirmed the variable is properly set, just as if I'd used the interactive menu, which does not yield any issue when submitting a query after selecting gpt-4as the model.

Ypot commented 1 year ago

Do you have an API for gpt4?

https://openai.com/waitlist/gpt-4-api

djs42012 commented 1 year ago

Do you have an API for gpt4?

https://openai.com/waitlist/gpt-4-api

Yes. Everything works just fine if I set the language model manually.

For context my full config for the mode is this:


(after! gptel
  (setq! gptel-api-key (my/lookup-password :host "openai.com")
         gptel-default-mode 'org-mode
         gptel-prompt-prefix-alist  '((markdown-mode . "### ")
                                     (org-mode . "* ")
                                     (text-mode . "### "))
         gptel-model "gpt-4"
         ))
djs42012 commented 1 year ago

For anyone interested, this is my current workaround to set the default model to gpt-4

(after! gptel
  (defun my/use-gpt-4-macro ()
    "lauch gpt-4"
    (interactive)
    (fset 'launch-gpt-4
          (kmacro-lambda-form [?  ?u ?\C-c return ?m ?4 return ?\C-g] 0 "%d"))
    (launch-gpt-4))
  (defadvice! launch-gptel-into-gpt-4 (&rest /)
    :after #'gptel
    (my/use-gpt-4-macro)
    ))

A bit of a hack but the expected behavior is there.

Even changing (defcustom gptel-model "gpt-3.5-turbo" to (defcustom gptel-model "gpt-4" in gptel.el did not have an effect.

karthink commented 1 year ago

gptel-model is a buffer-local variable, since you might want different concurrent sessions to use different models (this is especially true as I add support for more models).

So try

(after! gptel
 (setq! gptel-api-key (my/lookup-password :host "openai.com")
        gptel-default-mode 'org-mode
        gptel-prompt-prefix-alist  '((markdown-mode . "### ")
                                    (org-mode . "* ")
                                    (text-mode . "### ")))
 (setq-default gptel-model "gpt-4"))

(I don't know what setq! does.)

Another option is to use the customize interface to set gptel-model, or use custom-set-variables.

djs42012 commented 1 year ago

Thanks for the help. Unfortunately, I am getting the same error even with your suggestions. After posting about my kbd macro fix last night I incidentally updated the package running a doom sync -u, and can now no longer get gpt-4 to work under any circumstances. I am getting the same error as in the original post. So I’m not sure what to make here.

As an aside, I was using setq! by accident, but according to the docs setq! can be used as a drop-in replacement for setq and *should* be used instead of setopt. Luckily for me. Anyways, I changed it before trying anything else, just to be certain.

Thanks again, and let me know if I can provide anything else.

EDIT: I can still use other models via the API and gpt-4 on the web so I don't suspect it's an issue with the account.

karthink commented 1 year ago

@djs42012 Sorry, I'm not familiar with Doom emacs. It looks like an issue with state, so the most I can recommend is reinstalling gptel.

Perhaps a Doom emacs user can provide help...

karthink commented 11 months ago

@djs42012 Were you able to resolve the issue with setq! or with your OpenAI account?

djs42012 commented 11 months ago

Hi @karthink. So I just took another look at everything and I’m pretty certain this is an access issue having to do with this announcement, which was made just a few days after I first opened this issue. Basically, it says they granted API access to everyone who had made a payment of over $1, and my billing history shows only $0.67 based on my usage. I definitely have access to GPT-4 and an active “GPT Plus” account with working API access to older models, but I’m now wondering if I failed to meet some usage requirement for the GPT-4 API. I was definitely able to use GPT-4 via the API for some time before opening this issue, and as far as I can see, there are no additional knobs, levers, or paywalls I can access. Are you able to access the GPT-4 API via your package? And if so, can you confirm if your billing history shows a payment of over $1.00? I could be misunderstanding this completely. I will be reaching out to their support team soon.

djs42012 commented 11 months ago

Hi @karthink,

This is resolved. After the most recent round of billing, OpenAI (re?)enabled my gpt-4 API access. I was able to configure the mode as desired with the following

(after! gptel
  (defun my/set-gptel-model ()
    (setq-local gptel-model "gpt-4"))

  (add-hook! 'gptel-mode-hook #'my/set-gptel-model))

Thank you for the lovely package and your time here

karthink commented 11 months ago

Glad you were able to resolve it. setq-default is still preferable to setting it via a hook, but if it ain't broke...

Are you able to access the GPT-4 API via your package? And if so, can you confirm if your billing history shows a payment of over $1.00?

I can't access GPT-4 in any way -- package or otherwise, and I haven't accumulated a $1 bill yet. From the looks of things I must be a pretty casual user of ChatGPT, which is funny considering I thought it would be worth writing a package to access it from Emacs.

djs42012 commented 11 months ago

Thank you for the tip, I’d forgotten you mentioned it already. setq-default is much cleaner. Everything works just leaving that in an after! block.

Regarding the billing, I think I finally gained access after the second billing cycle of about $0.75 per month. So, maybe next month you’re up? 😆