mirror of
https://github.com/bitbaum/substrata.git
synced 2026-12-04 05:30:25 +01:00
ai-kit 1.13.0 classBudget: drafting may spend <=25% of the day and never below a 50% floor kept for Ask (env-tunable); spend recorded per class per UTC day (research_ai_spend) and shown on /data#ai-budget with its method. Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
20 lines
793 B
PL/PgSQL
20 lines
793 B
PL/PgSQL
BEGIN;
|
|
|
|
-- Model spend on this app's free keys, per UTC day and per class: 'interactive'
|
|
-- (a reader waiting on Ask) and 'background' (scheduled jobs such as event
|
|
-- drafting). Background may only spend from a capped slice and never below the
|
|
-- floor kept for readers (lib/ai-budget.ts). Tokens are the vendor's count when
|
|
-- it reports one, otherwise a characters/4 estimate.
|
|
CREATE TABLE IF NOT EXISTS research_ai_spend (
|
|
day date NOT NULL,
|
|
class text NOT NULL,
|
|
tokens bigint NOT NULL DEFAULT 0,
|
|
calls integer NOT NULL DEFAULT 0,
|
|
held integer NOT NULL DEFAULT 0,
|
|
PRIMARY KEY (day, class)
|
|
);
|
|
|
|
COMMENT ON TABLE research_ai_spend IS 'Per-day AI token spend by class (interactive/background) on the shared free keys; held = background calls refused to protect readers.';
|
|
|
|
COMMIT;
|