mirror of
https://github.com/openai/codex.git
synced 2026-09-14 11:57:03 +00:00
tests
This commit is contained in:
@@ -19,16 +19,14 @@ fn model_from_preset(preset: ModelPreset) -> Model {
|
||||
display_name: preset.display_name.to_string(),
|
||||
description: preset.description.to_string(),
|
||||
supported_reasoning_efforts: reasoning_efforts_from_preset(
|
||||
&preset.supported_reasoning_efforts,
|
||||
preset.supported_reasoning_efforts,
|
||||
),
|
||||
default_reasoning_effort: preset.default_reasoning_effort,
|
||||
is_default: preset.is_default,
|
||||
}
|
||||
}
|
||||
|
||||
fn reasoning_efforts_from_preset(
|
||||
efforts: &[ReasoningEffortPreset],
|
||||
) -> Vec<ReasoningEffortOption> {
|
||||
fn reasoning_efforts_from_preset(efforts: &[ReasoningEffortPreset]) -> Vec<ReasoningEffortOption> {
|
||||
efforts
|
||||
.iter()
|
||||
.map(|preset| ReasoningEffortOption {
|
||||
|
||||
@@ -41,7 +41,18 @@ impl ReasoningEffortPreset {
|
||||
}
|
||||
|
||||
pub fn label(&self) -> &'static str {
|
||||
self.label.unwrap_or_else(|| self.effort.label())
|
||||
self.label
|
||||
.unwrap_or_else(|| default_reasoning_effort_label(self.effort))
|
||||
}
|
||||
}
|
||||
|
||||
const fn default_reasoning_effort_label(effort: ReasoningEffort) -> &'static str {
|
||||
match effort {
|
||||
ReasoningEffort::None => "None",
|
||||
ReasoningEffort::Minimal => "Minimal",
|
||||
ReasoningEffort::Low => "Low",
|
||||
ReasoningEffort::Medium => "Medium",
|
||||
ReasoningEffort::High => "High",
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +76,7 @@ pub struct ModelPreset {
|
||||
/// Reasoning effort applied when none is explicitly chosen.
|
||||
pub default_reasoning_effort: ReasoningEffort,
|
||||
/// Supported reasoning effort options.
|
||||
pub supported_reasoning_efforts: Vec<ReasoningEffortPreset>,
|
||||
pub supported_reasoning_efforts: &'static [ReasoningEffortPreset],
|
||||
/// Whether this is the default model for new users.
|
||||
pub is_default: bool,
|
||||
/// recommended upgrade model
|
||||
@@ -80,7 +91,7 @@ static PRESETS: Lazy<Vec<ModelPreset>> = Lazy::new(|| {
|
||||
display_name: "codex-auto",
|
||||
description: "Automatically chooses the best Codex model configuration for your task.",
|
||||
default_reasoning_effort: ReasoningEffort::Medium,
|
||||
supported_reasoning_efforts: vec![
|
||||
supported_reasoning_efforts: &[
|
||||
ReasoningEffortPreset::with_label(ReasoningEffort::Low, "Works faster", "Fast"),
|
||||
ReasoningEffortPreset::with_label(
|
||||
ReasoningEffort::Medium,
|
||||
@@ -102,7 +113,7 @@ static PRESETS: Lazy<Vec<ModelPreset>> = Lazy::new(|| {
|
||||
display_name: "gpt-5.1-codex",
|
||||
description: "Optimized for codex.",
|
||||
default_reasoning_effort: ReasoningEffort::Medium,
|
||||
supported_reasoning_efforts: vec![
|
||||
supported_reasoning_efforts: &[
|
||||
ReasoningEffortPreset::new(
|
||||
ReasoningEffort::Low,
|
||||
"Fastest responses with limited reasoning",
|
||||
@@ -128,7 +139,7 @@ static PRESETS: Lazy<Vec<ModelPreset>> = Lazy::new(|| {
|
||||
display_name: "gpt-5.1-codex-mini",
|
||||
description: "Optimized for codex. Cheaper, faster, but less capable.",
|
||||
default_reasoning_effort: ReasoningEffort::Medium,
|
||||
supported_reasoning_efforts: vec![
|
||||
supported_reasoning_efforts: &[
|
||||
ReasoningEffortPreset::new(
|
||||
ReasoningEffort::Medium,
|
||||
"Dynamically adjusts reasoning based on the task",
|
||||
@@ -149,7 +160,7 @@ static PRESETS: Lazy<Vec<ModelPreset>> = Lazy::new(|| {
|
||||
display_name: "gpt-5.1",
|
||||
description: "Broad world knowledge with strong general reasoning.",
|
||||
default_reasoning_effort: ReasoningEffort::Medium,
|
||||
supported_reasoning_efforts: vec![
|
||||
supported_reasoning_efforts: &[
|
||||
ReasoningEffortPreset::new(
|
||||
ReasoningEffort::Low,
|
||||
"Balances speed with some reasoning; useful for straightforward queries and short explanations",
|
||||
@@ -176,7 +187,7 @@ static PRESETS: Lazy<Vec<ModelPreset>> = Lazy::new(|| {
|
||||
display_name: "gpt-5-codex",
|
||||
description: "Optimized for codex.",
|
||||
default_reasoning_effort: ReasoningEffort::Medium,
|
||||
supported_reasoning_efforts: vec![
|
||||
supported_reasoning_efforts: &[
|
||||
ReasoningEffortPreset::new(
|
||||
ReasoningEffort::Low,
|
||||
"Fastest responses with limited reasoning",
|
||||
@@ -205,7 +216,7 @@ static PRESETS: Lazy<Vec<ModelPreset>> = Lazy::new(|| {
|
||||
display_name: "gpt-5-codex-mini",
|
||||
description: "Optimized for codex. Cheaper, faster, but less capable.",
|
||||
default_reasoning_effort: ReasoningEffort::Medium,
|
||||
supported_reasoning_efforts: vec![
|
||||
supported_reasoning_efforts: &[
|
||||
ReasoningEffortPreset::new(
|
||||
ReasoningEffort::Medium,
|
||||
"Dynamically adjusts reasoning based on the task",
|
||||
@@ -229,7 +240,7 @@ static PRESETS: Lazy<Vec<ModelPreset>> = Lazy::new(|| {
|
||||
display_name: "gpt-5",
|
||||
description: "Broad world knowledge with strong general reasoning.",
|
||||
default_reasoning_effort: ReasoningEffort::Medium,
|
||||
supported_reasoning_efforts: vec![
|
||||
supported_reasoning_efforts: &[
|
||||
ReasoningEffortPreset::new(
|
||||
ReasoningEffort::Minimal,
|
||||
"Fastest responses with little reasoning",
|
||||
@@ -281,8 +292,8 @@ impl ModelPreset {
|
||||
self.supported_reasoning_efforts
|
||||
.iter()
|
||||
.find(|option| option.effort == effort)
|
||||
.map(|option| option.label())
|
||||
.unwrap_or_else(|| effort.label())
|
||||
.map(ReasoningEffortPreset::label)
|
||||
.unwrap_or_else(|| default_reasoning_effort_label(effort))
|
||||
}
|
||||
}
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -32,19 +32,6 @@ pub enum ReasoningEffort {
|
||||
High,
|
||||
}
|
||||
|
||||
impl ReasoningEffort {
|
||||
/// Friendly label that can be shown in UIs.
|
||||
pub fn label(self) -> &'static str {
|
||||
match self {
|
||||
ReasoningEffort::None => "None",
|
||||
ReasoningEffort::Minimal => "Minimal",
|
||||
ReasoningEffort::Low => "Fast",
|
||||
ReasoningEffort::Medium => "Balanced",
|
||||
ReasoningEffort::High => "Thorough",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A summary of the reasoning performed by the model. This can be useful for
|
||||
/// debugging and understanding the model's reasoning process.
|
||||
/// See https://platform.openai.com/docs/guides/reasoning?api-mode=responses#reasoning-summaries
|
||||
|
||||
@@ -95,7 +95,7 @@ fn should_show_model_migration_prompt(
|
||||
|
||||
fn format_model_change_target(model: &str, effort: Option<ReasoningEffortConfig>) -> String {
|
||||
if let Some(effort) = effort {
|
||||
format!("{model} ({})", effort.label())
|
||||
format!("{model} ({effort})")
|
||||
} else {
|
||||
format!("{model} with default reasoning")
|
||||
}
|
||||
|
||||
@@ -2110,7 +2110,7 @@ impl ChatWidget {
|
||||
});
|
||||
})];
|
||||
|
||||
let mut name = effort.label().to_string();
|
||||
let mut name = option.label().to_string();
|
||||
let is_current_option = current_effort == Some(effort);
|
||||
if effort == default_effort && !is_current_option {
|
||||
name.push_str(" (default)");
|
||||
@@ -2139,7 +2139,7 @@ impl ChatWidget {
|
||||
preferred_effort: Option<ReasoningEffortConfig>,
|
||||
) {
|
||||
let default_effort: ReasoningEffortConfig = preset.default_reasoning_effort;
|
||||
let supported = &preset.supported_reasoning_efforts;
|
||||
let supported = preset.supported_reasoning_efforts;
|
||||
|
||||
struct EffortChoice {
|
||||
stored: Option<ReasoningEffortConfig>,
|
||||
@@ -2192,7 +2192,11 @@ impl ChatWidget {
|
||||
let mut items: Vec<SelectionItem> = Vec::new();
|
||||
for choice in choices.iter() {
|
||||
let effort = choice.display;
|
||||
let mut effort_label = effort.label().to_string();
|
||||
let mut effort_label = supported
|
||||
.iter()
|
||||
.find(|option| option.effort == effort)
|
||||
.map(|option| option.label().to_string())
|
||||
.unwrap_or_else(|| effort.to_string());
|
||||
let is_current_choice = is_current_model && choice.stored == highlight_choice;
|
||||
if choice.stored == default_choice && !is_current_choice {
|
||||
effort_label.push_str(" (default)");
|
||||
|
||||
@@ -1579,7 +1579,7 @@ fn single_reasoning_option_skips_selection() {
|
||||
display_name: "model-with-single-reasoning",
|
||||
description: "",
|
||||
default_reasoning_effort: ReasoningEffortConfig::High,
|
||||
supported_reasoning_efforts: vec![ReasoningEffortPreset::new(
|
||||
supported_reasoning_efforts: &[ReasoningEffortPreset::new(
|
||||
ReasoningEffortConfig::High,
|
||||
"Maximizes reasoning depth for complex or ambiguous problems",
|
||||
None,
|
||||
|
||||
@@ -706,8 +706,8 @@ impl SessionHeaderHistoryCell {
|
||||
formatted
|
||||
}
|
||||
|
||||
fn reasoning_label(&self) -> Option<&'static str> {
|
||||
self.reasoning_effort.map(|effort| effort.label())
|
||||
fn reasoning_label(&self) -> Option<String> {
|
||||
self.reasoning_effort.map(|effort| effort.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user