Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
1979899
feat(gptel-anthropic): Add updated Anthropic models and properties
benthamite Oct 13, 2024
67c71b7
gptel-anthropic: Make anthropic model constant an internal variable
benthamite Oct 13, 2024
4e59c73
gptel-anthropic: Format docstring correctly
benthamite Oct 13, 2024
c102c7a
gptel-gemini: Add updated Gemini models and properties
benthamite Oct 13, 2024
74ff8de
gptel-gemini: Fix incorrect backend name
benthamite Oct 13, 2024
e70c935
gptel: Add updated OpenAI models and properties
benthamite Oct 14, 2024
8402742
gptel: fix accidentally misplaced quote
benthamite Oct 14, 2024
f75e541
gptel: Slightly shorten model description
benthamite Oct 14, 2024
478e201
gptel-transient: Update annotation function to show extra model details
benthamite Oct 14, 2024
87d1e53
gptel-gemini: make puntuation in the :description field consistent
benthamite Oct 14, 2024
52fa6fc
gptel-transient: Adjust formatting and ordering in annotation function
benthamite Oct 14, 2024
9c9f282
gptel: Shorten model :description fields to 70 chars or less
benthamite Oct 16, 2024
612f111
gptel-gemini: Shorten model :description fields to 70 chars or less
benthamite Oct 16, 2024
3d2ee46
gptel-transient: Further revise gptel--infix-provider
benthamite Oct 16, 2024
f6e0168
Rename :updated keyword to :cutoff-date
benthamite Oct 16, 2024
646b910
gptel-transient: Further revise gptel--infix-provider
benthamite Oct 16, 2024
6c2d86b
gptel: Shorten gpt-4-0125-preview model :description field to 70 char…
benthamite Oct 16, 2024
9d00c3b
gptel-openai: Mention gptel--openai-models in gptel-make-openai
benthamite Oct 17, 2024
7dd152a
gptel-transient: Update name of cutoff date property and variable
benthamite Oct 17, 2024
fd8086c
gptel-gemini: Add model cutoff dates
benthamite Oct 17, 2024
ed39bbc
gptel: Standardize cutoff date format
benthamite Oct 17, 2024
7b2ba07
Change cutoff date format to yyyy-mm
benthamite Oct 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 63 additions & 21 deletions gptel-anthropic.el
Original file line number Diff line number Diff line change
Expand Up @@ -178,29 +178,71 @@ files in the context."
;; (t context-string)))
;; (plist-get (car (last prompts)) :content)))

(defconst gptel--anthropic-models
'((claude-3-5-sonnet-20240620
:description "Highest level of intelligence and capability"
:capabilities (media tool)
:mime-types ("image/jpeg" "image/png" "image/gif" "image/webp")
:context-window 200
:input-cost 3
:output-cost 15
:cutoff-date "2024-04")
(claude-3-opus-20240229
:description "Top-level performance, intelligence, fluency, and understanding"
:capabilities (media tool)
:mime-types ("image/jpeg" "image/png" "image/gif" "image/webp")
:context-window 200
:input-cost 15
:output-cost 75
:cutoff-date "2023-08")
(claude-3-haiku-20240307
:description "Fast and most compact model for near-instant responsiveness"
:capabilities (media tool)
:mime-types ("image/jpeg" "image/png" "image/gif" "image/webp")
:context-window 200
:input-cost 0.25
:output-cost 1.25
:cutoff-date "2023-08")
(claude-3-sonnet-20240229
:description "Balance of intelligence and speed (legacy model)"
:capabilities (media tool)
:mime-types ("image/jpeg" "image/png" "image/gif" "image/webp")
:context-window 200
:input-cost 3
:output-cost 15
:cutoff-date "2023-08"))
"List of available Anthropic models and associated properties.
Keys:

- `:description': a brief description of the model.

- `:capabilities': a list of capabilities supported by the model.

- `:mime-types': a list of supported MIME types for media files.

- `:context-window': the context window size, in thousands of tokens.

- `:input-cost': the input cost, in US dollars per million tokens.

- `:output-cost': the output cost, in US dollars per million tokens.

