From a2cde3051558d3f0c5cb4c3395ecffe00435c4c7 Mon Sep 17 00:00:00 2001 From: J S <49557684+svilupp@users.noreply.github.com> Date: Wed, 14 Aug 2024 08:54:08 +0100 Subject: [PATCH] Add ChatGPT 4o (#195) --- CHANGELOG.md | 5 +++++ Project.toml | 2 +- src/llm_openai.jl | 45 +++++++++++++++++++++++++++++++++++++++++ src/user_preferences.jl | 6 ++++++ 4 files changed, 57 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 00fc0a244..433a9357e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +## [0.49.0] + +### Added +- Added new OpenAI's model "chatgpt-4o-latest" to the model registry with alias "chatgpt". This model represents the latest version of ChatGPT-4o tuned specifically for ChatGPT. + ## [0.48.0] ### Added diff --git a/Project.toml b/Project.toml index c2ca2ab49..d199ad268 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "PromptingTools" uuid = "670122d1-24a8-4d70-bfce-740807c42192" authors = ["J S @svilupp and contributors"] -version = "0.48.0" +version = "0.49.0" [deps] AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c" diff --git a/src/llm_openai.jl b/src/llm_openai.jl index fe866f022..2f3f51f31 100644 --- a/src/llm_openai.jl +++ b/src/llm_openai.jl @@ -683,6 +683,51 @@ const OPENAI_TOKEN_IDS = Dict("true" => 837, "39" => 2137, "40" => 1272 ) +# GPT-4o token IDs as per tiktoken +# "true": 3309, +# "false": 7556, +# "unknown": 33936, +# "other": 2141, +# "1": 16, +# "2": 17, +# "3": 18, +# "4": 19, +# "5": 20, +# "6": 21, +# "7": 22, +# "8": 23, +# "9": 24, +# "10": 702, +# "11": 994, +# "12": 899, +# "13": 1311, +# "14": 1265, +# "15": 1055, +# "16": 1125, +# "17": 1422, +# "18": 1157, +# "19": 858, +# "20": 455, +# "21": 2040, +# "22": 1709, +# "23": 1860, +# "24": 1494, +# "25": 1161, +# "26": 2109, +# "27": 2092, +# "28": 2029, +# "29": 2270, +# "30": 1130, +# "31": 2911, +# "32": 1398, +# "33": 2546, +# "34": 3020, +# "35": 2467, +# "36": 2636, +# "37": 2991, +# "38": 3150, +# "39": 3255, +# "40": 1723, """ encode_choices(schema::OpenAISchema, choices::AbstractVector{<:AbstractString}; kwargs...) diff --git a/src/user_preferences.jl b/src/user_preferences.jl index 6f770c88e..935fe1b95 100644 --- a/src/user_preferences.jl +++ b/src/user_preferences.jl @@ -330,6 +330,7 @@ aliases = merge( "gpt4v" => "gpt-4-vision-preview", # 4v is for "4 vision" "gpt4t" => "gpt-4-turbo", # 4t is for "4 turbo" "gpt3t" => "gpt-3.5-turbo-0125", # 3t is for "3 turbo" + "chatgpt" => "chatgpt-4o-latest", "ada" => "text-embedding-ada-002", "emb3small" => "text-embedding-3-small", "emb3large" => "text-embedding-3-large", @@ -467,6 +468,11 @@ registry = Dict{String, ModelSpec}( 1.5e-7, 6e-7, "GPT-4 Omni Mini, the smallest and fastest model based on GPT4 (and cheaper than GPT3.5Turbo). Context of 128K, knowledge until October 2023. Currently points to version gpt-4o-2024-07-18."), + "chatgpt-4o-latest" => ModelSpec("chatgpt-4o-latest", + OpenAISchema(), + 5e-6, + 1.5e-5, + "ChatGPT-4o-latest is the latest version of ChatGPT-4o tuned for ChatGPT. It is the NOT same as gpt-4o-latest."), "gpt-4-vision-preview" => ModelSpec( "gpt-4-vision-preview", OpenAISchema(),