Skip to content

Commit 8351ee9

Browse files
authored
Introduce llm-models-add, plus fix an issue with gemini 2.0 model (#136)
This is in response to a request from the discussion at #134 by @s-kostyaev. The user can add to the existing list of models via a function. It was possible before as well, but this makes it more obvious, and adds a layer of indirection in case we want to introduce a new variable for just user-specified models.
1 parent 9e754cd commit 8351ee9

File tree

4 files changed

+33
-9
lines changed

4 files changed

+33
-9
lines changed

NEWS.org

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
* Version 0.21.0
2+
- Add ~llm-models-add~ as a convenience method to add a model to the known list.
13
* Version 0.20.0
24
- Add ability to output according to a JSON spec.
35
- Add Gemini 2.0 Flash, Gemini 2.0 Flash Thinking, and Llama 3.3 and QwQ models.

README.org

+5-7
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,11 @@ When picking a chat or embedding model, anything can be used, as long as the ser
108108

109109
#+begin_src emacs-lisp
110110
(require 'llm-models)
111-
(add-to-list
112-
'llm-models
113-
(make-llm-model
114-
:name "Mistral" :symbol 'mistral
115-
:capabilities '(generation tool-use free-software)
116-
:context-length 8192
117-
:regex "mistral"))
111+
(llm-models-add
112+
:name "Mistral" :symbol 'mistral
113+
:capabilities '(generation tool-use free-software)
114+
:context-length 8192
115+
:regex "mistral"))
118116
#+end_src
119117

120118
The =:regex= needs to uniquely identify the model passed in from a provider's chat or embedding model.

llm-models-test.el

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
;; the models to ensure that the first match is the unique match.
3030
(let ((models-names-to-test '("gpt-3.5-turbo-instructo" "gpt-4" "gpt-4o"
3131
"gemini-1.5-flash" "llama-3" "llama-3.1"
32-
"llama3" "llama3.1")))
32+
"llama3" "llama3.1" "gemini-2.0-flash-thinking")))
3333
(dolist (model-name models-names-to-test)
3434
(let ((model-forward (llm-models-match model-name))
3535
(model-reverse (let ((llm-models (reverse llm-models)))

llm-models.el

+25-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ REGEX is a regular expression that can be used to identify the model, uniquely (
126126
:name "Gemini 2.0 Flash" :symbol 'gemini-2.0-flash
127127
:capabilities '(generation tool-use image-input audio-input video-input)
128128
:context-length 1048576
129-
:regex "gemini-2\\.0-flash")
129+
:regex "gemini-2\\.0-flash\\(-exp\\)?$")
130130
(make-llm-model
131131
:name "Gemini 2.0 Flash Thinking" :symbol 'gemini-2.0-flash-thinking
132132
:capabilities '(generation)
@@ -248,6 +248,30 @@ REGEX is a regular expression that can be used to identify the model, uniquely (
248248
"Return the model that matches NAME."
249249
(seq-find (lambda (model) (string-match-p (llm-model-regex model) (downcase name))) llm-models))
250250

251+
(cl-defun llm-models-add (&key name symbol capabilities context-length regex)
252+
"Add a model to the list of models.
253+
254+
NAME is the name of the model, appropriate for showing a user.
255+
256+
SYMBOL is a symbol representing the model, which just needs to be a
257+
unique symbol, and can also be searched on.
258+
259+
CAPABILITIES is a list of symbols representing the capabilities of the
260+
model. See `llm-capabilities' for the potential list of supported
261+
capabilities. This may have some capabilities not yet supported by the
262+
`llm-capabilities'.
263+
264+
CONTEXT-LENGTH is the maximum length of the context that can be used as
265+
input.
266+
267+
REGEX is a regular expression that will be used to identify the model
268+
uniquely, matched against the model specified by the user."
269+
(push (make-llm-model :name name
270+
:symbol symbol
271+
:capabilities capabilities
272+
:context-length context-length
273+
:regex regex) llm-models))
274+
251275
(provide 'llm-models)
252276

253277
;;; llm-models.el ends here

0 commit comments

Comments
 (0)