feat(weave): add cache token pricing columns to llm_token_prices#6484
Closed
andrewtruong wants to merge 6 commits intomasterfrom
Closed
feat(weave): add cache token pricing columns to llm_token_prices#6484andrewtruong wants to merge 6 commits intomasterfrom
andrewtruong wants to merge 6 commits intomasterfrom
Conversation
Add cache_read_input_tokens and cache_write_input_tokens to LLMUsageSchema, LLMCostSchema, and LLMAggregatedUsage so the data model can represent cached token counts and their costs. Update usage_utils.py to extract, normalize (cache_creation_input_tokens → cache_write_input_tokens), merge, and aggregate the new fields through the call hierarchy. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add cache_read_input_token_cost and cache_write_input_token_cost columns to the llm_token_prices table in both ClickHouse (migration 026) and SQLite. Update LLM_TOKEN_PRICES_COLUMNS, CostCreateInput, CostQueryOutput, and the SQLite cost application logic to read, write, and compute costs using the new columns. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Preview this PR with FeatureBee: https://beta.wandb.ai/?betaVersion=a294d19c358c500c37f2cde70eac24e48fe5fdc6 |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
026 is now taken by object_version_first_seen from master. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…to andrew/l3-cache-price-columns
3 tasks
Contributor
|
This PR has been inactive for 14 days. It will be closed in 7 days unless there is new activity. |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Summary
026_add_cache_token_costswithcache_read_input_token_costandcache_write_input_token_costcolumns (Float64, DEFAULT 0)llm_token_pricesCREATE TABLELLM_TOKEN_PRICES_COLUMNSintoken_costs.pyandbuild_model_prices_queryto SELECT the new columnscache_read_input_token_costandcache_write_input_token_costtoCostCreateInput(default 0.0) andCostQueryOutput_ensure_default_costs,_apply_costs_to_calls, andcost_createto read/write/compute with cache pricingContext
This is Layer 3 of the cached token tracking feature. It adds the storage columns for variable cache pricing, enabling downstream cost data fetching (L4) from LiteLLM and cache-aware cost calculation (L5).
Test plan
cost_createaccepts cache pricing fieldscost_queryreturns cache pricing fields_apply_costs_to_callscomputes cache token costs when pricing data exists🤖 Generated with Claude Code