feat(pricing): add function_tags, max_prompt_tokens, max_completion_tokens to model metadata and /api/pricing (#5931) - #5934
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (7)
🚧 Files skipped from review as they are similar to previous changes (7)
WalkthroughAdds function tags and prompt/completion token limits to backend model metadata and pricing output, carries them through the model management form and pricing display, and updates locale strings for the new labels and messages. ChangesModel Capability Metadata
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant Admin
participant Drawer as Model mutate drawer
participant ModelAPI
participant ModelMetadata
participant PricingAPI
Admin->>Drawer: enter function tags and token limits
Drawer->>ModelAPI: submit model payload
ModelAPI->>ModelMetadata: persist metadata
PricingAPI->>ModelMetadata: rebuild pricing metadata
ModelMetadata-->>PricingAPI: return function tags and token limits
PricingAPI-->>Admin: expose metadata in pricing details
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 3❌ Failed checks (3 warnings)
✅ Passed checks (2 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (3)
web/default/src/features/models/lib/model-form.ts (2)
98-118: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueRedundant
?? undefined— schema already yieldsnumber | undefined.
formData.max_prompt_tokenscan't benullper the Zod schema, so?? undefinedhas no effect here.♻️ Suggested simplification
- max_prompt_tokens: formData.max_prompt_tokens ?? undefined, - max_completion_tokens: formData.max_completion_tokens ?? undefined, + max_prompt_tokens: formData.max_prompt_tokens, + max_completion_tokens: formData.max_completion_tokens,🤖 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 `@web/default/src/features/models/lib/model-form.ts` around lines 98 - 118, The redundant nullish coalescing in transformFormDataToModelPayload should be removed because ModelFormValues already provides number | undefined for max_prompt_tokens and max_completion_tokens. Update the payload mapping in model-form.ts to pass formData.max_prompt_tokens and formData.max_completion_tokens directly, keeping the rest of the Model payload transformation unchanged.
37-39: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valuePrefer
.optional()overz.union([..., z.undefined()]).
z.union([z.number().int().positive(), z.undefined()])is functionally equivalent to.optional()but less idiomatic and produces a less precise inferred type (number | undefinedrequired key vsnumberoptional key).♻️ Suggested simplification
- max_prompt_tokens: z.union([z.number().int().positive(), z.undefined()]), - max_completion_tokens: z.union([z.number().int().positive(), z.undefined()]), + max_prompt_tokens: z.number().int().positive().optional(), + max_completion_tokens: z.number().int().positive().optional(),🤖 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 `@web/default/src/features/models/lib/model-form.ts` around lines 37 - 39, The schema in model-form.ts uses z.union([..., z.undefined()]) for max_prompt_tokens and max_completion_tokens, which should be simplified to the idiomatic optional form. Update the zod definitions near function_tags in the model form schema to use .optional() on the positive integer number schema instead of explicitly unioning with z.undefined(), so the inferred types are cleaner and the key is truly optional.web/default/src/features/pricing/components/model-details.tsx (1)
494-500: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRename the map parameter to avoid shadowing the
ttranslation function.
.map((t) => t.trim())shadows the outerconst { t } = useTranslation(). It doesn't break current behavior, but it's a lint hazard (no-shadow) and a latent bug risk if this scope is later extended to callt(...).♻️ Proposed fix
- <CatalogPillList items={model.function_tags.split(',').map((t) => t.trim()).filter(Boolean)} /> + <CatalogPillList items={model.function_tags.split(',').map((tag) => tag.trim()).filter(Boolean)} />🤖 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 `@web/default/src/features/pricing/components/model-details.tsx` around lines 494 - 500, The `model-details.tsx` rendering for `function_tags` should avoid shadowing the `t` translation function from `useTranslation()`. Update the `model.function_tags.split(',').map((t) => t.trim())` callback in the `CatalogInfoCell` / `CatalogPillList` block to use a different parameter name so `t(...)` remains unambiguous and lint-safe.
🤖 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.
Nitpick comments:
In `@web/default/src/features/models/lib/model-form.ts`:
- Around line 98-118: The redundant nullish coalescing in
transformFormDataToModelPayload should be removed because ModelFormValues
already provides number | undefined for max_prompt_tokens and
max_completion_tokens. Update the payload mapping in model-form.ts to pass
formData.max_prompt_tokens and formData.max_completion_tokens directly, keeping
the rest of the Model payload transformation unchanged.
- Around line 37-39: The schema in model-form.ts uses z.union([...,
z.undefined()]) for max_prompt_tokens and max_completion_tokens, which should be
simplified to the idiomatic optional form. Update the zod definitions near
function_tags in the model form schema to use .optional() on the positive
integer number schema instead of explicitly unioning with z.undefined(), so the
inferred types are cleaner and the key is truly optional.
In `@web/default/src/features/pricing/components/model-details.tsx`:
- Around line 494-500: The `model-details.tsx` rendering for `function_tags`
should avoid shadowing the `t` translation function from `useTranslation()`.
Update the `model.function_tags.split(',').map((t) => t.trim())` callback in the
`CatalogInfoCell` / `CatalogPillList` block to use a different parameter name so
`t(...)` remains unambiguous and lint-safe.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: c846d62b-711c-455b-bc05-7118ca6567dc
📒 Files selected for processing (13)
model/model_meta.gomodel/pricing.goweb/default/src/features/models/components/drawers/model-mutate-drawer.tsxweb/default/src/features/models/lib/model-form.tsweb/default/src/features/models/types.tsweb/default/src/features/pricing/components/model-details.tsxweb/default/src/features/pricing/types.tsweb/default/src/i18n/locales/en.jsonweb/default/src/i18n/locales/fr.jsonweb/default/src/i18n/locales/ja.jsonweb/default/src/i18n/locales/ru.jsonweb/default/src/i18n/locales/vi.jsonweb/default/src/i18n/locales/zh.json
|
需要这个功能,能合并吗 |
…okens to model metadata and /api/pricing (QuantumNous#5931)
…, max_completion_tokens
…adow in pricing details
8a746cb to
916de45
Compare
51fdfc5 to
2b6f1df
Compare
📝 变更描述 / Description
Adds
function_tags,max_prompt_tokens, andmax_completion_tokensfields to model metadata (backend GORM struct) and exposes them via/api/pricing. This enables users to see model capability tags and context length limits directly in the pricing catalog.model.Modelwith*int64for token counts (nullable) andstringfor function_tags.model.Pricingresponse populates these from metadata.Update()Select list includes all three fields.🚀 变更类型 / Type of change
🔗 关联任务 / Related Issue
✅ 提交前检查项 / Checklist
go vet ./...,go test ./model/...,go test ./controller/...,bun run typecheckall pass.📸 运行证明 / Proof of Work
go vet ./...— only pre-existingweb/classic/distwarninggo test ./model/...— okgo test ./controller/...— okSummary by CodeRabbit