Limits
import { actionsOf, limitsOf, servedOf, refusalOf, overlay, classesLabel, when, noticeOf, nearOf, navigable, CLASSES, CLASS_LABEL, paidPlan, worst } from '@hanzo/ui/product'
No examples yet.
Types
export type LimitState = 'ok' | 'near' | 'limited'export type LimitClass = 'premium' | 'ours' | 'free'export type LimitPayer = 'plan' | 'credits' | 'free' | 'none'export type PaidBy = LimitPayerexport type LimitReason = 'plan_allowance_used' | 'paid_plan_required' | 'free_plan_cap' | 'insufficient_balance' | 'model_cap'export type LimitActionKind = 'upgrade' | 'topup' | 'credits' | 'switch' | 'later'export interface LimitWindow {
percent: number
state: LimitState
resets_at: string | null
}export interface ClassLimit extends LimitWindow {
paying: LimitPayer
window?: LimitWindow
}export interface LimitAction {
kind: LimitActionKind
label: string
plan?: string
url?: string
model?: string
}export interface Limited {
reason: string
classes: LimitClass[]
message: string
}export interface PausedModel {
model: string
/** The model that answers in its place. */
fallback?: string
resets_at?: string | null
}export interface Limits {
/** The plan slug, or "" for a caller with no plan. */
plan: string
period_start?: string
period_end?: string
state: LimitState
classes: Partial<Record<LimitClass, ClassLimit>>
limited?: Limited
/** Models paused one by one, by exact id or glob. */
paused?: PausedModel[]
actions: LimitAction[]
upgrade?: string
/** The org keeps paying from credits once included usage runs out; absent when the server does not say. */
creditsAfterAllowance?: boolean
}export interface Served {
state: LimitState
class: LimitClass | null
paidBy: PaidBy | null
/** The model that answered in place of the one asked for: the one `X-Hanzo-Served` names, else `X-Hanzo-Fallback`'s. */
fallback: string | null
reason: string | null
}export interface Refusal {
status: number
code: string
message: string
class: LimitClass | null
resets_at: string | null
actions: LimitAction[]
/** Seconds, from Retry-After on a 429, when it names none to a day (`WAIT`). */
retry: number | null
}export interface LimitNotice {
reason: string
classes: LimitClass[]
message: string
actions: LimitAction[]
resets_at: string | null
fallback: string | null
/** A billing refusal is part of it: the reader has been turned away, not only read as limited. */
refused: boolean
}export interface Heard {
served: Served | null
refusal: Refusal | null
}Exports
actionsOflimitsOfservedOfrefusalOfoverlayclassesLabelwhennoticeOfnearOfnavigableCLASSESCLASS_LABELpaidPlanworsttype LimitStatetype LimitClasstype LimitPayertype PaidBytype LimitReasontype LimitActionKindtype LimitWindowtype ClassLimittype LimitActiontype Limitedtype PausedModeltype Limitstype Servedtype Refusaltype LimitNoticetype Heard