raindrop-ai 0.6.0 → 0.7.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 +17 -8
- package/dist/chunk-4Z7UHC7X.mjs +14850 -0
- package/dist/{chunk-ZVHQBBST.mjs → chunk-OX6X4ZWQ.mjs} +5 -1
- package/dist/{chunk-CFGEE5ID.mjs → chunk-RMP6BZSY.mjs} +59 -16
- package/dist/evals/cli.d.mts +1 -0
- package/dist/evals/cli.d.ts +1 -0
- package/dist/evals/cli.js +21135 -0
- package/dist/evals/cli.mjs +125 -0
- package/dist/{index-APN1jN-i.d.mts → index-n8AIAiRR.d.mts} +18838 -18626
- package/dist/{index-APN1jN-i.d.ts → index-n8AIAiRR.d.ts} +18838 -18626
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +731 -294
- package/dist/index.mjs +57 -14425
- package/dist/{portable-runtime-QZKU2VXS.mjs → portable-runtime-MFVOVFPB.mjs} +7 -2
- package/dist/tracing/index.d.mts +1 -1
- package/dist/tracing/index.d.ts +1 -1
- package/dist/tracing/index.js +5 -1
- package/dist/tracing/index.mjs +1 -1
- package/package.json +5 -1
|
@@ -1238,10 +1238,13 @@ installTracingSuppressionHook();
|
|
|
1238
1238
|
// package.json
|
|
1239
1239
|
var package_default = {
|
|
1240
1240
|
name: "raindrop-ai",
|
|
1241
|
-
version: "0.
|
|
1241
|
+
version: "0.7.0",
|
|
1242
1242
|
main: "dist/index.js",
|
|
1243
1243
|
module: "dist/index.mjs",
|
|
1244
1244
|
types: "dist/index.d.ts",
|
|
1245
|
+
bin: {
|
|
1246
|
+
"raindrop-evals": "dist/evals/cli.js"
|
|
1247
|
+
},
|
|
1245
1248
|
license: "MIT",
|
|
1246
1249
|
homepage: "https://www.raindrop.ai/docs/sdk/typescript/",
|
|
1247
1250
|
bugs: {
|
|
@@ -1338,6 +1341,7 @@ var package_default = {
|
|
|
1338
1341
|
tsup: {
|
|
1339
1342
|
entry: [
|
|
1340
1343
|
"src/index.ts",
|
|
1344
|
+
"src/evals/cli.ts",
|
|
1341
1345
|
"src/tracing/index.ts",
|
|
1342
1346
|
"src/otel/index.ts"
|
|
1343
1347
|
],
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// src/evals/definition.ts
|
|
2
|
+
import { createHash } from "crypto";
|
|
2
3
|
import { z } from "zod";
|
|
3
4
|
var EvalScoreSchema = z.union([
|
|
4
5
|
z.literal(1),
|
|
@@ -8,18 +9,46 @@ var EvalScoreSchema = z.union([
|
|
|
8
9
|
z.literal(5)
|
|
9
10
|
]);
|
|
10
11
|
var EVAL_DATASET = /* @__PURE__ */ Symbol.for("raindrop.evalDataset");
|
|
12
|
+
var DatasetRowInputSchema = z.object({
|
|
13
|
+
id: z.string().trim().min(1),
|
|
14
|
+
name: z.string().optional(),
|
|
15
|
+
input: z.string().nullable(),
|
|
16
|
+
output: z.string().nullable().default(null),
|
|
17
|
+
properties: z.record(z.string()).default({})
|
|
18
|
+
});
|
|
11
19
|
function defineDataset(dataset) {
|
|
20
|
+
var _a, _b;
|
|
12
21
|
const id = dataset.id.trim();
|
|
13
22
|
const name = dataset.name.trim();
|
|
14
|
-
const
|
|
23
|
+
const rows = dataset.rows.map((row) => {
|
|
24
|
+
var _a2;
|
|
25
|
+
const parsed = DatasetRowInputSchema.parse(row);
|
|
26
|
+
return {
|
|
27
|
+
id: parsed.id,
|
|
28
|
+
name: (_a2 = parsed.name) != null ? _a2 : parsed.id,
|
|
29
|
+
input: parsed.input,
|
|
30
|
+
output: parsed.output,
|
|
31
|
+
properties: parsed.properties
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
const version = (_b = (_a = dataset.version) == null ? void 0 : _a.trim()) != null ? _b : createHash("sha256").update(
|
|
35
|
+
JSON.stringify(
|
|
36
|
+
rows.map((row) => ({
|
|
37
|
+
...row,
|
|
38
|
+
properties: Object.fromEntries(
|
|
39
|
+
Object.keys(row.properties).sort().map((key) => [key, row.properties[key]])
|
|
40
|
+
)
|
|
41
|
+
}))
|
|
42
|
+
)
|
|
43
|
+
).digest("hex");
|
|
15
44
|
if (!id) throw new Error("Raindrop eval dataset ids cannot be empty");
|
|
16
45
|
if (!name) throw new Error("Raindrop eval dataset names cannot be empty");
|
|
17
46
|
if (!version) throw new Error("Raindrop eval dataset versions cannot be empty");
|
|
18
|
-
if (dataset.
|
|
19
|
-
throw new Error("Raindrop eval datasets require at least one
|
|
20
|
-
const ids =
|
|
21
|
-
if (ids.some((
|
|
22
|
-
if (new Set(ids).size !== ids.length) throw new Error("Raindrop eval
|
|
47
|
+
if (dataset.rows.length === 0)
|
|
48
|
+
throw new Error("Raindrop eval datasets require at least one row");
|
|
49
|
+
const ids = rows.map((entry) => entry.id);
|
|
50
|
+
if (ids.some((rowId) => !rowId)) throw new Error("Raindrop eval row ids cannot be empty");
|
|
51
|
+
if (new Set(ids).size !== ids.length) throw new Error("Raindrop eval row ids must be unique");
|
|
23
52
|
if (dataset.remote) {
|
|
24
53
|
if (!dataset.remote.reference.trim())
|
|
25
54
|
throw new Error("Raindrop remote dataset reference cannot be empty");
|
|
@@ -32,7 +61,7 @@ function defineDataset(dataset) {
|
|
|
32
61
|
id,
|
|
33
62
|
name,
|
|
34
63
|
version,
|
|
35
|
-
|
|
64
|
+
rows,
|
|
36
65
|
[EVAL_DATASET]: true
|
|
37
66
|
};
|
|
38
67
|
Object.defineProperty(defined, EVAL_DATASET, { enumerable: false });
|
|
@@ -52,7 +81,7 @@ var NumericThresholdSchema = z.union([
|
|
|
52
81
|
{ message: "Lower threshold cannot exceed upper threshold" }
|
|
53
82
|
);
|
|
54
83
|
function defineEvaluatorProgram(program) {
|
|
55
|
-
var _a, _b, _c;
|
|
84
|
+
var _a, _b, _c, _d;
|
|
56
85
|
const slug = program.slug.trim();
|
|
57
86
|
const name = program.name.trim();
|
|
58
87
|
const source = program.source.trim();
|
|
@@ -84,16 +113,18 @@ function defineEvaluatorProgram(program) {
|
|
|
84
113
|
return {
|
|
85
114
|
...program,
|
|
86
115
|
kind: "program",
|
|
116
|
+
scope: z.literal("batch").parse((_c = program.scope) != null ? _c : "batch"),
|
|
87
117
|
slug,
|
|
88
118
|
name,
|
|
89
119
|
source,
|
|
90
120
|
intent,
|
|
91
|
-
description: ((
|
|
121
|
+
description: ((_d = program.description) == null ? void 0 : _d.trim()) || null,
|
|
92
122
|
rules
|
|
93
123
|
};
|
|
94
124
|
}
|
|
95
125
|
function defineLocalEvaluator(evaluator) {
|
|
96
|
-
|
|
126
|
+
var _a;
|
|
127
|
+
return { ...evaluator, scope: z.literal("row").parse((_a = evaluator.scope) != null ? _a : "row") };
|
|
97
128
|
}
|
|
98
129
|
var EVAL_DEFINITION = /* @__PURE__ */ Symbol.for("raindrop.evalDefinition");
|
|
99
130
|
function defineEvalSuite(definition) {
|
|
@@ -103,6 +134,11 @@ function defineEvalSuite(definition) {
|
|
|
103
134
|
if (typeof dataset === "string" && dataset.length === 0) {
|
|
104
135
|
throw new Error("Raindrop eval suite datasets cannot be empty");
|
|
105
136
|
}
|
|
137
|
+
if (definition.datasetVersionId !== void 0) {
|
|
138
|
+
z.string().uuid().parse(definition.datasetVersionId);
|
|
139
|
+
if (typeof dataset !== "string")
|
|
140
|
+
throw new Error("A dataset version pin requires a published dataset slug");
|
|
141
|
+
}
|
|
106
142
|
if (typeof definition.run !== "function") {
|
|
107
143
|
throw new Error("Raindrop eval suite run must be a function");
|
|
108
144
|
}
|
|
@@ -131,6 +167,11 @@ function defineEvalSuite(definition) {
|
|
|
131
167
|
function isEvalSuiteDefinition(value) {
|
|
132
168
|
return typeof value === "object" && value !== null && EVAL_DEFINITION in value && value[EVAL_DEFINITION] === true;
|
|
133
169
|
}
|
|
170
|
+
function isPublishedEvalSuite(definition) {
|
|
171
|
+
return typeof definition.dataset === "string" && definition.datasetVersionId !== void 0 && definition.evaluators.every(
|
|
172
|
+
({ evaluator }) => typeof evaluator !== "string" && (!("kind" in evaluator) || evaluator.kind !== "program" || evaluator.expected !== void 0)
|
|
173
|
+
);
|
|
174
|
+
}
|
|
134
175
|
function evaluatorName(evaluator) {
|
|
135
176
|
return typeof evaluator.evaluator === "string" ? evaluator.evaluator.trim() : evaluator.evaluator.slug.trim();
|
|
136
177
|
}
|
|
@@ -193,8 +234,8 @@ function validateEvaluator(evaluator) {
|
|
|
193
234
|
if (typeof evaluator.evaluator.judge !== "function") {
|
|
194
235
|
throw new Error(`Raindrop local evaluator ${name} judge must be a function`);
|
|
195
236
|
}
|
|
196
|
-
if (evaluator.evaluator.scope !== "
|
|
197
|
-
throw new Error(`Raindrop local evaluator ${name} scope must be
|
|
237
|
+
if (evaluator.evaluator.scope !== "row") {
|
|
238
|
+
throw new Error(`Raindrop local evaluator ${name} scope must be row`);
|
|
198
239
|
}
|
|
199
240
|
const output = EvalOutputSchema.parse(evaluator.evaluator.output);
|
|
200
241
|
validateEvaluatorOutput(evaluator, output);
|
|
@@ -1095,17 +1136,18 @@ async function evaluatePortableEvaluator(evaluator, input) {
|
|
|
1095
1136
|
const artifact = await verifyPortableEvalArtifact(evaluator.artifact, {
|
|
1096
1137
|
expectedSha256: evaluator.expectedSha256
|
|
1097
1138
|
});
|
|
1098
|
-
const { runPortableEvaluator } = await import("./portable-runtime-
|
|
1099
|
-
const cases = (_a = input.
|
|
1139
|
+
const { runPortableEvaluator } = await import("./portable-runtime-MFVOVFPB.mjs");
|
|
1140
|
+
const cases = ((_a = input.rows) != null ? _a : []).map(({ rowId, ...pair }) => ({ ...pair, caseId: rowId }));
|
|
1100
1141
|
if (cases.length > 0 && (cases.length !== input.traces.length || cases.some(
|
|
1101
1142
|
(entry, index) => {
|
|
1102
1143
|
var _a2;
|
|
1103
1144
|
return entry.candidate.trace.event.id !== ((_a2 = input.traces[index]) == null ? void 0 : _a2.event.id);
|
|
1104
1145
|
}
|
|
1105
1146
|
))) {
|
|
1106
|
-
throw new Error("Raindrop portable evaluator
|
|
1147
|
+
throw new Error("Raindrop portable evaluator rows must match traces exactly, in slice order");
|
|
1107
1148
|
}
|
|
1108
|
-
const
|
|
1149
|
+
const { rows: _rows, ...runtimeInput } = input;
|
|
1150
|
+
const result = await runPortableEvaluator(evaluator, { ...runtimeInput, cases });
|
|
1109
1151
|
validatePortableResult(artifact, input.traces, result);
|
|
1110
1152
|
return result;
|
|
1111
1153
|
}
|
|
@@ -1183,6 +1225,7 @@ export {
|
|
|
1183
1225
|
defineLocalEvaluator,
|
|
1184
1226
|
defineEvalSuite,
|
|
1185
1227
|
isEvalSuiteDefinition,
|
|
1228
|
+
isPublishedEvalSuite,
|
|
1186
1229
|
evaluatorName,
|
|
1187
1230
|
evaluatorOutput,
|
|
1188
1231
|
validateEvaluatorOutput,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|