Add GPT 5.1 to Zed BYOK (#43492)

Release Notes:

- Added support for OpenAI's GPT 5.1 model to BYOK
This commit is contained in:
Mikayla Maki
2025-11-25 14:17:27 -08:00
committed by GitHub
parent 877763b960
commit 53eb35f5b2
4 changed files with 17 additions and 10 deletions
Generated
+2 -2
View File
@@ -17313,8 +17313,8 @@ dependencies = [
[[package]] [[package]]
name = "tiktoken-rs" name = "tiktoken-rs"
version = "0.8.0" version = "0.9.1"
source = "git+https://github.com/zed-industries/tiktoken-rs?rev=30c32a4522751699adeda0d5840c71c3b75ae73d#30c32a4522751699adeda0d5840c71c3b75ae73d" source = "git+https://github.com/zed-industries/tiktoken-rs?rev=7249f999c5fdf9bf3cc5c288c964454e4dac0c00#7249f999c5fdf9bf3cc5c288c964454e4dac0c00"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"base64 0.22.1", "base64 0.22.1",
+1 -1
View File
@@ -655,7 +655,7 @@ sysinfo = "0.37.0"
take-until = "0.2.0" take-until = "0.2.0"
tempfile = "3.20.0" tempfile = "3.20.0"
thiserror = "2.0.12" thiserror = "2.0.12"
tiktoken-rs = { git = "https://github.com/zed-industries/tiktoken-rs", rev = "30c32a4522751699adeda0d5840c71c3b75ae73d" } tiktoken-rs = { git = "https://github.com/zed-industries/tiktoken-rs", rev = "7249f999c5fdf9bf3cc5c288c964454e4dac0c00" }
time = { version = "0.3", features = [ time = { version = "0.3", features = [
"macros", "macros",
"parsing", "parsing",
@@ -277,6 +277,7 @@ impl LanguageModel for OpenAiLanguageModel {
| Model::Five | Model::Five
| Model::FiveMini | Model::FiveMini
| Model::FiveNano | Model::FiveNano
| Model::FivePointOne
| Model::O1 | Model::O1
| Model::O3 | Model::O3
| Model::O4Mini => true, | Model::O4Mini => true,
@@ -644,7 +645,6 @@ pub fn count_open_ai_tokens(
) -> BoxFuture<'static, Result<u64>> { ) -> BoxFuture<'static, Result<u64>> {
cx.background_spawn(async move { cx.background_spawn(async move {
let messages = collect_tiktoken_messages(request); let messages = collect_tiktoken_messages(request);
match model { match model {
Model::Custom { max_tokens, .. } => { Model::Custom { max_tokens, .. } => {
let model = if max_tokens >= 100_000 { let model = if max_tokens >= 100_000 {
@@ -672,11 +672,11 @@ pub fn count_open_ai_tokens(
| Model::O1 | Model::O1
| Model::O3 | Model::O3
| Model::O3Mini | Model::O3Mini
| Model::O4Mini => tiktoken_rs::num_tokens_from_messages(model.id(), &messages), | Model::O4Mini
// GPT-5 models don't have tiktoken support yet; fall back on gpt-4o tokenizer | Model::Five
Model::Five | Model::FiveMini | Model::FiveNano => { | Model::FiveMini
tiktoken_rs::num_tokens_from_messages("gpt-4o", &messages) | Model::FiveNano => tiktoken_rs::num_tokens_from_messages(model.id(), &messages), // GPT-5.1 doesn't have tiktoken support yet; fall back on gpt-4o tokenizer
} Model::FivePointOne => tiktoken_rs::num_tokens_from_messages("gpt-5", &messages),
} }
.map(|tokens| tokens as u64) .map(|tokens| tokens as u64)
}) })
+8 -1
View File
@@ -85,7 +85,8 @@ pub enum Model {
FiveMini, FiveMini,
#[serde(rename = "gpt-5-nano")] #[serde(rename = "gpt-5-nano")]
FiveNano, FiveNano,
#[serde(rename = "gpt-5.1")]
FivePointOne,
#[serde(rename = "custom")] #[serde(rename = "custom")]
Custom { Custom {
name: String, name: String,
@@ -121,6 +122,7 @@ impl Model {
"gpt-5" => Ok(Self::Five), "gpt-5" => Ok(Self::Five),
"gpt-5-mini" => Ok(Self::FiveMini), "gpt-5-mini" => Ok(Self::FiveMini),
"gpt-5-nano" => Ok(Self::FiveNano), "gpt-5-nano" => Ok(Self::FiveNano),
"gpt-5.1" => Ok(Self::FivePointOne),
invalid_id => anyhow::bail!("invalid model id '{invalid_id}'"), invalid_id => anyhow::bail!("invalid model id '{invalid_id}'"),
} }
} }
@@ -142,6 +144,7 @@ impl Model {
Self::Five => "gpt-5", Self::Five => "gpt-5",
Self::FiveMini => "gpt-5-mini", Self::FiveMini => "gpt-5-mini",
Self::FiveNano => "gpt-5-nano", Self::FiveNano => "gpt-5-nano",
Self::FivePointOne => "gpt-5.1",
Self::Custom { name, .. } => name, Self::Custom { name, .. } => name,
} }
} }
@@ -163,6 +166,7 @@ impl Model {
Self::Five => "gpt-5", Self::Five => "gpt-5",
Self::FiveMini => "gpt-5-mini", Self::FiveMini => "gpt-5-mini",
Self::FiveNano => "gpt-5-nano", Self::FiveNano => "gpt-5-nano",
Self::FivePointOne => "gpt-5.1",
Self::Custom { Self::Custom {
name, display_name, .. name, display_name, ..
} => display_name.as_ref().unwrap_or(name), } => display_name.as_ref().unwrap_or(name),
@@ -186,6 +190,7 @@ impl Model {
Self::Five => 272_000, Self::Five => 272_000,
Self::FiveMini => 272_000, Self::FiveMini => 272_000,
Self::FiveNano => 272_000, Self::FiveNano => 272_000,
Self::FivePointOne => 400_000,
Self::Custom { max_tokens, .. } => *max_tokens, Self::Custom { max_tokens, .. } => *max_tokens,
} }
} }
@@ -210,6 +215,7 @@ impl Model {
Self::Five => Some(128_000), Self::Five => Some(128_000),
Self::FiveMini => Some(128_000), Self::FiveMini => Some(128_000),
Self::FiveNano => Some(128_000), Self::FiveNano => Some(128_000),
Self::FivePointOne => Some(128_000),
} }
} }
@@ -237,6 +243,7 @@ impl Model {
| Self::FourPointOneNano | Self::FourPointOneNano
| Self::Five | Self::Five
| Self::FiveMini | Self::FiveMini
| Self::FivePointOne
| Self::FiveNano => true, | Self::FiveNano => true,
Self::O1 | Self::O3 | Self::O3Mini | Self::O4Mini | Model::Custom { .. } => false, Self::O1 | Self::O3 | Self::O3Mini | Self::O4Mini | Model::Custom { .. } => false,
} }