-
Hi! I love, love, gptel! However there is one point of significant friction I have, which is assigning backends & models to Emacs buffers. Below are two utility functions I've developed that set up the use of Gemini and ChatGpt.
I call one of them, and then do M-x gptel to set up a dedicated chat buffer for that specific backend & model. Then later I'll call the other defun, to prepare for the creation of a second buffer that uses the other model. I can then M-x gptel to create and use the 2nd back end and model. So far so good. However if I now switch to the 1st gptel buffer, I find that now it too is using the 2nd backend & model. I do know about the '=' feature in the transient menu, and I can use that to interactively fix up my confused buffers. But I've often not noticed this, which has led to frustration. I would much prefer if my defuns could be modified so that this isn't necessary. Is it possible? Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You are looking for (defun my/initialize-google-gemini ()
"Set up gptel for use with Google Gemini."
(interactive)
(let ((api-key (password-store-get "google-gemini") ))
(setq-local
gptel-model 'gemini-1.5-pro-latest
gptel-backend (gptel-make-gemini "Gemini"
:key api-key
:stream t))))
(defun my/initialize-chatgpt-4o-mini ()
"Set up gptel for use with ChatGPT."
(interactive)
(setq-local gptel-api-key (password-store-get-field "openai" "apikey"))
(setq-local gptel-model 'gpt-4o-mini)) Just remember to call this with the relevant buffer as the current one, for example via some hook. It used to be that setting models/backends buffer-locally was the default. But that led many users to complain about the friction: to change the model across a project, they had to change the model manually in every project buffer. So I made it global and added the
This wiki section may be of help. |
Beta Was this translation helpful? Give feedback.
You are looking for
setq-local
.Just remember to call this with the relevant buffer as the current one, for example via some hook.
It used to be that setti…