[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/llm c8604bd694 6/7: Add information about new models
From: |
ELPA Syncer |
Subject: |
[elpa] externals/llm c8604bd694 6/7: Add information about new models |
Date: |
Sat, 18 May 2024 15:58:21 -0400 (EDT) |
branch: externals/llm
commit c8604bd6943b573eec0b8a9f3b7d6536abc14137
Author: Andrew Hyatt <ahyatt@gmail.com>
Commit: Andrew Hyatt <ahyatt@gmail.com>
Add information about new models
---
NEWS.org | 2 ++
llm-openai.el | 39 ++++++++++++++++++++-------------------
llm-test.el | 11 ++++++++---
llm-vertex.el | 9 +++++----
4 files changed, 35 insertions(+), 26 deletions(-)
diff --git a/NEWS.org b/NEWS.org
index 8840d60259..a3d8122247 100644
--- a/NEWS.org
+++ b/NEWS.org
@@ -3,6 +3,8 @@
stronger foundation backed by parsing to spec. Thanks to Roman Scherer for
contributing the =plz= extensions that enable this, which are currently
bundled
in this package but will eventually become their own separate package.
+- Add model context information for Open AI's GPT 4-o.
+- Add model context information for Gemini's 1.5 models.
* Version 0.14.2
- Fix mangled copyright line (needed to get ELPA version unstuck).
- Fix Vertex response handling bug.
diff --git a/llm-openai.el b/llm-openai.el
index c03f13c897..80447092d2 100644
--- a/llm-openai.el
+++ b/llm-openai.el
@@ -127,10 +127,10 @@ PROVIDER is the Open AI provider struct."
(cl-defmethod llm-provider-embedding-extract-error ((_ llm-openai)
err-response)
(let ((errdata (assoc-default 'error err-response)))
- (when errdata
- (format "Open AI returned error: %s message: %s"
- (cdr (assoc 'type errdata))
- (cdr (assoc 'message errdata))))))
+ (when errdata
+ (format "Open AI returned error: %s message: %s"
+ (cdr (assoc 'type errdata))
+ (cdr (assoc 'message errdata))))))
(cl-defmethod llm-provider-chat-extract-error ((provider llm-openai)
err-response)
(llm-provider-embedding-extract-error provider err-response))
@@ -224,24 +224,24 @@ RESPONSE can be nil if the response is complete."
(dotimes (i (length (car data)))
(setf (aref cvec i) (make-llm-provider-utils-function-call)))
(cl-loop for part in data do
- (cl-loop for call in (append part nil) do
- (let* ((index (assoc-default 'index call))
- (id (assoc-default 'id call))
- (function (assoc-default 'function call))
- (name (assoc-default 'name function))
- (arguments (assoc-default 'arguments function)))
- (when id
- (setf (llm-provider-utils-function-call-id (aref cvec index))
id))
- (when name
- (setf (llm-provider-utils-function-call-name (aref cvec index))
name))
- (setf (llm-provider-utils-function-call-args (aref cvec index))
- (concat (llm-provider-utils-function-call-args (aref cvec
index))
- arguments)))))
+ (cl-loop for call in (append part nil) do
+ (let* ((index (assoc-default 'index call))
+ (id (assoc-default 'id call))
+ (function (assoc-default 'function call))
+ (name (assoc-default 'name function))
+ (arguments (assoc-default 'arguments function)))
+ (when id
+ (setf (llm-provider-utils-function-call-id (aref
cvec index)) id))
+ (when name
+ (setf (llm-provider-utils-function-call-name (aref
cvec index)) name))
+ (setf (llm-provider-utils-function-call-args (aref
cvec index))
+ (concat (llm-provider-utils-function-call-args
(aref cvec index))
+ arguments)))))
(cl-loop for call in (append cvec nil)
do (setf (llm-provider-utils-function-call-args call)
(json-read-from-string
(llm-provider-utils-function-call-args call)))
finally return (when (> (length cvec) 0)
- (append cvec nil)))))
+ (append cvec nil)))))
(cl-defmethod llm-name ((_ llm-openai))
"Return the name of the provider."
@@ -258,8 +258,9 @@ RESPONSE can be nil if the response is complete."
;; models, but not for 32k models.
(+ (* n 1024) (if (= n 16) 1 0))))
((equal model "gpt-4") 8192)
+ ((equal model "gpt-4o") 128000)
((string-match-p (rx (seq "gpt-4-" (+ ascii) "-preview")) model)
- 128000)
+ 128000)
((string-match-p (rx (seq "gpt-4-" (+ digit))) model)
8192)
((string-match-p (rx (seq "gpt-3.5-turbo-1" (+ digit))) model)
diff --git a/llm-test.el b/llm-test.el
index c784bce728..bb4ec76311 100644
--- a/llm-test.el
+++ b/llm-test.el
@@ -97,17 +97,22 @@
(should-have-token-limit "gpt-4" 8192)
(should-have-token-limit "gpt-4-32k" 32768)
(should-have-token-limit "gpt-4-0613" 8192)
- (should-have-token-limit "gpt-4-32k-0613" 32768)))
+ (should-have-token-limit "gpt-4-32k-0613" 32768)
+ (should-have-token-limit "gpt-4o" 128000)))
(ert-deftest llm-test-chat-token-limit-gemini ()
(should (= 30720 (llm-chat-token-limit (make-llm-gemini))))
(should (= 12288 (llm-chat-token-limit
- (make-llm-gemini :chat-model "gemini-pro-vision")))))
+ (make-llm-gemini :chat-model "gemini-pro-vision"))))
+ (should (= 1048576 (llm-chat-token-limit
+ (make-llm-gemini :chat-model "gemini-1.5-flash")))))
(ert-deftest llm-test-chat-token-limit-vertex ()
(should (= 30720 (llm-chat-token-limit (make-llm-vertex))))
(should (= 12288 (llm-chat-token-limit
- (make-llm-vertex :chat-model "gemini-pro-vision")))))
+ (make-llm-vertex :chat-model "gemini-pro-vision"))))
+ (should (= 1048576 (llm-chat-token-limit
+ (make-llm-gemini :chat-model "gemini-1.5-flash")))))
(ert-deftest llm-test-chat-token-limit-ollama ()
;; The code is straightforward, so no need to test all the models.
diff --git a/llm-vertex.el b/llm-vertex.el
index 1e433d9b2f..4a86e064e5 100644
--- a/llm-vertex.el
+++ b/llm-vertex.el
@@ -190,7 +190,7 @@ the key must be regenerated every hour."
'function))
(stringp
(llm-chat-prompt-interaction-content interaction)))
`(((text . ,(llm-chat-prompt-interaction-content
- interaction))))
+ interaction))))
(if (eq 'function
(llm-chat-prompt-interaction-role
interaction))
(let ((fc
(llm-chat-prompt-interaction-function-call-result interaction)))
@@ -214,7 +214,7 @@ the key must be regenerated every hour."
.
,(llm-provider-utils-openai-arguments
(llm-function-call-args
tool))))))))
- (llm-chat-prompt-functions prompt)))))
+ (llm-chat-prompt-functions prompt)))))
(llm-vertex--chat-parameters prompt)))
(defun llm-vertex--chat-parameters (prompt)
@@ -223,8 +223,8 @@ Return value is a cons for adding to an alist, unless there
is
nothing to add, in which case it is nil."
(let ((params-alist))
(when (llm-chat-prompt-temperature prompt)
- (push `(temperature . ,(llm-chat-prompt-temperature prompt))
- params-alist))
+ (push `(temperature . ,(llm-chat-prompt-temperature prompt))
+ params-alist))
(when (llm-chat-prompt-max-tokens prompt)
(push `(maxOutputTokens . ,(llm-chat-prompt-max-tokens prompt))
params-alist))
(when params-alist
@@ -318,6 +318,7 @@ If STREAMING is non-nil, use the URL for the streaming API."
"Get token limit for MODEL."
(cond ((equal "gemini-pro" model) 30720)
((equal "gemini-pro-vision" model) 12288)
+ ((string-match-p (rx (seq "gemini-1.5")) model) 1048576)
;; This shouldn't happen unless there's a new model, which could be a
;; smaller or larger model. We'll play it safe and choose a reasonable
;; number.
- [elpa] externals/llm updated (478afbcb41 -> ebb7b6e4cd), ELPA Syncer, 2024/05/18
- [elpa] externals/llm 8a668ff914 2/7: Some linting and packaging fixes, ELPA Syncer, 2024/05/18
- [elpa] externals/llm ebb7b6e4cd 7/7: Set version to 0.15.0, ELPA Syncer, 2024/05/18
- [elpa] externals/llm 94eb0a0689 3/7: Fix rest of lint errors, ELPA Syncer, 2024/05/18
- [elpa] externals/llm 3a129ba077 1/7: Started using Eldev to manage the package, so ignoring it for git, ELPA Syncer, 2024/05/18
- [elpa] externals/llm f2291e4638 4/7: Add Eldev and new CI file that uses it, ELPA Syncer, 2024/05/18
- [elpa] externals/llm c8604bd694 6/7: Add information about new models,
ELPA Syncer <=
- [elpa] externals/llm 81eec9db7b 5/7: Fix bad CI file, missing the top-level jobs specifier, ELPA Syncer, 2024/05/18