Spectre.Inference.BudgetSnapshot (Spectre v0.3.4)

Copy Markdown View Source

Immutable, per-attempt budget handed from the Instance to a worker/session.

Deadlines are absolute system milliseconds. Heartbeats may renew stall timers, but they never mutate deadline_at.

Summary

Types

limit()

@type limit() :: non_neg_integer() | number() | nil

t()

@type t() :: %Spectre.Inference.BudgetSnapshot{
  attempt_id: String.t(),
  deadline_at: integer() | nil,
  estimation_policy: :provider | :conservative | :unavailable,
  inference_id: String.t(),
  pricing_ref: String.t() | nil,
  remaining: %{optional(atom()) => limit()},
  reserved: Spectre.Inference.Usage.t()
}

Functions

deadline_exceeded?(budget_snapshot, now)

@spec deadline_exceeded?(t(), integer()) :: boolean()

exceeded(snapshot, usage)

@spec exceeded(t(), Spectre.Inference.Usage.t() | map()) :: :ok | {:error, atom()}

new(opts)

@spec new(keyword()) :: t()