Function: gptel-get-tool
gptel-get-tool is a natively compiled function defined in
gptel-request.el.
Signature
(gptel-get-tool PATH)
Documentation
Find tool in gptel's tool registry at PATH.
PATH can be specified
- as a string representing the tool name, like "search_db",
- or as a list representing a category and tool name,
like '("emacs" "read_buffer").
In both cases, the first matching gptel-tool is returned.
- as a string representing a category, like "filesystem".
In this case a list of all gptel-tools with this category is
returned.
- as a gptel-tool object, which is returned as-is.
Source Code
;; Defined in /nix/store/q3r7g81pvghw7a523kjk2k2zih3pfk8z-emacs-packages-deps/share/emacs/site-lisp/elpa/gptel-20261002.545/gptel-request.el
(defun gptel-get-tool (path)
"Find tool in gptel's tool registry at PATH.
PATH can be specified
- as a string representing the tool name, like \"search_db\",
- or as a list representing a category and tool name,
like \\='(\"emacs\" \"read_buffer\").
In both cases, the first matching gptel-tool is returned.
- as a string representing a category, like \"filesystem\".
In this case a list of all gptel-tools with this category is
returned.
- as a gptel-tool object, which is returned as-is."
(or (cl-etypecase path
(cons (let ((tc (map-nested-elt gptel--known-tools path)))
(if (consp tc) (map-values tc) tc)))
(string (if-let* ((category (assoc path gptel--known-tools)))
(map-values (cdr category))
(cl-loop for (_ . tools) in gptel--known-tools
if (assoc path tools)
return (cdr it))))
(gptel-tool path))
(error "No tool matches for %S" path)))