Skip to content

feat: 添加日志表格输出速度 (tokens/s) 计算字段#4237

Open
Zhenyi-Wang wants to merge 1 commit intoQuantumNous:mainfrom
Zhenyi-Wang:feat/log-speed-column
Open

feat: 添加日志表格输出速度 (tokens/s) 计算字段#4237
Zhenyi-Wang wants to merge 1 commit intoQuantumNous:mainfrom
Zhenyi-Wang:feat/log-speed-column

Conversation

@Zhenyi-Wang
Copy link
Copy Markdown

@Zhenyi-Wang Zhenyi-Wang commented Apr 14, 2026

Summary

  • /console/log 使用日志表格中新增「速度」列,显示 LLM 输出的 tokens/s 指标
  • 计算公式:completion_tokens / (use_time - frt/1000),即输出 token 数除以首字后的生成耗时
  • 表头附带 help 图标,hover 显示计算公式说明
  • 补全 7 种语言(zh-CN、en、zh-TW、ja、fr、ru、vi)的国际化翻译

Closes #717

Changes

文件 说明
UsageLogsColumnDefs.jsx 新增 speed 列定义(表头 + render)
useUsageLogsData.jsx COLUMN_KEYS、可见性配置、预计算 speed
web/src/i18n/locales/*.json 7 个语言文件添加翻译

Test plan

  • 访问 /console/log,确认「速度」列显示在「输出」和「花费」之间
  • 流式请求:speed = completion_tokens / (use_time - frt),数值正确
  • 非流式请求:frt 为 0,speed = completion_tokens / use_time
  • frt >= use_time 时显示 -
  • 非消费类型日志(充值/管理/系统)不显示
  • 切换语言,确认翻译正确显示

Summary by CodeRabbit

  • New Features
    • Added output speed column to usage logs table displaying tokens per second. Speed calculated as output tokens divided by (total time - first token latency). Shown for applicable record types. Includes multilingual support for English, French, Japanese, Russian, Vietnamese, Simplified Chinese, and Traditional Chinese.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 14, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3345fde1-cbb0-46c2-b01d-f68e79176f6c

📥 Commits

Reviewing files that changed from the base of the PR and between 8c8661d and d85dd67.

📒 Files selected for processing (9)
  • web/src/components/table/usage-logs/UsageLogsColumnDefs.jsx
  • web/src/hooks/usage-logs/useUsageLogsData.jsx
  • web/src/i18n/locales/en.json
  • web/src/i18n/locales/fr.json
  • web/src/i18n/locales/ja.json
  • web/src/i18n/locales/ru.json
  • web/src/i18n/locales/vi.json
  • web/src/i18n/locales/zh-CN.json
  • web/src/i18n/locales/zh-TW.json

Walkthrough

A new speed metric column is added to the usage logs table that displays output tokens per second, calculated as completion tokens divided by adjusted generation time (total time minus first response time). The feature includes conditional rendering for specific log types and multilingual support.

Changes

Cohort / File(s) Summary
Speed Column Display
web/src/components/table/usage-logs/UsageLogsColumnDefs.jsx, web/src/hooks/usage-logs/useUsageLogsData.jsx
Added new speed column definition with conditional rendering for record types 0, 2, 5, and 6. Implemented speed calculation as completion_tokens / (use_time - first_response_time), with fallback to 0 and formatting to 1 decimal place.
Internationalization
web/src/i18n/locales/{en,fr,ja,ru,vi,zh-CN,zh-TW}.json
Added translations for speed metric label and formula explanation across six language files: English, French, Japanese, Russian, Vietnamese, Simplified Chinese, and Traditional Chinese.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested reviewers

  • seefs001

Poem

🐰 Hops with glee, let me say,
Speed metrics brighten up the day!
Tokens flowing, swift and true,
Six languages, one feature new!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding a speed (tokens/s) calculation column to the usage logs table.
Linked Issues check ✅ Passed The PR successfully implements all coding requirements from issue #717: adds speed column to logs table, implements calculation logic, updates column definitions, and adds translations for 7 languages.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing the speed column feature: column definition, calculation logic, visibility configuration, and i18n translations for the new feature.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

日志中增加速度显示

2 participants