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

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

[nongnu] elpa/gptel 3935a6dcf8 221/273: :recycle:: Untangle Gemini model


From: ELPA Syncer
Subject: [nongnu] elpa/gptel 3935a6dcf8 221/273: :recycle:: Untangle Gemini model and endpoint #212 (#213)
Date: Wed, 1 May 2024 10:02:32 -0400 (EDT)

branch: elpa/gptel
commit 3935a6dcf82389f9112473a7662e0ad802b124e8
Author: Cash Prokop-Weaver <56796112+cashpw@users.noreply.github.com>
Commit: GitHub <noreply@github.com>

    :recycle:: Untangle Gemini model and endpoint #212 (#213)
    
    gptel-gemini.el (gptel-make-gemini): Decouple the Gemini model
    from the API endpoint.  This is to support additional model
    options in the future.
---
 gptel-gemini.el | 32 +++++++++++++++-----------------
 1 file changed, 15 insertions(+), 17 deletions(-)

diff --git a/gptel-gemini.el b/gptel-gemini.el
index ab52a61015..9609d90cac 100644
--- a/gptel-gemini.el
+++ b/gptel-gemini.el
@@ -115,7 +115,7 @@
           (host "generativelanguage.googleapis.com")
           (protocol "https")
           (models '("gemini-pro"))
-          (endpoint "/v1beta/models/gemini-pro:"))
+          (endpoint "/v1beta/models"))
 
   "Register a Gemini backend for gptel with NAME.
 
@@ -126,8 +126,7 @@ CURL-ARGS (optional) is a list of additional Curl arguments.
 HOST (optional) is the API host, defaults to
 \"generativelanguage.googleapis.com\".
 
-MODELS is a list of available model names.  Currently only
-\"gemini-pro\" is available.
+MODELS is a list of available model names.
 
 STREAM is a boolean to enable streaming responses, defaults to
 false.
@@ -135,8 +134,7 @@ false.
 PROTOCOL (optional) specifies the protocol, \"https\" by default.
 
 ENDPOINT (optional) is the API endpoint for completions, defaults to
-\"/v1beta/models/gemini-pro:streamGenerateContent\" if STREAM is true and
-\"/v1beta/models/gemini-pro:generateContent\" otherwise.
+\"/v1beta/models\".
 
 HEADER (optional) is for additional headers to send with each
 request. It should be an alist or a function that retuns an
@@ -156,18 +154,18 @@ function that returns the key."
                   :endpoint endpoint
                   :stream stream
                   :key key
-                  :url
-                  (if stream
-                      (lambda ()
-                        (concat protocol "://" host endpoint
-                                (if gptel-stream
-                                    "streamGenerateContent"
-                                  "generateContent")
-                                "?key=" (gptel--get-api-key)))
-                    (lambda ()
-                      (concat protocol "://" host endpoint
-                              "generateContent" "?key="
-                              (gptel--get-api-key)))))))
+                  :url (lambda ()
+                         (let ((method (if (and stream
+                                                gptel-stream)
+                                           "streamGenerateContent"
+                                         "generateContent")))
+                           (format "%s://%s%s/%s:%s?key=%s"
+                                   protocol
+                                   host
+                                   endpoint
+                                   gptel-model
+                                   method
+                                   (gptel--get-api-key)))))))
     (prog1 backend
       (setf (alist-get name gptel--known-backends
                        nil nil #'equal)



reply via email to

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