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.

open_ai: Add GPT-6 Sol and Luna BYOK support (#64628)

Ben Kunklebc6dd34d4c91
diff --git a/crates/language_models/src/provider/open_ai.rs b/crates/language_models/src/provider/open_ai.rs
index a99342f725a..496c7b867ff 100644
--- a/crates/language_models/src/provider/open_ai.rs
+++ b/crates/language_models/src/provider/open_ai.rs
@@ -511,6 +511,8 @@ impl LanguageModel for OpenAiLanguageModel {
| Model::FivePointSixTerra
| Model::FivePointSixLuna
| Model::SixAstra
+ | Model::SixSol
+ | Model::SixLuna
| Model::O3 => true,
Model::Four => false,
Model::Custom {
diff --git a/crates/open_ai/src/completion.rs b/crates/open_ai/src/completion.rs
index 359fe281bd5..9dbd0bd27d4 100644
--- a/crates/open_ai/src/completion.rs
+++ b/crates/open_ai/src/completion.rs
@@ -42,9 +42,17 @@ fn service_tier_for(speed: Option<language_model_core::Speed>) -> Option<Service
}
}
-/// Astra rejects temperature at every reasoning effort, including the default value.
-fn temperature_for_model(model_id: &str, temperature: Option<f32>) -> Option<f32> {
- temperature.filter(|_| model_id != crate::Model::SixAstra.id())
+/// Omitting effort enables reasoning on Sol/Luna, which then reject temperature.
+fn temperature_for_model(
+ model_id: &str,
+ temperature: Option<f32>,
+ reasoning_effort: Option<ReasoningEffort>,
+) -> Option<f32> {
+ temperature.filter(|_| match model_id {
+ "gpt-6-astra" => false,
+ "gpt-6-sol" | "gpt-6-luna" => reasoning_effort == Some(ReasoningEffort::None),
+ _ => true,
+ })
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
@@ -201,7 +209,11 @@ pub fn into_open_ai(
None
},
stop: request.stop,
- temperature: temperature_for_model(model_id, request.temperature.or(Some(1.0))),
+ temperature: temperature_for_model(
+ model_id,
+ request.temperature.or(Some(1.0)),
+ reasoning_effort,
+ ),
max_completion_tokens: match max_tokens_parameter {
ChatCompletionMaxTokensParameter::MaxCompletionTokens => max_output_tokens,
ChatCompletionMaxTokensParameter::MaxTokens => None,
@@ -390,7 +402,7 @@ pub fn into_open_ai_response(
store: Some(false),
include,
stream,
- temperature: temperature_for_model(model_id, temperature),
+ temperature: temperature_for_model(model_id, temperature, reasoning_effort),
top_p: None,
max_output_tokens,
parallel_tool_calls: if tools.is_empty() {
@@ -2356,14 +2368,23 @@ mod tests {
#[test]
fn request_conversion_omits_unsupported_temperature() -> Result<()> {
- for (model_id, temperature, expected_temperature) in [
- ("gpt-6-astra", Some(0.25), None),
- ("gpt-6-astra", None, None),
- ("gpt-4o-mini", Some(0.25), Some(0.25)),
- ("custom-model", Some(0.25), Some(0.25)),
+ use ReasoningEffort::{Medium, None as NoReasoning};
+
+ for (model_id, temperature, effort, expected_temperature) in [
+ ("gpt-6-astra", Some(0.25), None, None),
+ ("gpt-6-astra", None, None, None),
+ ("gpt-6-sol", Some(0.25), None, None),
+ ("gpt-6-sol", Some(0.25), Some(Medium), None),
+ ("gpt-6-sol", Some(0.25), Some(NoReasoning), Some(0.25)),
+ ("gpt-6-luna", Some(0.25), None, None),
+ ("gpt-6-luna", Some(0.25), Some(Medium), None),
+ ("gpt-6-luna", Some(0.25), Some(NoReasoning), Some(0.25)),
+ ("gpt-4o-mini", Some(0.25), None, Some(0.25)),
+ ("custom-model", Some(0.25), None, Some(0.25)),
] {
let request = LanguageModelRequest {
temperature,
+ thinking_allowed: effort != Some(NoReasoning),
..Default::default()
};
let response = into_open_ai_response(
@@ -2372,8 +2393,8 @@ mod tests {
true,
true,
None,
- None,
- false,
+ effort,
+ effort == Some(NoReasoning),
&OPEN_AI_PROVIDER_ID,
)?;
let chat = into_open_ai(
@@ -2383,9 +2404,14 @@ mod tests {
true,
None,
ChatCompletionMaxTokensParameter::MaxCompletionTokens,
- None,
+ effort,
false,
)?;
+ assert_eq!(
+ response.reasoning.as_ref().map(|config| config.effort),
+ effort
+ );
+ assert_eq!(chat.reasoning_effort, effort);
for (endpoint, serialized) in [
("responses", serde_json::to_value(response)?),
@@ -2394,7 +2420,7 @@ mod tests {
assert_eq!(
serialized.get("temperature"),
expected_temperature.map(serde_json::Value::from).as_ref(),
- "{endpoint} temperature for {model_id} with {temperature:?}",
+ "{endpoint} temperature for {model_id} with {temperature:?}, {effort:?}",
);
}
}
diff --git a/crates/open_ai/src/open_ai.rs b/crates/open_ai/src/open_ai.rs
index f4c020726f9..c45f77e87e6 100644
--- a/crates/open_ai/src/open_ai.rs
+++ b/crates/open_ai/src/open_ai.rs
@@ -102,6 +102,10 @@ pub enum Model {
FivePointSixLuna,
#[serde(rename = "gpt-6-astra")]
SixAstra,
+ #[serde(rename = "gpt-6-sol")]
+ SixSol,
+ #[serde(rename = "gpt-6-luna")]
+ SixLuna,
#[serde(rename = "custom")]
Custom {
name: String,
@@ -152,6 +156,8 @@ impl Model {
"gpt-5.6-terra" => Ok(Self::FivePointSixTerra),
"gpt-5.6-luna" => Ok(Self::FivePointSixLuna),
"gpt-6-astra" => Ok(Self::SixAstra),
+ "gpt-6-sol" => Ok(Self::SixSol),
+ "gpt-6-luna" => Ok(Self::SixLuna),
invalid_id => anyhow::bail!("invalid model id '{invalid_id}'"),
}
}
@@ -177,6 +183,8 @@ impl Model {
Self::FivePointSixTerra => "gpt-5.6-terra",
Self::FivePointSixLuna => "gpt-5.6-luna",
Self::SixAstra => "gpt-6-astra",
+ Self::SixSol => "gpt-6-sol",
+ Self::SixLuna => "gpt-6-luna",
Self::Custom { name, .. } => name,
}
}
@@ -202,6 +210,8 @@ impl Model {
Self::FivePointSixTerra => "GPT-5.6 Terra",
Self::FivePointSixLuna => "GPT-5.6 Luna",
Self::SixAstra => "GPT-6 Astra",
+ Self::SixSol => "GPT-6 Sol",
+ Self::SixLuna => "GPT-6 Luna",
Self::Custom { display_name, .. } => display_name.as_deref().unwrap_or(&self.id()),
}
}
@@ -227,6 +237,8 @@ impl Model {
Self::FivePointSixTerra => 1_050_000,
Self::FivePointSixLuna => 1_050_000,
Self::SixAstra => 1_050_000,
+ Self::SixSol => 1_050_000,
+ Self::SixLuna => 1_050_000,
Self::Custom { max_tokens, .. } => *max_tokens,
}
}
@@ -255,6 +267,8 @@ impl Model {
Self::FivePointSixTerra => Some(128_000),
Self::FivePointSixLuna => Some(128_000),
Self::SixAstra => Some(128_000),
+ Self::SixSol => Some(128_000),
+ Self::SixLuna => Some(128_000),
}
}
@@ -279,7 +293,9 @@ impl Model {
| Self::FivePointFivePro
| Self::FivePointSixTerra
| Self::FivePointSixLuna
- | Self::SixAstra => Some(ReasoningEffort::Medium),
+ | Self::SixAstra
+ | Self::SixSol
+ | Self::SixLuna => Some(ReasoningEffort::Medium),
_ => None,
}
}
@@ -326,7 +342,11 @@ impl Model {
ReasoningEffort::High,
ReasoningEffort::XHigh,
],
- Self::FivePointSixSol | Self::FivePointSixTerra | Self::FivePointSixLuna => &[
+ Self::FivePointSixSol
+ | Self::FivePointSixTerra
+ | Self::FivePointSixLuna
+ | Self::SixSol
+ | Self::SixLuna => &[
ReasoningEffort::None,
ReasoningEffort::Low,
ReasoningEffort::Medium,
@@ -388,6 +408,8 @@ impl Model {
| Self::FivePointSixTerra
| Self::FivePointSixLuna
| Self::SixAstra
+ | Self::SixSol
+ | Self::SixLuna
| Self::FiveNano => true,
Self::O3 | Model::Custom { .. } => false,
}
@@ -419,7 +441,9 @@ impl Model {
| Self::FivePointSixSol
| Self::FivePointSixTerra
| Self::FivePointSixLuna
- | Self::SixAstra => true,
+ | Self::SixAstra
+ | Self::SixSol
+ | Self::SixLuna => true,
Self::Four
| Self::FourOmniMini
| Self::O3
@@ -450,7 +474,9 @@ impl Model {
| Self::FivePointSixSol
| Self::FivePointSixTerra
| Self::FivePointSixLuna
- | Self::SixAstra => true,
+ | Self::SixAstra
+ | Self::SixSol
+ | Self::SixLuna => true,
Self::Four
| Self::FiveNano
| Self::FivePointFourNano