gptel-gemini.el (gptel-make-gemini): Decouple the Gemini model from the API endpoint. This is to support additional model options in the future.
This commit is contained in:
parent
3d6147830e
commit
3935a6dcf8
1 changed files with 15 additions and 17 deletions
|
@ -115,7 +115,7 @@
|
||||||
(host "generativelanguage.googleapis.com")
|
(host "generativelanguage.googleapis.com")
|
||||||
(protocol "https")
|
(protocol "https")
|
||||||
(models '("gemini-pro"))
|
(models '("gemini-pro"))
|
||||||
(endpoint "/v1beta/models/gemini-pro:"))
|
(endpoint "/v1beta/models"))
|
||||||
|
|
||||||
"Register a Gemini backend for gptel with NAME.
|
"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
|
HOST (optional) is the API host, defaults to
|
||||||
\"generativelanguage.googleapis.com\".
|
\"generativelanguage.googleapis.com\".
|
||||||
|
|
||||||
MODELS is a list of available model names. Currently only
|
MODELS is a list of available model names.
|
||||||
\"gemini-pro\" is available.
|
|
||||||
|
|
||||||
STREAM is a boolean to enable streaming responses, defaults to
|
STREAM is a boolean to enable streaming responses, defaults to
|
||||||
false.
|
false.
|
||||||
|
@ -135,8 +134,7 @@ false.
|
||||||
PROTOCOL (optional) specifies the protocol, \"https\" by default.
|
PROTOCOL (optional) specifies the protocol, \"https\" by default.
|
||||||
|
|
||||||
ENDPOINT (optional) is the API endpoint for completions, defaults to
|
ENDPOINT (optional) is the API endpoint for completions, defaults to
|
||||||
\"/v1beta/models/gemini-pro:streamGenerateContent\" if STREAM is true and
|
\"/v1beta/models\".
|
||||||
\"/v1beta/models/gemini-pro:generateContent\" otherwise.
|
|
||||||
|
|
||||||
HEADER (optional) is for additional headers to send with each
|
HEADER (optional) is for additional headers to send with each
|
||||||
request. It should be an alist or a function that retuns an
|
request. It should be an alist or a function that retuns an
|
||||||
|
@ -156,18 +154,18 @@ function that returns the key."
|
||||||
:endpoint endpoint
|
:endpoint endpoint
|
||||||
:stream stream
|
:stream stream
|
||||||
:key key
|
:key key
|
||||||
:url
|
:url (lambda ()
|
||||||
(if stream
|
(let ((method (if (and stream
|
||||||
(lambda ()
|
gptel-stream)
|
||||||
(concat protocol "://" host endpoint
|
"streamGenerateContent"
|
||||||
(if gptel-stream
|
"generateContent")))
|
||||||
"streamGenerateContent"
|
(format "%s://%s%s/%s:%s?key=%s"
|
||||||
"generateContent")
|
protocol
|
||||||
"?key=" (gptel--get-api-key)))
|
host
|
||||||
(lambda ()
|
endpoint
|
||||||
(concat protocol "://" host endpoint
|
gptel-model
|
||||||
"generateContent" "?key="
|
method
|
||||||
(gptel--get-api-key)))))))
|
(gptel--get-api-key)))))))
|
||||||
(prog1 backend
|
(prog1 backend
|
||||||
(setf (alist-get name gptel--known-backends
|
(setf (alist-get name gptel--known-backends
|
||||||
nil nil #'equal)
|
nil nil #'equal)
|
||||||
|
|
Loading…
Add table
Reference in a new issue