emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/gptel 43f625ecb9 209/273: gptel-openai: curl-args slot in


From: ELPA Syncer
Subject: [nongnu] elpa/gptel 43f625ecb9 209/273: gptel-openai: curl-args slot in gptel-backend (#221)
Date: Wed, 1 May 2024 10:02:25 -0400 (EDT)

branch: elpa/gptel
commit 43f625ecb90d7955431f670877d6d7c213ecef04
Author: r0man <roman@burningswell.com>
Commit: GitHub <noreply@github.com>

    gptel-openai: curl-args slot in gptel-backend (#221)
    
    gptel-openai.el (gptel-backend, gptel-make-openai,
    gptel-make-azure): Add a curl-args slot to the backend struct for
    additional Curl arguments.
    
    Usage example: This can be used to set the `--cert` and `--key`
    options in a custom backend that uses mutal TLS to communicate
    with an OpenAI proxy/gateway.
    
    gptel-curl.el (gptel-curl--get-args): Add backend-specific
    curl-args when creating HTTP requests.
    
    gptel-gemini.el (gptel-make-gemini): Add a curl-args slot to the
    constructor.
    gptel-kagi.el (gptel-make-kagi): Ditto.
    gptel-ollama.el (gptel-make-ollama): Ditto.
---
 gptel-curl.el   |  1 +
 gptel-gemini.el |  5 ++++-
 gptel-kagi.el   |  5 ++++-
 gptel-ollama.el |  5 ++++-
 gptel-openai.el | 14 +++++++++++---
 5 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/gptel-curl.el b/gptel-curl.el
index 353d2c4a72..c696f0fbec 100644
--- a/gptel-curl.el
+++ b/gptel-curl.el
@@ -66,6 +66,7 @@ PROMPTS is the data to send, TOKEN is a unique identifier."
       (gptel--log data "request body"))
     (append
      gptel-curl--common-args
+     (gptel-backend-curl-args gptel-backend)
      (list (format "-w(%s . %%{size_header})" token))
      (if (length< data gptel-curl-file-size-threshold)
          (list (format "-d%s" data))
diff --git a/gptel-gemini.el b/gptel-gemini.el
index 90119a3cfc..ab52a61015 100644
--- a/gptel-gemini.el
+++ b/gptel-gemini.el
@@ -111,7 +111,7 @@
 
 ;;;###autoload
 (cl-defun gptel-make-gemini
-    (name &key header key (stream nil)
+    (name &key curl-args header key (stream nil)
           (host "generativelanguage.googleapis.com")
           (protocol "https")
           (models '("gemini-pro"))
@@ -121,6 +121,8 @@
 
 Keyword arguments:
 
+CURL-ARGS (optional) is a list of additional Curl arguments.
+
 HOST (optional) is the API host, defaults to
 \"generativelanguage.googleapis.com\".
 
@@ -145,6 +147,7 @@ KEY (optional) is a variable whose value is the API key, or
 function that returns the key."
   (declare (indent 1))
   (let ((backend (gptel--make-gemini
+                  :curl-args curl-args
                   :name name
                   :host host
                   :header header
diff --git a/gptel-kagi.el b/gptel-kagi.el
index f89066ea97..98b191feb6 100644
--- a/gptel-kagi.el
+++ b/gptel-kagi.el
@@ -120,7 +120,7 @@
 
 ;;;###autoload
 (cl-defun gptel-make-kagi
-    (name &key stream key
+    (name &key curl-args stream key
           (host "kagi.com")
           (header (lambda () `(("Authorization" . ,(concat "Bot " 
(gptel--get-api-key))))))
           (models '("fastgpt"
@@ -132,6 +132,8 @@
 
 Keyword arguments:
 
+CURL-ARGS (optional) is a list of additional Curl arguments.
+
 HOST is the Kagi host (with port), defaults to \"kagi.com\".
 
 MODELS is a list of available Kagi models: only fastgpt is supported.
@@ -159,6 +161,7 @@ Example:
   (declare (indent 1))
   stream                                ;Silence byte-compiler
   (let ((backend (gptel--make-kagi
+                  :curl-args curl-args
                   :name name
                   :host host
                   :header header
diff --git a/gptel-ollama.el b/gptel-ollama.el
index e9c2dca6bc..f501e7bd5e 100644
--- a/gptel-ollama.el
+++ b/gptel-ollama.el
@@ -101,7 +101,7 @@ Ollama models.")
 
 ;;;###autoload
 (cl-defun gptel-make-ollama
-    (name &key header key models stream
+    (name &key curl-args header key models stream
           (host "localhost:11434")
           (protocol "http")
           (endpoint "/api/generate"))
@@ -109,6 +109,8 @@ Ollama models.")
 
 Keyword arguments:
 
+CURL-ARGS (optional) is a list of additional Curl arguments.
+
 HOST is where Ollama runs (with port), defaults to localhost:11434
 
 MODELS is a list of available model names.
@@ -140,6 +142,7 @@ Example:
   :stream t)"
   (declare (indent 1))
   (let ((backend (gptel--make-ollama
+                  :curl-args curl-args
                   :name name
                   :host host
                   :header header
diff --git a/gptel-openai.el b/gptel-openai.el
index 627ff38732..bf0825fed6 100644
--- a/gptel-openai.el
+++ b/gptel-openai.el
@@ -49,7 +49,7 @@
     (gptel-backend (:constructor gptel--make-backend)
                    (:copier gptel--copy-backend))
   name host header protocol stream
-  endpoint key models url)
+  endpoint key models url curl-args)
 
 ;;; OpenAI (ChatGPT)
 (cl-defstruct (gptel-openai (:constructor gptel--make-openai)
@@ -115,7 +115,7 @@
 
 ;;;###autoload
 (cl-defun gptel-make-openai
-    (name &key models stream key
+    (name &key curl-args models stream key
           (header
            (lambda () (when-let (key (gptel--get-api-key))
                    `(("Authorization" . ,(concat "Bearer " key))))))
@@ -126,6 +126,8 @@
 
 Keyword arguments:
 
+CURL-ARGS (optional) is a list of additional Curl arguments.
+
 HOST (optional) is the API host, typically \"api.openai.com\".
 
 MODELS is a list of available model names.
@@ -147,6 +149,7 @@ KEY (optional) is a variable whose value is the API key, or
 function that returns the key."
   (declare (indent 1))
   (let ((backend (gptel--make-openai
+                  :curl-args curl-args
                   :name name
                   :host host
                   :header header
@@ -166,7 +169,7 @@ function that returns the key."
 ;;; Azure
 ;;;###autoload
 (cl-defun gptel-make-azure
-    (name &key host
+    (name &key curl-args host
           (protocol "https")
           (header (lambda () `(("api-key" . ,(gptel--get-api-key)))))
           (key 'gptel-api-key)
@@ -175,6 +178,8 @@ function that returns the key."
 
 Keyword arguments:
 
+CURL-ARGS (optional) is a list of additional Curl arguments.
+
 HOST is the API host.
 
 MODELS is a list of available model names.
@@ -207,6 +212,7 @@ Example:
  :models \\='(\"gpt-3.5-turbo\" \"gpt-4\"))"
   (declare (indent 1))
   (let ((backend (gptel--make-openai
+                  :curl-args curl-args
                   :name name
                   :host host
                   :header header
@@ -230,6 +236,8 @@ Example:
 
 Keyword arguments:
 
+CURL-ARGS (optional) is a list of additional Curl arguments.
+
 HOST is where GPT4All runs (with port), typically localhost:8491
 
 MODELS is a list of available model names.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]