feat: add cache token pricing support in usage calculation

- Add cache price field to ModelPrice interface
  - Support both cached_tokens and cache_tokens fields for compatibility
  - Separate prompt, cache, and completion pricing in cost calculation
  - Deduct cached tokens from input tokens before prompt pricing
  - Refactor getApiStats/getModelStats to reuse calculateCost function
  - Update i18n labels for model pricing
This commit is contained in:
Supra4E8C
2025-12-14 18:50:37 +08:00
parent e615979757
commit 9d648e3404
3 changed files with 56 additions and 36 deletions

View File

@@ -511,8 +511,9 @@
"model_price_model_label": "Model",
"model_price_select_placeholder": "Choose a model",
"model_price_select_hint": "Models come from usage details",
"model_price_prompt": "Prompt price ($/1M tokens)",
"model_price_completion": "Completion price ($/1M tokens)",
"model_price_prompt": "Prompt price",
"model_price_completion": "Completion price",
"model_price_cache": "Cache price",
"model_price_save": "Save Price",
"model_price_empty": "No model prices set",
"model_price_model": "Model",

View File

@@ -521,8 +521,9 @@
"model_price_model_label": "选择模型",
"model_price_select_placeholder": "选择模型",
"model_price_select_hint": "模型列表来自使用统计明细",
"model_price_prompt": "提示价格 ($/1M tokens)",
"model_price_completion": "补全价格 ($/1M tokens)",
"model_price_prompt": "提示价格",
"model_price_completion": "补全价格",
"model_price_cache": "缓存价格",
"model_price_save": "保存价格",
"model_price_empty": "暂未设置任何模型价格",
"model_price_model": "模型",