Rho.Budget (rho v0.1.0)

Copy Markdown View Source

The per-day cost cap: what the model calls cost today, priced by req_llm from each reply's usage (notional on a Claude or ChatGPT subscription), against the host's Rho.Settings.daily_cap/1.

The ledger is spend.json in the data dir, {"YYYY-MM-DD" => dollars} by the device's local date, the last 31 days kept. The loop checks check/1 before every model call and record/2s every reply, across all sessions. A reply that runs past the cap still finishes (its cost is only known at the end); the next call is refused.

Summary

Functions

:ok, or {:over, spent_today, cap} once today's spend reached the cap.

Adds cost dollars to the day's spend (non-positive costs are ignored).

Today's spend in dollars.

The phone's local date.

Functions

check(dir, date \\ today())

@spec check(Path.t(), Date.t()) :: :ok | {:over, float(), float()}

:ok, or {:over, spent_today, cap} once today's spend reached the cap.

record(dir, cost, date \\ today())

@spec record(Path.t(), number(), Date.t()) :: :ok

Adds cost dollars to the day's spend (non-positive costs are ignored).

spent(dir, date \\ today())

@spec spent(Path.t(), Date.t()) :: float()

Today's spend in dollars.

today()

@spec today() :: Date.t()

The phone's local date.