Function: gptel--preprocess-tool-args
gptel--preprocess-tool-args is a natively compiled function defined in
gptel-request.el.
Signature
(gptel--preprocess-tool-args SPEC)
Documentation
Convert symbol :type values in tool SPEC to strings destructively.
Source Code
;; Defined in /nix/store/q3r7g81pvghw7a523kjk2k2zih3pfk8z-emacs-packages-deps/share/emacs/site-lisp/elpa/gptel-20261002.545/gptel-request.el
(defun gptel--preprocess-tool-args (spec)
"Convert symbol :type values in tool SPEC to strings destructively."
;; NOTE: Do not use `sequencep' here, as that covers strings too and breaks
;; things.
(when (or (listp spec) (vectorp spec))
(cond
((vectorp spec)
(cl-loop for element across spec
for idx upfrom 0
do (aset spec idx (gptel--preprocess-tool-args element))))
((keywordp (car spec))
(let ((tail spec))
(while tail
(when (and (eq (car tail) :type) (symbolp (cadr tail)))
(setcar (cdr tail) (symbol-name (cadr tail))))
;; TODO: Handle :enum ("provided" "as" "list") here, convert to
;; :enum ["provided" "as" "array"]
(when (or (listp (cadr tail)) (vectorp (cadr tail)))
(gptel--preprocess-tool-args (cadr tail)))
(setq tail (cddr tail)))))
((listp spec) (dolist (element spec)
(when (listp element)
(gptel--preprocess-tool-args element))))))
spec)