Replies: 2 comments 2 replies
-
I came up with this "solution": (defun my/ai-emacs-do ()
"Execute the users request in emacs"
(interactive)
;; tool
(let ((emacs-eval-tool
(gptel-make-tool
:name "emacs_eval"
:function (lambda (code)
(condition-case err
(let ((result (eval (read code))))
(format "Evaluation result: %S" result))
(error (format "Error: %s" (error-message-string err)))))
:description "Evaluate Emacs Lisp code and return the result"
:args '((:name "code"
:type "string"
:description "Emacs Lisp code to evaluate")))))
(setq-local gptel-tools (list emacs-eval-tool))
(setq-local gptel-use-tools t)
)
;; system prompt
(setq-local gptel--system-message "You are a helpful assistant living inside Emacs.
Use the emacs_eval tool to fullfill the request of the user.")
(gptel--suffix-send '("m" "e"))
) Feels not right to use the internal function |
Beta Was this translation helpful? Give feedback.
0 replies
-
The wiki needs to be updated. Method 1: let-bind around gptel-send: (let ((gptel-tools (list (gptel-get-tool "emacs-eval")))
(gptel--system-message "You are a helpful assistant living inside Emacs.
Use the emacs_eval tool to fullfill the request of the user."))
(gptel-send)) Method 2: use a preset (gptel-make-preset 'eval
:tools '("emacs-eval")
:system "You are a helpful assistant living inside Emacs.
Use the emacs_eval tool to fullfill the request of the user.")
(gptel-with-preset 'eval (gptel-send)) Afterwards, you can also switch to this preset from the menu or send a prompt with this preset by including You can also use the lower level |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I would like to create a custom command which does not pop up the transient menu. Instead it uses a preselected system prompt and uses preselected tools.
On the wiki page about custom commands there is no hint how to select tools. Is this even supported in
gptel-request
?Or is there a way to invoke
gptel-send
with predefined parameters?Beta Was this translation helpful? Give feedback.
All reactions