[PR #260] [CLOSED] perf(tokens): 优化token计算性能,减少CPU占用 #327

Closed
opened 2026-02-27 07:18:58 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/justlovemaki/AIClient-2-API/pull/260
Author: @doitcan-oiu
Created: 1/17/2026
Status: Closed

Base: mainHead: main


📝 Commits (10+)

  • 392b829 Merge pull request #123 from unihon/feature/provider-health-api
  • 4de10e4 refactor: directly import and use setLanguage from i18n module in login page.
  • 383cccc fix: add missing 'index' to Gemini streaming tool calls and improve tests
  • d76ce17 chore: Add .gitignore rules for token store, usage cache, and OAuth credentials.
  • 686106f fix: map finish_reason to 'tool_calls' in Gemini stream when tool calls are present
  • 3e2ed6f Merge pull request #124 from lemon07r/main
  • 1eeb310 chore: 更新项目名称并添加忽略文件
  • ded3a8e fix(claude-kiro): 确保历史消息以assistantResponseMessage结尾
  • 945de61 feat(provider): 添加跨类型 Fallback 链支持
  • 7846f35 fix(usage): 修复provider_health接口过滤参数不生效问题

📄 Description

  • 重构 estimateInputTokens 函数,将多次 token 计算合并为单次
  • 新增 processContent 辅助函数统一处理内容
  • 提前拼接所有文本再统一计算 token,减少 countTextTokens 调用次数
  • 保持原有逻辑不变,优化算法复杂度

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/justlovemaki/AIClient-2-API/pull/260 **Author:** [@doitcan-oiu](https://github.com/doitcan-oiu) **Created:** 1/17/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `main` --- ### 📝 Commits (10+) - [`392b829`](https://github.com/justlovemaki/AIClient-2-API/commit/392b8295ec709c24d21b3f0159264b3ee28a0c20) Merge pull request #123 from unihon/feature/provider-health-api - [`4de10e4`](https://github.com/justlovemaki/AIClient-2-API/commit/4de10e42a1659c87fa22342dafc0bae968d7aca9) refactor: directly import and use `setLanguage` from i18n module in login page. - [`383cccc`](https://github.com/justlovemaki/AIClient-2-API/commit/383cccc473aba705601f9b7e81e7b30a19f64428) fix: add missing 'index' to Gemini streaming tool calls and improve tests - [`d76ce17`](https://github.com/justlovemaki/AIClient-2-API/commit/d76ce170ac615c49d945735edbf07f7ac446169e) chore: Add .gitignore rules for token store, usage cache, and OAuth credentials. - [`686106f`](https://github.com/justlovemaki/AIClient-2-API/commit/686106f81379d738bfd922ee191796add721f8c6) fix: map finish_reason to 'tool_calls' in Gemini stream when tool calls are present - [`3e2ed6f`](https://github.com/justlovemaki/AIClient-2-API/commit/3e2ed6f7c4dd0d247d90862b61202a8d8595dd78) Merge pull request #124 from lemon07r/main - [`1eeb310`](https://github.com/justlovemaki/AIClient-2-API/commit/1eeb3105ddf38d59b1456112ff1152e9ad2ca1b4) chore: 更新项目名称并添加忽略文件 - [`ded3a8e`](https://github.com/justlovemaki/AIClient-2-API/commit/ded3a8ef825fc798c6cd4fc661b269f86b13829f) fix(claude-kiro): 确保历史消息以assistantResponseMessage结尾 - [`945de61`](https://github.com/justlovemaki/AIClient-2-API/commit/945de61347e516d88e4bf4944d66b44214fc9524) feat(provider): 添加跨类型 Fallback 链支持 - [`7846f35`](https://github.com/justlovemaki/AIClient-2-API/commit/7846f35c50985e7d89fad1bc9867c4e62d12e4ee) fix(usage): 修复provider_health接口过滤参数不生效问题 ### 📄 Description - 重构 estimateInputTokens 函数,将多次 token 计算合并为单次 - 新增 processContent 辅助函数统一处理内容 - 提前拼接所有文本再统一计算 token,减少 countTextTokens 调用次数 - 保持原有逻辑不变,优化算法复杂度 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 07:18:58 +03:00
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/AIClient-2-API-justlovemaki#327
No description provided.