karthink / gptel

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

How to register additional backends in doom emacs? #309

Closed laurentHYZ closed 1 month ago

laurentHYZ commented 1 month ago

Hi Karthink, I have installed and used gptel, and I was watching your YT video in order to understand how I can add additional LLM, but I am missing something. The documentation says that registering a backend for , say, anthropic should look like that: (gptel-make-anthropic "Claude" ;Any name you want :stream t ;Streaming responses :key "your-api-key")

Where do I put that code within doom emacs? thank you!

karthink commented 1 month ago

@laurentHYZ

You would put that in config.el in Doom Emacs (I think).

You can do something like this:

;; All gptel configuration:
(use-package gptel
  :defer
  :config
  (gptel-make-anthropic "Claude" ;Any name you want
    :stream t ;Streaming responses
    :key "your-api-key"))

If you're only using Claude, you may want to make that the default backend for gptel, as indicated in the README.

laurentHYZ commented 1 month ago

Hi Karthink, I modified my doom .config.el as follow: (use-package! gptel :config (setq! gptel-api-key "sk-proj-ant...") :defer :config (gptel-make-anthropic "Claude" ;Any name you want :stream t ;Streaming responses :key "sk-ant-api...") It does not work, I don't see a new option to pick from within my gptel-menu.

I must be missing a keyword required in doom. In Doom use-package should be replaced by use-package!, should (gptel-make-anthropic "C...") be replaced by (setq! gptel-make-anthropic ...).

Thank you!

karthink commented 1 month ago

Could you try this?

(use-package! gptel
  :config
  (setq! gptel-api-key "sk-proj-ant...")
  (gptel-make-anthropic "Claude"        ;Any name you want 
    :stream t                           ;Streaming responses 
    :key "sk-ant-api..."))

We'll have to ask a Doom Emacs user if this doesn't work.

edmundmiller commented 1 month ago

https://github.com/edmundmiller/.doom.d/blob/ef037dda348aa8d50499a451e309e6ef494b15d5/modules/app/ai/config.el#L30-L41

Here's my config

laurentHYZ commented 1 month ago

https://github.com/edmundmiller/.doom.d/blob/ef037dda348aa8d50499a451e309e6ef494b15d5/modules/app/ai/config.el#L30-L41

Here's my config

Hi Edmund, I was late the check the issue here and did not reply on time, sorry about that and thank you for sharing your config. I have tried it and I have little problems with the authentication, but this issue is closed. thank you!