Repository navigation
fix(core): bill gemini thinking tokens when attaching model pricing - #1426
Closed
greysonlalonde wants to merge 2 commits into
Closed
greysonlalonde wants to merge 2 commits into
greysonlalonde wants to merge 2 commits into
Conversation
- attach_estimated_cost_for_provider bills gemini thoughts_tokens at the output rate through billed_usage - checked token sums so an overflowing gemini total or billed output count leaves total_tokens or cost unset - test: thinking-token billing and overflow cases Signed-off-by: Greyson Lalonde <[email protected]>
- ApiSpecificResponse::GeminiGenerateContent carries tool_use_prompt_tokens from toolUsePromptTokenCount - computed total_tokens includes tool-use prompt tokens so it matches totalTokenCount - billed_usage folds tool_use_prompt_tokens into prompt_tokens so cost estimates bill them at the input rate - ToolUsePromptBilling reads webSearchQueries, maps grounding chunks, and the Maps widget token so Search and Maps grounded responses bill none of them - rate tiers select from reported prompt_tokens so folded counts never cross a threshold - SeparateUsageCounts shared by the codec and attach_estimated_cost_for_provider so both billing paths agree - test: total, api_specific, input-rate billing, grounding exclusion, tier selection, input overflow, and redaction pass-through Signed-off-by: Greyson Lalonde <[email protected]>
Contributor
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
📒 Files selected for processing: 8
✨ Finishing Touches
Comment |
Contributor
Author
|
Opened from wrong branch |
2 tasks done
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Cost estimates attached through model pricing didn't account for gemini thinking tokens reported in
api_specific.thoughts_tokens. This bills thinking tokens at the output rate on either pricing path.Details
billed_usagefoldsthoughts_tokensinto billed output count forattach_estimated_cost_for_providerand built-in gemini codec.total_tokensor the cost estimate unset.Where should the reviewer start?
billed_usageincrates/core/src/codec/model_pricing.rs.Summary by CodeRabbit
New Features
Bug Fixes
Documentation