Skip to content

gptel-transient: tool selection using completing-read-multiple #653

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ahmed-shariff
Copy link

@ahmed-shariff ahmed-shariff commented Feb 18, 2025

Building off this comment: #514 (comment)

This is a proposal for replacing the tool selection sub menu in gptel-menu with completing-read-multiple.
This replaces the gptel-tools prefix with infexes to (a) add, (b) remove and (c) remove-all tools. (a) and (b) use completing-read-multiple. The candidate list in both would have the individual tools as well as the categories. When adding, if a category is selected, all tools related to that are added. The same would happen when removing.

A quick demo of what it looks like for now:

Recording.2025-02-17.230051.mp4

What do you think about this?

TODO:

  • annotations

Adds infixes that use completing-read-multiple to add/remove tools to
use in place of the sub menu suffix
`completing-read-multiple' for the tools option now only shows the
relevant items with the category. Also correctly handle duplicate
values.
@ahmed-shariff
Copy link
Author

Added the annotations:
image

@psionic-k
Copy link
Contributor

Reviewing the video, seems pretty good. As our tool numbers grow, narrowing and completion seem like the right way. I can easily see the average gptel user having 50 tools by the end of the year.

Did you incidentally create a programming interface so I can set tools by category from an Elisp program?

@ahmed-shariff
Copy link
Author

Thanks for taking a look at this.

I had not implemented programming interfaces for that. Though, it should be pretty straightforward to do?

(setq gptel-tools (alist-get "emacs" gptel--known-tools nil nil #'string-equal))

I remember seeing a discussion about having a programmatic interface tool use, but couldn't find it in a rush 😅
If that is of interest, it should be straightforward to add.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants