feat(intake): accept chat completion cost metrics#73
Conversation
Documentation preview is readyPreview: https://nvidia-nemo.github.io/nemo-platform/pr-preview/pr-73/pr-73/ Built from This preview is deployed from this PR branch, updates when docs changes are pushed, and will be removed when the PR closes. |
|
Signed-off-by: Andrew Suter-Morris <asutermorris@nvidia.com>
Signed-off-by: Andrew Suter-Morris <asutermorris@nvidia.com>
Signed-off-by: Andrew Suter-Morris <asutermorris@nvidia.com>
4dc519d to
cda365b
Compare
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughAdds optional USD cost fields and a typed cost_details map to OpenAPI, CLI, ingest request model, and span extraction; backend computes semantic cost attributes from explicit fields or cost_details aliases; integration tests cover persistence, alias rejection, and alternative usage shapes. ChangesCost field support for chat completions ingest
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@openapi/ga/individual/platform.openapi.yaml`:
- Around line 13367-13373: Update the OpenAPI schema for the cost_details object
(symbol: cost_details) to document that certain keys are reserved and will be
rejected by the backend; specifically add to the description (or an adjacent
vendorExt) a short note that the fields cost_total_usd, cost_input_usd, and
cost_output_usd are reserved and cannot be provided in cost_details (requests
including them will result in a 422 validation error), so clients know to avoid
those names.
🪄 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: 0b02536f-091a-4d7f-9cba-e1f0da5d09c8
⛔ Files ignored due to path filters (5)
sdk/python/nemo-platform/.nmpcontext/openapi.yamlis excluded by!sdk/**sdk/python/nemo-platform/src/nemo_platform/cli/commands/api/intake/ingest/chat_completions.pyis excluded by!sdk/**sdk/python/nemo-platform/src/nemo_platform/resources/intake/ingest/chat_completions.pyis excluded by!sdk/**sdk/python/nemo-platform/src/nemo_platform/types/intake/ingest/chat_completion_create_params.pyis excluded by!sdk/**sdk/python/nemo-platform/tests/api_resources/intake/ingest/test_chat_completions.pyis excluded by!sdk/**
📒 Files selected for processing (6)
openapi/ga/individual/platform.openapi.yamlopenapi/ga/openapi.yamlopenapi/openapi.yamlpackages/nemo_platform_ext/src/nemo_platform_ext/cli/commands/api/intake/ingest/chat_completions.pyservices/intake/src/nmp/intake/spans/ingest/chat_completions.pyservices/intake/tests/integration/spans/test_chat_completions_ingest.py
BrianNewsom
left a comment
There was a problem hiding this comment.
Looks good after the changes we discussed live.
1e584ba to
5fc712e
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@services/intake/src/nmp/intake/spans/ingest/chat_completions.py`:
- Around line 187-188: The loop writing body.cost_details into attributes can
overwrite canonical cost fields (e.g., total/input/output colliding with
cost_usd/cost_input_usd); change the logic in the block where
attribute_bags.put_unhandled_source_attribute is called for body.cost_details so
that you either (a) map known keys ("total","input","output") to the canonical
names ("llm.cost_usd","llm.cost_input_usd","llm.cost_output_usd") and write
those only if the canonical attribute is not already present, or (b) namespace
the incoming keys (e.g., "llm.cost_details.{key}") to avoid collisions
altogether; update the code paths around body.cost_details and
attribute_bags.put_unhandled_source_attribute accordingly so existing canonical
cost attributes are preserved.
🪄 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: aecf7064-395c-4862-bd52-43cc93f1a5b1
📒 Files selected for processing (2)
services/intake/src/nmp/intake/spans/ingest/chat_completions.pyservices/intake/tests/integration/spans/test_chat_completions_ingest.py
🚧 Files skipped from review as they are similar to previous changes (1)
- services/intake/tests/integration/spans/test_chat_completions_ingest.py
Signed-off-by: Andrew Suter-Morris <asutermorris@nvidia.com>
5fc712e to
f432172
Compare
* feat(intake): accept chat completion cost metrics Signed-off-by: Andrew Suter-Morris <asutermorris@nvidia.com> * fix(intake): align chat completion cost fields with ATIF Signed-off-by: Andrew Suter-Morris <asutermorris@nvidia.com> * chore(intake): sync generated SDK cost fields Signed-off-by: Andrew Suter-Morris <asutermorris@nvidia.com> * fix(intake): keep chat completions usage openai-shaped Signed-off-by: Andrew Suter-Morris <asutermorris@nvidia.com> --------- Signed-off-by: Andrew Suter-Morris <asutermorris@nvidia.com> Signed-off-by: Alex Ray <alray@nvidia.com>
Summary by CodeRabbit
New Features
Bug Fixes / Validation
Tests