Skip to content

feat(llmcost): aip properties#3928

Merged
hekike merged 3 commits intomainfrom
feat/llmcost-api-aip
Mar 6, 2026
Merged

feat(llmcost): aip properties#3928
hekike merged 3 commits intomainfrom
feat/llmcost-api-aip

Conversation

@hekike
Copy link
Contributor

@hekike hekike commented Mar 6, 2026

Model and Provider objects.

Summary by CodeRabbit

  • Refactor
    • Pricing responses now return nested provider and model objects (each with id and name) instead of flat string fields for clearer, structured data.
  • User-facing improvement
    • Provider names are normalized for readability—known providers use friendly labels and unknown provider IDs are prettified.

@hekike hekike requested a review from tothandras March 6, 2026 15:58
@hekike hekike requested a review from a team as a code owner March 6, 2026 15:58
@hekike hekike added the release-note/ignore Ignore this change when generating release notes label Mar 6, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 6, 2026

📝 Walkthrough

Walkthrough

Refactors LLMCost Price representation: replaces flat string fields for provider and model with nested structured types (Provider/Model) in the spec and generated API, and updates domain-to-API conversion to populate these nested types with provider display-name formatting.

Changes

Cohort / File(s) Summary
TypeSpec Schema Definition
api/spec/src/v3/llmcost/prices.tsp
Changed Price.provider from string to Provider; removed model_id/model_name and added model of type Model. Added public Provider and Model types with id and name.
Generated API Types
api/v3/api.gen.go
Added LLMCostProvider and LLMCostModel structs. Updated LLMCostPrice to replace Provider string, ModelId, and ModelName with nested Provider LLMCostProvider and Model LLMCostModel. JSON tags and comments adjusted.
Domain-to-API Conversion
api/v3/handlers/llmcost/convert.go
Updated domainPriceToAPI to emit nested api.LLMCostProvider and api.LLMCostModel. Added providerDisplayNames map and formatProviderName helper; imported strings.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • tothandras
🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'feat(llmcost): aip properties' is vague and unclear—'aip properties' doesn't clearly convey the actual change of refactoring Model and Provider to structured types. Consider a more descriptive title like 'feat(llmcost): refactor model and provider as structured types' to better reflect the substantive API changes.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/llmcost-api-aip

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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
api/v3/handlers/llmcost/convert.go (1)

16-44: Keep the provider label source out of the handler.

Provider.Name is public API now, but the canonical names live in a handler-local map. That makes new provider additions easy to miss, and the fallback can send rough labels straight to clients. I’d move the display-name helper next to the llmcost.Provider definitions, or at least cover it with a small test there. As per coding guidelines, "In general when reviewing the Golang code make readability and maintainability a priority, even potentially suggest restructuring the code to improve them."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@api/v3/handlers/llmcost/convert.go` around lines 16 - 44, Move the
providerDisplayNames map and formatProviderName function out of the handler and
into the llmcost package alongside the Provider type/definitions so canonical
display names are owned by the domain model rather than a handler; update code
that calls formatProviderName to import the llmcost symbol, and add a small unit
test in the llmcost package that asserts known provider IDs map to their
canonical names and that the empty-string and fallback capitalization behavior
work as expected (referencing providerDisplayNames and formatProviderName).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@api/spec/src/v3/llmcost/prices.tsp`:
- Around line 50-56: The change nests provider and model into objects for
LLMCostPrice (symbols: provider, model, LLMCostPrice) which breaks wire-format
for existing v3 clients; restore backward compatibility by providing a migration
path: accept both old top-level string fields (provider, model_id/model_name)
and the new nested objects during deserialization in LLMCostPrice, preserve
serializing to the existing format for the migration window or gate the new
nested schema behind an explicit version flag/contract change, and add clear
mapping logic between old field names and the new Provider/Model structures so
both old and new clients remain supported.
- Around line 87-109: The public doc comments for the Provider and Model types
include stray closing parentheses that propagate into generated Go comments;
edit the comments in the Provider and Model definitions (the model named
Provider and the model named Model) and remove the extra ')' characters from the
four field descriptions (Provider.id, Provider.name, Model.id, Model.name) so
the sentences read correctly without the stray punctuation.

---

Nitpick comments:
In `@api/v3/handlers/llmcost/convert.go`:
- Around line 16-44: Move the providerDisplayNames map and formatProviderName
function out of the handler and into the llmcost package alongside the Provider
type/definitions so canonical display names are owned by the domain model rather
than a handler; update code that calls formatProviderName to import the llmcost
symbol, and add a small unit test in the llmcost package that asserts known
provider IDs map to their canonical names and that the empty-string and fallback
capitalization behavior work as expected (referencing providerDisplayNames and
formatProviderName).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 0e5c6e74-3206-4b5d-a8d1-9e7f5be5b208

📥 Commits

Reviewing files that changed from the base of the PR and between b3975b4 and 7f67f27.

⛔ Files ignored due to path filters (1)
  • api/v3/openapi.yaml is excluded by !**/openapi.yaml
📒 Files selected for processing (3)
  • api/spec/src/v3/llmcost/prices.tsp
  • api/v3/api.gen.go
  • api/v3/handlers/llmcost/convert.go

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@api/v3/api.gen.go`:
- Around line 2399-2406: The API response shape for LLMCostPrice has changed
from flat fields to nested objects (the struct now uses Model LLMCostModel,
Pricing LLMCostModelPricing, Provider LLMCostProvider in api.gen.go), which is a
breaking change; update all public docs/OpenAPI spec, generated client code,
example responses, and any consumer-facing docs to reflect the new nested
structure and note the breaking change, and add a clear migration note
referencing the conversion helper domainPriceToAPI() so integrators know how
server-side conversion is handled and what to expect in responses.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 90e7f9fe-9fd2-4db8-8529-d2f420094aa4

📥 Commits

Reviewing files that changed from the base of the PR and between 1b920e8 and 927143b.

⛔ Files ignored due to path filters (1)
  • api/v3/openapi.yaml is excluded by !**/openapi.yaml
📒 Files selected for processing (2)
  • api/spec/src/v3/llmcost/prices.tsp
  • api/v3/api.gen.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • api/spec/src/v3/llmcost/prices.tsp

@hekike hekike merged commit 18ecad3 into main Mar 6, 2026
26 checks passed
@hekike hekike deleted the feat/llmcost-api-aip branch March 6, 2026 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-note/ignore Ignore this change when generating release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants