Function: gptel--inspect-query
gptel--inspect-query is a natively compiled function defined in
gptel.el.
Signature
(gptel--inspect-query &optional REQUEST-FSM FORMAT)
Documentation
Show the full LLM query that will be sent in a buffer.
This functions as a dry run of gptel-send. The request data
may be edited and the query continued from this buffer.
REQUEST-FSM is the state of the request, as returned by
gptel-request. If FORMAT is the symbol json, show the encoded
JSON query instead of the Lisp structure gptel uses.
Source Code
;; Defined in /nix/store/q3r7g81pvghw7a523kjk2k2zih3pfk8z-emacs-packages-deps/share/emacs/site-lisp/elpa/gptel-20261002.545/gptel.el
(defun gptel--inspect-query (&optional request-fsm format)
"Show the full LLM query that will be sent in a buffer.
This functions as a dry run of `gptel-send'. The request data
may be edited and the query continued from this buffer.
REQUEST-FSM is the state of the request, as returned by
`gptel-request'. If FORMAT is the symbol json, show the encoded
JSON query instead of the Lisp structure gptel uses."
(unless request-fsm (setq request-fsm gptel--fsm-last))
(if (bufferp (plist-get (gptel-fsm-info request-fsm) :data))
(letrec ((dry-run-poll
(run-with-timer
0 1 (lambda (fsm form)
(unless (bufferp (plist-get (gptel-fsm-info fsm) :data))
(cancel-timer dry-run-poll)
(gptel--inspect-query fsm form)))
request-fsm format))))
(with-current-buffer (plist-get (gptel-fsm-info request-fsm) :buffer)
(gptel--update-status " Ready" 'success))
(with-current-buffer (get-buffer-create "*gptel-query*")
(let* ((standard-output (current-buffer))
(inhibit-read-only t)
(print-length nil)
(request-data
(plist-get (gptel-fsm-info request-fsm) :data)))
(buffer-disable-undo)
(erase-buffer)
(if (eq format 'json)
(progn (fundamental-mode)
(insert (gptel--json-encode request-data))
(json-pretty-print-buffer))
(lisp-data-mode)
(prin1 request-data)
(pp-buffer))
(setq-local gptel--fsm-last request-fsm)
(goto-char (point-min))
(view-mode 1)
(setq buffer-undo-list nil)
(use-local-map
(make-composed-keymap
(define-keymap
"C-c C-c" #'gptel--continue-query
"C-c C-w" (lambda () "Copy Curl command for query."
(interactive) (gptel--continue-query 'copy))
"C-c C-k" #'quit-window)
(current-local-map)))
(unless header-line-format
(setq header-line-format
(substitute-command-keys
(concat
"Edit request: \\[read-only-mode],"
" Send request: \\[gptel--continue-query],"
(format " Copy Curl: %s"
(propertize "C-c C-w" 'face 'help-key-binding))
" Quit: \\[quit-window]"))))
(display-buffer (current-buffer) gptel-display-buffer-action)))))