- `:cutoff-date': the knowledge cutoff date.

Information about the Anthropic models was obtained from the following
sources:

- <https://www.anthropic.com/pricing#anthropic-api>
- <https://www.anthropic.com/news/claude-3-5-sonnet>
- <https://support.anthropic.com/en/articles/8114494-how-up-to-date-is-claude-s-training-data>")

;;;###autoload
(cl-defun gptel-make-anthropic
(name &key curl-args stream key
(header
(lambda () (when-let (key (gptel--get-api-key))
`(("x-api-key" . ,key)
("anthropic-version" . "2023-06-01")))))
(models '((claude-3-5-sonnet-20240620
:description "Balance of intelligence and speed"
:capabilities (media tool)
:mime-types ("image/jpeg" "image/png" "image/gif" "image/webp"))
(claude-3-sonnet-20240229
:description "Highest level of intelligence and capability"
:capabilities (media tool)
:mime-types ("image/jpeg" "image/png" "image/gif" "image/webp"))
(claude-3-haiku-20240307
:description "Fast and most compact model for near-instant responsiveness"
:capabilities (media tool)
:mime-types ("image/jpeg" "image/png" "image/gif" "image/webp"))
(claude-3-opus-20240229
:description "Top-level performance, intelligence, fluency, and understanding"
:capabilities (media tool)
:mime-types ("image/jpeg" "image/png" "image/gif" "image/webp"))))
`(("x-api-key" . ,key)
("anthropic-version" . "2023-06-01")))))
(models gptel--anthropic-models)
(host "api.anthropic.com")
(protocol "https")
(endpoint "/v1/messages"))
Expand All @@ -219,9 +261,9 @@ information, in the form

(model-name . plist)

Currently recognized plist keys are :description, :capabilities
and :mime-types. An example of a model specification including
both kinds of specs:
For a list of currently recognized plist keys, see
`gptel--anthropic-models'. An example of a model specification
including both kinds of specs:

:models
\\='(claude-3-haiku-20240307 ;Simple specs
Expand Down
75 changes: 57 additions & 18 deletions gptel-gemini.el
Original file line number Diff line number Diff line change
Expand Up @@ -184,26 +184,65 @@ files in the context."
current))
(plist-get (car (last prompts)) :parts))))

(defconst gptel--gemini-models
'((gemini-pro
:description "The previous generation of Google's multimodal AI model"
:capabilities (tool json media)
:mime-types ("image/png" "image/jpeg" "image/webp" "image/heic" "image/heif"
"application/pdf" "text/plain" "text/csv" "text/html")
:context-window 32
:input-cost 0.50
:output-cost 1.50
:cutoff-date "2023-02")
(gemini-1.5-flash
:description "A faster, more efficient version of Gemini 1.5 optimized for speed"
:capabilities (tool json media)
:mime-types ("image/png" "image/jpeg" "image/webp" "image/heic" "image/heif"
"application/pdf" "text/plain" "text/csv" "text/html")
:context-window 1000
;; input & output price is halved for prompts of 128k tokens or less
:input-cost 0.15
:output-cost 0.60
:cutoff-date "2024-05")
(gemini-1.5-pro-latest
:description "Google's latest model with enhanced capabilities across various tasks"
:capabilities (tool json media)
:mime-types ("image/png" "image/jpeg" "image/webp" "image/heic" "image/heif"
"application/pdf" "text/plain" "text/csv" "text/html")
:context-window 2000
;; input & output price is halved for prompts of 128k tokens or less
:input-cost 2.50
:output-cost 10
:cutoff-date "2024-05"))
"List of available Gemini models and associated properties.
Keys:

- `:description': a brief description of the model.

- `:capabilities': a list of capabilities supported by the model.

- `:mime-types': a list of supported MIME types for media files.

- `:context-window': the context window size, in thousands of tokens.

- `:input-cost': the input cost, in US dollars per million tokens.

- `:output-cost': the output cost, in US dollars per million tokens.

