mirror of
https://github.com/codewhale-hq/Codewhale.git
synced 2026-11-12 18:18:10 -10:00
fix: include reasoning tokens in cost calc; auto-detect CNY on zh-Hans locale
This commit is contained in:
1 parent
c188cade88
commit
946c12b4d3
4 files changed
+13
-4
No files matched your search
@@ -450,6 +450,7 @@ mod tests {
|
||||
};
|
||||
let mut app = App::new(options, &Config::default());
|
||||
app.ui_locale = crate::localization::Locale::En;
|
||||
app.cost_currency = crate::pricing::CostCurrency::Usd;
|
||||
app.api_provider = crate::config::ApiProvider::Deepseek;
|
||||
app
|
||||
}
|
||||
|
||||
@@ -195,7 +195,9 @@ fn calculate_turn_cost_from_usage_with_pricing(pricing: CurrencyPricing, usage:
|
||||
let hit_cost = (hit_tokens as f64 / 1_000_000.0) * pricing.input_cache_hit_per_million;
|
||||
let miss_cost = ((miss_tokens.saturating_add(uncategorized_input)) as f64 / 1_000_000.0)
|
||||
* pricing.input_cache_miss_per_million;
|
||||
let output_cost = (usage.output_tokens as f64 / 1_000_000.0) * pricing.output_per_million;
|
||||
let reasoning = usage.reasoning_tokens.unwrap_or(0);
|
||||
let effective_output = usage.output_tokens.saturating_add(reasoning);
|
||||
let output_cost = (effective_output as f64 / 1_000_000.0) * pricing.output_per_million;
|
||||
hit_cost + miss_cost + output_cost
|
||||
}
|
||||
|
||||
|
||||
@@ -1245,8 +1245,10 @@ impl App {
|
||||
let show_thinking = settings.show_thinking;
|
||||
let show_tool_details = settings.show_tool_details;
|
||||
let ui_locale = resolve_locale(&settings.locale);
|
||||
let cost_currency =
|
||||
CostCurrency::from_setting(&settings.cost_currency).unwrap_or(CostCurrency::Usd);
|
||||
let cost_currency = match (settings.cost_currency.as_str(), ui_locale.tag()) {
|
||||
("usd", "zh-Hans") => CostCurrency::Cny,
|
||||
_ => CostCurrency::from_setting(&settings.cost_currency).unwrap_or(CostCurrency::Usd),
|
||||
};
|
||||
let composer_density = ComposerDensity::from_setting(&settings.composer_density);
|
||||
let composer_border = settings.composer_border;
|
||||
let composer_vim_enabled = settings
|
||||
|
||||
@@ -1059,7 +1059,11 @@ fn create_test_app() -> App {
|
||||
resume_session_id: None,
|
||||
initial_input: None,
|
||||
};
|
||||
App::new(options, &Config::default())
|
||||
let mut app = App::new(options, &Config::default());
|
||||
// Pin locale and currency for deterministic tests regardless of host locale.
|
||||
app.cost_currency = crate::pricing::CostCurrency::Usd;
|
||||
app.ui_locale = crate::localization::Locale::En;
|
||||
app
|
||||
}
|
||||
|
||||
fn create_test_options() -> TuiOptions {
|
||||
|
||||
Reference in new issue
Block a user