Documentation
¶
Overview ¶
Package initcost is init being up front about its cost, since it is never bounded (design 10 Q6, Q10, Q10a): what a token of its spend is worth, the estimate of the rest of a run once it has gathered, with propose in one session or in shares (design 02 §2.3.1), the yes it waits for, the one warning when the spend passes the estimate's top, the table of what each phase spent, and what a run measured, kept for the next estimate. Spend reads in weighted tokens first, with the cost estimate beside it when prices are known.
Index ¶
- func Proceed(w io.Writer, e Estimate, a Ask) bool
- func Record(c *spend.Cache, st Stored, recovered spend.Count, at time.Time)
- func Table(rows []Row) string
- func Unit(c *spend.Cache, agent string) string
- func WarnPast(w io.Writer, m *spend.Meter, top spend.Spend)
- type Ask
- type Estimate
- type Row
- type Stored
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Proceed ¶
Proceed reports whether a run goes on past e: Yes goes on, Confirm asks, and without either the run stops, naming e and a.Rerun. When it stops, for a no or a question that could not be asked, it says why on w.
func Record ¶ added in v0.0.6
Record keeps what a recovery of every proposed capability measured, for the next estimate (spend.Cache.RecordRatio): recovered, recovery's spend, against the stored gather's estimated tokens, and propose's spend as the store holds it, whether it ran in the same run or in an earlier --propose, against its raw tokens. Unpriced spend would mix units, and a store without a gather or a propose holds nothing to measure against, so neither is recorded.
func Table ¶
Table is rows as a markdown table, with their total, the raw counts beside the weighted tokens and the cost estimate.
Types ¶
type Ask ¶
type Ask struct {
// Yes goes on without asking (--yes).
Yes bool
// Confirm asks the person; nil when there is no terminal to ask on.
Confirm func(question string) (bool, error)
// Rerun is the command that goes on without asking.
Rerun string
}
Ask says how a run may go on past its estimate.
type Estimate ¶
type Estimate struct {
// Discovery is what discovery spent.
Discovery spend.Spend
// Prompt and Reply are propose's prompt and reply reserve, and Sources
// the gathered sources, in estimated tokens.
Prompt, Reply, Sources int
Shares int
// Ratios are the factors' ranges and the runs they come from.
Ratios spend.Ratios
// Lo and Hi are the range, weighed.
Lo, Hi spend.Spend
}
Estimate is what the rest of a run is expected to spend, in weighted tokens, as a range measured from past runs: propose's prompt and reply reserve, which are known, times propose's weighted-to-raw factor, plus the sources' estimated tokens times recovery's weighted-to-sources ratio. Propose in shares counts every share's prompt and the merge's, and a reply reserve for each. A one-turn session writes its whole prompt to a 1-hour cache at twice input, so both are measured, never assumed. It is never a limit.
func For ¶
For estimates the rest of a run from gather g, whose sources take sources estimated tokens, after discovery spent what m has counted: propose in one session, or in the shares it needs within the window m's agent states (shares.Estimate). A source larger than one share is a *shares.TooLarge, returned before anything is spent on propose.