Skip to content

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

Closed
Zhenyi-Wang wants to merge 1 commit into
QuantumNous:mainfrom
Zhenyi-Wang:feat/log-speed-column
Closed

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

Conversation

@Zhenyi-Wang

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

Copy link
Copy Markdown

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 an output "Speed" column to the usage logs table showing tokens/sec (output tokens ÷ (total time − time to first token)). Displayed only for applicable record types; shows a placeholder when speed is missing or non-positive. Column enabled by default.
    • Added translations for the new label and help text in EN, FR, JA, RU, VI, ZH‑CN, and ZH‑TW.

@coderabbitai

coderabbitai Bot commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

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: 98207903-214c-405b-87da-13fa327c5acf

📥 Commits

Reviewing files that changed from the base of the PR and between d85dd67 and 25077e7.

📒 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
✅ Files skipped from review due to trivial changes (7)
  • web/src/i18n/locales/zh-CN.json
  • web/src/i18n/locales/ja.json
  • web/src/i18n/locales/zh-TW.json
  • web/src/i18n/locales/vi.json
  • web/src/i18n/locales/fr.json
  • web/src/i18n/locales/en.json
  • web/src/i18n/locales/ru.json
🚧 Files skipped from review as they are similar to previous changes (2)
  • web/src/hooks/usage-logs/useUsageLogsData.jsx
  • web/src/components/table/usage-logs/UsageLogsColumnDefs.jsx

Walkthrough

Added a new "速度" (Speed) column to usage logs; the hook computes per-log speed as completion_tokens / (use_time - first_response_time) and the column renders the formatted value for specific log types, with i18n entries added for label and formula.

Changes

Cohort / File(s) Summary
Speed Column Display
web/src/components/table/usage-logs/UsageLogsColumnDefs.jsx, web/src/hooks/usage-logs/useUsageLogsData.jsx
Introduced COLUMN_KEYS.SPEED, added column definition with conditional render for record type in {0,2,5,6}; hook computes `speed = completion_tokens / (use_time - (other?.frt
Internationalization
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
Added translation keys for the label "速度" and the explanatory formula "输出速度 (tokens/s) = 输出 tokens / (总耗时 - 首字耗时)" across languages.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant UsageLogsHook as Hook
    participant UsageLogsTable as Table
    participant I18n as i18n
    User->>Table: open usage logs
    Table->>Hook: request logs data
    Hook->>Hook: compute per-log `speed` (completion_tokens / (use_time - frt))
    Hook-->>Table: return logs with `speed`
    Table->>I18n: get label/tooltip text
    Table->>User: render rows with Speed column (conditional)
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Suggested reviewers

  • seefs001

Poem

🐰 I crunch the logs with nimble paws,

Tokens per second, without a pause.
Six tongues now sing the speed so bright,
Rows render true in morning light.
Hooray — a rabbit’s metric delight! 🎉

🚥 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 PR title accurately describes the main change: adding a speed (tokens/s) calculation field to the usage logs table.
Linked Issues check ✅ Passed The PR implementation fully addresses issue #717's objectives: adds speed column with correct calculation formula, includes proper i18n translations for 7 languages, and implements both display and data computation logic.
Out of Scope Changes check ✅ Passed All changes are directly within scope: speed column definition and rendering, speed calculation logic in data hook, and i18n translations for speed feature—no unrelated modifications detected.
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.

@Zhenyi-Wang

Copy link
Copy Markdown
Author

@seefs001 麻烦大佬抽空看看,只是在前端日志加个计算列,用于显示token速度,小改动

@Zhenyi-Wang
Zhenyi-Wang force-pushed the feat/log-speed-column branch from 25077e7 to 706b122 Compare May 28, 2026 06:24
@Zhenyi-Wang

Copy link
Copy Markdown
Author

已 rebase 到最新 main 并解决冲突,当前可合并。PR 仅在前端日志表格新增一个 tokens/s 计算列,纯展示逻辑。@t0ng7u 麻烦抽空 review 一下 🙏

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