From 511d0bc20f0e6ecc7d3cd69d7a8201dc70ef1c9d Mon Sep 17 00:00:00 2001 From: GitHub Workflow Date: Thu, 1 Feb 2024 00:02:41 +0000 Subject: [PATCH] Automated update of model definitions Signed-off-by: GitHub Workflow --- Cargo.toml | 2 +- src/model.rs | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 5fd53cb..58eb8a6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "turbocommit" -version = "0.15.1" +version = "0.15.2" edition = "2021" authors = [ "Sett",] description = "A CLI tool to create commit messages with OpenAI GPT models" diff --git a/src/model.rs b/src/model.rs index a33dae6..a01be8a 100644 --- a/src/model.rs +++ b/src/model.rs @@ -3,6 +3,8 @@ use serde::{Serialize, Deserialize}; #[derive(Debug, Copy, Clone, Default, PartialEq)] pub enum Model { + Gpt40125Preview, + Gpt4TurboPreview, Gpt41106Preview, Gpt4VisionPreview, Gpt4, @@ -12,7 +14,10 @@ pub enum Model { #[default] Gpt35Turbo, Gpt35Turbo16k, + Gpt35Turbo0301, + Gpt35Turbo0613, Gpt35Turbo1106, + Gpt35Turbo16k0613, } impl FromStr for Model { @@ -20,6 +25,8 @@ impl FromStr for Model { fn from_str(s: &str) -> Result { match s { + "gpt-4-0125-preview" => Ok(Self::Gpt40125Preview), + "gpt-4-turbo-preview" => Ok(Self::Gpt4TurboPreview), "gpt-4-1106-preview" => Ok(Self::Gpt41106Preview), "gpt-4-vision-preview" => Ok(Self::Gpt4VisionPreview), "gpt-4" => Ok(Self::Gpt4), @@ -28,7 +35,10 @@ impl FromStr for Model { "gpt-4-32k-0613" => Ok(Self::Gpt432k0613), "gpt-3.5-turbo" => Ok(Self::Gpt35Turbo), "gpt-3.5-turbo-16k" => Ok(Self::Gpt35Turbo16k), + "gpt-3.5-turbo-0301" => Ok(Self::Gpt35Turbo0301), + "gpt-3.5-turbo-0613" => Ok(Self::Gpt35Turbo0613), "gpt-3.5-turbo-1106" => Ok(Self::Gpt35Turbo1106), + "gpt-3.5-turbo-16k-0613" => Ok(Self::Gpt35Turbo16k0613), _ => Err(format!("{} is not a valid model", s)), } } @@ -38,6 +48,8 @@ impl FromStr for Model { impl ToString for Model { fn to_string(&self) -> String { match self { + Self::Gpt40125Preview { .. } => String::from("gpt-4-0125-preview"), + Self::Gpt4TurboPreview { .. } => String::from("gpt-4-turbo-preview"), Self::Gpt41106Preview { .. } => String::from("gpt-4-1106-preview"), Self::Gpt4VisionPreview { .. } => String::from("gpt-4-vision-preview"), Self::Gpt4 { .. } => String::from("gpt-4"), @@ -46,7 +58,10 @@ impl ToString for Model { Self::Gpt432k0613 { .. } => String::from("gpt-4-32k-0613"), Self::Gpt35Turbo { .. } => String::from("gpt-3.5-turbo"), Self::Gpt35Turbo16k { .. } => String::from("gpt-3.5-turbo-16k"), + Self::Gpt35Turbo0301 { .. } => String::from("gpt-3.5-turbo-0301"), + Self::Gpt35Turbo0613 { .. } => String::from("gpt-3.5-turbo-0613"), Self::Gpt35Turbo1106 { .. } => String::from("gpt-3.5-turbo-1106"), + Self::Gpt35Turbo16k0613 { .. } => String::from("gpt-3.5-turbo-16k-0613"), } } } @@ -73,6 +88,8 @@ impl<'de> Deserialize<'de> for Model { impl Model { pub fn all() -> Vec { vec![ + Self::Gpt40125Preview, + Self::Gpt4TurboPreview, Self::Gpt41106Preview, Self::Gpt4VisionPreview, Self::Gpt4, @@ -81,12 +98,17 @@ impl Model { Self::Gpt432k0613, Self::Gpt35Turbo, Self::Gpt35Turbo16k, + Self::Gpt35Turbo0301, + Self::Gpt35Turbo0613, Self::Gpt35Turbo1106, + Self::Gpt35Turbo16k0613, ] } pub fn cost(&self, prompt_tokens: usize, completion_tokens: usize) -> f64 { let (prompt_cost, completion_cost) = match self { + Self::Gpt40125Preview => (0.01, 0.03), + Self::Gpt4TurboPreview => (0.01, 0.03), Self::Gpt41106Preview => (0.01, 0.03), Self::Gpt4VisionPreview => (0.01, 0.03), Self::Gpt4 => (0.01, 0.03), @@ -95,7 +117,10 @@ impl Model { Self::Gpt432k0613 => (0.06, 0.12), Self::Gpt35Turbo => (0.0015, 0.002), Self::Gpt35Turbo16k => (0.0015, 0.002), + Self::Gpt35Turbo0301 => (0.0015, 0.002), + Self::Gpt35Turbo0613 => (0.0015, 0.002), Self::Gpt35Turbo1106 => (0.001, 0.002), + Self::Gpt35Turbo16k0613 => (0.0015, 0.002), }; (prompt_tokens as f64).mul_add( prompt_cost / 1000.0, @@ -105,6 +130,8 @@ impl Model { pub const fn context_size(&self) -> usize { match self { + Self::Gpt40125Preview => 128000, + Self::Gpt4TurboPreview => 128000, Self::Gpt41106Preview => 128000, Self::Gpt4VisionPreview => 128000, Self::Gpt4 => 8192, @@ -113,7 +140,10 @@ impl Model { Self::Gpt432k0613 => 32768, Self::Gpt35Turbo => 4096, Self::Gpt35Turbo16k => 16385, + Self::Gpt35Turbo0301 => 4096, + Self::Gpt35Turbo0613 => 4096, Self::Gpt35Turbo1106 => 16385, + Self::Gpt35Turbo16k0613 => 16385, } } } \ No newline at end of file