fix(tui): price Xiaomi MiMo primary models#2750
Conversation
There was a problem hiding this comment.
cyq1017 has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.
|
Thanks @cyq1017 for taking the time to contribute. This repository is currently observing a maintainer-managed contribution gate in dry-run mode, so this pull request is staying open. When enforcement is enabled, pull requests from contributors who are not listed in Please read |
There was a problem hiding this comment.
Code Review
This pull request refactors the pricing logic in crates/tui/src/pricing.rs to map Xiaomi Mimo models to DeepSeek V4 pricing rates, extracting the pricing structures into dedicated helper functions and adding corresponding unit tests. The reviewer suggested simplifying the control flow and making it more idiomatic by combining the exact string matches and the substring checks into a single match expression with guards.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| match lower.as_str() { | ||
| "xiaomi/mimo-v2.5-pro" | "mimo-v2.5-pro" => return Some(deepseek_v4_pro_pricing()), | ||
| "xiaomi/mimo-v2.5" | "mimo-v2.5" => return Some(deepseek_v4_flash_pricing()), | ||
| _ => {} | ||
| } | ||
| if lower.contains("v4-pro") || lower.contains("v4pro") { | ||
| // DeepSeek's pricing page says the V4-Pro promotional 75% discount | ||
| // becomes the official one-quarter base price after 2026-05-31 15:59 | ||
| // UTC. Keep using the adjusted rate after that cutoff (#2489). | ||
| Some(ModelPricing { | ||
| usd: CurrencyPricing { | ||
| input_cache_hit_per_million: 0.003625, | ||
| input_cache_miss_per_million: 0.435, | ||
| output_per_million: 0.87, | ||
| }, | ||
| cny: CurrencyPricing { | ||
| input_cache_hit_per_million: 0.025, | ||
| input_cache_miss_per_million: 3.0, | ||
| output_per_million: 6.0, | ||
| }, | ||
| }) | ||
| if lower.contains("deepseek") { | ||
| if lower.contains("v4-pro") || lower.contains("v4pro") { | ||
| // DeepSeek's pricing page says the V4-Pro promotional 75% discount | ||
| // becomes the official one-quarter base price after 2026-05-31 15:59 | ||
| // UTC. Keep using the adjusted rate after that cutoff (#2489). | ||
| Some(deepseek_v4_pro_pricing()) | ||
| } else { | ||
| Some(deepseek_v4_flash_pricing()) | ||
| } | ||
| } else { | ||
| // deepseek-v4-flash pricing. | ||
| Some(ModelPricing { | ||
| usd: CurrencyPricing { | ||
| input_cache_hit_per_million: 0.0028, | ||
| input_cache_miss_per_million: 0.14, | ||
| output_per_million: 0.28, | ||
| }, | ||
| cny: CurrencyPricing { | ||
| input_cache_hit_per_million: 0.02, | ||
| input_cache_miss_per_million: 1.0, | ||
| output_per_million: 2.0, | ||
| }, | ||
| }) | ||
| None | ||
| } |
There was a problem hiding this comment.
The control flow can be simplified and made more idiomatic by combining the exact match and the contains checks into a single match expression. This avoids the need for explicit return statements and makes the function's structure cleaner.
match lower.as_str() {
"xiaomi/mimo-v2.5-pro" | "mimo-v2.5-pro" => Some(deepseek_v4_pro_pricing()),
"xiaomi/mimo-v2.5" | "mimo-v2.5" => Some(deepseek_v4_flash_pricing()),
_ if lower.contains("deepseek") => {
if lower.contains("v4-pro") || lower.contains("v4pro") {
// DeepSeek's pricing page says the V4-Pro promotional 75% discount
// becomes the official one-quarter base price after 2026-05-31 15:59
// UTC. Keep using the adjusted rate after that cutoff (#2489).
Some(deepseek_v4_pro_pricing())
} else {
Some(deepseek_v4_flash_pricing())
}
}
_ => None,
}
Addresses #2731.
Summary
mimo-v2.5-proandxiaomi/mimo-v2.5-prousing the same rates as DeepSeek V4-Pro.mimo-v2.5andxiaomi/mimo-v2.5using the same rates as DeepSeek V4-Flash.Verification
cargo test -p codewhale-tui xiaomi_mimo_primary_models_use_matching_deepseek_v4_rates -- --nocapturecargo test -p codewhale-tui pricing::tests -- --nocapturecargo check -p codewhale-tuirustfmt --edition 2024 --check crates/tui/src/pricing.rsgit diff --checkLocal macOS verification used Command Line Tools clang because the full Xcode toolchain lookup hangs in this environment.