fix: Token 计量全面加固 — OpenAI 格式兼容 + 模型感知编码 + tiktoken fallback#80
Merged
Conversation
added 5 commits
July 18, 2026 05:21
bigmanBass666
marked this pull request as ready for review
July 17, 2026 22:31
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
改动内容
修复了 sensenova 等 provider 的 token 计量问题,同时对 token 估算体系做了全面加固。
提交历史 (4 commits)
调研背景
已完成行业调研 (docs/research/token-metering-best-practices.md),对比了 Helicone、OpenRouter、Portkey、Kong、Langfuse、LiteLLM 等项目的做法。AK-Switch 当前的做法(实际值优先 → tiktoken+校准 → 纯 tiktoken)与业界最佳实践一致。
验证
Resolves: #28