- `:cutoff-date': the knowledge cutoff date.

Information about the Gemini models was obtained from the following
source:

- <https://ai.google.dev/pricing>
- <https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models>")

;;;###autoload
(cl-defun gptel-make-gemini
(name &key curl-args header key (stream nil)
(host "generativelanguage.googleapis.com")
(protocol "https")
(models '((gemini-pro
:description "Complex reasoning tasks, problem solving, data extraction and generation"
:capabilities (tool json media)
:mime-types ("image/png" "image/jpeg" "image/webp" "image/heic" "image/heif"
"application/pdf" "text/plain" "text/csv" "text/html"))
(gemini-1.5-flash
:description "Fast and versatile performance across a diverse variety of tasks"
:capabilities (tool json media)
:mime-types ("image/png" "image/jpeg" "image/webp" "image/heic" "image/heif"
"application/pdf" "text/plain" "text/csv" "text/html"))
(gemini-1.5-pro-latest
:description "Complex reasoning tasks, problem solving, data extraction and generation"
:capabilities (tool json media)
:mime-types ("image/png" "image/jpeg" "image/webp" "image/heic" "image/heif"
"application/pdf" "text/plain" "text/csv" "text/html"))))
(models gptel--gemini-models)
(endpoint "/v1beta/models"))

"Register a Gemini backend for gptel with NAME.
Expand All @@ -222,9 +261,9 @@ information, in the form

(model-name . plist)

Currently recognized plist keys are :description, :capabilities
and :mime-types. An example of a model specification including
both kinds of specs:
For a list of currently recognized plist keys, see
`gptel--gemini-models'. An example of a model specification
including both kinds of specs:

:models
\\='(gemini-pro ;Simple specs
Expand Down
6 changes: 3 additions & 3 deletions gptel-openai.el
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,9 @@ information, in the form

(model-name . plist)

