Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add gptel-register-tool function #738

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions gptel.el
Original file line number Diff line number Diff line change
Expand Up @@ -1675,6 +1675,18 @@ callback as its first argument, which it runs with the result:
nil nil #'equal)
tool)))

(defun gptel-register-tool (spec)
"Register a tool defined by SPEC with gptel.
SPEC is a plist that can be passed to `gptel-make-tool'. Add the tool
to `gptel-tools', replacing any tool with the same name."
(let ((tool (apply #'gptel-make-tool spec)))
(setq gptel-tools
(cons tool (seq-remove
(lambda (existing)
(string= (gptel-tool-name existing)
(gptel-tool-name tool)))
gptel-tools)))))

(cl-defgeneric gptel--parse-tools (_backend tools)
"Parse TOOLS and return a list of prompts.

Expand Down