catalog

package
v1.0.0-alpha.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 11, 2026 License: Apache-2.0 Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package catalog prices token classes against the pinned sheets.

Index

Constants

View Source
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.

Variables

View Source
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

This section is empty.

Types

type Catalog

type Catalog struct {
	// contains filtered or unexported fields
}

Catalog is one pinned release.

func Load

func Load() (*Catalog, error)

Load reads the release embedded in the binary.

func Parse

func Parse(version string, release fs.FS) (*Catalog, error)

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) Lookup

func (c *Catalog) Lookup(q Query) (Price, error)

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 falls to the sheet's non-zero fallback row, and the Price says so.

func (*Catalog) ServiceProviderName

func (c *Catalog) ServiceProviderName(provider string) (string, error)

ServiceProviderName is the provider's name as its sheet states it.

func (*Catalog) Version

func (c *Catalog) Version() string

Version names the release.

type Multiplier

type Multiplier struct {
	SkuPriceID string
	Factor     decimal.Decimal
}

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
	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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL