Stebalien/gptel-futur

Integration of futur with gptel

★ 0Forks 0Emacs LispGitHub ↗Compare

README

gptel-futur

futur integration for gptel.

Usage

First, install with your favorite package manager (from VC, this package isn’t on (M)ELPA).

(use-package :vc "https://github.com/Stebalien/gptel-futur")

Then you can define tools with futurs as follows:

(gptel-futur-make-tool
 :name "curl"
 :description "Fetch a URL with cURL."
 :confirm t
 :category "web"
 :args '((:name "url" :type string :description "The URL to fetch"))
 :function
 (lambda (url)
   (futur-with-temp-buffer
     (futur-let* ((buf (current-buffer))
                  (res <- (futur-process-call "curl" nil buf nil "-fsSL" "--" url)))
       (with-current-buffer buf
         (if ((= res 0)) (buffer-string) (format "Failed to fetch %s" url)))))))

You can make async requests as follows:

(defun notmuch-mark-if-spam ()
  "Determine if the current message is spam and asynchronously mark it as such."
  (futur-let* ((id (notmuch-show-get-message-id))
               (spam-p <- (gptel-futur-request (buffer-string-no-properties)
                            :system "You are an expert spam detector. Decide whether the provided message message is spam (true) or not (false)."
                            :schema '(:type bool))))
    :error-fun
    ((t (err) (display-warning
               'org-mode (format ": %s" err)
               :error)))
    (when spam-p
      (notmuch-tag id "+spam" 'omit-history))))

This is especially useful if you need to make a sequence of requests.

License

GPLv3 © Steven Allen 2026

Contributors

Stebalien

Issues