Add support for OpenAI o3 and o4-mini models (#28881)

Release Notes:

- Add support for OpenAI o3 and o4-mini models via OpenAI API and
Copilot Chat providers.

---------

Co-authored-by: Peter Tripp <peter@zed.dev>
This commit is contained in:
Umesh Yadav 2025-04-17 20:28:41 +05:30 committed by GitHub
parent 002235d0da
commit 8117940aca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 33 additions and 2 deletions

View file

@ -85,6 +85,10 @@ pub enum Model {
O1Mini,
#[serde(rename = "o3-mini", alias = "o3-mini")]
O3Mini,
#[serde(rename = "o3", alias = "o3")]
O3,
#[serde(rename = "o4-mini", alias = "o4-mini")]
O4Mini,
#[serde(rename = "custom")]
Custom {
@ -112,6 +116,8 @@ impl Model {
"o1-preview" => Ok(Self::O1Preview),
"o1-mini" => Ok(Self::O1Mini),
"o3-mini" => Ok(Self::O3Mini),
"o3" => Ok(Self::O3),
"o4-mini" => Ok(Self::O4Mini),
_ => Err(anyhow!("invalid model id")),
}
}
@ -130,6 +136,8 @@ impl Model {
Self::O1Preview => "o1-preview",
Self::O1Mini => "o1-mini",
Self::O3Mini => "o3-mini",
Self::O3 => "o3",
Self::O4Mini => "o4-mini",
Self::Custom { name, .. } => name,
}
}
@ -148,6 +156,8 @@ impl Model {
Self::O1Preview => "o1-preview",
Self::O1Mini => "o1-mini",
Self::O3Mini => "o3-mini",
Self::O3 => "o3",
Self::O4Mini => "o4-mini",
Self::Custom {
name, display_name, ..
} => display_name.as_ref().unwrap_or(name),
@ -168,6 +178,8 @@ impl Model {
Self::O1Preview => 128_000,
Self::O1Mini => 128_000,
Self::O3Mini => 200_000,
Self::O3 => 200_000,
Self::O4Mini => 200_000,
Self::Custom { max_tokens, .. } => *max_tokens,
}
}