Skip to content

Commit

Permalink
gptel: Allow setting custom curl path
Browse files Browse the repository at this point in the history
This commit allows the user to set a custom path to the curl executable.

Windows has some strange notions of what "curl" is, and this can't
always be changed easily. With this variable, a user can let gptel use
the curl executable of their choosing -- allowing full response
streaming.
  • Loading branch information
Ronald Leppink committed Mar 11, 2024
1 parent d502ad8 commit 9104d4f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions gptel-curl.el
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ the response is inserted into the current buffer after point."
(args (gptel-curl--get-args (plist-get info :prompt) token))
(stream (and gptel-stream (gptel-backend-stream gptel-backend)))
(process (apply #'start-process "gptel-curl"
(generate-new-buffer "*gptel-curl*") "curl" args)))
(generate-new-buffer "*gptel-curl*") gptel-curl-path args)))
(when (eq gptel-log-level 'debug)
(gptel--log (json-encode (cons "curl" args))
(gptel--log (json-encode (cons gptel-curl-path args))
"request Curl command"))
(with-current-buffer (process-buffer process)
(set-process-query-on-exit-flag process nil)
Expand Down
7 changes: 6 additions & 1 deletion gptel.el
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,12 @@ all at once. This wait is asynchronous.
:type 'boolean)
(make-obsolete-variable 'gptel-playback 'gptel-stream "0.3.0")

(defcustom gptel-use-curl (and (executable-find "curl") t)
(defcustom gptel-curl-path "curl"
"The path to the curl executable."
:group 'gptel
:type 'string)

(defcustom gptel-use-curl (and (executable-find gptel-curl-path) t)
"Whether gptel should prefer Curl when available."
:group 'gptel
:type 'boolean)
Expand Down

0 comments on commit 9104d4f

Please sign in to comment.