Documentation
¶
Overview ¶
Package catalog prices token classes against the pinned sheets.
Index ¶
Constants ¶
const ( RegionGlobal = focus.RegionGlobal TierStandard = "standard" // TierFast is fast mode, which the sheets name as a tier. TierFast = "fast" )
Region and tier values the sheets use for default routing.
const ( ProviderAnthropic = "anthropic" ProviderOpenAI = "openai" ProviderGoogle = "google" )
The providers whose sheets price a model by the model's own name.
Variables ¶
var ErrNoPrice = errors.New("catalog: no price and no fallback")
ErrNoPrice means a sheet has neither a price nor a fallback for a class.
Functions ¶
func OwnerOf ¶
OwnerOf is the provider whose sheet prices a model, read from the model's name: the provider that publishes it, whoever served the request. It is empty when the name belongs to no provider the catalog holds a sheet for.
func PricesRead ¶
PricesRead is the day the prices of a release the binary carries were read, as YYYY-MM-DD: the date its sheets state, and the oldest one when its sheets state several. It is false for a release the binary does not carry.
Types ¶
type Catalog ¶
type Catalog struct {
// contains filtered or unexported fields
}
Catalog is one pinned release.
func Parse ¶
Parse reads every sheet in a release directory. A release holds one sheet per provider; a second one is refused, because the lookup would read only one of them. Two releases are two catalogs, each parsed on its own.
func (*Catalog) Ended ¶
Ended lists, by provider and then model, each model whose every unit price in its sheet ended by at's day, the last of them after the sheet's date. Such a model prices at the fallback tier from On, whatever its tier and class. A model whose prices had all ended by the sheet's date is left out: the sheet carries them for the days before their end, and no newer release prices the model again on that account.
func (*Catalog) Lookup ¶
Lookup prices one token class. At the fast tier, a cache class the sheet prices only as a multiple of the input price is the fast input price times the class's prompt_cache multiplier. A model, tier or class the sheet does not name, or whose price ended before the query's day, falls to the sheet's non-zero fallback row, and the Price says so, and which of the two it was.
func (*Catalog) ServiceProviderName ¶
ServiceProviderName is the provider's name as its sheet states it.
type Ended ¶
type Ended struct {
Provider string
ServiceProviderName string
Model string
// On is the first day none of the model's prices holds, as YYYY-MM-DD.
On string
}
Ended is a model a sheet prices on no day from the one asked about on.
type Multiplier ¶
Multiplier is one multiplier row of a sheet.
func (Multiplier) CacheNote ¶
func (m Multiplier) CacheNote(class focus.TokenClass) string
CacheNote names the prompt_cache multiplier a price was composed with.
type Price ¶
type Price struct {
SkuPriceID string
ListUnitPrice decimal.Decimal
PricingUnit string
Fallback bool
FallbackBasis string
// EndedOn is set on a fallback price when the sheet names the model, tier
// and class, and their rows that held before the query's day had all
// ended by it: the day the last of them ended, as YYYY-MM-DD. It is empty
// when no row of theirs ended by that day, as for a model the sheet never
// names.
EndedOn string
ResidencyMultiplier *decimal.Decimal
// CacheMultiplier is the sheet's prompt_cache multiplier when the sheet
// states the tier's input price and not the class's, and the price is the
// one times the other. Nil when a row states the class's price.
CacheMultiplier *Multiplier
// ContextTierMin and ContextTierMax are the matched row's context tier,
// as the sheet states it: a request's input is above the first and at or
// below the second. Nil means the tier is open on that side.
ContextTierMin, ContextTierMax *int64
}
Price is the answer to a Query.
type Query ¶
type Query struct {
Provider string
Model string
Class focus.TokenClass
ServiceTier string
Region string
// ContextInputTokens selects a long-context tier. Zero means the agent
// reported no per-request input, and the lowest tier applies.
ContextInputTokens int64
At time.Time
}
Query names one token class of one request.