Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion crates/cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,10 @@ enum ModelCommand {
#[arg(long, value_enum)]
provider: Option<ProviderArg>,
},
/// Set the default model (e.g. "pro", "flash", "deepseek-v4-pro").
Set {
model: String,
},
}

#[derive(Debug, Args)]
Expand Down Expand Up @@ -754,7 +758,7 @@ fn run() -> Result<()> {
Some(Commands::Auth(args)) => run_auth_command(&mut store, args.command),
Some(Commands::McpServer) => run_mcp_server_command(&mut store),
Some(Commands::Config(args)) => run_config_command(&mut store, args.command),
Some(Commands::Model(args)) => run_model_command(args.command, runtime_overrides.provider),
Some(Commands::Model(args)) => run_model_command(&mut store, args.command, runtime_overrides.provider),
Some(Commands::Thread(args)) => run_thread_command(args.command),
Some(Commands::Sandbox(args)) => run_sandbox_command(args.command),
Some(Commands::AppServer(args)) => {
Expand Down Expand Up @@ -1495,6 +1499,7 @@ fn model_command_provider_hint(
}

fn run_model_command(
store: &mut ConfigStore,
command: ModelCommand,
top_level_provider: Option<ProviderKind>,
) -> Result<()> {
Expand All @@ -1519,6 +1524,21 @@ fn run_model_command(
println!("used_fallback: {}", resolved.used_fallback);
Ok(())
}
ModelCommand::Set { model } => {
let trimmed = model.trim();
if trimmed.is_empty() {
bail!("Model name cannot be empty");
}
let canonical = match trimmed.to_ascii_lowercase().as_str() {
"pro" | "deepseek-v4-pro" | "deepseek-v4pro" => "deepseek-v4-pro",
"flash" | "deepseek-v4-flash" | "deepseek-v4flash" => "deepseek-v4-flash",
_ => trimmed,
};
store.config.default_text_model = Some(canonical.to_string());
store.save()?;
println!("Default model set to '{canonical}'");
Ok(())
}
Comment on lines +1527 to +1541

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The current implementation of ModelCommand::Set strictly rejects any model name that does not start with "deepseek" (unless it matches the "pro" or "flash" shortcuts). Since CodeWhale supports other providers (such as OpenAI, Anthropic, etc.), this restriction completely breaks the ability for non-DeepSeek users to set their default model (e.g., codewhale model set claude-sonnet-4-6 will fail).

We should allow any non-empty model name to be set, while still supporting the "pro" and "flash" shortcuts for DeepSeek.

        ModelCommand::Set { model } => {
            let trimmed = model.trim();
            if trimmed.is_empty() {
                bail!("Model name cannot be empty");
            }
            let canonical = match trimmed.to_ascii_lowercase().as_str() {
                "pro" | "deepseek-v4-pro" | "deepseek-v4pro" => "deepseek-v4-pro".to_string(),
                "flash" | "deepseek-v4-flash" | "deepseek-v4flash" => "deepseek-v4-flash".to_string(),
                _ => trimmed.to_string(),
            };
            store.config.default_text_model = Some(canonical.clone());
            store.save()?;
            println!("Default model set to '{canonical}'");
            Ok(())
        }

}
}

Expand Down
4 changes: 2 additions & 2 deletions crates/tui/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -616,8 +616,8 @@ fn deepseek_alias_deprecation(model_lower: &str) -> Option<ModelAliasDeprecation
#[must_use]
pub fn canonical_model_name(model: &str) -> Option<&'static str> {
match model.trim().to_ascii_lowercase().as_str() {
"deepseek-v4pro" => Some("deepseek-v4-pro"),
"deepseek-v4flash" => Some("deepseek-v4-flash"),
"pro" | "deepseek-v4-pro" | "deepseek-v4pro" => Some("deepseek-v4-pro"),
"flash" | "deepseek-v4-flash" | "deepseek-v4flash" => Some("deepseek-v4-flash"),
_ => None,
}
}
Expand Down