Variable: gptel-prompt-transform-functions
gptel-prompt-transform-functions is a customizable variable defined in
gptel-request.el.
Value
(gptel--transform-apply-preset
gptel--transform-add-context)
Documentation
Handlers to augment or transform a query before sending it.
This hook is called in a temporary buffer containing the text to be sent, with the cursor at the end of the prompt. You can use it to modify the buffer or buffer-local variables as required.
Since these functions modify the prompt construction buffer, the order
in which they run is significant! In particular, you may want to add
your function before (the default) or after
gptel--transform-add-context, which adds gptel's context (other
buffers, files etc) to this buffer.
Example: A typical use case might be to search for occurrences of $(cmd) and replace it with the output of the shell command cmd, making it easy to send the output of shell commands to the LLM.
Transform functions can be synchronous or asynchronous.
Synchronous hook functions must accept zero or one argument: the state
machine (see gptel-fsm) for the current request.
Asynchronous hook functions must accept two arguments: a callback to call after the transformation is complete, and the state machine for the current request.
Note that while this set of handlers can certainly be set with a global value to be applied to all queries in all buffers, it meant to be set locally for a specific buffer, or chat topic, or only the context of a certain task.
Aliases
gptel-prompt-filter-hook (obsolete since 0.9.9)
Source Code
;; Defined in /nix/store/q3r7g81pvghw7a523kjk2k2zih3pfk8z-emacs-packages-deps/share/emacs/site-lisp/elpa/gptel-20261002.545/gptel-request.el
(defcustom gptel-prompt-transform-functions
'(gptel--transform-apply-preset gptel--transform-add-context)
"Handlers to augment or transform a query before sending it.
This hook is called in a temporary buffer containing the text to
be sent, with the cursor at the end of the prompt. You can use
it to modify the buffer or buffer-local variables as required.
Since these functions modify the prompt construction buffer, the order
in which they run is significant! In particular, you may want to add
your function before (the default) or after
`gptel--transform-add-context', which adds gptel's context (other
buffers, files etc) to this buffer.
Example: A typical use case might be to search for occurrences of $(cmd)
and replace it with the output of the shell command cmd, making it easy
to send the output of shell commands to the LLM.
Transform functions can be synchronous or asynchronous.
Synchronous hook functions must accept zero or one argument: the state
machine (see `gptel-fsm') for the current request.
Asynchronous hook functions must accept two arguments: a callback to
call after the transformation is complete, and the state machine for the
current request.
Note that while this set of handlers can certainly be set with a global
value to be applied to all queries in all buffers, it meant to be set
locally for a specific buffer, or chat topic, or only the context of a
certain task."
:type 'hook)