pareta 0.1.0 → 0.2.1
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 +63 -63
- package/dist/index.cjs +60 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +98 -1
- package/dist/index.d.ts +98 -1
- package/dist/index.mjs +60 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
# pareta
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/pareta)
|
|
4
|
-
[](https://github.com/Pareta-AI/pareta-js/blob/main/LICENSE)
|
|
4
|
+
[](https://github.com/Pareta-AI/pareta-js/blob/main/LICENSE)
|
|
6
5
|
|
|
7
|
-
TypeScript/JavaScript client for [Pareta](https://pareta.ai) —
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
TypeScript/JavaScript client for [Pareta](https://pareta.ai). One model id —
|
|
7
|
+
`"auto"` — and Pareta plans each request, routes it to benchmark-proven open
|
|
8
|
+
specialists, verifies the result, and falls back to a frontier model when
|
|
9
|
+
that's the right call. One request, one bill; you never pay for Pareta's
|
|
10
|
+
orchestration or cold starts.
|
|
11
11
|
|
|
12
12
|
```bash
|
|
13
13
|
npm install pareta # or: pnpm add pareta / yarn add pareta / bun add pareta
|
|
@@ -16,93 +16,93 @@ npm install pareta # or: pnpm add pareta / yarn add pareta / bun add pare
|
|
|
16
16
|
```ts
|
|
17
17
|
import { Pareta } from "pareta";
|
|
18
18
|
|
|
19
|
-
const pa = Pareta.fromEnv();
|
|
19
|
+
const pa = Pareta.fromEnv(); // reads PARETA_API_KEY
|
|
20
|
+
// or: new Pareta({ apiKey: "pareta_sk_…", baseURL: "https://api.pareta.ai" })
|
|
20
21
|
|
|
21
22
|
const res = await pa.chat.completions.create({
|
|
22
|
-
model: "
|
|
23
|
-
messages: [{ role: "user", content: "Extract the
|
|
23
|
+
model: "auto", // the routing brain — the product
|
|
24
|
+
messages: [{ role: "user", content: "Extract the total from this invoice: …" }],
|
|
24
25
|
});
|
|
25
26
|
console.log(res.choices[0].message.content);
|
|
26
|
-
```
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
// Streaming (progress while Pareta plans + executes, then tokens)
|
|
29
|
+
for await (const chunk of await pa.chat.completions.create({
|
|
30
|
+
model: "auto", messages: [...], stream: true,
|
|
31
|
+
})) {
|
|
32
|
+
process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
|
|
33
|
+
}
|
|
34
|
+
```
|
|
31
35
|
|
|
32
|
-
##
|
|
36
|
+
## Is it actually good? Measure it on YOUR data
|
|
33
37
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
38
|
+
Don't take the routing brain on faith — benchmark it. `pa.evals` runs `"auto"`
|
|
39
|
+
head-to-head against frontier models on your own ground truth and prices every
|
|
40
|
+
contender honestly:
|
|
37
41
|
|
|
38
42
|
```ts
|
|
39
|
-
const
|
|
43
|
+
const set = await pa.evals.sets.create({ task: "invoice-extraction", items: [...] });
|
|
44
|
+
const run = await pa.evals.runs.create({
|
|
45
|
+
evalSet: set.id, models: ["auto"], frontier: ["claude-opus-4-7"], wait: true,
|
|
46
|
+
});
|
|
40
47
|
```
|
|
41
48
|
|
|
42
|
-
|
|
49
|
+
And watch what your live traffic is doing — spend, success rate, and the
|
|
50
|
+
projected savings vs calling a frontier directly:
|
|
43
51
|
|
|
44
52
|
```ts
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const res = await pa.chat.completions.create({
|
|
49
|
-
model: ep.id!,
|
|
53
|
+
await pa.auto.metrics(); // requests, success, spend, savings
|
|
54
|
+
await pa.auto.compareFrontier({ // one prompt, metered, side-by-side
|
|
55
|
+
model: "gpt-5.5",
|
|
50
56
|
messages: [{ role: "user", content: "…" }],
|
|
51
57
|
});
|
|
52
58
|
```
|
|
53
59
|
|
|
54
|
-
|
|
60
|
+
## Inference is OpenAI-compatible
|
|
61
|
+
|
|
62
|
+
You don't even need this SDK to call Pareta — point the `openai` package at
|
|
63
|
+
`baseURL` + your key and set `model: "auto"`:
|
|
55
64
|
|
|
56
65
|
```ts
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
66
|
+
import OpenAI from "openai";
|
|
67
|
+
const client = new OpenAI({ apiKey: "pareta_sk_…", baseURL: "https://api.pareta.ai/v1" });
|
|
68
|
+
const res = await client.chat.completions.create({ model: "auto", messages: [...] });
|
|
60
69
|
```
|
|
61
70
|
|
|
62
|
-
|
|
71
|
+
This SDK's unique value is everything AROUND that call — evals on your data,
|
|
72
|
+
auto metrics, the benchmark catalog, and the dedicated-endpoint control plane.
|
|
63
73
|
|
|
64
|
-
|
|
65
|
-
const lb = await pa.tasks.leaderboard("invoice-extraction");
|
|
66
|
-
console.log(lb.recommended, lb.frontier?.name); // open pick + frontier baseline
|
|
67
|
-
```
|
|
74
|
+
## Dedicated endpoints (when you want to pin one model)
|
|
68
75
|
|
|
69
|
-
|
|
76
|
+
`"auto"` routes per request. When a workload wants one specific open model on
|
|
77
|
+
dedicated capacity, deploy it and call it by endpoint id:
|
|
70
78
|
|
|
71
79
|
```ts
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
items: [{ input: { text: "cancel my plan" }, expected: "cancellation" }],
|
|
75
|
-
models: ["qwen-1"],
|
|
76
|
-
frontier: "benchmarked", // also race the benchmarked frontier models
|
|
77
|
-
wait: true,
|
|
78
|
-
});
|
|
79
|
-
console.log(run.cost, run.results.map((r) => [r.modelId, r.qualityMean]));
|
|
80
|
-
```
|
|
80
|
+
const ep = await pa.endpoints.deploy({ task: "invoice-extraction", model: "recommended", wait: true });
|
|
81
|
+
const res = await pa.chat.completions.create({ model: ep.id, messages: [...] });
|
|
81
82
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
## Errors
|
|
83
|
+
for (const m of await pa.models.list()) console.log(m.id);
|
|
84
|
+
```
|
|
86
85
|
|
|
87
|
-
|
|
86
|
+
Discovery (`pa.tasks.match`, `pa.tasks.leaderboard`) tells you which open
|
|
87
|
+
models are benchmark-proven for your task and what the frontier baseline costs.
|
|
88
88
|
|
|
89
|
-
|
|
90
|
-
import { InsufficientCreditsError, EndpointNotReadyError } from "pareta";
|
|
89
|
+
## Auth
|
|
91
90
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
if (e instanceof InsufficientCreditsError) { /* top up in the dashboard */ }
|
|
96
|
-
if (e instanceof EndpointNotReadyError) { /* endpoint is cold/stopped */ }
|
|
97
|
-
}
|
|
98
|
-
```
|
|
91
|
+
Mint a `pareta_sk_` key in the dashboard (key management is browser-only) and
|
|
92
|
+
pass it as `apiKey` or via `PARETA_API_KEY`. The SDK only ever *consumes* a
|
|
93
|
+
key; it never creates, lists, or revokes them.
|
|
99
94
|
|
|
100
|
-
##
|
|
95
|
+
## Errors
|
|
101
96
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
97
|
+
All errors subclass `ParetaError` — `AuthenticationError` (401),
|
|
98
|
+
`InsufficientCreditsError` (402), `NotFoundError` (404),
|
|
99
|
+
`EndpointNotReadyError` (503), `RateLimitError` (429, auto-retried),
|
|
100
|
+
`BadRequestError` (400/422), and `APIConnectionError` / `APITimeoutError`
|
|
101
|
+
(transport, auto-retried). Idempotent GETs and 429/5xx/timeouts are retried
|
|
102
|
+
with exponential backoff (`maxRetries`, default 2).
|
|
105
103
|
|
|
106
|
-
##
|
|
104
|
+
## Python
|
|
107
105
|
|
|
108
|
-
|
|
106
|
+
The same surface ships as a Python package: [`pip install pareta`](https://pypi.org/project/pareta/),
|
|
107
|
+
plus a CLI (`pareta[cli]`) and an MCP server (`pareta[mcp]`). Docs for both:
|
|
108
|
+
[docs.pareta.ai](https://docs.pareta.ai).
|
package/dist/index.cjs
CHANGED
|
@@ -303,6 +303,20 @@ var Endpoint = class extends BaseModel {
|
|
|
303
303
|
get isLive() {
|
|
304
304
|
return this.raw.status === "live";
|
|
305
305
|
}
|
|
306
|
+
/** Structured-extraction endpoints (contract / SEC / ICD …): the system prompt
|
|
307
|
+
* the benchmark used. The proxy applies it automatically when you send no
|
|
308
|
+
* `system` message (so quality matches the leaderboard by default); returned
|
|
309
|
+
* here so you can read it, or override it with your own `system` message.
|
|
310
|
+
* `null` when the task has no injectable prompt (see `promptScaffold`). */
|
|
311
|
+
get recommendedSystemPrompt() {
|
|
312
|
+
return this.raw.recommendedSystemPrompt ?? null;
|
|
313
|
+
}
|
|
314
|
+
/** Fixed-label classification endpoints: a copy-and-customize `system` prompt
|
|
315
|
+
* template. NEVER auto-applied — the categories are yours, not the benchmark's
|
|
316
|
+
* — so fill them in and send it as your `system` message. `null` otherwise. */
|
|
317
|
+
get promptScaffold() {
|
|
318
|
+
return this.raw.promptScaffold ?? null;
|
|
319
|
+
}
|
|
306
320
|
};
|
|
307
321
|
function endpointList(raw) {
|
|
308
322
|
return (raw ?? []).map((e) => new Endpoint(e));
|
|
@@ -375,6 +389,20 @@ function evalSetFromCreate(raw) {
|
|
|
375
389
|
function evalSetList(raw) {
|
|
376
390
|
return (raw?.eval_sets ?? []).map((e) => new EvalSet(e));
|
|
377
391
|
}
|
|
392
|
+
var EvalItemResult = class extends BaseModel {
|
|
393
|
+
get idx() {
|
|
394
|
+
return this.raw.idx ?? null;
|
|
395
|
+
}
|
|
396
|
+
get score() {
|
|
397
|
+
return this.raw.score ?? null;
|
|
398
|
+
}
|
|
399
|
+
get prediction() {
|
|
400
|
+
return this.raw.prediction ?? null;
|
|
401
|
+
}
|
|
402
|
+
get error() {
|
|
403
|
+
return this.raw.error ?? null;
|
|
404
|
+
}
|
|
405
|
+
};
|
|
378
406
|
var EvalResult = class extends BaseModel {
|
|
379
407
|
get modelId() {
|
|
380
408
|
return this.raw.model_id ?? null;
|
|
@@ -401,6 +429,10 @@ var EvalResult = class extends BaseModel {
|
|
|
401
429
|
get errorCount() {
|
|
402
430
|
return this.raw.error_count ?? null;
|
|
403
431
|
}
|
|
432
|
+
/** Per-item rows (idx/score/prediction/error); empty when not persisted. */
|
|
433
|
+
get perItem() {
|
|
434
|
+
return (this.raw.per_item ?? []).map((it) => new EvalItemResult(it));
|
|
435
|
+
}
|
|
404
436
|
};
|
|
405
437
|
var LeaderboardEntry = class extends BaseModel {
|
|
406
438
|
get name() {
|
|
@@ -865,6 +897,31 @@ var Evals = class {
|
|
|
865
897
|
}
|
|
866
898
|
};
|
|
867
899
|
|
|
900
|
+
// src/resources/auto.ts
|
|
901
|
+
var Auto = class {
|
|
902
|
+
constructor(client) {
|
|
903
|
+
this.client = client;
|
|
904
|
+
}
|
|
905
|
+
client;
|
|
906
|
+
/** Your org's `model: "auto"` traffic, rolled up. Read-only, free. */
|
|
907
|
+
metrics() {
|
|
908
|
+
return this.client.request("GET", "/v1/auto/metrics");
|
|
909
|
+
}
|
|
910
|
+
/**
|
|
911
|
+
* One prompt against a frontier vendor for a side-by-side with
|
|
912
|
+
* `model: "auto"` — METERED at the vendor's actual token cost (a failed
|
|
913
|
+
* vendor call bills $0). Allowed models: gpt-5.5, gemini-3-5-flash,
|
|
914
|
+
* gemini-3-1-pro, claude-sonnet-4-6.
|
|
915
|
+
*/
|
|
916
|
+
compareFrontier(params) {
|
|
917
|
+
return this.client.request(
|
|
918
|
+
"POST",
|
|
919
|
+
"/v1/playground/frontier",
|
|
920
|
+
{ body: params }
|
|
921
|
+
);
|
|
922
|
+
}
|
|
923
|
+
};
|
|
924
|
+
|
|
868
925
|
// src/client.ts
|
|
869
926
|
var DEFAULT_BASE_URL = "https://api.pareta.ai";
|
|
870
927
|
var DEFAULT_TIMEOUT_MS = 6e4;
|
|
@@ -885,6 +942,7 @@ var Pareta = class _Pareta {
|
|
|
885
942
|
endpoints;
|
|
886
943
|
tasks;
|
|
887
944
|
evals;
|
|
945
|
+
auto;
|
|
888
946
|
constructor(options = {}) {
|
|
889
947
|
if (!options.apiKey) {
|
|
890
948
|
throw new ParetaError(
|
|
@@ -905,6 +963,7 @@ var Pareta = class _Pareta {
|
|
|
905
963
|
this.endpoints = new Endpoints(this);
|
|
906
964
|
this.tasks = new Tasks(this);
|
|
907
965
|
this.evals = new Evals(this);
|
|
966
|
+
this.auto = new Auto(this);
|
|
908
967
|
}
|
|
909
968
|
/** Build from PARETA_API_KEY (+ optional PARETA_BASE_URL); explicit opts win. */
|
|
910
969
|
static fromEnv(options = {}) {
|
|
@@ -1092,6 +1151,7 @@ exports.ConflictError = ConflictError;
|
|
|
1092
1151
|
exports.Endpoint = Endpoint;
|
|
1093
1152
|
exports.EndpointMetrics = EndpointMetrics;
|
|
1094
1153
|
exports.EndpointNotReadyError = EndpointNotReadyError;
|
|
1154
|
+
exports.EvalItemResult = EvalItemResult;
|
|
1095
1155
|
exports.EvalResult = EvalResult;
|
|
1096
1156
|
exports.EvalRun = EvalRun;
|
|
1097
1157
|
exports.EvalRuns = EvalRuns;
|