Currently recognized plist keys are :description, :capabilities
and :mime-types. An example of a model specification including
both kinds of specs:
For a list of currently recognized plist keys, see
`gptel--openai-models'. An example of a model specification
including both kinds of specs:

:models
\\='(gpt-3.5-turbo ;Simple specs
Expand Down
31 changes: 22 additions & 9 deletions gptel-transient.el
Original file line number Diff line number Diff line change
Expand Up @@ -551,15 +551,28 @@ responses."
with completion-extra-properties =
`(:annotation-function
,(lambda (comp)
(let* ((model (nth 2 (assoc comp models-alist)))
(desc (get model :description))
(caps (get model :capabilities)))
(when (or desc caps)
(concat
(propertize " " 'display `(space :align-to (0.33 . ,(window-width))))
desc
(propertize " " 'display `(space :align-to (0.75 . ,(window-width))))
(when caps (prin1-to-string caps)))))))
(let* ((model (nth 2 (assoc comp models-alist)))
(desc (get model :description))
(caps (get model :capabilities))
(context (get model :context-window))
(input-cost (get model :input-cost))
(output-cost (get model :output-cost))
(cutoff (get model :cutoff-date)))
(when (or desc caps context input-cost output-cost cutoff)
(concat
(propertize " " 'display `(space :align-to 40))
(when desc (truncate-string-to-width desc 70 nil ? t t))
" " (propertize " " 'display `(space :align-to 112))
(when caps (truncate-string-to-width (prin1-to-string caps) 21 nil ? t t))
" " (propertize " " 'display `(space :align-to 134))
(when context (format "%5dk" context))
" " (propertize " " 'display `(space :align-to 142))
(when input-cost (format "$%5.2f in" input-cost))
(if (and input-cost output-cost) "," " ")
" " (propertize " " 'display `(space :align-to 153))
(when output-cost (format "$%6.2f out" output-cost))
" " (propertize " " 'display `(space :align-to 166))
cutoff)))))
finally return
(cdr (assoc (completing-read prompt models-alist nil t)
models-alist)))))
Expand Down
122 changes: 97 additions & 25 deletions gptel.el
Original file line number Diff line number Diff line change
Expand Up @@ -455,32 +455,104 @@ To set the temperature for a chat session interactively call

(defvar gptel--known-backends)

(defconst gptel--openai-models
'((gpt-4o
:description "Advanced model for complex tasks; cheaper & faster than GPT-Turbo"
:capabilities (media tool json url)
:mime-types ("image/jpeg" "image/png" "image/gif" "image/webp")
:context-window 128
:input-cost 2.50
:output-cost 10
:cutoff-date "2023-10")
(gpt-4o-mini
:description "Cheap model for fast tasks; cheaper & more capable than GPT-3.5 Turbo"
:capabilities (media tool json url)
:mime-types ("image/jpeg" "image/png" "image/gif" "image/webp")
:context-window 128
:input-cost 0.15
:output-cost 0.60
:cutoff-date "2023-10")
(gpt-4-turbo
:description "Previous high-intelligence model"
:capabilities (media tool url)
:mime-types ("image/jpeg" "image/png" "image/gif" "image/webp")
:context-window 128
:input-cost 10
:output-cost 30
:cutoff-date "2023-12")
;; points to gpt-4-0613
(gpt-4
:description "GPT-4 snapshot from June 2023 with improved function calling support"
:context-window 8.192
:input-cost 30
:output-cost 60
:cutoff-date "2023-09")
(gpt-4-turbo-preview
:description "Points to gpt-4-0125-preview"
:context-window 128
:input-cost 10
:output-cost 30
:cutoff-date "2023-12")
(gpt-4-0125-preview
:description "GPT-4 Turbo preview model intended to reduce cases of “laziness”"
:context-window 128
:input-cost 10
:output-cost 30
:cutoff-date "2023-12")
;; limited information available
(gpt-4-32k
:input-cost 60
:output-cost 120)
(gpt-4-1106-preview
:description "Preview model with improved function calling support"
:context-window 128
:input-cost 10
:output-cost 30
:cutoff-date "2023-04")
(gpt-3.5-turbo
:description "More expensive & less capable than GPT-4o-mini; use that instead"
:capabilities (tool)
:mime-types ("image/jpeg" "image/png" "image/gif" "image/webp")
:context-window 16.358
:input-cost 0.50
:output-cost 1.50
:cutoff-date "2021-09")
(gpt-3.5-turbo-16k
:description "More expensive & less capable than GPT-4o-mini; use that instead"
:mime-types ("image/jpeg" "image/png" "image/gif" "image/webp")
:context-window 16.385
:input-cost 3
:output-cost 4
:cutoff-date "2021-09"))
"List of available OpenAI models and associated properties.
Keys:

- `:description': a brief description of the model.

- `:capabilities': a list of capabilities supported by the model.

- `:mime-types': a list of supported MIME types for media files.

- `:context-window': the context window size, in thousands of tokens.

- `:input-cost': the input cost, in US dollars per million tokens.

- `:output-cost': the output cost, in US dollars per million tokens.

- `:cutoff-date': the knowledge cutoff date.

Information about the OpenAI models was obtained from the following
sources:

- <https://openai.com/pricing>
- <https://platform.openai.com/docs/models>")

(defvar gptel--openai
(gptel-make-openai
"ChatGPT"
:key 'gptel-api-key
:stream t
:models
'((gpt-4o-mini
:capabilities (media tool json url)
:description "Affordable and intelligent small model for fast, lightweight tasks"
:mime-types ("image/jpeg" "image/png" "image/gif" "image/webp"))
(gpt-4o
:capabilities (media tool json url)
:description "High-intelligence flagship model for complex, multi-step tasks"
:mime-types ("image/jpeg" "image/png" "image/gif" "image/webp"))
(gpt-3.5-turbo
:description "Fast, inexpensive model for simple tasks"
:mime-types ("image/jpeg" "image/png" "image/gif" "image/webp")
:capabilities (tool))
(gpt-3.5-turbo-16k :description "Fast, inexpensive model for simple tasks, 16K context"
:mime-types ("image/jpeg" "image/png" "image/gif" "image/webp"))
(gpt-4-turbo
:capabilities (media tool url)
:description "Previous high-intelligence model"
:mime-types ("image/jpeg" "image/png" "image/gif" "image/webp"))
(gpt-4 :description "Previous high-intelligence model")
gpt-4-turbo-preview gpt-4-32k gpt-4-1106-preview gpt-4-0125-preview)))
"ChatGPT"
:key 'gptel-api-key
:stream t
:models gptel--openai-models))

(defcustom gptel-backend gptel--openai
"LLM backend to use.
Expand All @@ -503,7 +575,7 @@ README for examples."
:type `(choice
(const :tag "ChatGPT" ,gptel--openai)
(restricted-sexp :match-alternatives (gptel-backend-p 'nil)
:tag "Other backend")))
:tag "Other backend")))

(defvar gptel-expert-commands nil
"Whether experimental gptel options should be enabled.
Expand Down