Replies: 3 comments 2 replies
-
There are many ways to speed up switching between models/backends/directives -- gptel's defaults try to be simple and discoverable, not fast. Ranked easy to involved, you could try: Keyboard macros
Most sequences of keys can be automated easily. Assuming your leader key is (keymap-global-set "<f6>" "SPC u SPC a r h h d") to jump to the directive editor. You can set up keyboard macros for other things too, like switching to gpt-4: (keymap-global-set "SPC a 4" "SPC u SPC a r - m c h a <return> 4 <return>") Call gptel functions directlyThe transient menu is available at Helper functions
How is what you're doing (to switch between gpt-4 and gpt-3.5) tedious? It's just one keybinding? To be safe, you should be setting the backend along with the model.
If you know these combinations ahead of time, you can do something like this: (defvar my/gptel-presets
;; PRESET NAME MODEL BACKEND NAME DIRECTIVE
'(("gpt4+coding" "gpt-4" "ChatGPT" "My coding directive for gpt-4")
("mixtral+summarize" "Mixtral..." "anyscale" "My directive for summarizing with Mixtral")
("gpt-3.5+general" "gpt-3.5-turbo" "ChatGPT" "My directive for gpt-3.5"))
"List of preset combinations for gptel.")
(defun my/gptel-switch-preset (preset)
(interactive (list (completing-read
"Select preset: "
(mapcar #'car my/gptel-presets)
nil t)))
(let ((combination (assoc preset my/gptel-presets)))
(setq gptel-model (nth 1 combination)
gptel-backend (cdr (assoc (nth 2 combination) gptel--known-backends))
gptel--system-message (nth 3 combination))
(message "Selected gptel preset: %s" preset))) NOTE: This can break in the future as it accesses internal gptel variables ( Custom gptel queries with
|
Beta Was this translation helpful? Give feedback.
-
I'm curious to see if anyone has created a way of switching out the default prompt on a mode-by-mode basis. For example, I have a prompt to write me commands while I'm in I created a new directive using this code: (defun nlj/get-relative-file-path (filename)
"Get the full path of FILENAME relative to the current file.
FILENAME is the name of the file to look up.
Returns the absolute path of the file relative to the directory of
either the current loaded file or current buffer."
(expand-file-name filename
(file-name-directory (or load-file-name buffer-file-name))))
(defun nlj/llm-get-directives ()
"Reads all the directive files in the directives directory, and creates an alist of
the form (DIRECTIVE . CONTENT). Each directive name is the file name without the extension."
(let ((dir (nlj/get-relative-file-path "directives"))) ; this just expands the relative path to absolute path
(mapcar (lambda (file)
`(,(intern (file-name-base file))
.
,(f-read-text file)))
(f-files dir
(lambda (file)
(string= "txt" (f-ext file)))))))
(use-package! gptel
:config
;; <redacted>
(dolist (entry (nlj/llm-get-directives))
(add-to-list 'gptel-directives entry t))) and then to use it, I call The approaches that I can currently think of are:
I think that (1) might be a better option. More generally it would be nice to have a major mode to directive map, but this might introduce too much maintenance overhead on the user side. Let me know your thoughts! |
Beta Was this translation helpful? Give feedback.
-
With the addition of presets, there is now a built-in way to switch to another model, backend, system message, set of tools (etc) all at once. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
From @LazerJesus (#177)
with this gptel becomes even more important to my daily work. i love it!
i got a couple of questions, not sure if here is the best spot, so let me know if i should start a new issue about any of these.
managing multiple backends
at the moment i toggle models by keybinding custom expressions. like this
but with multiple backends that is becoming tedious. is there a better way?
whats the fastest way to provide one-off directives
i often highlight text regions and want to write just a few words as directive.
using the gpt-system buffer (reached via
h h
from the gptel minibuffer) is about 8 key hits for me.open minibuffer, h h, closing minibuffer, clearing text, c-c c-c.
is there a faster way?
managing directives / directives per model?
different models have different strengths and weaknesses, therefore i use them for different reasons.
for example, i use gpt4 for coding and mixtral for summarizing large bodies of text.
that requires different directives. is it possible to have directives per model?
how would i do that?
Beta Was this translation helpful? Give feedback.
All reactions