@trazum/core 1.81.0 → 1.82.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -18
- package/dist/advisories.d.ts +33 -1
- package/dist/advisories.d.ts.map +1 -1
- package/dist/advisories.js +103 -16
- package/dist/advisories.js.map +1 -1
- package/dist/band.d.ts +131 -0
- package/dist/band.d.ts.map +1 -0
- package/dist/band.js +210 -0
- package/dist/band.js.map +1 -0
- package/dist/conform.d.ts +1 -1
- package/dist/conform.d.ts.map +1 -1
- package/dist/conform.js +84 -1
- package/dist/conform.js.map +1 -1
- package/dist/helicone.d.ts +92 -0
- package/dist/helicone.d.ts.map +1 -0
- package/dist/helicone.js +194 -0
- package/dist/helicone.js.map +1 -0
- package/dist/i18n/en.d.ts.map +1 -1
- package/dist/i18n/en.js +9 -3
- package/dist/i18n/en.js.map +1 -1
- package/dist/i18n/es.d.ts.map +1 -1
- package/dist/i18n/es.js +9 -3
- package/dist/i18n/es.js.map +1 -1
- package/dist/i18n/types.d.ts +43 -1
- package/dist/i18n/types.d.ts.map +1 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/litellm.d.ts +98 -0
- package/dist/litellm.d.ts.map +1 -0
- package/dist/litellm.js +207 -0
- package/dist/litellm.js.map +1 -0
- package/dist/measured-profile.d.ts +4 -0
- package/dist/measured-profile.d.ts.map +1 -1
- package/dist/measured-profile.js +22 -1
- package/dist/measured-profile.js.map +1 -1
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +36 -0
- package/dist/schemas.js.map +1 -1
- package/dist/tokenizer.d.ts +45 -49
- package/dist/tokenizer.d.ts.map +1 -1
- package/dist/tokenizer.js +100 -51
- package/dist/tokenizer.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/verdict-bridge.d.ts +113 -0
- package/dist/verdict-bridge.d.ts.map +1 -0
- package/dist/verdict-bridge.js +127 -0
- package/dist/verdict-bridge.js.map +1 -0
- package/package.json +1 -1
- package/src/advisories.ts +132 -15
- package/src/band.ts +213 -0
- package/src/conform.ts +100 -1
- package/src/helicone.ts +227 -0
- package/src/i18n/en.ts +10 -3
- package/src/i18n/es.ts +10 -3
- package/src/i18n/types.ts +45 -1
- package/src/index.ts +17 -1
- package/src/litellm.ts +243 -0
- package/src/measured-profile.ts +26 -2
- package/src/schemas.ts +36 -0
- package/src/tokenizer.ts +101 -51
- package/src/types.ts +1 -0
- package/src/verdict-bridge.ts +200 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LiteLLM's spend log, read as a usage log.
|
|
3
|
+
*
|
|
4
|
+
* `from-claude-code` proved the pattern and `from-otel` generalised it: a pure
|
|
5
|
+
* converter turns one tool's export into Trazum's usage-log records, and every
|
|
6
|
+
* door prices it from there. LiteLLM is the gateway a great many teams already
|
|
7
|
+
* put in front of every provider, so its `LiteLLM_SpendLogs` table is the one
|
|
8
|
+
* export most likely to already exist on somebody's disk.
|
|
9
|
+
*
|
|
10
|
+
* **The format is derived, not guessed.** Every field below is read off
|
|
11
|
+
* `litellm/proxy/schema.prisma` in BerriAI/litellm, model `LiteLLM_SpendLogs`.
|
|
12
|
+
* A converter written from memory of an API is a converter that silently
|
|
13
|
+
* mis-reads somebody's bill, and this project has one rule above all others
|
|
14
|
+
* about numbers it cannot justify.
|
|
15
|
+
*
|
|
16
|
+
* ## What maps
|
|
17
|
+
*
|
|
18
|
+
* | LiteLLM | Trazum |
|
|
19
|
+
* | --- | --- |
|
|
20
|
+
* | `model` | `model` |
|
|
21
|
+
* | `prompt_tokens` | `usage.input_tokens` |
|
|
22
|
+
* | `completion_tokens` | `usage.output_tokens` |
|
|
23
|
+
* | `startTime` | `ts` |
|
|
24
|
+
* | `session_id` | `session` |
|
|
25
|
+
* | `request_tags[0]`, else `metadata.tags[0]`, else `model_group` | `label` |
|
|
26
|
+
*
|
|
27
|
+
* ## What deliberately does not cross
|
|
28
|
+
*
|
|
29
|
+
* The row carries `messages` and `response` — the prompt itself and the
|
|
30
|
+
* completion — plus `api_key` (hashed, still credential-shaped),
|
|
31
|
+
* `requester_ip_address`, `user` and `end_user`. **None of it is read.** The
|
|
32
|
+
* converter names the fields it takes and takes nothing else, and a fixture
|
|
33
|
+
* plants a marker in each of them and greps the whole output.
|
|
34
|
+
*
|
|
35
|
+
* ## What it refuses to invent
|
|
36
|
+
*
|
|
37
|
+
* `cache_hit` is a flag and `cache_key` an identifier; neither is a token
|
|
38
|
+
* count. A converted record therefore carries no cache split at all, and the
|
|
39
|
+
* caching questions come back `cannot-tell` rather than answered from a
|
|
40
|
+
* guess — the same refusal as inventing a price. `cacheFlagged` counts the
|
|
41
|
+
* rows that said "hit" so the operator can see the gap is real rather than
|
|
42
|
+
* empty.
|
|
43
|
+
*
|
|
44
|
+
* `spend` is LiteLLM's own priced figure and is **never** merged into
|
|
45
|
+
* Trazum's catalogue-priced total. It is a second measurement of the same
|
|
46
|
+
* calls, kept apart the way the store's provider-billed standing is kept
|
|
47
|
+
* apart from the log's, and returned on its own so a caller who wants to
|
|
48
|
+
* compare the two can, deliberately.
|
|
49
|
+
*/
|
|
50
|
+
/** One converted record, shaped exactly as `parseUsageLine` reads it. */
|
|
51
|
+
export interface LiteLlmRecord {
|
|
52
|
+
model: string;
|
|
53
|
+
ts?: string;
|
|
54
|
+
label?: string;
|
|
55
|
+
session?: string;
|
|
56
|
+
usage: {
|
|
57
|
+
input_tokens: number;
|
|
58
|
+
output_tokens: number;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
export interface LiteLlmConversion {
|
|
62
|
+
records: LiteLlmRecord[];
|
|
63
|
+
/** Rows that were spend logs and converted. */
|
|
64
|
+
rows: number;
|
|
65
|
+
/** Rows naming no model: counted, never guessed at, never dropped silently. */
|
|
66
|
+
unnamedModel: number;
|
|
67
|
+
/** Rows carrying no token counts at all — a logged call nobody can price. */
|
|
68
|
+
noTokens: number;
|
|
69
|
+
/** Rows LiteLLM marked as a cache hit, with no token split to act on. */
|
|
70
|
+
cacheFlagged: number;
|
|
71
|
+
/**
|
|
72
|
+
* LiteLLM's own total for the converted rows, in USD, or null when no row
|
|
73
|
+
* carried one. **Never** added to anything Trazum computes: it is the
|
|
74
|
+
* gateway's arithmetic over the gateway's price table, and merging two
|
|
75
|
+
* price tables into one figure is how a report becomes quietly wrong.
|
|
76
|
+
*/
|
|
77
|
+
reportedSpendUsd: number | null;
|
|
78
|
+
/** Lines or documents that did not parse as JSON at all. */
|
|
79
|
+
unparseable: number;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Convert a LiteLLM spend-log export.
|
|
83
|
+
*
|
|
84
|
+
* Accepts a JSON array of rows, a single row, `{ data: [...] }` as the proxy's
|
|
85
|
+
* own endpoints return it, or newline-delimited rows — so a `psql --json`
|
|
86
|
+
* dump, an API response and a streamed capture all work. Pure over its input.
|
|
87
|
+
*/
|
|
88
|
+
export declare function litellmRecords(text: string): LiteLlmConversion;
|
|
89
|
+
/**
|
|
90
|
+
* Whether a file looks like a LiteLLM spend log, by shape.
|
|
91
|
+
*
|
|
92
|
+
* Deliberately narrow: `request_id` beside one of the two token columns, and
|
|
93
|
+
* a field no other export in this project carries. A looser test would claim
|
|
94
|
+
* an OpenAI usage response, whose rows also have `prompt_tokens`, and refuse
|
|
95
|
+
* it in this file's words instead of letting the code that can read it try.
|
|
96
|
+
*/
|
|
97
|
+
export declare function looksLikeLiteLlm(text: string, prefixBytes?: number): boolean;
|
|
98
|
+
//# sourceMappingURL=litellm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"litellm.d.ts","sourceRoot":"","sources":["../src/litellm.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AAEH,yEAAyE;AACzE,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE;QACL,YAAY,EAAE,MAAM,CAAC;QACrB,aAAa,EAAE,MAAM,CAAC;KACvB,CAAC;CACH;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,aAAa,EAAE,CAAC;IACzB,+CAA+C;IAC/C,IAAI,EAAE,MAAM,CAAC;IACb,+EAA+E;IAC/E,YAAY,EAAE,MAAM,CAAC;IACrB,6EAA6E;IAC7E,QAAQ,EAAE,MAAM,CAAC;IACjB,yEAAyE;IACzE,YAAY,EAAE,MAAM,CAAC;IACrB;;;;;OAKG;IACH,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,4DAA4D;IAC5D,WAAW,EAAE,MAAM,CAAC;CACrB;AAqDD;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,iBAAiB,CAmF9D;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,SAAO,GAAG,OAAO,CAQ1E"}
|
package/dist/litellm.js
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LiteLLM's spend log, read as a usage log.
|
|
3
|
+
*
|
|
4
|
+
* `from-claude-code` proved the pattern and `from-otel` generalised it: a pure
|
|
5
|
+
* converter turns one tool's export into Trazum's usage-log records, and every
|
|
6
|
+
* door prices it from there. LiteLLM is the gateway a great many teams already
|
|
7
|
+
* put in front of every provider, so its `LiteLLM_SpendLogs` table is the one
|
|
8
|
+
* export most likely to already exist on somebody's disk.
|
|
9
|
+
*
|
|
10
|
+
* **The format is derived, not guessed.** Every field below is read off
|
|
11
|
+
* `litellm/proxy/schema.prisma` in BerriAI/litellm, model `LiteLLM_SpendLogs`.
|
|
12
|
+
* A converter written from memory of an API is a converter that silently
|
|
13
|
+
* mis-reads somebody's bill, and this project has one rule above all others
|
|
14
|
+
* about numbers it cannot justify.
|
|
15
|
+
*
|
|
16
|
+
* ## What maps
|
|
17
|
+
*
|
|
18
|
+
* | LiteLLM | Trazum |
|
|
19
|
+
* | --- | --- |
|
|
20
|
+
* | `model` | `model` |
|
|
21
|
+
* | `prompt_tokens` | `usage.input_tokens` |
|
|
22
|
+
* | `completion_tokens` | `usage.output_tokens` |
|
|
23
|
+
* | `startTime` | `ts` |
|
|
24
|
+
* | `session_id` | `session` |
|
|
25
|
+
* | `request_tags[0]`, else `metadata.tags[0]`, else `model_group` | `label` |
|
|
26
|
+
*
|
|
27
|
+
* ## What deliberately does not cross
|
|
28
|
+
*
|
|
29
|
+
* The row carries `messages` and `response` — the prompt itself and the
|
|
30
|
+
* completion — plus `api_key` (hashed, still credential-shaped),
|
|
31
|
+
* `requester_ip_address`, `user` and `end_user`. **None of it is read.** The
|
|
32
|
+
* converter names the fields it takes and takes nothing else, and a fixture
|
|
33
|
+
* plants a marker in each of them and greps the whole output.
|
|
34
|
+
*
|
|
35
|
+
* ## What it refuses to invent
|
|
36
|
+
*
|
|
37
|
+
* `cache_hit` is a flag and `cache_key` an identifier; neither is a token
|
|
38
|
+
* count. A converted record therefore carries no cache split at all, and the
|
|
39
|
+
* caching questions come back `cannot-tell` rather than answered from a
|
|
40
|
+
* guess — the same refusal as inventing a price. `cacheFlagged` counts the
|
|
41
|
+
* rows that said "hit" so the operator can see the gap is real rather than
|
|
42
|
+
* empty.
|
|
43
|
+
*
|
|
44
|
+
* `spend` is LiteLLM's own priced figure and is **never** merged into
|
|
45
|
+
* Trazum's catalogue-priced total. It is a second measurement of the same
|
|
46
|
+
* calls, kept apart the way the store's provider-billed standing is kept
|
|
47
|
+
* apart from the log's, and returned on its own so a caller who wants to
|
|
48
|
+
* compare the two can, deliberately.
|
|
49
|
+
*/
|
|
50
|
+
const asObject = (value) => typeof value === 'object' && value !== null && !Array.isArray(value)
|
|
51
|
+
? value
|
|
52
|
+
: null;
|
|
53
|
+
const tryParse = (text) => {
|
|
54
|
+
try {
|
|
55
|
+
return JSON.parse(text);
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
const asCount = (value) => {
|
|
62
|
+
const n = typeof value === 'string' ? Number(value) : value;
|
|
63
|
+
return typeof n === 'number' && Number.isFinite(n) && n >= 0 ? n : undefined;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* The first tag LiteLLM carries for a row, from the two places it puts them.
|
|
67
|
+
*
|
|
68
|
+
* `request_tags` is the documented column and `metadata.tags` is where the
|
|
69
|
+
* proxy writes them when the caller passes them in the request body. First
|
|
70
|
+
* only: a workload has one name in a bill, and joining several tags into one
|
|
71
|
+
* label would invent a workload that does not exist.
|
|
72
|
+
*/
|
|
73
|
+
function labelOf(row) {
|
|
74
|
+
const fromColumn = Array.isArray(row.request_tags) ? row.request_tags : null;
|
|
75
|
+
if (fromColumn !== null && typeof fromColumn[0] === 'string' && fromColumn[0] !== '') {
|
|
76
|
+
return fromColumn[0];
|
|
77
|
+
}
|
|
78
|
+
const metadata = asObject(row.metadata);
|
|
79
|
+
const fromMetadata = metadata !== null && Array.isArray(metadata.tags) ? metadata.tags : null;
|
|
80
|
+
if (fromMetadata !== null && typeof fromMetadata[0] === 'string' && fromMetadata[0] !== '') {
|
|
81
|
+
return fromMetadata[0];
|
|
82
|
+
}
|
|
83
|
+
// The public model name a proxy route is known by. A weaker label than a
|
|
84
|
+
// tag — it groups by route rather than by workload — and better than none.
|
|
85
|
+
if (typeof row.model_group === 'string' && row.model_group !== '')
|
|
86
|
+
return row.model_group;
|
|
87
|
+
return undefined;
|
|
88
|
+
}
|
|
89
|
+
/** `startTime` as an ISO instant, or undefined when it is not a time. */
|
|
90
|
+
function timeOf(row) {
|
|
91
|
+
const raw = row.startTime ?? row.start_time;
|
|
92
|
+
if (typeof raw !== 'string' && typeof raw !== 'number')
|
|
93
|
+
return undefined;
|
|
94
|
+
const ms = typeof raw === 'number' ? raw : Date.parse(raw);
|
|
95
|
+
if (!Number.isFinite(ms))
|
|
96
|
+
return undefined;
|
|
97
|
+
return new Date(ms).toISOString();
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Convert a LiteLLM spend-log export.
|
|
101
|
+
*
|
|
102
|
+
* Accepts a JSON array of rows, a single row, `{ data: [...] }` as the proxy's
|
|
103
|
+
* own endpoints return it, or newline-delimited rows — so a `psql --json`
|
|
104
|
+
* dump, an API response and a streamed capture all work. Pure over its input.
|
|
105
|
+
*/
|
|
106
|
+
export function litellmRecords(text) {
|
|
107
|
+
const out = {
|
|
108
|
+
records: [],
|
|
109
|
+
rows: 0,
|
|
110
|
+
unnamedModel: 0,
|
|
111
|
+
noTokens: 0,
|
|
112
|
+
cacheFlagged: 0,
|
|
113
|
+
reportedSpendUsd: null,
|
|
114
|
+
unparseable: 0,
|
|
115
|
+
};
|
|
116
|
+
const rows = [];
|
|
117
|
+
const whole = tryParse(text);
|
|
118
|
+
if (whole !== undefined) {
|
|
119
|
+
if (Array.isArray(whole))
|
|
120
|
+
rows.push(...whole);
|
|
121
|
+
else {
|
|
122
|
+
const doc = asObject(whole);
|
|
123
|
+
// `{ data: [...] }` is what the proxy's spend endpoints return.
|
|
124
|
+
if (doc !== null && Array.isArray(doc.data))
|
|
125
|
+
rows.push(...doc.data);
|
|
126
|
+
else if (doc !== null)
|
|
127
|
+
rows.push(doc);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
for (const line of text.split('\n')) {
|
|
132
|
+
if (line.trim() === '')
|
|
133
|
+
continue;
|
|
134
|
+
const parsed = tryParse(line);
|
|
135
|
+
if (parsed === undefined)
|
|
136
|
+
out.unparseable += 1;
|
|
137
|
+
else if (Array.isArray(parsed))
|
|
138
|
+
rows.push(...parsed);
|
|
139
|
+
else
|
|
140
|
+
rows.push(parsed);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
let spend = 0;
|
|
144
|
+
let sawSpend = false;
|
|
145
|
+
for (const raw of rows) {
|
|
146
|
+
const row = asObject(raw);
|
|
147
|
+
if (row === null)
|
|
148
|
+
continue;
|
|
149
|
+
// A spend log row is one that carries at least one of the two token
|
|
150
|
+
// columns. Anything else in the same file is not a call and is skipped
|
|
151
|
+
// rather than converted into a record of zero.
|
|
152
|
+
const input = asCount(row.prompt_tokens);
|
|
153
|
+
const output = asCount(row.completion_tokens);
|
|
154
|
+
if (input === undefined && output === undefined)
|
|
155
|
+
continue;
|
|
156
|
+
out.rows += 1;
|
|
157
|
+
if (input === 0 && output === 0)
|
|
158
|
+
out.noTokens += 1;
|
|
159
|
+
if (row.cache_hit === true || row.cache_hit === 'true' || row.cache_hit === 'True') {
|
|
160
|
+
out.cacheFlagged += 1;
|
|
161
|
+
}
|
|
162
|
+
const reported = asCount(row.spend);
|
|
163
|
+
if (reported !== undefined) {
|
|
164
|
+
spend += reported;
|
|
165
|
+
sawSpend = true;
|
|
166
|
+
}
|
|
167
|
+
const model = typeof row.model === 'string' ? row.model.trim() : '';
|
|
168
|
+
if (model === '') {
|
|
169
|
+
// Counted, never guessed at. `model_group` is a route name, not a model,
|
|
170
|
+
// and pricing a call by the route it took would be a figure attributed
|
|
171
|
+
// to something it does not describe.
|
|
172
|
+
out.unnamedModel += 1;
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
const ts = timeOf(row);
|
|
176
|
+
const label = labelOf(row);
|
|
177
|
+
const session = typeof row.session_id === 'string' && row.session_id !== ''
|
|
178
|
+
? row.session_id
|
|
179
|
+
: undefined;
|
|
180
|
+
out.records.push({
|
|
181
|
+
model,
|
|
182
|
+
...(ts !== undefined ? { ts } : {}),
|
|
183
|
+
...(label !== undefined ? { label } : {}),
|
|
184
|
+
...(session !== undefined ? { session } : {}),
|
|
185
|
+
usage: { input_tokens: input ?? 0, output_tokens: output ?? 0 },
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
out.reportedSpendUsd = sawSpend ? spend : null;
|
|
189
|
+
return out;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Whether a file looks like a LiteLLM spend log, by shape.
|
|
193
|
+
*
|
|
194
|
+
* Deliberately narrow: `request_id` beside one of the two token columns, and
|
|
195
|
+
* a field no other export in this project carries. A looser test would claim
|
|
196
|
+
* an OpenAI usage response, whose rows also have `prompt_tokens`, and refuse
|
|
197
|
+
* it in this file's words instead of letting the code that can read it try.
|
|
198
|
+
*/
|
|
199
|
+
export function looksLikeLiteLlm(text, prefixBytes = 8192) {
|
|
200
|
+
const head = text.slice(0, prefixBytes);
|
|
201
|
+
if (!head.includes('prompt_tokens') && !head.includes('completion_tokens'))
|
|
202
|
+
return false;
|
|
203
|
+
return (head.includes('"request_id"') ||
|
|
204
|
+
head.includes('"custom_llm_provider"') ||
|
|
205
|
+
head.includes('"model_group"'));
|
|
206
|
+
}
|
|
207
|
+
//# sourceMappingURL=litellm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"litellm.js","sourceRoot":"","sources":["../src/litellm.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AAmCH,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAkC,EAAE,CAClE,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;IAClE,CAAC,CAAE,KAAiC;IACpC,CAAC,CAAC,IAAI,CAAC;AAEX,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAW,EAAE;IACzC,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,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AC,CAAC,CAAC,EAAE,CAAC;YACzC,GAAG,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC7C,KAAK,EAAE,EAAE,YAAY,EAAE,KAAK,IAAI,CAAC,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC,EAAE;SAChE,CAAC,CAAC;IACL,CAAC;IAED,GAAG,CAAC,gBAAgB,GAAG,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;IAC/C,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY,EAAE,WAAW,GAAG,IAAI;IAC/D,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC;IACxC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,mBAAmB,CAAC;QAAE,OAAO,KAAK,CAAC;IACzF,OAAO,CACL,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC;QAC7B,IAAI,CAAC,QAAQ,CAAC,uBAAuB,CAAC;QACtC,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,CAC/B,CAAC;AACJ,CAAC"}
|
|
@@ -68,6 +68,10 @@ export interface MeasuredUsage {
|
|
|
68
68
|
* call is the same size. It is handed over as the better of two
|
|
69
69
|
* approximations — a measured token share beats a typed call share — and
|
|
70
70
|
* named honestly here so no rendering can call it something it is not.
|
|
71
|
+
*
|
|
72
|
+
* The denominator is every input token, **writes included**. Leaving writes
|
|
73
|
+
* out made a constantly-rewritten cache report a high hit rate, which is the
|
|
74
|
+
* one workload that most needs to be told otherwise.
|
|
71
75
|
*/
|
|
72
76
|
cacheReadShare: number;
|
|
73
77
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"measured-profile.d.ts","sourceRoot":"","sources":["../src/measured-profile.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,cAAc,IAAI,CAAC;AAEhC,iFAAiF;AACjF,eAAO,MAAM,aAAa,KAAK,CAAC;AAEhC,MAAM,WAAW,aAAa;IAC5B,6EAA6E;IAC7E,OAAO,EAAE,YAAY,CAAC;IACtB,oEAAoE;IACpE,KAAK,EAAE,MAAM,CAAC;IACd,2EAA2E;IAC3E,QAAQ,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB;;;;;OAKG;IACH,MAAM,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IACpD
|
|
1
|
+
{"version":3,"file":"measured-profile.d.ts","sourceRoot":"","sources":["../src/measured-profile.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,cAAc,IAAI,CAAC;AAEhC,iFAAiF;AACjF,eAAO,MAAM,aAAa,KAAK,CAAC;AAEhC,MAAM,WAAW,aAAa;IAC5B,6EAA6E;IAC7E,OAAO,EAAE,YAAY,CAAC;IACtB,oEAAoE;IACpE,KAAK,EAAE,MAAM,CAAC;IACd,2EAA2E;IAC3E,QAAQ,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB;;;;;OAKG;IACH,MAAM,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IACpD;;;;;;;;;;;;;OAaG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;;;OAIG;IACH,MAAM,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,kBAAkB,EAAE,MAAM,CAAA;KAAE,CAAC;IACtE,iEAAiE;IACjE,gBAAgB,EAAE,OAAO,CAAC;CAC3B;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,kBAAkB,EAC1B,KAAK,EAAE,MAAM,EACb,OAAO,GAAE;IAAE,aAAa,CAAC,EAAE,OAAO,CAAA;CAAO,GACxC,aAAa,GAAG,IAAI,CA2EtB;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,aAAa;IAC5B,yDAAyD;IACzD,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAClE,yEAAyE;IACzE,oBAAoB,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC9D,2EAA2E;IAC3E,oBAAoB,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAC7D;AAED,wBAAgB,aAAa,CAC3B,MAAM,EAAE,kBAAkB,EAC1B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC7B,aAAa,CAsBf"}
|
package/dist/measured-profile.js
CHANGED
|
@@ -55,6 +55,7 @@ export function measuredUsage(report, label, options = {}) {
|
|
|
55
55
|
const outputTokens = slices.reduce((sum, row) => sum + row.breakdown.outputTokens, 0);
|
|
56
56
|
const inputTokens = slices.reduce((sum, row) => sum + row.breakdown.inputTokens, 0);
|
|
57
57
|
const cacheReadTokens = slices.reduce((sum, row) => sum + row.breakdown.cacheReadTokens, 0);
|
|
58
|
+
const cacheWriteTokens = slices.reduce((sum, row) => sum + row.breakdown.cacheWriteTokens, 0);
|
|
58
59
|
// The model carrying the most spend. Ties break on the larger call count, so
|
|
59
60
|
// the answer is stable rather than dependent on map ordering.
|
|
60
61
|
const ranked = [...slices].sort((a, b) => b.breakdown.totalUsd - a.breakdown.totalUsd || b.breakdown.calls - a.breakdown.calls);
|
|
@@ -69,7 +70,27 @@ export function measuredUsage(report, label, options = {}) {
|
|
|
69
70
|
const scaled = spanDays !== null && spanDays >= MIN_SCALE_DAYS
|
|
70
71
|
? { fromDays: spanDays, factor: SCALE_TO_DAYS / spanDays }
|
|
71
72
|
: null;
|
|
72
|
-
|
|
73
|
+
/**
|
|
74
|
+
* Every input token in the denominator, writes included.
|
|
75
|
+
*
|
|
76
|
+
* This was `reads / (input + reads)`, which leaves cache *writes* out of the
|
|
77
|
+
* total it is a share of. A workload that rewrites its prefix on every call
|
|
78
|
+
* and reads it back rarely then reports a **high** hit rate: with 100 read
|
|
79
|
+
* tokens, no plain input and 10,000 written, the old expression answers 100%
|
|
80
|
+
* where the truth is 1%.
|
|
81
|
+
*
|
|
82
|
+
* That is the worst direction for this number to be wrong in. It is handed
|
|
83
|
+
* to `optimize` as `cacheHitRate`, which decides whether caching is paying
|
|
84
|
+
* off — so the shape that is burning money on writes was the shape most
|
|
85
|
+
* likely to be told its cache was working perfectly.
|
|
86
|
+
*
|
|
87
|
+
* Writes are input tokens: they are billed at the input rate times the write
|
|
88
|
+
* multiplier, they arrive in the same `usage` block, and any accounting of
|
|
89
|
+
* "what share of the input came from cache" that omits them is answering a
|
|
90
|
+
* narrower question than the one it is named for.
|
|
91
|
+
*/
|
|
92
|
+
const allInputTokens = inputTokens + cacheReadTokens + cacheWriteTokens;
|
|
93
|
+
const readShare = allInputTokens > 0 ? cacheReadTokens / allInputTokens : 0;
|
|
73
94
|
return {
|
|
74
95
|
profile: {
|
|
75
96
|
model: chosen.model,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"measured-profile.js","sourceRoot":"","sources":["../src/measured-profile.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAIxC;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC;AAEhC,iFAAiF;AACjF,MAAM,CAAC,MAAM,aAAa,GAAG,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"measured-profile.js","sourceRoot":"","sources":["../src/measured-profile.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAIxC;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC;AAEhC,iFAAiF;AACjF,MAAM,CAAC,MAAM,aAAa,GAAG,EAAE,CAAC;AA8ChC;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAC3B,MAA0B,EAC1B,KAAa,EACb,OAAO,GAAgC,EAAE;IAEzC,MAAM,MAAM,GAAG,MAAM,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,KAAK,KAAK,CAAC,CAAC;IAC3E,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAErC,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,GAAG,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IACxE,IAAI,KAAK,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAE7B,MAAM,QAAQ,GAA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M,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC;IAC/C,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;IAEpE,OAAO,EAAE,MAAM,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,CAAC;AAChE,CAAC"}
|
package/dist/schemas.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AA6CjD;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AA6CjD;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAwI1E,CAAC;AAEF,6EAA6E;AAC7E,wBAAgB,cAAc,CAAC,IAAI,EAAE,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAE1E"}
|
package/dist/schemas.js
CHANGED
|
@@ -145,6 +145,42 @@ export const CONTRACT_SCHEMAS = {
|
|
|
145
145
|
cannotSay: array,
|
|
146
146
|
unpricedRecords: number,
|
|
147
147
|
}),
|
|
148
|
+
'routing-measurement': doc('routing-measurement', {
|
|
149
|
+
slice: object,
|
|
150
|
+
evaluation: object,
|
|
151
|
+
}),
|
|
152
|
+
'example-pruning': doc('example-pruning', {
|
|
153
|
+
provider: string,
|
|
154
|
+
model: string,
|
|
155
|
+
selfAgreement: number,
|
|
156
|
+
recoverableTokens: number,
|
|
157
|
+
callsMade: number,
|
|
158
|
+
contributions: array,
|
|
159
|
+
}),
|
|
160
|
+
'store-inventory': doc('store-inventory', {
|
|
161
|
+
providers: array,
|
|
162
|
+
totalRecords: number,
|
|
163
|
+
span: objectOrNull,
|
|
164
|
+
possiblyDouble: number,
|
|
165
|
+
unknownVersion: number,
|
|
166
|
+
totalUsd: number,
|
|
167
|
+
unreadable: array,
|
|
168
|
+
}),
|
|
169
|
+
conformance: doc('conformance', {
|
|
170
|
+
contract: stringOrNull,
|
|
171
|
+
because: stringOrNull,
|
|
172
|
+
problems: array,
|
|
173
|
+
unavailable: array,
|
|
174
|
+
records: { type: ['number', 'null'] },
|
|
175
|
+
conforms: boolean,
|
|
176
|
+
}),
|
|
177
|
+
'watch-cycle': doc('watch-cycle', {
|
|
178
|
+
firedAtMs: number,
|
|
179
|
+
crossings: array,
|
|
180
|
+
suppressed: array,
|
|
181
|
+
abstentions: array,
|
|
182
|
+
gap: objectOrNull,
|
|
183
|
+
}),
|
|
148
184
|
};
|
|
149
185
|
/** The schema for one named contract — the object `trazum schema` prints. */
|
|
150
186
|
export function contractSchema(name) {
|
package/dist/schemas.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;GAgBG;AAEH,MAAM,KAAK,GAAG,8CAA8C,CAAC;AAE7D,4DAA4D;AAC5D,SAAS,GAAG,CAAC,IAAkB,EAAE,UAAmC;IAClE,OAAO;QACL,OAAO,EAAE,KAAK;QACd,GAAG,EAAE,8CAA8C,IAAI,UAAU;QACjE,KAAK,EAAE,UAAU,IAAI,4BAA4B;QACjD,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,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Y;QAClB,cAAc,EAAE,MAAM;QACtB,cAAc,EAAE,MAAM;QACtB,QAAQ,EAAE,MAAM;QAChB,UAAU,EAAE,KAAK;KAClB,CAAC;IACF,WAAW,EAAE,GAAG,CAAC,aAAa,EAAE;QAC9B,QAAQ,EAAE,YAAY;QACtB,OAAO,EAAE,YAAY;QACrB,QAAQ,EAAE,KAAK;QACf,WAAW,EAAE,KAAK;QAClB,OAAO,EAAE,EAAE,IAAI,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,EAAE;QACrC,QAAQ,EAAE,OAAO;KAClB,CAAC;IACF,aAAa,EAAE,GAAG,CAAC,aAAa,EAAE;QAChC,SAAS,EAAE,MAAM;QACjB,SAAS,EAAE,KAAK;QAChB,UAAU,EAAE,KAAK;QACjB,WAAW,EAAE,KAAK;QAClB,GAAG,EAAE,YAAY;KAClB,CAAC;CACH,CAAC;AAEF,6EAA6E;AAC7E,MAAM,UAAU,cAAc,CAAC,IAAkB;IAC/C,OAAO,gBAAgB,CAAC,IAAI,CAAC,CAAC;AAChC,CAAC"}
|
package/dist/tokenizer.d.ts
CHANGED
|
@@ -2,71 +2,67 @@
|
|
|
2
2
|
* Dependency-free token estimator.
|
|
3
3
|
*
|
|
4
4
|
* This is NOT a real tokenizer: it is a heuristic calibrated per character
|
|
5
|
-
* class
|
|
6
|
-
*
|
|
7
|
-
* two versions of the same prompt — but do NOT bill anyone from it.
|
|
5
|
+
* class, built for comparing two versions of the same prompt — but do NOT bill
|
|
6
|
+
* anyone from it.
|
|
8
7
|
*
|
|
9
|
-
* **
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
8
|
+
* **Its accuracy is not one number, and the years it was written as one were
|
|
9
|
+
* the mistake.** The branches below treat CJK, digits and punctuation quite
|
|
10
|
+
* differently from words, and there was never a reason those should land on the
|
|
11
|
+
* same accuracy. Measured over 47 samples against the official counting
|
|
12
|
+
* endpoint they do not: the worst error is 3.2% on CJK, 5.6% on Latin prose,
|
|
13
|
+
* 25.1% on code and quoting, and 32.5% on a digit-dominant table. `band.ts`
|
|
14
|
+
* holds the bands those measurements earn and `bandFor(text)` is what a caller
|
|
15
|
+
* should print; the constant below is only the widest of them, for callers that
|
|
16
|
+
* have no text in hand.
|
|
16
17
|
*
|
|
17
|
-
* `test/token-band.test.js`
|
|
18
|
-
*
|
|
18
|
+
* `test/token-band.test.js` holds every sample against the band `bandFor` gives
|
|
19
|
+
* it, and a sample edited since it was measured fails rather than passing
|
|
20
|
+
* quietly.
|
|
19
21
|
*
|
|
20
22
|
* For exact numbers use `countTokensAnthropic` (the official token-counting
|
|
21
23
|
* endpoint, which is free) or pass your own `TokenCounter`.
|
|
22
24
|
*/
|
|
23
25
|
/**
|
|
24
|
-
* The
|
|
26
|
+
* The widest band this estimator is published under, as a percentage.
|
|
25
27
|
*
|
|
26
|
-
* **
|
|
27
|
-
* releases as a design target nobody had checked; the first
|
|
28
|
-
* of eight samples outside it and it went to `25`; fixing
|
|
29
|
-
* calibrating per language brought it back to `15
|
|
30
|
-
*
|
|
28
|
+
* **A history worth keeping, because each value was believed at the time.** It
|
|
29
|
+
* was `15` for eight releases as a design target nobody had checked; the first
|
|
30
|
+
* measurement found two of eight samples outside it and it went to `25`; fixing
|
|
31
|
+
* the digit divisor and calibrating per language brought it back to `15`, and
|
|
32
|
+
* splitting kana from han — Japanese had been +11.2% and Chinese −3.2% under one
|
|
33
|
+
* rule — brought it to `10`. Four values, each an improvement, and all four
|
|
34
|
+
* wrong in the same way.
|
|
31
35
|
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
+
* **The corpus they were measured on was the corpus they were fitted to.**
|
|
37
|
+
* Twenty-one samples held thirteen files of Latin prose and exactly one each of
|
|
38
|
+
* code, numeric and punctuation, and those single files were where the constants
|
|
39
|
+
* came from. The worst error it could show was 6.4%, and 10 looked like a
|
|
40
|
+
* comfortable margin over it. Neither figure was about the estimator.
|
|
36
41
|
*
|
|
37
|
-
* **
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
* safe direction for a tool that reports money.
|
|
42
|
+
* **It is no longer one number, and this one is the widest.** A corpus of
|
|
43
|
+
* thirteen prose files and one each of code, numeric and punctuation put the
|
|
44
|
+
* band at 10, and those single files were the set the constants had been fitted
|
|
45
|
+
* to. Measured on forty-seven, the same estimator is 6% out on prose and 33%
|
|
46
|
+
* out on a CSV ledger. `bandFor` in `band.ts` is what a caller that has the
|
|
47
|
+
* text should use.
|
|
44
48
|
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
* **Which samples the band rests on matters more than the number.** Eight of the
|
|
52
|
-
* twenty-one had a constant fitted to them — seven Latin divisors and the digit
|
|
53
|
-
* divisor — so their residuals are optimistic by construction. The two worst
|
|
54
|
-
* errors in the corpus, `code-heavy` at 6.4% and `punctuation-heavy` at 5.7%, are
|
|
55
|
-
* fitted to nothing at all, and they are what sets this figure.
|
|
56
|
-
*
|
|
57
|
-
* Exported so every report, README and tool description reads the same number. It
|
|
58
|
-
* was a literal in twenty-four files before this, with the only machine-readable
|
|
59
|
-
* copy in a test, and `token-band.test.js` now fails any file that states a
|
|
60
|
-
* different one.
|
|
49
|
+
* This stays for the callers that do not have it — a figure covering the whole
|
|
50
|
+
* catalogue of text, which can only be the worst of them. Widening it from 10
|
|
51
|
+
* to 33 makes every claim that reads it true where it had been false, at the
|
|
52
|
+
* cost of understating the estimator on prose. That trade is deliberate: a
|
|
53
|
+
* caller with no text cannot know which it is holding, and there is only one
|
|
54
|
+
* safe direction to guess in.
|
|
61
55
|
*/
|
|
62
|
-
export declare const ESTIMATE_ERROR_BAND_PCT =
|
|
56
|
+
export declare const ESTIMATE_ERROR_BAND_PCT = 33;
|
|
63
57
|
/**
|
|
64
58
|
* Whose tokenizer that band was measured against.
|
|
65
59
|
*
|
|
66
60
|
* The number above is not a property of the estimator; it is a property of the
|
|
67
|
-
* estimator **against Claude**.
|
|
68
|
-
* family. Trazum prices seven, and
|
|
69
|
-
*
|
|
61
|
+
* estimator **against Claude**. Forty-seven samples, one counting endpoint, one
|
|
62
|
+
* family. Trazum prices seven, and the two that have since been run are far
|
|
63
|
+
* outside anything published here: DeepSeek 94.5% at worst, Mistral 103.1%. On
|
|
64
|
+
* a GPT or a Gemini prompt nobody has measured it at all, and
|
|
65
|
+
* `measuredForeignError` answers null rather than the nearest number.
|
|
70
66
|
*
|
|
71
67
|
* Exported as a name rather than left implicit in a comment because the band
|
|
72
68
|
* had already leaked out of its domain in three places: an advisory that told a
|
package/dist/tokenizer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokenizer.d.ts","sourceRoot":"","sources":["../src/tokenizer.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"tokenizer.d.ts","sourceRoot":"","sources":["../src/tokenizer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAKH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAE1C;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,wBAAwB,cAAc,CAAC;AAEpD;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,OAAO,CAExE;AA+HD;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAiJnD;AAED,sDAAsD;AACtD,MAAM,MAAM,iBAAiB,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;AAElE,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,+DAA+D;IAC/D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;IACzB,gFAAgF;IAChF,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,uBAAuB,GAAG,iBAAiB,CA6BxF"}
|