Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Add Grok 4.7 to Supergrok and XAi (#64567)

Raphael Lüthy16c9aa7ea6d8
diff --git a/crates/language_models/src/provider/x_ai.rs b/crates/language_models/src/provider/x_ai.rs
index 8bc9e8562d8..708d05f3830 100644
--- a/crates/language_models/src/provider/x_ai.rs
+++ b/crates/language_models/src/provider/x_ai.rs
@@ -271,7 +271,7 @@ fn x_ai_reasoning_efforts(model: &x_ai::Model) -> &'static [open_ai::ReasoningEf
open_ai::ReasoningEffort::Medium,
open_ai::ReasoningEffort::High,
],
- x_ai::Model::Grok46 => &[
+ x_ai::Model::Grok46 | x_ai::Model::Grok47 => &[
open_ai::ReasoningEffort::Low,
open_ai::ReasoningEffort::Medium,
open_ai::ReasoningEffort::High,
@@ -284,7 +284,9 @@ fn x_ai_reasoning_efforts(model: &x_ai::Model) -> &'static [open_ai::ReasoningEf
fn default_thinking_reasoning_effort(model: &x_ai::Model) -> Option<open_ai::ReasoningEffort> {
match model {
x_ai::Model::Grok43 => Some(open_ai::ReasoningEffort::Low),
- x_ai::Model::Grok45 | x_ai::Model::Grok46 => Some(open_ai::ReasoningEffort::High),
+ x_ai::Model::Grok45 | x_ai::Model::Grok46 | x_ai::Model::Grok47 => {
+ Some(open_ai::ReasoningEffort::High)
+ }
_ => None,
}
}
diff --git a/crates/language_models/src/provider/x_ai_subscribed.rs b/crates/language_models/src/provider/x_ai_subscribed.rs
index 5d60000d2c5..a9362c3d304 100644
--- a/crates/language_models/src/provider/x_ai_subscribed.rs
+++ b/crates/language_models/src/provider/x_ai_subscribed.rs
@@ -56,7 +56,7 @@ impl LanguageModelProvider for XAiSubscribedProvider {
}
fn default_model(&self, cx: &App) -> Option<Arc<dyn LanguageModel>> {
- Some(self.create_model(SuperGrokModel::Grok46, cx))
+ Some(self.create_model(SuperGrokModel::Grok47, cx))
}
fn default_fast_model(&self, cx: &App) -> Option<Arc<dyn LanguageModel>> {
diff --git a/crates/x_ai/src/x_ai.rs b/crates/x_ai/src/x_ai.rs
index ab254c6f630..f2916945631 100644
--- a/crates/x_ai/src/x_ai.rs
+++ b/crates/x_ai/src/x_ai.rs
@@ -7,13 +7,15 @@ pub const XAI_API_URL: &str = "https://api.x.ai/v1";
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[derive(Clone, Debug, Default, Serialize, Deserialize, PartialEq, EnumIter)]
pub enum Model {
- #[default]
#[serde(rename = "grok-4.3", alias = "grok-4.3-latest")]
Grok43,
#[serde(rename = "grok-4.5", alias = "grok-4.5-latest")]
Grok45,
#[serde(rename = "grok-4.6", alias = "grok-4.6-latest")]
Grok46,
+ #[default]
+ #[serde(rename = "grok-4.7", alias = "grok-4.7-latest")]
+ Grok47,
#[serde(rename = "grok-4.20-0309-reasoning")]
Grok420Reasoning,
#[serde(rename = "grok-4.20-0309-non-reasoning")]
@@ -42,6 +44,7 @@ impl Model {
"grok-4.3" => Ok(Self::Grok43),
"grok-4.5" => Ok(Self::Grok45),
"grok-4.6" => Ok(Self::Grok46),
+ "grok-4.7" => Ok(Self::Grok47),
"grok-4.20-0309-reasoning" => Ok(Self::Grok420Reasoning),
"grok-4.20-0309-non-reasoning" => Ok(Self::Grok420NonReasoning),
_ => anyhow::bail!("invalid model id '{id}'"),
@@ -53,6 +56,7 @@ impl Model {
Self::Grok43 => "grok-4.3",
Self::Grok45 => "grok-4.5",
Self::Grok46 => "grok-4.6",
+ Self::Grok47 => "grok-4.7",
Self::Grok420Reasoning => "grok-4.20-0309-reasoning",
Self::Grok420NonReasoning => "grok-4.20-0309-non-reasoning",
Self::Custom { name, .. } => name,
@@ -64,6 +68,7 @@ impl Model {
Self::Grok43 => "Grok 4.3",
Self::Grok45 => "Grok 4.5",
Self::Grok46 => "Grok 4.6",
+ Self::Grok47 => "Grok 4.7",
Self::Grok420Reasoning => "Grok 4.20 Reasoning",
Self::Grok420NonReasoning => "Grok 4.20 (Non-Reasoning)",
Self::Custom {
@@ -75,7 +80,7 @@ impl Model {
pub fn max_token_count(&self) -> u64 {
match self {
Self::Grok43 => 1_000_000,
- Self::Grok45 | Self::Grok46 => 500_000,
+ Self::Grok45 | Self::Grok46 | Self::Grok47 => 500_000,
Self::Grok420Reasoning | Self::Grok420NonReasoning => 2_000_000,
Self::Custom { max_tokens, .. } => *max_tokens,
}
@@ -84,7 +89,7 @@ impl Model {
pub fn max_output_tokens(&self) -> Option<u64> {
match self {
Self::Grok43 | Self::Grok420Reasoning | Self::Grok420NonReasoning => Some(64_000),
- Self::Grok45 | Self::Grok46 => None,
+ Self::Grok45 | Self::Grok46 | Self::Grok47 => None,
Self::Custom {
max_output_tokens, ..
} => *max_output_tokens,
@@ -96,6 +101,7 @@ impl Model {
Self::Grok43
| Self::Grok45
| Self::Grok46
+ | Self::Grok47
| Self::Grok420Reasoning
| Self::Grok420NonReasoning => true,
Self::Custom {
@@ -115,6 +121,7 @@ impl Model {
Self::Grok43
| Self::Grok45
| Self::Grok46
+ | Self::Grok47
| Self::Grok420Reasoning
| Self::Grok420NonReasoning => true,
Self::Custom {
@@ -130,6 +137,7 @@ impl Model {
Self::Grok43
| Self::Grok45
| Self::Grok46
+ | Self::Grok47
| Self::Grok420Reasoning
| Self::Grok420NonReasoning => true,
Self::Custom {
@@ -142,7 +150,7 @@ impl Model {
pub fn supports_reasoning_effort(&self) -> bool {
match self {
- Self::Grok43 | Self::Grok45 | Self::Grok46 => true,
+ Self::Grok43 | Self::Grok45 | Self::Grok46 | Self::Grok47 => true,
Self::Grok420Reasoning | Self::Grok420NonReasoning | Self::Custom { .. } => false,
}
}
diff --git a/crates/x_ai_subscribed/src/x_ai_subscribed.rs b/crates/x_ai_subscribed/src/x_ai_subscribed.rs
index e5a95994604..a830b130e70 100644
--- a/crates/x_ai_subscribed/src/x_ai_subscribed.rs
+++ b/crates/x_ai_subscribed/src/x_ai_subscribed.rs
@@ -241,6 +241,7 @@ impl State {
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum SuperGrokModel {
+ Grok47,
Grok46,
Grok45,
GrokBuild01,
@@ -248,11 +249,12 @@ pub enum SuperGrokModel {
impl SuperGrokModel {
pub fn all() -> Vec<Self> {
- vec![Self::Grok46, Self::Grok45, Self::GrokBuild01]
+ vec![Self::Grok47, Self::Grok46, Self::Grok45, Self::GrokBuild01]
}
fn x_ai_model(&self) -> Option<x_ai::Model> {
match self {
+ Self::Grok47 => Some(x_ai::Model::Grok47),
Self::Grok46 => Some(x_ai::Model::Grok46),
Self::Grok45 => Some(x_ai::Model::Grok45),
// grok-build-0.1 is SuperGrok-only; it is not in the BYOK catalog.
@@ -262,6 +264,7 @@ impl SuperGrokModel {
pub fn id(&self) -> &str {
match self {
+ Self::Grok47 => "grok-4.7",
Self::Grok46 => "grok-4.6",
Self::Grok45 => "grok-4.5",
Self::GrokBuild01 => "grok-build-0.1",
@@ -270,6 +273,7 @@ impl SuperGrokModel {
pub fn display_name(&self) -> &str {
match self {
+ Self::Grok47 => "Grok 4.7",
Self::Grok46 => "Grok 4.6",
Self::Grok45 => "Grok 4.5",
Self::GrokBuild01 => "Grok Build 0.1",
@@ -340,15 +344,15 @@ struct SuperGrokLanguageModel {
}
fn advertised_reasoning_efforts(model: &SuperGrokModel) -> &'static [ReasoningEffort] {
- // xAI rejects `reasoning_effort: "none"` on grok-4.5/4.6. Compact and title
- // requests disable thinking, so we omit the field instead of sending none.
+ // xAI rejects `reasoning_effort: "none"` on grok-4.5 and newer. Compact and
+ // title requests disable thinking, so we omit the field instead of sending none.
match model.x_ai_model() {
Some(x_ai::Model::Grok45) => &[
ReasoningEffort::Low,
ReasoningEffort::Medium,
ReasoningEffort::High,
],
- Some(x_ai::Model::Grok46) => &[
+ Some(x_ai::Model::Grok46 | x_ai::Model::Grok47) => &[
ReasoningEffort::Low,
ReasoningEffort::Medium,
ReasoningEffort::High,
@@ -360,7 +364,9 @@ fn advertised_reasoning_efforts(model: &SuperGrokModel) -> &'static [ReasoningEf
fn default_thinking_reasoning_effort(model: &SuperGrokModel) -> Option<ReasoningEffort> {
match model.x_ai_model() {
- Some(x_ai::Model::Grok45 | x_ai::Model::Grok46) => Some(ReasoningEffort::High),
+ Some(x_ai::Model::Grok45 | x_ai::Model::Grok46 | x_ai::Model::Grok47) => {
+ Some(ReasoningEffort::High)
+ }
_ => None,
}
}
@@ -967,49 +973,52 @@ mod tests {
use std::sync::atomic::{AtomicUsize, Ordering};
#[test]
- fn grok_46_supports_xhigh_and_defaults_to_high() {
- let effort_levels = supported_thinking_effort_levels(&SuperGrokModel::Grok46);
- let values = effort_levels
- .iter()
- .map(|level| level.value.as_ref())
- .collect::<Vec<_>>();
-
- assert_eq!(values, ["low", "medium", "high", "xhigh"]);
- assert_eq!(
- effort_levels
+ fn grok_47_and_46_supports_xhigh_and_defaults_to_high() {
+ for model in [SuperGrokModel::Grok46, SuperGrokModel::Grok47] {
+ let effort_levels = supported_thinking_effort_levels(&model);
+ let values = effort_levels
.iter()
- .find(|level| level.is_default)
- .map(|level| level.value.as_ref()),
- Some("high")
- );
+ .map(|level| level.value.as_ref())
+ .collect::<Vec<_>>();
+
+ assert_eq!(values, ["low", "medium", "high", "xhigh"]);
+ assert_eq!(
+ effort_levels
+ .iter()
+ .find(|level| level.is_default)
+ .map(|level| level.value.as_ref()),
+ Some("high")
+ );
+ }
}
#[test]
- fn grok_46_request_uses_selected_reasoning_effort() {
+ fn grok_47_and_46_request_uses_selected_reasoning_effort() {
let request = LanguageModelRequest {
thinking_allowed: true,
thinking_effort: Some("xhigh".to_string()),
..Default::default()
};
- assert_eq!(
- reasoning_effort_for_request(&request, &SuperGrokModel::Grok46),
- Some(ReasoningEffort::XHigh)
- );
+ for model in [SuperGrokModel::Grok46, SuperGrokModel::Grok47] {
+ assert_eq!(
+ reasoning_effort_for_request(&request, &model),
+ Some(ReasoningEffort::XHigh)
+ );
+ }
}
#[test]
- fn grok_46_omits_reasoning_effort_when_thinking_is_disabled() {
+ fn grok_47_and_46_omits_reasoning_effort_when_thinking_is_disabled() {
let request = LanguageModelRequest {
thinking_allowed: false,
thinking_effort: Some("medium".to_string()),
..Default::default()
};
- assert_eq!(
- reasoning_effort_for_request(&request, &SuperGrokModel::Grok46),
- None
- );
+ for model in [SuperGrokModel::Grok46, SuperGrokModel::Grok47] {
+ assert_eq!(reasoning_effort_for_request(&request, &model), None);
+ }
}
#[test]
@@ -1044,7 +1053,8 @@ mod tests {
}
#[test]
- fn grok_46_and_45_omit_max_output_tokens() {
+ fn grok_47_and_46_and_45_omit_max_output_tokens() {
+ assert_eq!(SuperGrokModel::Grok47.max_output_tokens(), None);
assert_eq!(SuperGrokModel::Grok46.max_output_tokens(), None);
assert_eq!(SuperGrokModel::Grok45.max_output_tokens(), None);
assert_eq!(