Documentation
¶
Overview ¶
Package aitaste meters the free account's AI taste: a few answers a month from the operator's key (Pro v6).
Two counters stand behind it. ai_taste_usage holds one row per (user, UTC month) on the request pool under row-level security; Reserve takes a unit atomically and Refund gives it back, so the count cannot pass the quota however the calls race. ai_taste_spend holds what the day's free-taste calls may still cost the operator, on the system pool: a hold at the route's estimate is taken before the call and settled to the real cost after it. Both fail CLOSED: a store error refuses the call.
Index ¶
Constants ¶
const ( // MonthlyQuota is how many operator-key answers a free account takes in a UTC calendar month. MonthlyQuota = 5 // DefaultDailyCeilingUSD is what free-taste calls may cost the operator in a UTC day, on top of the Console spend limit. DefaultDailyCeilingUSD = 5.0 // EstimateUSD is held per call before it runs and settled to the real cost after. It sits above the dearest measured // operator answer (about four cents on the efficiency route). EstimateUSD = 0.06 )
Variables ¶
This section is empty.
Functions ¶
func MonthStart ¶
MonthStart is the first day of now's UTC calendar month, the key of ai_taste_usage.
Types ¶
type Gate ¶
type Gate struct {
Store *Store
Spend *Spend
User uuid.UUID
Quota int
Now func() time.Time
// contains filtered or unexported fields
}
Gate is one request's ai.Taste for a free account: the ceiling's hold first (so a refused call burns no taste), then the user's unit.
type Spend ¶
type Spend struct {
// contains filtered or unexported fields
}
Spend is the install-wide daily ceiling on free-taste cost, on the system pool.
func NewSpend ¶
NewSpend wires the ceiling to the system pool. A nil pool yields a nil Spend, which refuses every hold.
func (*Spend) Adjust ¶
Adjust moves the day's spend by delta (a settlement: real cost minus the hold; a release: minus the hold). Never below zero.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store counts a user's taste on the request pool.