Skip to content

Commit 8943339

Browse files
committed
fix: make stats pricing model match case-insensitive
1 parent 7954d02 commit 8943339

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/cortex-cli/src/stats_cmd.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ fn get_model_pricing(model: &str) -> ModelPricing {
218218

219219
// Fall back to default pricing (may be outdated - users can override via CORTEX_PRICING_*)
220220
// Pricing per 1M tokens (as of late 2024/early 2025 - may change)
221-
match model {
221+
match model_lower.as_str() {
222222
// Anthropic
223223
m if m.contains("claude-opus-4") || m.contains("opus-4") => ModelPricing {
224224
input_per_million: 15.0,
@@ -735,6 +735,14 @@ mod tests {
735735
assert!((cost - 12.5).abs() < 0.001);
736736
}
737737

738+
#[test]
739+
fn test_calculate_cost_is_case_insensitive_for_builtin_pricing() {
740+
let lowercase_cost = calculate_cost("gpt-4o", 1_000_000, 1_000_000);
741+
let uppercase_cost = calculate_cost("GPT-4O", 1_000_000, 1_000_000);
742+
743+
assert!((uppercase_cost - lowercase_cost).abs() < f64::EPSILON);
744+
}
745+
738746
#[test]
739747
fn test_validate_days_range() {
740748
// Valid values

0 commit comments

Comments
 (0)