Skip to content

Commit db1a610

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 d020b41 commit db1a610

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
@@ -289,12 +289,19 @@ https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-process
289289
(define-obsolete-variable-alias 'gptel-prompt-filter-hook
290290
'gptel-prompt-transform-functions "0.9.9")
291291

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

0 commit comments

Comments
 (0)