Skip to content

Commit 72b0f38

Browse files
committed
gptel: Set default for gptel-prompt-transform-functions
* gptel.el (gptel-prompt-transform-functions): Set the default transformers/augmentors. They (i) apply any preset included at the beginning of the prompt (via `@preset`) and (ii) add gptel's context to the prompt buffer. Note that `gptel-prompt-transform-functions' (or a list containing augmentors) needs to be passed explicitly to `gptel-request' (via the `:transforms' argument) for it to take effect. `gptel-send' does this. It is not read from the environment as this can have unexpected side-effects when using `gptel-request' as a library.
1 parent 665bce9 commit 72b0f38

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

gptel.el

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,12 +284,19 @@ https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-process
284284
(define-obsolete-variable-alias 'gptel-prompt-filter-hook
285285
'gptel-prompt-transform-functions "0.9.9")
286286

287-
(defcustom gptel-prompt-transform-functions nil
287+
(defcustom gptel-prompt-transform-functions
288+
'(gptel--transform-apply-preset gptel--transform-add-context)
288289
"Handlers to augment or transform a query before sending it.
289290
290291
This hook is called in a temporary buffer containing the text to
291292
be sent, with the cursor at the end of the prompt. You can use
292-
it to modify the buffer as required.
293+
it to modify the buffer or buffer-local variables as required.
294+
295+
Since these functions modify the prompt construction buffer, the order
296+
in which they run is significant! In particular, you may want to add
297+
your function before (the default) or after
298+
`gptel--transform-add-context', which adds gptel's context (other
299+
buffers, files etc) to this buffer.
293300
294301
Example: A typical use case might be to search for occurrences of $(cmd)
295302
and replace it with the output of the shell command cmd, making it easy

0 commit comments

Comments
 (0)