-
Notifications
You must be signed in to change notification settings - Fork 199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to bind changing a model to a key for quicker access? #680
Comments
Hello @benma you can use this helper function (defun set-gptel-model-and-backend (model backend)
"Set the gptel-model and gptel-backend variables based on the selected MODEL and BACKEND."
(setq gptel-model model)
(setq gptel-backend (cdr (assoc backend gptel--known-backends)))
(message "\"%s:%s\" selected" backend model)) then you can change the model with instructions like this: (set-gptel-model-and-backend 'gpt-4-turbo "ChatGPT") (set-gptel-model-and-backend 'claude-3-opus-20240229 "Claude") you can read the model and backend names from gptel-menu and adapt the lines accordingly I have additionally defined a "model picker" quick selection menu. If i press "Super-M" the following menu pops up and i can quickly select the needed model by pressing the number. The full Code in my .emacs file looks like this. ;; gptel model selector
(require 'transient)
(defun set-gptel-model-and-backend (model backend)
"Set the gptel-model and gptel-backend variables based on the selected MODEL and BACKEND."
(setq gptel-model model)
(setq gptel-backend (cdr (assoc backend gptel--known-backends)))
(message "\"%s:%s\" selected" backend model))
(transient-define-prefix gptel-model-picker ()
"Transient for selecting AI models."
["Select AI Model"
("1" "claude opus" (lambda () (interactive) (set-gptel-model-and-backend 'claude-3-opus-20240229 "Claude")))
("2" "gpt4-turbo" (lambda () (interactive) (set-gptel-model-and-backend 'gpt-4-turbo "ChatGPT")))
("3" "gpt4o" (lambda () (interactive) (set-gptel-model-and-backend 'gpt-4o "Github Models 2")))
("4" "claude sonnet" (lambda () (interactive) (set-gptel-model-and-backend 'claude-3-5-sonnet-20240620 "Claude")))
("5" "new claude sonnet" (lambda () (interactive) (set-gptel-model-and-backend 'claude-3-5-sonnet-20241022 "Claude")))
("6" "claude sonnet 3.7" (lambda () (interactive) (set-gptel-model-and-backend 'claude-3-7-sonnet-20250219 "Claude")))
("7" "Deepseek-R1" (lambda () (interactive) (set-gptel-model-and-backend' DeepSeek-R1 "Github Models 2" )))
("b" "Deepseek-R1 backup " (lambda () (interactive) (set-gptel-model-and-backend' DeepSeek-R1 "Github Models" )))
("c" "Deepseek-R1 deepseek api " (lambda () (interactive) (set-gptel-model-and-backend' deepseek-reasoner "DeepSeek" )))
("8" "Deepseek-V3" (lambda () (interactive) (set-gptel-model-and-backend 'deepseek/deepseek-chat "OpenRouter")))
])
(global-set-key (kbd "C-c m") 'gptel-model-picker)
(global-set-key (kbd "s-m") 'gptel-model-picker) does this answer your question or do you need further help? |
This works very nicely, thanks a lot. |
To change the model, currently I invoke gptel-menu, then hit
-m
. I change models frequently, so I'd like have a simple keybinding to launch into this directly. Is there a way?Thanks
The text was updated successfully, but these errors were encountered: