feat(experiments): Add avg tokens column to evaluations table - #929
Conversation
Signed-off-by: shanaiabuggy <59746633+shanaiabuggy@users.noreply.github.com>
📝 WalkthroughWalkthroughAdds token rollups from ClickHouse through the evaluations API and Studio, including filtering, sorting, response schemas, OpenAPI documentation, guarded aggregation, and tests. ChangesEvaluation token metrics
Sequence Diagram(s)sequenceDiagram
participant Studio
participant EvaluationsAPI
participant EvaluationRollupRepository
participant ClickHouse
Studio->>EvaluationsAPI: Request evaluations with tokens sort/filter
EvaluationsAPI->>EvaluationRollupRepository: Load evaluation rollups
EvaluationRollupRepository->>ClickHouse: Query token aggregates
ClickHouse-->>EvaluationRollupRepository: Return token distributions
EvaluationRollupRepository-->>EvaluationsAPI: Return rollup.tokens
EvaluationsAPI-->>Studio: Return token metrics
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
services/intake/src/nmp/intake/api/v2/experiments/endpoints.py (1)
1138-1150: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winHandle
tokensin_evaluation_sort_value
tokens.<stat>falls through to the evaluators path, sosort=tokens.meanandfilter[tokens.*]treat the metric as missing. Add atokensbranch here.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@services/intake/src/nmp/intake/api/v2/experiments/endpoints.py` around lines 1138 - 1150, Update _evaluation_sort_value to explicitly handle tokens.<stat> paths before the evaluators fallback, using the same metric-stat resolution behavior as the existing cost_usd and latency_ms branches. Ensure sort=tokens.mean and filter[tokens.*] resolve the token metric instead of treating it as missing.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@web/packages/studio/src/components/dataViews/ExperimentGroupDataView/index.tsx`:
- Around line 445-448: Alias the `run_count` property to a camelCase `runCount`
local during destructuring in the row rendering logic, then continue passing
`runCount` to `MeanValueTooltipCell`. Keep the API field name `run_count` only
at the boundary.
---
Outside diff comments:
In `@services/intake/src/nmp/intake/api/v2/experiments/endpoints.py`:
- Around line 1138-1150: Update _evaluation_sort_value to explicitly handle
tokens.<stat> paths before the evaluators fallback, using the same metric-stat
resolution behavior as the existing cost_usd and latency_ms branches. Ensure
sort=tokens.mean and filter[tokens.*] resolve the token metric instead of
treating it as missing.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 7da86dd5-1071-40c4-843b-0001b3529a03
📒 Files selected for processing (8)
openapi/ga/individual/platform.openapi.yamlopenapi/ga/openapi.yamlopenapi/openapi.yamlservices/intake/src/nmp/intake/api/v2/experiments/endpoints.pyservices/intake/src/nmp/intake/api/v2/experiments/schemas.pyservices/intake/src/nmp/intake/spans/evaluation_rollup_repository.pyservices/intake/tests/test_experiment_rollup_repository.pyweb/packages/studio/src/components/dataViews/ExperimentGroupDataView/index.tsx
|
Signed-off-by: shanaiabuggy <59746633+shanaiabuggy@users.noreply.github.com>
Signed-off-by: shanaiabuggy <59746633+shanaiabuggy@users.noreply.github.com>
Screen.Recording.2026-07-27.at.3.38.31.PM.mov
Summary by CodeRabbit
tokens.*(for example,tokens.mean).-when no value is available.tokensrollup fields and query/sort/filter options.