mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #4746] [Engine] serve: print what the counted tokens would have cost at your own prices #5158
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#5158
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/4746
Author: @au70ma70n
Created: 10/30/2026
Status: 🔄 Open
Base:
main← Head:engine-plain-cost-pricing📝 Commits (3)
145e349[GUI] settings: let a long help line wrap instead of squeezing every field419a478[Engine] serve: keep the Monitor's token counts between starts0b7d7d9[Engine] serve: print what the counted tokens would have cost at your own prices📊 Changes
7 files changed (+377 additions, -6 deletions)
View changed files
📝
docs/DETAILS.md(+12 -1)📝
serve/runconfig.py(+4 -0)📝
serve/server.py(+136 -1)➕
serve/test_totals.py(+189 -0)📝
serve/web/app.css(+7 -2)📝
serve/web/app.js(+28 -2)📝
serve/web/index.html(+1 -0)📄 Description
Draft — the costing story wants scope agreement first: #4742. It lands after #4745 (it prices the counts that PR keeps between starts); merge order is #4743 → #4745 → this one → #4747, and until the branch before it merges this pull request's diff also shows those commits and shrinks on its own as they merge.
Branch
engine-plain-cost-pricing, basemain.Problem and result
The Monitor counts tokens and says nothing about what they would have cost. Strata charges nothing of its own — the hardware is already bought — so a dollar figure only means what an API would have asked for the same work. After: two prices,
cost_input_per_millionandcost_output_per_million, editable in the page's Settings view and overridable for one start with--cost-inand--cost-out, read when the server starts like every other setting./metricstotals carry the rates andcost_usd;/metrics/prometheusgains the counterstrata:cost_usd. The Monitor's state card gains one short line — the cost first, then what the model was given, what the cache already held, and what it returned, with the date the counting began — narrow enough for a phone, while the sentence under the request table still gives the same counts in full and serves as that line's tooltip. With no price set, no figure is printed rather than a$0.00that would read as a model that works for free.Related discussion
#4742 — the one scope issue opened for the costing story (this pull request, #4745 which keeps the counts it prices, and #4747 which splits the price); it waits on a maintainer's yes.
Approach
The server does the arithmetic and sends the rate each kind of token is paid at, so a page never multiplies and never needs to know a price. A price in the config that is not a number is reported once at start and treated as no price at all, because a bad setting must not cost a start. A flag wins over the config for one start. The long sentence's wording moved from "prompt tokens read … written" to "input tokens read … output tokens", so the sentence names the parts the prices name. The example the tests hold: $5 per million in and $25 per million out prices 2,000,000 read and 100,000 written at 2 × $5 + 0.1 × $25 = $12.50.
Validation
Passed:
serve.test_totalson this branch's tree (which also carries #4745's commits) — the 8 tests that are this PR's:Cost.test_no_price_means_no_cost,Cost.test_a_million_tokens_costs_its_price,Cost.test_the_response_carries_the_prices_and_the_cost,Cost.test_the_cost_covers_every_start_the_file_remembers, andPriceSettings.test_both_prices_are_editable_from_the_page,test_a_price_set_from_the_page_is_written_and_read_back,test_only_a_price_of_at_least_nothing_is_a_price,test_the_two_prices_travel_with_their_own_name_only. Environment as in #4745's Validation (Windows 11 NT 10.0.26200, Python 3.10.11, no GPU and no downloads, at870aedd9+ these changes).Failed: none observed.
Not run: a live screenshot of the new state line with an API key present (see #4743's note on the headless profile); the app's
npm test(no node here); the Terminal suite (no pytest).Limits
One currency (US dollars), no exchange rate, one flat price per million; a changed price works from the next start, not mid-run;
strata:cost_usdis a counter over the window #4745 keeps, so it grows across starts and restarts on--totals-reset.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.