Fix usage accounting and refresh API pricing - #11
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6b9f62e610
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if modelID.hasPrefix("claude-opus-") { return priceTable["anthropic/claude-opus-5-5"]! } | ||
| if modelID.hasPrefix("claude-fable-") { return priceTable["anthropic/claude-fable-5-1"]! } | ||
| if modelID.hasPrefix("claude-mythos-") { return priceTable["anthropic/claude-mythos-5-1"]! } | ||
| if modelID.hasPrefix("claude-sonnet-") { return priceTable["anthropic/claude-sonnet-5"]! } | ||
| if modelID.hasPrefix("claude-haiku-") { return priceTable["anthropic/claude-haiku-4-5"]! } |
There was a problem hiding this comment.
Recognize generation-first Claude model IDs
Historical Claude API IDs place the generation before the family, such as claude-3-opus-20240229 and claude-3-5-haiku-20241022. These new prefix checks do not recognize those IDs, so they now fall through to the generic $3/$15 fallback; previously the family matching selected the Opus or Haiku estimate. Consequently, existing transcripts can substantially underprice Opus usage or overprice Haiku usage. Match both official ID layouts, or explicitly alias these historical models before applying the generic fallback.
Useful? React with 👍 / 👎.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
改动
token_usage_record并按响应 ID 去重;旧日志的首条及计数重置使用last_token_usage,避免把跨文件累计基线计入用量。扫描缓存版本升至 9。美元数值仍是标准 API 价格下的等价估算,不代表订阅实际扣费。本次未改动额度网络请求或 credits 展示。
验证
swift build --scratch-path /Users/gnonymous/Documents/Github/CodingBar/.build通过。CodingBar --self-test全部通过,涵盖现有额度响应格式回归。