branch: elpa/gptel
commit 7d063daefca53d467e7be8ab900e2f82f0b914be
Author: Felipe Ochoa <fel...@incquery.com>
Commit: karthink <karthikchikmaga...@gmail.com>

    gptel: Allow specifying a curl executable
    
    Some distros' versions of curl don't have support for the
    --aws-sigv4 argument.  This is required for the AWS bedrock
    backend implementation.  Allow the Curl executable path to be
    specified.
    
    * gptel.el (gptel-use-curl): Can now be a string (Curl path)
    (gptel--curl-path): Get the Curl path.
    
    * gptel-curl.el (gptel-curl-get-response): Use specified Curl
    path.
---
 gptel-curl.el |  4 ++--
 gptel.el      | 13 +++++++++++--
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/gptel-curl.el b/gptel-curl.el
index 1af28fe46e..d887c9d8a3 100644
--- a/gptel-curl.el
+++ b/gptel-curl.el
@@ -137,13 +137,13 @@ the response is inserted into the current buffer after 
point."
          (args (gptel-curl--get-args info token))
          (stream (plist-get info :stream))
          (process (apply #'start-process "gptel-curl"
-                         (gptel--temp-buffer " *gptel-curl*") "curl" args)))
+                         (gptel--temp-buffer " *gptel-curl*") 
(gptel--curl-path) args)))
     ;; Don't try to convert cr-lf to cr on Windows so that curl's "header size
     ;; in bytes" stays correct. Explicitly set utf-8 for non-win systems too,
     ;; for cases when buffer coding system is not set to utf-8.
     (set-process-coding-system process 'utf-8-unix 'utf-8-unix)
     (when (eq gptel-log-level 'debug)
-      (gptel--log (mapconcat #'shell-quote-argument (cons "curl" args) " \\\n")
+      (gptel--log (mapconcat #'shell-quote-argument (cons (gptel--curl-path) 
args) " \\\n")
                   "request Curl command" 'no-json))
     (with-current-buffer (process-buffer process)
       (set-process-query-on-exit-flag process nil)
diff --git a/gptel.el b/gptel.el
index 919d2a5620..246234cefa 100644
--- a/gptel.el
+++ b/gptel.el
@@ -250,8 +250,13 @@ all at once.  This wait is asynchronous.
   :type 'boolean)
 
 (defcustom gptel-use-curl (and (executable-find "curl") t)
-  "Whether gptel should prefer Curl when available."
-  :type 'boolean)
+  "Whether gptel should prefer Curl when available.
+
+Can be set to t, nil, or a string path to the curl executable."
+  :type '(choice
+          (const nil :tag "Do not use curl")
+          (const t :tag "Use the system curl")
+          (string :tag "Path to the curl executable")))
 
 (defcustom gptel-org-convert-response t
   "Whether gptel should convert Markdown responses to Org markup.
@@ -1056,6 +1061,10 @@ Note: Changing this variable does not affect gptel\\='s 
behavior
 in any way.")
 (put 'gptel--backend-name 'safe-local-variable #'always)
 
+(defsubst gptel--curl-path ()
+  "Curl executable to use."
+  (if (stringp gptel-use-curl) gptel-use-curl "curl"))
+
 ;;;; Model interface
 ;; NOTE: This interface would be simpler to implement as a defstruct.  But then
 ;; users cannot set `gptel-model' to a symbol/string directly, or we'd need

Reply via email to