braintrust 0.2.3 → 0.2.5
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/dev/dist/index.d.mts +7261 -471
- package/dev/dist/index.d.ts +7261 -471
- package/dev/dist/index.js +1396 -111
- package/dev/dist/index.mjs +1451 -166
- package/dist/browser.d.mts +9148 -2040
- package/dist/browser.d.ts +9148 -2040
- package/dist/browser.js +1490 -107
- package/dist/browser.mjs +1513 -130
- package/dist/cli.js +1490 -177
- package/dist/index.d.mts +15826 -2367
- package/dist/index.d.ts +15826 -2367
- package/dist/index.js +1642 -199
- package/dist/index.mjs +1639 -196
- package/package.json +6 -2
package/dist/cli.js
CHANGED
|
@@ -164,11 +164,11 @@ var require_out = __commonJS({
|
|
|
164
164
|
async.read(path9, getSettings(optionsOrSettingsOrCallback), callback);
|
|
165
165
|
}
|
|
166
166
|
exports2.stat = stat2;
|
|
167
|
-
function
|
|
167
|
+
function statSync2(path9, optionsOrSettings) {
|
|
168
168
|
const settings = getSettings(optionsOrSettings);
|
|
169
169
|
return sync.read(path9, settings);
|
|
170
170
|
}
|
|
171
|
-
exports2.statSync =
|
|
171
|
+
exports2.statSync = statSync2;
|
|
172
172
|
function getSettings(settingsOrOptions = {}) {
|
|
173
173
|
if (settingsOrOptions instanceof settings_1.default) {
|
|
174
174
|
return settingsOrOptions;
|
|
@@ -1232,7 +1232,7 @@ var require_package = __commonJS({
|
|
|
1232
1232
|
"package.json"(exports2, module2) {
|
|
1233
1233
|
module2.exports = {
|
|
1234
1234
|
name: "braintrust",
|
|
1235
|
-
version: "0.2.
|
|
1235
|
+
version: "0.2.5",
|
|
1236
1236
|
description: "SDK for integrating Braintrust",
|
|
1237
1237
|
repository: {
|
|
1238
1238
|
type: "git",
|
|
@@ -1294,6 +1294,9 @@ var require_package = __commonJS({
|
|
|
1294
1294
|
author: "",
|
|
1295
1295
|
license: "MIT",
|
|
1296
1296
|
devDependencies: {
|
|
1297
|
+
"@ai-sdk/anthropic": "^1.0.5",
|
|
1298
|
+
"@anthropic-ai/sdk": "^0.35.0",
|
|
1299
|
+
"@openai/agents": "^0.0.14",
|
|
1297
1300
|
ai: "^4.3.16",
|
|
1298
1301
|
"@jest/globals": "^29.7.0",
|
|
1299
1302
|
"@nodelib/fs.walk": "^1.2.8",
|
|
@@ -1312,6 +1315,7 @@ var require_package = __commonJS({
|
|
|
1312
1315
|
autoevals: "^0.0.69",
|
|
1313
1316
|
"cross-env": "^7.0.3",
|
|
1314
1317
|
"npm-run-all": "^4.1.5",
|
|
1318
|
+
"openapi-zod-client": "^1.18.3",
|
|
1315
1319
|
prettier: "^3.5.3",
|
|
1316
1320
|
tinybench: "^4.0.1",
|
|
1317
1321
|
"ts-jest": "^29.1.4",
|
|
@@ -1324,7 +1328,7 @@ var require_package = __commonJS({
|
|
|
1324
1328
|
},
|
|
1325
1329
|
dependencies: {
|
|
1326
1330
|
"@ai-sdk/provider": "^1.1.3",
|
|
1327
|
-
"@braintrust/core": "0.0.
|
|
1331
|
+
"@braintrust/core": "0.0.94",
|
|
1328
1332
|
"@next/env": "^14.2.3",
|
|
1329
1333
|
"@vercel/functions": "^1.0.2",
|
|
1330
1334
|
argparse: "^2.0.1",
|
|
@@ -1435,47 +1439,1262 @@ var Queue = class {
|
|
|
1435
1439
|
|
|
1436
1440
|
// src/logger.ts
|
|
1437
1441
|
var import_core2 = require("@braintrust/core");
|
|
1438
|
-
var import_typespecs2 = require("@braintrust/core/typespecs");
|
|
1439
|
-
var import_functions = require("@vercel/functions");
|
|
1440
|
-
var import_mustache2 = __toESM(require("mustache"));
|
|
1441
|
-
var import_zod2 = require("zod");
|
|
1442
1442
|
|
|
1443
|
-
// src/
|
|
1444
|
-
var import_typespecs = require("@braintrust/core/typespecs");
|
|
1445
|
-
var import_eventsource_parser = require("eventsource-parser");
|
|
1443
|
+
// src/generated_types.ts
|
|
1446
1444
|
var import_zod = require("zod");
|
|
1447
|
-
var
|
|
1445
|
+
var AclObjectType = import_zod.z.union([
|
|
1446
|
+
import_zod.z.enum([
|
|
1447
|
+
"organization",
|
|
1448
|
+
"project",
|
|
1449
|
+
"experiment",
|
|
1450
|
+
"dataset",
|
|
1451
|
+
"prompt",
|
|
1452
|
+
"prompt_session",
|
|
1453
|
+
"group",
|
|
1454
|
+
"role",
|
|
1455
|
+
"org_member",
|
|
1456
|
+
"project_log",
|
|
1457
|
+
"org_project"
|
|
1458
|
+
]),
|
|
1459
|
+
import_zod.z.null()
|
|
1460
|
+
]);
|
|
1461
|
+
var Permission = import_zod.z.enum([
|
|
1462
|
+
"create",
|
|
1463
|
+
"read",
|
|
1464
|
+
"update",
|
|
1465
|
+
"delete",
|
|
1466
|
+
"create_acls",
|
|
1467
|
+
"read_acls",
|
|
1468
|
+
"update_acls",
|
|
1469
|
+
"delete_acls"
|
|
1470
|
+
]);
|
|
1471
|
+
var Acl = import_zod.z.object({
|
|
1472
|
+
id: import_zod.z.string().uuid(),
|
|
1473
|
+
object_type: AclObjectType.and(import_zod.z.string()),
|
|
1474
|
+
object_id: import_zod.z.string().uuid(),
|
|
1475
|
+
user_id: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
1476
|
+
group_id: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
1477
|
+
permission: Permission.and(import_zod.z.union([import_zod.z.string(), import_zod.z.null()])).optional(),
|
|
1478
|
+
restrict_object_type: AclObjectType.and(import_zod.z.unknown()).optional(),
|
|
1479
|
+
role_id: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
1480
|
+
_object_org_id: import_zod.z.string().uuid(),
|
|
1481
|
+
created: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional()
|
|
1482
|
+
});
|
|
1483
|
+
var AISecret = import_zod.z.object({
|
|
1484
|
+
id: import_zod.z.string().uuid(),
|
|
1485
|
+
created: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
1486
|
+
updated_at: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
1487
|
+
org_id: import_zod.z.string().uuid(),
|
|
1488
|
+
name: import_zod.z.string(),
|
|
1489
|
+
type: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
1490
|
+
metadata: import_zod.z.union([import_zod.z.object({}).partial().passthrough(), import_zod.z.null()]).optional(),
|
|
1491
|
+
preview_secret: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional()
|
|
1492
|
+
});
|
|
1493
|
+
var ResponseFormatJsonSchema = import_zod.z.object({
|
|
1494
|
+
name: import_zod.z.string(),
|
|
1495
|
+
description: import_zod.z.string().optional(),
|
|
1496
|
+
schema: import_zod.z.union([import_zod.z.object({}).partial().passthrough(), import_zod.z.string()]).optional(),
|
|
1497
|
+
strict: import_zod.z.union([import_zod.z.boolean(), import_zod.z.null()]).optional()
|
|
1498
|
+
});
|
|
1499
|
+
var ResponseFormat = import_zod.z.union([
|
|
1500
|
+
import_zod.z.object({ type: import_zod.z.literal("json_object") }),
|
|
1501
|
+
import_zod.z.object({
|
|
1502
|
+
type: import_zod.z.literal("json_schema"),
|
|
1503
|
+
json_schema: ResponseFormatJsonSchema
|
|
1504
|
+
}),
|
|
1505
|
+
import_zod.z.object({ type: import_zod.z.literal("text") }),
|
|
1506
|
+
import_zod.z.null()
|
|
1507
|
+
]);
|
|
1508
|
+
var AnyModelParams = import_zod.z.object({
|
|
1509
|
+
temperature: import_zod.z.number().optional(),
|
|
1510
|
+
top_p: import_zod.z.number().optional(),
|
|
1511
|
+
max_tokens: import_zod.z.number(),
|
|
1512
|
+
max_completion_tokens: import_zod.z.number().optional(),
|
|
1513
|
+
frequency_penalty: import_zod.z.number().optional(),
|
|
1514
|
+
presence_penalty: import_zod.z.number().optional(),
|
|
1515
|
+
response_format: ResponseFormat.optional(),
|
|
1516
|
+
tool_choice: import_zod.z.union([
|
|
1517
|
+
import_zod.z.literal("auto"),
|
|
1518
|
+
import_zod.z.literal("none"),
|
|
1519
|
+
import_zod.z.literal("required"),
|
|
1520
|
+
import_zod.z.object({
|
|
1521
|
+
type: import_zod.z.literal("function"),
|
|
1522
|
+
function: import_zod.z.object({ name: import_zod.z.string() })
|
|
1523
|
+
})
|
|
1524
|
+
]).optional(),
|
|
1525
|
+
function_call: import_zod.z.union([
|
|
1526
|
+
import_zod.z.literal("auto"),
|
|
1527
|
+
import_zod.z.literal("none"),
|
|
1528
|
+
import_zod.z.object({ name: import_zod.z.string() })
|
|
1529
|
+
]).optional(),
|
|
1530
|
+
n: import_zod.z.number().optional(),
|
|
1531
|
+
stop: import_zod.z.array(import_zod.z.string()).optional(),
|
|
1532
|
+
reasoning_effort: import_zod.z.enum(["minimal", "low", "medium", "high"]).optional(),
|
|
1533
|
+
verbosity: import_zod.z.enum(["low", "medium", "high"]).optional(),
|
|
1534
|
+
top_k: import_zod.z.number().optional(),
|
|
1535
|
+
stop_sequences: import_zod.z.array(import_zod.z.string()).optional(),
|
|
1536
|
+
max_tokens_to_sample: import_zod.z.number().optional(),
|
|
1537
|
+
maxOutputTokens: import_zod.z.number().optional(),
|
|
1538
|
+
topP: import_zod.z.number().optional(),
|
|
1539
|
+
topK: import_zod.z.number().optional(),
|
|
1540
|
+
use_cache: import_zod.z.boolean().optional()
|
|
1541
|
+
});
|
|
1542
|
+
var ApiKey = import_zod.z.object({
|
|
1543
|
+
id: import_zod.z.string().uuid(),
|
|
1544
|
+
created: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
1545
|
+
name: import_zod.z.string(),
|
|
1546
|
+
preview_name: import_zod.z.string(),
|
|
1547
|
+
user_id: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
1548
|
+
user_email: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
1549
|
+
user_given_name: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
1550
|
+
user_family_name: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
1551
|
+
org_id: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional()
|
|
1552
|
+
});
|
|
1553
|
+
var BraintrustAttachmentReference = import_zod.z.object({
|
|
1554
|
+
type: import_zod.z.literal("braintrust_attachment"),
|
|
1555
|
+
filename: import_zod.z.string().min(1),
|
|
1556
|
+
content_type: import_zod.z.string().min(1),
|
|
1557
|
+
key: import_zod.z.string().min(1)
|
|
1558
|
+
});
|
|
1559
|
+
var ExternalAttachmentReference = import_zod.z.object({
|
|
1560
|
+
type: import_zod.z.literal("external_attachment"),
|
|
1561
|
+
filename: import_zod.z.string().min(1),
|
|
1562
|
+
content_type: import_zod.z.string().min(1),
|
|
1563
|
+
url: import_zod.z.string().min(1)
|
|
1564
|
+
});
|
|
1565
|
+
var AttachmentReference = import_zod.z.discriminatedUnion("type", [
|
|
1566
|
+
BraintrustAttachmentReference,
|
|
1567
|
+
ExternalAttachmentReference
|
|
1568
|
+
]);
|
|
1569
|
+
var UploadStatus = import_zod.z.enum(["uploading", "done", "error"]);
|
|
1570
|
+
var AttachmentStatus = import_zod.z.object({
|
|
1571
|
+
upload_status: UploadStatus,
|
|
1572
|
+
error_message: import_zod.z.string().optional()
|
|
1573
|
+
});
|
|
1574
|
+
var BraintrustModelParams = import_zod.z.object({ use_cache: import_zod.z.boolean() }).partial();
|
|
1575
|
+
var CallEvent = import_zod.z.union([
|
|
1576
|
+
import_zod.z.object({
|
|
1577
|
+
id: import_zod.z.string().optional(),
|
|
1578
|
+
data: import_zod.z.string(),
|
|
1579
|
+
event: import_zod.z.literal("text_delta")
|
|
1580
|
+
}),
|
|
1581
|
+
import_zod.z.object({
|
|
1582
|
+
id: import_zod.z.string().optional(),
|
|
1583
|
+
data: import_zod.z.string(),
|
|
1584
|
+
event: import_zod.z.literal("reasoning_delta")
|
|
1585
|
+
}),
|
|
1586
|
+
import_zod.z.object({
|
|
1587
|
+
id: import_zod.z.string().optional(),
|
|
1588
|
+
data: import_zod.z.string(),
|
|
1589
|
+
event: import_zod.z.literal("json_delta")
|
|
1590
|
+
}),
|
|
1591
|
+
import_zod.z.object({
|
|
1592
|
+
id: import_zod.z.string().optional(),
|
|
1593
|
+
data: import_zod.z.string(),
|
|
1594
|
+
event: import_zod.z.literal("progress")
|
|
1595
|
+
}),
|
|
1596
|
+
import_zod.z.object({
|
|
1597
|
+
id: import_zod.z.string().optional(),
|
|
1598
|
+
data: import_zod.z.string(),
|
|
1599
|
+
event: import_zod.z.literal("error")
|
|
1600
|
+
}),
|
|
1601
|
+
import_zod.z.object({
|
|
1602
|
+
id: import_zod.z.string().optional(),
|
|
1603
|
+
data: import_zod.z.string(),
|
|
1604
|
+
event: import_zod.z.literal("console")
|
|
1605
|
+
}),
|
|
1606
|
+
import_zod.z.object({
|
|
1607
|
+
id: import_zod.z.string().optional(),
|
|
1608
|
+
event: import_zod.z.literal("start"),
|
|
1609
|
+
data: import_zod.z.literal("")
|
|
1610
|
+
}),
|
|
1611
|
+
import_zod.z.object({
|
|
1612
|
+
id: import_zod.z.string().optional(),
|
|
1613
|
+
event: import_zod.z.literal("done"),
|
|
1614
|
+
data: import_zod.z.literal("")
|
|
1615
|
+
})
|
|
1616
|
+
]);
|
|
1617
|
+
var ChatCompletionContentPartTextWithTitle = import_zod.z.object({
|
|
1618
|
+
text: import_zod.z.string().default(""),
|
|
1619
|
+
type: import_zod.z.literal("text"),
|
|
1620
|
+
cache_control: import_zod.z.object({ type: import_zod.z.literal("ephemeral") }).optional()
|
|
1621
|
+
});
|
|
1622
|
+
var ChatCompletionContentPartImageWithTitle = import_zod.z.object({
|
|
1623
|
+
image_url: import_zod.z.object({
|
|
1624
|
+
url: import_zod.z.string(),
|
|
1625
|
+
detail: import_zod.z.union([import_zod.z.literal("auto"), import_zod.z.literal("low"), import_zod.z.literal("high")]).optional()
|
|
1626
|
+
}),
|
|
1627
|
+
type: import_zod.z.literal("image_url")
|
|
1628
|
+
});
|
|
1629
|
+
var ChatCompletionContentPart = import_zod.z.union([
|
|
1630
|
+
ChatCompletionContentPartTextWithTitle,
|
|
1631
|
+
ChatCompletionContentPartImageWithTitle
|
|
1632
|
+
]);
|
|
1633
|
+
var ChatCompletionContentPartText = import_zod.z.object({
|
|
1634
|
+
text: import_zod.z.string().default(""),
|
|
1635
|
+
type: import_zod.z.literal("text"),
|
|
1636
|
+
cache_control: import_zod.z.object({ type: import_zod.z.literal("ephemeral") }).optional()
|
|
1637
|
+
});
|
|
1638
|
+
var ChatCompletionMessageToolCall = import_zod.z.object({
|
|
1639
|
+
id: import_zod.z.string(),
|
|
1640
|
+
function: import_zod.z.object({ arguments: import_zod.z.string(), name: import_zod.z.string() }),
|
|
1641
|
+
type: import_zod.z.literal("function")
|
|
1642
|
+
});
|
|
1643
|
+
var ChatCompletionMessageReasoning = import_zod.z.object({ id: import_zod.z.string(), content: import_zod.z.string() }).partial();
|
|
1644
|
+
var ChatCompletionMessageParam = import_zod.z.union([
|
|
1645
|
+
import_zod.z.object({
|
|
1646
|
+
content: import_zod.z.union([import_zod.z.string(), import_zod.z.array(ChatCompletionContentPartText)]),
|
|
1647
|
+
role: import_zod.z.literal("system"),
|
|
1648
|
+
name: import_zod.z.string().optional()
|
|
1649
|
+
}),
|
|
1650
|
+
import_zod.z.object({
|
|
1651
|
+
content: import_zod.z.union([import_zod.z.string(), import_zod.z.array(ChatCompletionContentPart)]),
|
|
1652
|
+
role: import_zod.z.literal("user"),
|
|
1653
|
+
name: import_zod.z.string().optional()
|
|
1654
|
+
}),
|
|
1655
|
+
import_zod.z.object({
|
|
1656
|
+
role: import_zod.z.literal("assistant"),
|
|
1657
|
+
content: import_zod.z.union([import_zod.z.string(), import_zod.z.array(ChatCompletionContentPartText), import_zod.z.null()]).optional(),
|
|
1658
|
+
function_call: import_zod.z.object({ arguments: import_zod.z.string(), name: import_zod.z.string() }).optional(),
|
|
1659
|
+
name: import_zod.z.string().optional(),
|
|
1660
|
+
tool_calls: import_zod.z.array(ChatCompletionMessageToolCall).optional(),
|
|
1661
|
+
reasoning: import_zod.z.array(ChatCompletionMessageReasoning).optional()
|
|
1662
|
+
}),
|
|
1663
|
+
import_zod.z.object({
|
|
1664
|
+
content: import_zod.z.union([import_zod.z.string(), import_zod.z.array(ChatCompletionContentPartText)]),
|
|
1665
|
+
role: import_zod.z.literal("tool"),
|
|
1666
|
+
tool_call_id: import_zod.z.string().default("")
|
|
1667
|
+
}),
|
|
1668
|
+
import_zod.z.object({
|
|
1669
|
+
content: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]),
|
|
1670
|
+
name: import_zod.z.string(),
|
|
1671
|
+
role: import_zod.z.literal("function")
|
|
1672
|
+
}),
|
|
1673
|
+
import_zod.z.object({
|
|
1674
|
+
content: import_zod.z.union([import_zod.z.string(), import_zod.z.array(ChatCompletionContentPartText)]),
|
|
1675
|
+
role: import_zod.z.literal("developer"),
|
|
1676
|
+
name: import_zod.z.string().optional()
|
|
1677
|
+
}),
|
|
1678
|
+
import_zod.z.object({
|
|
1679
|
+
role: import_zod.z.literal("model"),
|
|
1680
|
+
content: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional()
|
|
1681
|
+
})
|
|
1682
|
+
]);
|
|
1683
|
+
var ChatCompletionOpenAIMessageParam = import_zod.z.union([
|
|
1684
|
+
import_zod.z.object({
|
|
1685
|
+
content: import_zod.z.union([import_zod.z.string(), import_zod.z.array(ChatCompletionContentPartText)]),
|
|
1686
|
+
role: import_zod.z.literal("system"),
|
|
1687
|
+
name: import_zod.z.string().optional()
|
|
1688
|
+
}),
|
|
1689
|
+
import_zod.z.object({
|
|
1690
|
+
content: import_zod.z.union([import_zod.z.string(), import_zod.z.array(ChatCompletionContentPart)]),
|
|
1691
|
+
role: import_zod.z.literal("user"),
|
|
1692
|
+
name: import_zod.z.string().optional()
|
|
1693
|
+
}),
|
|
1694
|
+
import_zod.z.object({
|
|
1695
|
+
role: import_zod.z.literal("assistant"),
|
|
1696
|
+
content: import_zod.z.union([import_zod.z.string(), import_zod.z.array(ChatCompletionContentPartText), import_zod.z.null()]).optional(),
|
|
1697
|
+
function_call: import_zod.z.object({ arguments: import_zod.z.string(), name: import_zod.z.string() }).optional(),
|
|
1698
|
+
name: import_zod.z.string().optional(),
|
|
1699
|
+
tool_calls: import_zod.z.array(ChatCompletionMessageToolCall).optional(),
|
|
1700
|
+
reasoning: import_zod.z.array(ChatCompletionMessageReasoning).optional()
|
|
1701
|
+
}),
|
|
1702
|
+
import_zod.z.object({
|
|
1703
|
+
content: import_zod.z.union([import_zod.z.string(), import_zod.z.array(ChatCompletionContentPartText)]),
|
|
1704
|
+
role: import_zod.z.literal("tool"),
|
|
1705
|
+
tool_call_id: import_zod.z.string().default("")
|
|
1706
|
+
}),
|
|
1707
|
+
import_zod.z.object({
|
|
1708
|
+
content: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]),
|
|
1709
|
+
name: import_zod.z.string(),
|
|
1710
|
+
role: import_zod.z.literal("function")
|
|
1711
|
+
}),
|
|
1712
|
+
import_zod.z.object({
|
|
1713
|
+
content: import_zod.z.union([import_zod.z.string(), import_zod.z.array(ChatCompletionContentPartText)]),
|
|
1714
|
+
role: import_zod.z.literal("developer"),
|
|
1715
|
+
name: import_zod.z.string().optional()
|
|
1716
|
+
})
|
|
1717
|
+
]);
|
|
1718
|
+
var ChatCompletionTool = import_zod.z.object({
|
|
1719
|
+
function: import_zod.z.object({
|
|
1720
|
+
name: import_zod.z.string(),
|
|
1721
|
+
description: import_zod.z.string().optional(),
|
|
1722
|
+
parameters: import_zod.z.object({}).partial().passthrough().optional()
|
|
1723
|
+
}),
|
|
1724
|
+
type: import_zod.z.literal("function")
|
|
1725
|
+
});
|
|
1726
|
+
var CodeBundle = import_zod.z.object({
|
|
1727
|
+
runtime_context: import_zod.z.object({
|
|
1728
|
+
runtime: import_zod.z.enum(["node", "python"]),
|
|
1729
|
+
version: import_zod.z.string()
|
|
1730
|
+
}),
|
|
1731
|
+
location: import_zod.z.union([
|
|
1732
|
+
import_zod.z.object({
|
|
1733
|
+
type: import_zod.z.literal("experiment"),
|
|
1734
|
+
eval_name: import_zod.z.string(),
|
|
1735
|
+
position: import_zod.z.union([
|
|
1736
|
+
import_zod.z.object({ type: import_zod.z.literal("task") }),
|
|
1737
|
+
import_zod.z.object({ type: import_zod.z.literal("scorer"), index: import_zod.z.number().int().gte(0) })
|
|
1738
|
+
])
|
|
1739
|
+
}),
|
|
1740
|
+
import_zod.z.object({ type: import_zod.z.literal("function"), index: import_zod.z.number().int().gte(0) })
|
|
1741
|
+
]),
|
|
1742
|
+
bundle_id: import_zod.z.string(),
|
|
1743
|
+
preview: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional()
|
|
1744
|
+
});
|
|
1745
|
+
var Dataset = import_zod.z.object({
|
|
1746
|
+
id: import_zod.z.string().uuid(),
|
|
1747
|
+
project_id: import_zod.z.string().uuid(),
|
|
1748
|
+
name: import_zod.z.string(),
|
|
1749
|
+
description: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
1750
|
+
created: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
1751
|
+
deleted_at: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
1752
|
+
user_id: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
1753
|
+
metadata: import_zod.z.union([import_zod.z.object({}).partial().passthrough(), import_zod.z.null()]).optional()
|
|
1754
|
+
});
|
|
1755
|
+
var ObjectReference = import_zod.z.union([
|
|
1756
|
+
import_zod.z.object({
|
|
1757
|
+
object_type: import_zod.z.enum([
|
|
1758
|
+
"project_logs",
|
|
1759
|
+
"experiment",
|
|
1760
|
+
"dataset",
|
|
1761
|
+
"prompt",
|
|
1762
|
+
"function",
|
|
1763
|
+
"prompt_session"
|
|
1764
|
+
]),
|
|
1765
|
+
object_id: import_zod.z.string().uuid(),
|
|
1766
|
+
id: import_zod.z.string(),
|
|
1767
|
+
_xact_id: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
1768
|
+
created: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional()
|
|
1769
|
+
}),
|
|
1770
|
+
import_zod.z.null()
|
|
1771
|
+
]);
|
|
1772
|
+
var DatasetEvent = import_zod.z.object({
|
|
1773
|
+
id: import_zod.z.string(),
|
|
1774
|
+
_xact_id: import_zod.z.string(),
|
|
1775
|
+
created: import_zod.z.string().datetime({ offset: true }),
|
|
1776
|
+
_pagination_key: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
1777
|
+
project_id: import_zod.z.string().uuid(),
|
|
1778
|
+
dataset_id: import_zod.z.string().uuid(),
|
|
1779
|
+
input: import_zod.z.unknown().optional(),
|
|
1780
|
+
expected: import_zod.z.unknown().optional(),
|
|
1781
|
+
metadata: import_zod.z.union([
|
|
1782
|
+
import_zod.z.object({ model: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]) }).partial().passthrough(),
|
|
1783
|
+
import_zod.z.null()
|
|
1784
|
+
]).optional(),
|
|
1785
|
+
tags: import_zod.z.union([import_zod.z.array(import_zod.z.string()), import_zod.z.null()]).optional(),
|
|
1786
|
+
span_id: import_zod.z.string(),
|
|
1787
|
+
root_span_id: import_zod.z.string(),
|
|
1788
|
+
is_root: import_zod.z.union([import_zod.z.boolean(), import_zod.z.null()]).optional(),
|
|
1789
|
+
origin: ObjectReference.optional()
|
|
1790
|
+
});
|
|
1791
|
+
var EnvVar = import_zod.z.object({
|
|
1792
|
+
id: import_zod.z.string().uuid(),
|
|
1793
|
+
object_type: import_zod.z.enum(["organization", "project", "function"]),
|
|
1794
|
+
object_id: import_zod.z.string().uuid(),
|
|
1795
|
+
name: import_zod.z.string(),
|
|
1796
|
+
created: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
1797
|
+
used: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional()
|
|
1798
|
+
});
|
|
1799
|
+
var RepoInfo = import_zod.z.union([
|
|
1800
|
+
import_zod.z.object({
|
|
1801
|
+
commit: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]),
|
|
1802
|
+
branch: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]),
|
|
1803
|
+
tag: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]),
|
|
1804
|
+
dirty: import_zod.z.union([import_zod.z.boolean(), import_zod.z.null()]),
|
|
1805
|
+
author_name: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]),
|
|
1806
|
+
author_email: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]),
|
|
1807
|
+
commit_message: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]),
|
|
1808
|
+
commit_time: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]),
|
|
1809
|
+
git_diff: import_zod.z.union([import_zod.z.string(), import_zod.z.null()])
|
|
1810
|
+
}).partial(),
|
|
1811
|
+
import_zod.z.null()
|
|
1812
|
+
]);
|
|
1813
|
+
var Experiment = import_zod.z.object({
|
|
1814
|
+
id: import_zod.z.string().uuid(),
|
|
1815
|
+
project_id: import_zod.z.string().uuid(),
|
|
1816
|
+
name: import_zod.z.string(),
|
|
1817
|
+
description: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
1818
|
+
created: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
1819
|
+
repo_info: RepoInfo.optional(),
|
|
1820
|
+
commit: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
1821
|
+
base_exp_id: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
1822
|
+
deleted_at: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
1823
|
+
dataset_id: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
1824
|
+
dataset_version: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
1825
|
+
public: import_zod.z.boolean(),
|
|
1826
|
+
user_id: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
1827
|
+
metadata: import_zod.z.union([import_zod.z.object({}).partial().passthrough(), import_zod.z.null()]).optional(),
|
|
1828
|
+
tags: import_zod.z.union([import_zod.z.array(import_zod.z.string()), import_zod.z.null()]).optional()
|
|
1829
|
+
});
|
|
1830
|
+
var SpanType = import_zod.z.union([
|
|
1831
|
+
import_zod.z.enum(["llm", "score", "function", "eval", "task", "tool"]),
|
|
1832
|
+
import_zod.z.null()
|
|
1833
|
+
]);
|
|
1834
|
+
var SpanAttributes = import_zod.z.union([
|
|
1835
|
+
import_zod.z.object({ name: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]), type: SpanType }).partial().passthrough(),
|
|
1836
|
+
import_zod.z.null()
|
|
1837
|
+
]);
|
|
1838
|
+
var ExperimentEvent = import_zod.z.object({
|
|
1839
|
+
id: import_zod.z.string(),
|
|
1840
|
+
_xact_id: import_zod.z.string(),
|
|
1841
|
+
created: import_zod.z.string().datetime({ offset: true }),
|
|
1842
|
+
_pagination_key: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
1843
|
+
project_id: import_zod.z.string().uuid(),
|
|
1844
|
+
experiment_id: import_zod.z.string().uuid(),
|
|
1845
|
+
input: import_zod.z.unknown().optional(),
|
|
1846
|
+
output: import_zod.z.unknown().optional(),
|
|
1847
|
+
expected: import_zod.z.unknown().optional(),
|
|
1848
|
+
error: import_zod.z.unknown().optional(),
|
|
1849
|
+
scores: import_zod.z.union([import_zod.z.record(import_zod.z.union([import_zod.z.number(), import_zod.z.null()])), import_zod.z.null()]).optional(),
|
|
1850
|
+
metadata: import_zod.z.union([
|
|
1851
|
+
import_zod.z.object({ model: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]) }).partial().passthrough(),
|
|
1852
|
+
import_zod.z.null()
|
|
1853
|
+
]).optional(),
|
|
1854
|
+
tags: import_zod.z.union([import_zod.z.array(import_zod.z.string()), import_zod.z.null()]).optional(),
|
|
1855
|
+
metrics: import_zod.z.union([import_zod.z.record(import_zod.z.number()), import_zod.z.null()]).optional(),
|
|
1856
|
+
context: import_zod.z.union([
|
|
1857
|
+
import_zod.z.object({
|
|
1858
|
+
caller_functionname: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]),
|
|
1859
|
+
caller_filename: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]),
|
|
1860
|
+
caller_lineno: import_zod.z.union([import_zod.z.number(), import_zod.z.null()])
|
|
1861
|
+
}).partial().passthrough(),
|
|
1862
|
+
import_zod.z.null()
|
|
1863
|
+
]).optional(),
|
|
1864
|
+
span_id: import_zod.z.string(),
|
|
1865
|
+
span_parents: import_zod.z.union([import_zod.z.array(import_zod.z.string()), import_zod.z.null()]).optional(),
|
|
1866
|
+
root_span_id: import_zod.z.string(),
|
|
1867
|
+
span_attributes: SpanAttributes.optional(),
|
|
1868
|
+
is_root: import_zod.z.union([import_zod.z.boolean(), import_zod.z.null()]).optional(),
|
|
1869
|
+
origin: ObjectReference.optional()
|
|
1870
|
+
});
|
|
1871
|
+
var ExtendedSavedFunctionId = import_zod.z.union([
|
|
1872
|
+
import_zod.z.object({ type: import_zod.z.literal("function"), id: import_zod.z.string() }),
|
|
1873
|
+
import_zod.z.object({ type: import_zod.z.literal("global"), name: import_zod.z.string() }),
|
|
1874
|
+
import_zod.z.object({
|
|
1875
|
+
type: import_zod.z.literal("slug"),
|
|
1876
|
+
project_id: import_zod.z.string(),
|
|
1877
|
+
slug: import_zod.z.string()
|
|
1878
|
+
})
|
|
1879
|
+
]);
|
|
1880
|
+
var PromptBlockDataNullish = import_zod.z.union([
|
|
1881
|
+
import_zod.z.object({ type: import_zod.z.literal("completion"), content: import_zod.z.string() }),
|
|
1882
|
+
import_zod.z.object({
|
|
1883
|
+
type: import_zod.z.literal("chat"),
|
|
1884
|
+
messages: import_zod.z.array(ChatCompletionMessageParam),
|
|
1885
|
+
tools: import_zod.z.string().optional()
|
|
1886
|
+
}),
|
|
1887
|
+
import_zod.z.null()
|
|
1888
|
+
]);
|
|
1889
|
+
var ModelParams = import_zod.z.union([
|
|
1890
|
+
import_zod.z.object({
|
|
1891
|
+
use_cache: import_zod.z.boolean(),
|
|
1892
|
+
temperature: import_zod.z.number(),
|
|
1893
|
+
top_p: import_zod.z.number(),
|
|
1894
|
+
max_tokens: import_zod.z.number(),
|
|
1895
|
+
max_completion_tokens: import_zod.z.number(),
|
|
1896
|
+
frequency_penalty: import_zod.z.number(),
|
|
1897
|
+
presence_penalty: import_zod.z.number(),
|
|
1898
|
+
response_format: ResponseFormat,
|
|
1899
|
+
tool_choice: import_zod.z.union([
|
|
1900
|
+
import_zod.z.literal("auto"),
|
|
1901
|
+
import_zod.z.literal("none"),
|
|
1902
|
+
import_zod.z.literal("required"),
|
|
1903
|
+
import_zod.z.object({
|
|
1904
|
+
type: import_zod.z.literal("function"),
|
|
1905
|
+
function: import_zod.z.object({ name: import_zod.z.string() })
|
|
1906
|
+
})
|
|
1907
|
+
]),
|
|
1908
|
+
function_call: import_zod.z.union([
|
|
1909
|
+
import_zod.z.literal("auto"),
|
|
1910
|
+
import_zod.z.literal("none"),
|
|
1911
|
+
import_zod.z.object({ name: import_zod.z.string() })
|
|
1912
|
+
]),
|
|
1913
|
+
n: import_zod.z.number(),
|
|
1914
|
+
stop: import_zod.z.array(import_zod.z.string()),
|
|
1915
|
+
reasoning_effort: import_zod.z.enum(["minimal", "low", "medium", "high"]),
|
|
1916
|
+
verbosity: import_zod.z.enum(["low", "medium", "high"])
|
|
1917
|
+
}).partial().passthrough(),
|
|
1918
|
+
import_zod.z.object({
|
|
1919
|
+
use_cache: import_zod.z.boolean().optional(),
|
|
1920
|
+
max_tokens: import_zod.z.number(),
|
|
1921
|
+
temperature: import_zod.z.number(),
|
|
1922
|
+
top_p: import_zod.z.number().optional(),
|
|
1923
|
+
top_k: import_zod.z.number().optional(),
|
|
1924
|
+
stop_sequences: import_zod.z.array(import_zod.z.string()).optional(),
|
|
1925
|
+
max_tokens_to_sample: import_zod.z.number().optional()
|
|
1926
|
+
}).passthrough(),
|
|
1927
|
+
import_zod.z.object({
|
|
1928
|
+
use_cache: import_zod.z.boolean(),
|
|
1929
|
+
temperature: import_zod.z.number(),
|
|
1930
|
+
maxOutputTokens: import_zod.z.number(),
|
|
1931
|
+
topP: import_zod.z.number(),
|
|
1932
|
+
topK: import_zod.z.number()
|
|
1933
|
+
}).partial().passthrough(),
|
|
1934
|
+
import_zod.z.object({
|
|
1935
|
+
use_cache: import_zod.z.boolean(),
|
|
1936
|
+
temperature: import_zod.z.number(),
|
|
1937
|
+
topK: import_zod.z.number()
|
|
1938
|
+
}).partial().passthrough(),
|
|
1939
|
+
import_zod.z.object({ use_cache: import_zod.z.boolean() }).partial().passthrough()
|
|
1940
|
+
]);
|
|
1941
|
+
var PromptOptionsNullish = import_zod.z.union([
|
|
1942
|
+
import_zod.z.object({ model: import_zod.z.string(), params: ModelParams, position: import_zod.z.string() }).partial(),
|
|
1943
|
+
import_zod.z.null()
|
|
1944
|
+
]);
|
|
1945
|
+
var PromptParserNullish = import_zod.z.union([
|
|
1946
|
+
import_zod.z.object({
|
|
1947
|
+
type: import_zod.z.literal("llm_classifier"),
|
|
1948
|
+
use_cot: import_zod.z.boolean(),
|
|
1949
|
+
choice_scores: import_zod.z.record(import_zod.z.number().gte(0).lte(1))
|
|
1950
|
+
}),
|
|
1951
|
+
import_zod.z.null()
|
|
1952
|
+
]);
|
|
1953
|
+
var SavedFunctionId = import_zod.z.union([
|
|
1954
|
+
import_zod.z.object({ type: import_zod.z.literal("function"), id: import_zod.z.string() }),
|
|
1955
|
+
import_zod.z.object({ type: import_zod.z.literal("global"), name: import_zod.z.string() })
|
|
1956
|
+
]);
|
|
1957
|
+
var PromptDataNullish = import_zod.z.union([
|
|
1958
|
+
import_zod.z.object({
|
|
1959
|
+
prompt: PromptBlockDataNullish,
|
|
1960
|
+
options: PromptOptionsNullish,
|
|
1961
|
+
parser: PromptParserNullish,
|
|
1962
|
+
tool_functions: import_zod.z.union([import_zod.z.array(SavedFunctionId), import_zod.z.null()]),
|
|
1963
|
+
origin: import_zod.z.union([
|
|
1964
|
+
import_zod.z.object({
|
|
1965
|
+
prompt_id: import_zod.z.string(),
|
|
1966
|
+
project_id: import_zod.z.string(),
|
|
1967
|
+
prompt_version: import_zod.z.string()
|
|
1968
|
+
}).partial(),
|
|
1969
|
+
import_zod.z.null()
|
|
1970
|
+
])
|
|
1971
|
+
}).partial(),
|
|
1972
|
+
import_zod.z.null()
|
|
1973
|
+
]);
|
|
1974
|
+
var FunctionTypeEnumNullish = import_zod.z.union([
|
|
1975
|
+
import_zod.z.enum(["llm", "scorer", "task", "tool"]),
|
|
1976
|
+
import_zod.z.null()
|
|
1977
|
+
]);
|
|
1978
|
+
var FunctionIdRef = import_zod.z.object({}).partial().passthrough();
|
|
1979
|
+
var PromptBlockData = import_zod.z.union([
|
|
1980
|
+
import_zod.z.object({ type: import_zod.z.literal("completion"), content: import_zod.z.string() }),
|
|
1981
|
+
import_zod.z.object({
|
|
1982
|
+
type: import_zod.z.literal("chat"),
|
|
1983
|
+
messages: import_zod.z.array(ChatCompletionMessageParam),
|
|
1984
|
+
tools: import_zod.z.string().optional()
|
|
1985
|
+
})
|
|
1986
|
+
]);
|
|
1987
|
+
var GraphNode = import_zod.z.union([
|
|
1988
|
+
import_zod.z.object({
|
|
1989
|
+
description: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
1990
|
+
position: import_zod.z.union([import_zod.z.object({ x: import_zod.z.number(), y: import_zod.z.number() }), import_zod.z.null()]).optional(),
|
|
1991
|
+
type: import_zod.z.literal("function"),
|
|
1992
|
+
function: FunctionIdRef
|
|
1993
|
+
}),
|
|
1994
|
+
import_zod.z.object({
|
|
1995
|
+
description: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
1996
|
+
position: import_zod.z.union([import_zod.z.object({ x: import_zod.z.number(), y: import_zod.z.number() }), import_zod.z.null()]).optional(),
|
|
1997
|
+
type: import_zod.z.literal("input")
|
|
1998
|
+
}),
|
|
1999
|
+
import_zod.z.object({
|
|
2000
|
+
description: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
2001
|
+
position: import_zod.z.union([import_zod.z.object({ x: import_zod.z.number(), y: import_zod.z.number() }), import_zod.z.null()]).optional(),
|
|
2002
|
+
type: import_zod.z.literal("output")
|
|
2003
|
+
}),
|
|
2004
|
+
import_zod.z.object({
|
|
2005
|
+
description: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
2006
|
+
position: import_zod.z.union([import_zod.z.object({ x: import_zod.z.number(), y: import_zod.z.number() }), import_zod.z.null()]).optional(),
|
|
2007
|
+
type: import_zod.z.literal("literal"),
|
|
2008
|
+
value: import_zod.z.unknown().optional()
|
|
2009
|
+
}),
|
|
2010
|
+
import_zod.z.object({
|
|
2011
|
+
description: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
2012
|
+
position: import_zod.z.union([import_zod.z.object({ x: import_zod.z.number(), y: import_zod.z.number() }), import_zod.z.null()]).optional(),
|
|
2013
|
+
type: import_zod.z.literal("btql"),
|
|
2014
|
+
expr: import_zod.z.string()
|
|
2015
|
+
}),
|
|
2016
|
+
import_zod.z.object({
|
|
2017
|
+
description: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
2018
|
+
position: import_zod.z.union([import_zod.z.object({ x: import_zod.z.number(), y: import_zod.z.number() }), import_zod.z.null()]).optional(),
|
|
2019
|
+
type: import_zod.z.literal("gate"),
|
|
2020
|
+
condition: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional()
|
|
2021
|
+
}),
|
|
2022
|
+
import_zod.z.object({
|
|
2023
|
+
description: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
2024
|
+
position: import_zod.z.union([import_zod.z.object({ x: import_zod.z.number(), y: import_zod.z.number() }), import_zod.z.null()]).optional(),
|
|
2025
|
+
type: import_zod.z.literal("aggregator")
|
|
2026
|
+
}),
|
|
2027
|
+
import_zod.z.object({
|
|
2028
|
+
description: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
2029
|
+
position: import_zod.z.union([import_zod.z.object({ x: import_zod.z.number(), y: import_zod.z.number() }), import_zod.z.null()]).optional(),
|
|
2030
|
+
type: import_zod.z.literal("prompt_template"),
|
|
2031
|
+
prompt: PromptBlockData
|
|
2032
|
+
})
|
|
2033
|
+
]);
|
|
2034
|
+
var GraphEdge = import_zod.z.object({
|
|
2035
|
+
source: import_zod.z.object({ node: import_zod.z.string().max(1024), variable: import_zod.z.string() }),
|
|
2036
|
+
target: import_zod.z.object({ node: import_zod.z.string().max(1024), variable: import_zod.z.string() }),
|
|
2037
|
+
purpose: import_zod.z.enum(["control", "data", "messages"])
|
|
2038
|
+
});
|
|
2039
|
+
var GraphData = import_zod.z.object({
|
|
2040
|
+
type: import_zod.z.literal("graph"),
|
|
2041
|
+
nodes: import_zod.z.record(GraphNode),
|
|
2042
|
+
edges: import_zod.z.record(GraphEdge)
|
|
2043
|
+
});
|
|
2044
|
+
var FunctionData = import_zod.z.union([
|
|
2045
|
+
import_zod.z.object({ type: import_zod.z.literal("prompt") }),
|
|
2046
|
+
import_zod.z.object({
|
|
2047
|
+
type: import_zod.z.literal("code"),
|
|
2048
|
+
data: import_zod.z.union([
|
|
2049
|
+
import_zod.z.object({ type: import_zod.z.literal("bundle") }).and(CodeBundle),
|
|
2050
|
+
import_zod.z.object({
|
|
2051
|
+
type: import_zod.z.literal("inline"),
|
|
2052
|
+
runtime_context: import_zod.z.object({
|
|
2053
|
+
runtime: import_zod.z.enum(["node", "python"]),
|
|
2054
|
+
version: import_zod.z.string()
|
|
2055
|
+
}),
|
|
2056
|
+
code: import_zod.z.string()
|
|
2057
|
+
})
|
|
2058
|
+
])
|
|
2059
|
+
}),
|
|
2060
|
+
GraphData,
|
|
2061
|
+
import_zod.z.object({
|
|
2062
|
+
type: import_zod.z.literal("remote_eval"),
|
|
2063
|
+
endpoint: import_zod.z.string(),
|
|
2064
|
+
eval_name: import_zod.z.string(),
|
|
2065
|
+
parameters: import_zod.z.object({}).partial().passthrough()
|
|
2066
|
+
}),
|
|
2067
|
+
import_zod.z.object({ type: import_zod.z.literal("global"), name: import_zod.z.string() })
|
|
2068
|
+
]);
|
|
2069
|
+
var Function2 = import_zod.z.object({
|
|
2070
|
+
id: import_zod.z.string().uuid(),
|
|
2071
|
+
_xact_id: import_zod.z.string(),
|
|
2072
|
+
project_id: import_zod.z.string().uuid(),
|
|
2073
|
+
log_id: import_zod.z.literal("p"),
|
|
2074
|
+
org_id: import_zod.z.string().uuid(),
|
|
2075
|
+
name: import_zod.z.string(),
|
|
2076
|
+
slug: import_zod.z.string(),
|
|
2077
|
+
description: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
2078
|
+
created: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
2079
|
+
prompt_data: PromptDataNullish.optional(),
|
|
2080
|
+
tags: import_zod.z.union([import_zod.z.array(import_zod.z.string()), import_zod.z.null()]).optional(),
|
|
2081
|
+
metadata: import_zod.z.union([import_zod.z.object({}).partial().passthrough(), import_zod.z.null()]).optional(),
|
|
2082
|
+
function_type: FunctionTypeEnumNullish.optional(),
|
|
2083
|
+
function_data: FunctionData,
|
|
2084
|
+
origin: import_zod.z.union([
|
|
2085
|
+
import_zod.z.object({
|
|
2086
|
+
object_type: AclObjectType.and(import_zod.z.string()),
|
|
2087
|
+
object_id: import_zod.z.string().uuid(),
|
|
2088
|
+
internal: import_zod.z.union([import_zod.z.boolean(), import_zod.z.null()]).optional()
|
|
2089
|
+
}),
|
|
2090
|
+
import_zod.z.null()
|
|
2091
|
+
]).optional(),
|
|
2092
|
+
function_schema: import_zod.z.union([
|
|
2093
|
+
import_zod.z.object({ parameters: import_zod.z.unknown(), returns: import_zod.z.unknown() }).partial(),
|
|
2094
|
+
import_zod.z.null()
|
|
2095
|
+
]).optional()
|
|
2096
|
+
});
|
|
2097
|
+
var FunctionFormat = import_zod.z.enum(["llm", "code", "global", "graph"]);
|
|
2098
|
+
var PromptData = import_zod.z.object({
|
|
2099
|
+
prompt: PromptBlockDataNullish,
|
|
2100
|
+
options: PromptOptionsNullish,
|
|
2101
|
+
parser: PromptParserNullish,
|
|
2102
|
+
tool_functions: import_zod.z.union([import_zod.z.array(SavedFunctionId), import_zod.z.null()]),
|
|
2103
|
+
origin: import_zod.z.union([
|
|
2104
|
+
import_zod.z.object({
|
|
2105
|
+
prompt_id: import_zod.z.string(),
|
|
2106
|
+
project_id: import_zod.z.string(),
|
|
2107
|
+
prompt_version: import_zod.z.string()
|
|
2108
|
+
}).partial(),
|
|
2109
|
+
import_zod.z.null()
|
|
2110
|
+
])
|
|
2111
|
+
}).partial();
|
|
2112
|
+
var FunctionTypeEnum = import_zod.z.enum(["llm", "scorer", "task", "tool"]);
|
|
2113
|
+
var FunctionId = import_zod.z.union([
|
|
2114
|
+
import_zod.z.object({ function_id: import_zod.z.string(), version: import_zod.z.string().optional() }),
|
|
1448
2115
|
import_zod.z.object({
|
|
1449
|
-
|
|
1450
|
-
|
|
2116
|
+
project_name: import_zod.z.string(),
|
|
2117
|
+
slug: import_zod.z.string(),
|
|
2118
|
+
version: import_zod.z.string().optional()
|
|
1451
2119
|
}),
|
|
2120
|
+
import_zod.z.object({ global_function: import_zod.z.string() }),
|
|
1452
2121
|
import_zod.z.object({
|
|
1453
|
-
|
|
1454
|
-
|
|
2122
|
+
prompt_session_id: import_zod.z.string(),
|
|
2123
|
+
prompt_session_function_id: import_zod.z.string(),
|
|
2124
|
+
version: import_zod.z.string().optional()
|
|
1455
2125
|
}),
|
|
1456
2126
|
import_zod.z.object({
|
|
1457
|
-
|
|
1458
|
-
|
|
2127
|
+
inline_context: import_zod.z.object({
|
|
2128
|
+
runtime: import_zod.z.enum(["node", "python"]),
|
|
2129
|
+
version: import_zod.z.string()
|
|
2130
|
+
}),
|
|
2131
|
+
code: import_zod.z.string(),
|
|
2132
|
+
name: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional()
|
|
1459
2133
|
}),
|
|
1460
2134
|
import_zod.z.object({
|
|
1461
|
-
|
|
1462
|
-
|
|
2135
|
+
inline_prompt: PromptData.optional(),
|
|
2136
|
+
inline_function: import_zod.z.object({}).partial().passthrough(),
|
|
2137
|
+
function_type: FunctionTypeEnum.optional(),
|
|
2138
|
+
name: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional()
|
|
1463
2139
|
}),
|
|
1464
2140
|
import_zod.z.object({
|
|
1465
|
-
|
|
1466
|
-
|
|
2141
|
+
inline_prompt: PromptData,
|
|
2142
|
+
function_type: FunctionTypeEnum.optional(),
|
|
2143
|
+
name: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional()
|
|
2144
|
+
})
|
|
2145
|
+
]);
|
|
2146
|
+
var FunctionObjectType = import_zod.z.enum([
|
|
2147
|
+
"prompt",
|
|
2148
|
+
"tool",
|
|
2149
|
+
"scorer",
|
|
2150
|
+
"task",
|
|
2151
|
+
"agent"
|
|
2152
|
+
]);
|
|
2153
|
+
var FunctionOutputType = import_zod.z.enum(["completion", "score", "any"]);
|
|
2154
|
+
var GitMetadataSettings = import_zod.z.object({
|
|
2155
|
+
collect: import_zod.z.enum(["all", "none", "some"]),
|
|
2156
|
+
fields: import_zod.z.array(
|
|
2157
|
+
import_zod.z.enum([
|
|
2158
|
+
"commit",
|
|
2159
|
+
"branch",
|
|
2160
|
+
"tag",
|
|
2161
|
+
"dirty",
|
|
2162
|
+
"author_name",
|
|
2163
|
+
"author_email",
|
|
2164
|
+
"commit_message",
|
|
2165
|
+
"commit_time",
|
|
2166
|
+
"git_diff"
|
|
2167
|
+
])
|
|
2168
|
+
).optional()
|
|
2169
|
+
});
|
|
2170
|
+
var Group = import_zod.z.object({
|
|
2171
|
+
id: import_zod.z.string().uuid(),
|
|
2172
|
+
org_id: import_zod.z.string().uuid(),
|
|
2173
|
+
user_id: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
2174
|
+
created: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
2175
|
+
name: import_zod.z.string(),
|
|
2176
|
+
description: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
2177
|
+
deleted_at: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
2178
|
+
member_users: import_zod.z.union([import_zod.z.array(import_zod.z.string().uuid()), import_zod.z.null()]).optional(),
|
|
2179
|
+
member_groups: import_zod.z.union([import_zod.z.array(import_zod.z.string().uuid()), import_zod.z.null()]).optional()
|
|
2180
|
+
});
|
|
2181
|
+
var IfExists = import_zod.z.enum(["error", "ignore", "replace"]);
|
|
2182
|
+
var InvokeParent = import_zod.z.union([
|
|
2183
|
+
import_zod.z.object({
|
|
2184
|
+
object_type: import_zod.z.enum(["project_logs", "experiment", "playground_logs"]),
|
|
2185
|
+
object_id: import_zod.z.string(),
|
|
2186
|
+
row_ids: import_zod.z.union([
|
|
2187
|
+
import_zod.z.object({
|
|
2188
|
+
id: import_zod.z.string(),
|
|
2189
|
+
span_id: import_zod.z.string(),
|
|
2190
|
+
root_span_id: import_zod.z.string()
|
|
2191
|
+
}),
|
|
2192
|
+
import_zod.z.null()
|
|
2193
|
+
]).optional(),
|
|
2194
|
+
propagated_event: import_zod.z.union([import_zod.z.object({}).partial().passthrough(), import_zod.z.null()]).optional()
|
|
1467
2195
|
}),
|
|
2196
|
+
import_zod.z.string()
|
|
2197
|
+
]);
|
|
2198
|
+
var StreamingMode = import_zod.z.union([import_zod.z.enum(["auto", "parallel"]), import_zod.z.null()]);
|
|
2199
|
+
var InvokeFunction = FunctionId.and(
|
|
1468
2200
|
import_zod.z.object({
|
|
1469
|
-
|
|
1470
|
-
|
|
2201
|
+
input: import_zod.z.unknown(),
|
|
2202
|
+
expected: import_zod.z.unknown(),
|
|
2203
|
+
metadata: import_zod.z.union([import_zod.z.object({}).partial().passthrough(), import_zod.z.null()]),
|
|
2204
|
+
tags: import_zod.z.union([import_zod.z.array(import_zod.z.string()), import_zod.z.null()]),
|
|
2205
|
+
messages: import_zod.z.array(ChatCompletionMessageParam),
|
|
2206
|
+
parent: InvokeParent,
|
|
2207
|
+
stream: import_zod.z.union([import_zod.z.boolean(), import_zod.z.null()]),
|
|
2208
|
+
mode: StreamingMode,
|
|
2209
|
+
strict: import_zod.z.union([import_zod.z.boolean(), import_zod.z.null()])
|
|
2210
|
+
}).partial()
|
|
2211
|
+
);
|
|
2212
|
+
var MessageRole = import_zod.z.enum([
|
|
2213
|
+
"system",
|
|
2214
|
+
"user",
|
|
2215
|
+
"assistant",
|
|
2216
|
+
"function",
|
|
2217
|
+
"tool",
|
|
2218
|
+
"model",
|
|
2219
|
+
"developer"
|
|
2220
|
+
]);
|
|
2221
|
+
var OnlineScoreConfig = import_zod.z.union([
|
|
2222
|
+
import_zod.z.object({
|
|
2223
|
+
sampling_rate: import_zod.z.number().gte(0).lte(1),
|
|
2224
|
+
scorers: import_zod.z.array(SavedFunctionId),
|
|
2225
|
+
btql_filter: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
2226
|
+
apply_to_root_span: import_zod.z.union([import_zod.z.boolean(), import_zod.z.null()]).optional(),
|
|
2227
|
+
apply_to_span_names: import_zod.z.union([import_zod.z.array(import_zod.z.string()), import_zod.z.null()]).optional(),
|
|
2228
|
+
skip_logging: import_zod.z.union([import_zod.z.boolean(), import_zod.z.null()]).optional()
|
|
1471
2229
|
}),
|
|
2230
|
+
import_zod.z.null()
|
|
2231
|
+
]);
|
|
2232
|
+
var Organization = import_zod.z.object({
|
|
2233
|
+
id: import_zod.z.string().uuid(),
|
|
2234
|
+
name: import_zod.z.string(),
|
|
2235
|
+
api_url: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
2236
|
+
is_universal_api: import_zod.z.union([import_zod.z.boolean(), import_zod.z.null()]).optional(),
|
|
2237
|
+
proxy_url: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
2238
|
+
realtime_url: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
2239
|
+
created: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional()
|
|
2240
|
+
});
|
|
2241
|
+
var ProjectSettings = import_zod.z.union([
|
|
1472
2242
|
import_zod.z.object({
|
|
1473
|
-
|
|
1474
|
-
|
|
2243
|
+
comparison_key: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]),
|
|
2244
|
+
baseline_experiment_id: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]),
|
|
2245
|
+
spanFieldOrder: import_zod.z.union([
|
|
2246
|
+
import_zod.z.array(
|
|
2247
|
+
import_zod.z.object({
|
|
2248
|
+
object_type: import_zod.z.string(),
|
|
2249
|
+
column_id: import_zod.z.string(),
|
|
2250
|
+
position: import_zod.z.string(),
|
|
2251
|
+
layout: import_zod.z.union([import_zod.z.literal("full"), import_zod.z.literal("two_column"), import_zod.z.null()]).optional()
|
|
2252
|
+
})
|
|
2253
|
+
),
|
|
2254
|
+
import_zod.z.null()
|
|
2255
|
+
]),
|
|
2256
|
+
remote_eval_sources: import_zod.z.union([
|
|
2257
|
+
import_zod.z.array(
|
|
2258
|
+
import_zod.z.object({
|
|
2259
|
+
url: import_zod.z.string(),
|
|
2260
|
+
name: import_zod.z.string(),
|
|
2261
|
+
description: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional()
|
|
2262
|
+
})
|
|
2263
|
+
),
|
|
2264
|
+
import_zod.z.null()
|
|
2265
|
+
])
|
|
2266
|
+
}).partial(),
|
|
2267
|
+
import_zod.z.null()
|
|
2268
|
+
]);
|
|
2269
|
+
var Project = import_zod.z.object({
|
|
2270
|
+
id: import_zod.z.string().uuid(),
|
|
2271
|
+
org_id: import_zod.z.string().uuid(),
|
|
2272
|
+
name: import_zod.z.string(),
|
|
2273
|
+
created: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
2274
|
+
deleted_at: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
2275
|
+
user_id: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
2276
|
+
settings: ProjectSettings.optional()
|
|
2277
|
+
});
|
|
2278
|
+
var RetentionObjectType = import_zod.z.enum([
|
|
2279
|
+
"project_logs",
|
|
2280
|
+
"experiment",
|
|
2281
|
+
"dataset"
|
|
2282
|
+
]);
|
|
2283
|
+
var ProjectAutomation = import_zod.z.object({
|
|
2284
|
+
id: import_zod.z.string().uuid(),
|
|
2285
|
+
project_id: import_zod.z.string().uuid(),
|
|
2286
|
+
user_id: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
2287
|
+
created: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
2288
|
+
name: import_zod.z.string(),
|
|
2289
|
+
description: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
2290
|
+
config: import_zod.z.union([
|
|
2291
|
+
import_zod.z.object({
|
|
2292
|
+
event_type: import_zod.z.literal("logs"),
|
|
2293
|
+
btql_filter: import_zod.z.string(),
|
|
2294
|
+
interval_seconds: import_zod.z.number().gte(1).lte(2592e3),
|
|
2295
|
+
action: import_zod.z.object({ type: import_zod.z.literal("webhook"), url: import_zod.z.string() })
|
|
2296
|
+
}),
|
|
2297
|
+
import_zod.z.object({
|
|
2298
|
+
event_type: import_zod.z.literal("btql_export"),
|
|
2299
|
+
export_definition: import_zod.z.union([
|
|
2300
|
+
import_zod.z.object({ type: import_zod.z.literal("log_traces") }),
|
|
2301
|
+
import_zod.z.object({ type: import_zod.z.literal("log_spans") }),
|
|
2302
|
+
import_zod.z.object({ type: import_zod.z.literal("btql_query"), btql_query: import_zod.z.string() })
|
|
2303
|
+
]),
|
|
2304
|
+
export_path: import_zod.z.string(),
|
|
2305
|
+
format: import_zod.z.enum(["jsonl", "parquet"]),
|
|
2306
|
+
interval_seconds: import_zod.z.number().gte(1).lte(2592e3),
|
|
2307
|
+
credentials: import_zod.z.object({
|
|
2308
|
+
type: import_zod.z.literal("aws_iam"),
|
|
2309
|
+
role_arn: import_zod.z.string(),
|
|
2310
|
+
external_id: import_zod.z.string()
|
|
2311
|
+
}),
|
|
2312
|
+
batch_size: import_zod.z.union([import_zod.z.number(), import_zod.z.null()]).optional()
|
|
2313
|
+
}),
|
|
2314
|
+
import_zod.z.object({
|
|
2315
|
+
event_type: import_zod.z.literal("retention"),
|
|
2316
|
+
object_type: RetentionObjectType,
|
|
2317
|
+
retention_days: import_zod.z.number().gte(0)
|
|
2318
|
+
})
|
|
2319
|
+
])
|
|
2320
|
+
});
|
|
2321
|
+
var ProjectLogsEvent = import_zod.z.object({
|
|
2322
|
+
id: import_zod.z.string(),
|
|
2323
|
+
_xact_id: import_zod.z.string(),
|
|
2324
|
+
_pagination_key: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
2325
|
+
created: import_zod.z.string().datetime({ offset: true }),
|
|
2326
|
+
org_id: import_zod.z.string().uuid(),
|
|
2327
|
+
project_id: import_zod.z.string().uuid(),
|
|
2328
|
+
log_id: import_zod.z.literal("g"),
|
|
2329
|
+
input: import_zod.z.unknown().optional(),
|
|
2330
|
+
output: import_zod.z.unknown().optional(),
|
|
2331
|
+
expected: import_zod.z.unknown().optional(),
|
|
2332
|
+
error: import_zod.z.unknown().optional(),
|
|
2333
|
+
scores: import_zod.z.union([import_zod.z.record(import_zod.z.union([import_zod.z.number(), import_zod.z.null()])), import_zod.z.null()]).optional(),
|
|
2334
|
+
metadata: import_zod.z.union([
|
|
2335
|
+
import_zod.z.object({ model: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]) }).partial().passthrough(),
|
|
2336
|
+
import_zod.z.null()
|
|
2337
|
+
]).optional(),
|
|
2338
|
+
tags: import_zod.z.union([import_zod.z.array(import_zod.z.string()), import_zod.z.null()]).optional(),
|
|
2339
|
+
metrics: import_zod.z.union([import_zod.z.record(import_zod.z.number()), import_zod.z.null()]).optional(),
|
|
2340
|
+
context: import_zod.z.union([
|
|
2341
|
+
import_zod.z.object({
|
|
2342
|
+
caller_functionname: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]),
|
|
2343
|
+
caller_filename: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]),
|
|
2344
|
+
caller_lineno: import_zod.z.union([import_zod.z.number(), import_zod.z.null()])
|
|
2345
|
+
}).partial().passthrough(),
|
|
2346
|
+
import_zod.z.null()
|
|
2347
|
+
]).optional(),
|
|
2348
|
+
span_id: import_zod.z.string(),
|
|
2349
|
+
span_parents: import_zod.z.union([import_zod.z.array(import_zod.z.string()), import_zod.z.null()]).optional(),
|
|
2350
|
+
root_span_id: import_zod.z.string(),
|
|
2351
|
+
is_root: import_zod.z.union([import_zod.z.boolean(), import_zod.z.null()]).optional(),
|
|
2352
|
+
span_attributes: SpanAttributes.optional(),
|
|
2353
|
+
origin: ObjectReference.optional()
|
|
2354
|
+
});
|
|
2355
|
+
var ProjectScoreType = import_zod.z.enum([
|
|
2356
|
+
"slider",
|
|
2357
|
+
"categorical",
|
|
2358
|
+
"weighted",
|
|
2359
|
+
"minimum",
|
|
2360
|
+
"maximum",
|
|
2361
|
+
"online",
|
|
2362
|
+
"free-form"
|
|
2363
|
+
]);
|
|
2364
|
+
var ProjectScoreCategory = import_zod.z.object({
|
|
2365
|
+
name: import_zod.z.string(),
|
|
2366
|
+
value: import_zod.z.number()
|
|
2367
|
+
});
|
|
2368
|
+
var ProjectScoreCategories = import_zod.z.union([
|
|
2369
|
+
import_zod.z.array(ProjectScoreCategory),
|
|
2370
|
+
import_zod.z.record(import_zod.z.number()),
|
|
2371
|
+
import_zod.z.array(import_zod.z.string()),
|
|
2372
|
+
import_zod.z.null()
|
|
2373
|
+
]);
|
|
2374
|
+
var ProjectScoreConfig = import_zod.z.union([
|
|
2375
|
+
import_zod.z.object({
|
|
2376
|
+
multi_select: import_zod.z.union([import_zod.z.boolean(), import_zod.z.null()]),
|
|
2377
|
+
destination: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]),
|
|
2378
|
+
online: OnlineScoreConfig
|
|
2379
|
+
}).partial(),
|
|
2380
|
+
import_zod.z.null()
|
|
2381
|
+
]);
|
|
2382
|
+
var ProjectScore = import_zod.z.object({
|
|
2383
|
+
id: import_zod.z.string().uuid(),
|
|
2384
|
+
project_id: import_zod.z.string().uuid(),
|
|
2385
|
+
user_id: import_zod.z.string().uuid(),
|
|
2386
|
+
created: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
2387
|
+
name: import_zod.z.string(),
|
|
2388
|
+
description: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
2389
|
+
score_type: ProjectScoreType,
|
|
2390
|
+
categories: ProjectScoreCategories.optional(),
|
|
2391
|
+
config: ProjectScoreConfig.optional(),
|
|
2392
|
+
position: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional()
|
|
2393
|
+
});
|
|
2394
|
+
var ProjectTag = import_zod.z.object({
|
|
2395
|
+
id: import_zod.z.string().uuid(),
|
|
2396
|
+
project_id: import_zod.z.string().uuid(),
|
|
2397
|
+
user_id: import_zod.z.string().uuid(),
|
|
2398
|
+
created: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
2399
|
+
name: import_zod.z.string(),
|
|
2400
|
+
description: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
2401
|
+
color: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
2402
|
+
position: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional()
|
|
2403
|
+
});
|
|
2404
|
+
var Prompt = import_zod.z.object({
|
|
2405
|
+
id: import_zod.z.string().uuid(),
|
|
2406
|
+
_xact_id: import_zod.z.string(),
|
|
2407
|
+
project_id: import_zod.z.string().uuid(),
|
|
2408
|
+
log_id: import_zod.z.literal("p"),
|
|
2409
|
+
org_id: import_zod.z.string().uuid(),
|
|
2410
|
+
name: import_zod.z.string(),
|
|
2411
|
+
slug: import_zod.z.string(),
|
|
2412
|
+
description: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
2413
|
+
created: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
2414
|
+
prompt_data: PromptDataNullish.optional(),
|
|
2415
|
+
tags: import_zod.z.union([import_zod.z.array(import_zod.z.string()), import_zod.z.null()]).optional(),
|
|
2416
|
+
metadata: import_zod.z.union([import_zod.z.object({}).partial().passthrough(), import_zod.z.null()]).optional(),
|
|
2417
|
+
function_type: FunctionTypeEnumNullish.optional()
|
|
2418
|
+
});
|
|
2419
|
+
var PromptOptions = import_zod.z.object({ model: import_zod.z.string(), params: ModelParams, position: import_zod.z.string() }).partial();
|
|
2420
|
+
var PromptSessionEvent = import_zod.z.object({
|
|
2421
|
+
id: import_zod.z.string(),
|
|
2422
|
+
_xact_id: import_zod.z.string(),
|
|
2423
|
+
created: import_zod.z.string().datetime({ offset: true }),
|
|
2424
|
+
_pagination_key: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
2425
|
+
project_id: import_zod.z.string().uuid(),
|
|
2426
|
+
prompt_session_id: import_zod.z.string().uuid(),
|
|
2427
|
+
prompt_session_data: import_zod.z.unknown().optional(),
|
|
2428
|
+
prompt_data: import_zod.z.unknown().optional(),
|
|
2429
|
+
function_data: import_zod.z.unknown().optional(),
|
|
2430
|
+
function_type: FunctionTypeEnumNullish.optional(),
|
|
2431
|
+
object_data: import_zod.z.unknown().optional(),
|
|
2432
|
+
completion: import_zod.z.unknown().optional(),
|
|
2433
|
+
tags: import_zod.z.union([import_zod.z.array(import_zod.z.string()), import_zod.z.null()]).optional()
|
|
2434
|
+
});
|
|
2435
|
+
var Role = import_zod.z.object({
|
|
2436
|
+
id: import_zod.z.string().uuid(),
|
|
2437
|
+
org_id: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
2438
|
+
user_id: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
2439
|
+
created: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
2440
|
+
name: import_zod.z.string(),
|
|
2441
|
+
description: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
2442
|
+
deleted_at: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
2443
|
+
member_permissions: import_zod.z.union([
|
|
2444
|
+
import_zod.z.array(
|
|
2445
|
+
import_zod.z.object({
|
|
2446
|
+
permission: Permission,
|
|
2447
|
+
restrict_object_type: AclObjectType.optional()
|
|
2448
|
+
})
|
|
2449
|
+
),
|
|
2450
|
+
import_zod.z.null()
|
|
2451
|
+
]).optional(),
|
|
2452
|
+
member_roles: import_zod.z.union([import_zod.z.array(import_zod.z.string().uuid()), import_zod.z.null()]).optional()
|
|
2453
|
+
});
|
|
2454
|
+
var RunEval = import_zod.z.object({
|
|
2455
|
+
project_id: import_zod.z.string(),
|
|
2456
|
+
data: import_zod.z.union([
|
|
2457
|
+
import_zod.z.object({
|
|
2458
|
+
dataset_id: import_zod.z.string(),
|
|
2459
|
+
_internal_btql: import_zod.z.union([import_zod.z.object({}).partial().passthrough(), import_zod.z.null()]).optional()
|
|
2460
|
+
}),
|
|
2461
|
+
import_zod.z.object({
|
|
2462
|
+
project_name: import_zod.z.string(),
|
|
2463
|
+
dataset_name: import_zod.z.string(),
|
|
2464
|
+
_internal_btql: import_zod.z.union([import_zod.z.object({}).partial().passthrough(), import_zod.z.null()]).optional()
|
|
2465
|
+
}),
|
|
2466
|
+
import_zod.z.object({ data: import_zod.z.array(import_zod.z.unknown()) })
|
|
2467
|
+
]),
|
|
2468
|
+
task: FunctionId.and(import_zod.z.unknown()),
|
|
2469
|
+
scores: import_zod.z.array(FunctionId),
|
|
2470
|
+
experiment_name: import_zod.z.string().optional(),
|
|
2471
|
+
metadata: import_zod.z.object({}).partial().passthrough().optional(),
|
|
2472
|
+
parent: InvokeParent.and(import_zod.z.unknown()).optional(),
|
|
2473
|
+
stream: import_zod.z.boolean().optional(),
|
|
2474
|
+
trial_count: import_zod.z.union([import_zod.z.number(), import_zod.z.null()]).optional(),
|
|
2475
|
+
is_public: import_zod.z.union([import_zod.z.boolean(), import_zod.z.null()]).optional(),
|
|
2476
|
+
timeout: import_zod.z.union([import_zod.z.number(), import_zod.z.null()]).optional(),
|
|
2477
|
+
max_concurrency: import_zod.z.union([import_zod.z.number(), import_zod.z.null()]).optional().default(10),
|
|
2478
|
+
base_experiment_name: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
2479
|
+
base_experiment_id: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
2480
|
+
git_metadata_settings: GitMetadataSettings.and(
|
|
2481
|
+
import_zod.z.union([import_zod.z.object({}).partial(), import_zod.z.null()])
|
|
2482
|
+
).optional(),
|
|
2483
|
+
repo_info: RepoInfo.and(import_zod.z.unknown()).optional(),
|
|
2484
|
+
strict: import_zod.z.union([import_zod.z.boolean(), import_zod.z.null()]).optional(),
|
|
2485
|
+
stop_token: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
2486
|
+
extra_messages: import_zod.z.string().optional(),
|
|
2487
|
+
tags: import_zod.z.array(import_zod.z.string()).optional()
|
|
2488
|
+
});
|
|
2489
|
+
var ServiceToken = import_zod.z.object({
|
|
2490
|
+
id: import_zod.z.string().uuid(),
|
|
2491
|
+
created: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
2492
|
+
name: import_zod.z.string(),
|
|
2493
|
+
preview_name: import_zod.z.string(),
|
|
2494
|
+
user_id: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
2495
|
+
user_email: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
2496
|
+
user_given_name: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
2497
|
+
user_family_name: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
2498
|
+
org_id: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional()
|
|
2499
|
+
});
|
|
2500
|
+
var SpanIFrame = import_zod.z.object({
|
|
2501
|
+
id: import_zod.z.string().uuid(),
|
|
2502
|
+
project_id: import_zod.z.string().uuid(),
|
|
2503
|
+
user_id: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
2504
|
+
created: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
2505
|
+
deleted_at: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
2506
|
+
name: import_zod.z.string(),
|
|
2507
|
+
description: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
2508
|
+
url: import_zod.z.string(),
|
|
2509
|
+
post_message: import_zod.z.union([import_zod.z.boolean(), import_zod.z.null()]).optional()
|
|
2510
|
+
});
|
|
2511
|
+
var SSEConsoleEventData = import_zod.z.object({
|
|
2512
|
+
stream: import_zod.z.enum(["stderr", "stdout"]),
|
|
2513
|
+
message: import_zod.z.string()
|
|
2514
|
+
});
|
|
2515
|
+
var SSEProgressEventData = import_zod.z.object({
|
|
2516
|
+
id: import_zod.z.string(),
|
|
2517
|
+
object_type: FunctionObjectType,
|
|
2518
|
+
origin: ObjectReference.and(import_zod.z.unknown()).optional(),
|
|
2519
|
+
format: FunctionFormat,
|
|
2520
|
+
output_type: FunctionOutputType,
|
|
2521
|
+
name: import_zod.z.string(),
|
|
2522
|
+
event: import_zod.z.enum([
|
|
2523
|
+
"reasoning_delta",
|
|
2524
|
+
"text_delta",
|
|
2525
|
+
"json_delta",
|
|
2526
|
+
"error",
|
|
2527
|
+
"console",
|
|
2528
|
+
"start",
|
|
2529
|
+
"done",
|
|
2530
|
+
"progress"
|
|
2531
|
+
]),
|
|
2532
|
+
data: import_zod.z.string()
|
|
2533
|
+
});
|
|
2534
|
+
var ToolFunctionDefinition = import_zod.z.object({
|
|
2535
|
+
type: import_zod.z.literal("function"),
|
|
2536
|
+
function: import_zod.z.object({
|
|
2537
|
+
name: import_zod.z.string(),
|
|
2538
|
+
description: import_zod.z.string().optional(),
|
|
2539
|
+
parameters: import_zod.z.object({}).partial().passthrough().optional(),
|
|
2540
|
+
strict: import_zod.z.union([import_zod.z.boolean(), import_zod.z.null()]).optional()
|
|
2541
|
+
})
|
|
2542
|
+
});
|
|
2543
|
+
var User = import_zod.z.object({
|
|
2544
|
+
id: import_zod.z.string().uuid(),
|
|
2545
|
+
given_name: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
2546
|
+
family_name: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
2547
|
+
email: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
2548
|
+
avatar_url: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
2549
|
+
created: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional()
|
|
2550
|
+
});
|
|
2551
|
+
var ViewDataSearch = import_zod.z.union([
|
|
2552
|
+
import_zod.z.object({
|
|
2553
|
+
filter: import_zod.z.union([import_zod.z.array(import_zod.z.unknown()), import_zod.z.null()]),
|
|
2554
|
+
tag: import_zod.z.union([import_zod.z.array(import_zod.z.unknown()), import_zod.z.null()]),
|
|
2555
|
+
match: import_zod.z.union([import_zod.z.array(import_zod.z.unknown()), import_zod.z.null()]),
|
|
2556
|
+
sort: import_zod.z.union([import_zod.z.array(import_zod.z.unknown()), import_zod.z.null()])
|
|
2557
|
+
}).partial(),
|
|
2558
|
+
import_zod.z.null()
|
|
2559
|
+
]);
|
|
2560
|
+
var ViewData = import_zod.z.union([
|
|
2561
|
+
import_zod.z.object({ search: ViewDataSearch }).partial(),
|
|
2562
|
+
import_zod.z.null()
|
|
2563
|
+
]);
|
|
2564
|
+
var ViewOptions = import_zod.z.union([
|
|
2565
|
+
import_zod.z.object({
|
|
2566
|
+
viewType: import_zod.z.literal("monitor"),
|
|
2567
|
+
options: import_zod.z.object({
|
|
2568
|
+
spanType: import_zod.z.union([import_zod.z.enum(["range", "frame"]), import_zod.z.null()]),
|
|
2569
|
+
rangeValue: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]),
|
|
2570
|
+
frameStart: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]),
|
|
2571
|
+
frameEnd: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]),
|
|
2572
|
+
tzUTC: import_zod.z.union([import_zod.z.boolean(), import_zod.z.null()]),
|
|
2573
|
+
chartVisibility: import_zod.z.union([import_zod.z.record(import_zod.z.boolean()), import_zod.z.null()]),
|
|
2574
|
+
projectId: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]),
|
|
2575
|
+
type: import_zod.z.union([import_zod.z.enum(["project", "experiment"]), import_zod.z.null()]),
|
|
2576
|
+
groupBy: import_zod.z.union([import_zod.z.string(), import_zod.z.null()])
|
|
2577
|
+
}).partial()
|
|
1475
2578
|
}),
|
|
1476
2579
|
import_zod.z.object({
|
|
1477
|
-
|
|
1478
|
-
|
|
2580
|
+
columnVisibility: import_zod.z.union([import_zod.z.record(import_zod.z.boolean()), import_zod.z.null()]),
|
|
2581
|
+
columnOrder: import_zod.z.union([import_zod.z.array(import_zod.z.string()), import_zod.z.null()]),
|
|
2582
|
+
columnSizing: import_zod.z.union([import_zod.z.record(import_zod.z.number()), import_zod.z.null()]),
|
|
2583
|
+
grouping: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]),
|
|
2584
|
+
rowHeight: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]),
|
|
2585
|
+
tallGroupRows: import_zod.z.union([import_zod.z.boolean(), import_zod.z.null()]),
|
|
2586
|
+
layout: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]),
|
|
2587
|
+
chartHeight: import_zod.z.union([import_zod.z.number(), import_zod.z.null()]),
|
|
2588
|
+
excludedMeasures: import_zod.z.union([
|
|
2589
|
+
import_zod.z.array(
|
|
2590
|
+
import_zod.z.object({
|
|
2591
|
+
type: import_zod.z.enum(["none", "score", "metric", "metadata"]),
|
|
2592
|
+
value: import_zod.z.string()
|
|
2593
|
+
})
|
|
2594
|
+
),
|
|
2595
|
+
import_zod.z.null()
|
|
2596
|
+
]),
|
|
2597
|
+
yMetric: import_zod.z.union([
|
|
2598
|
+
import_zod.z.object({
|
|
2599
|
+
type: import_zod.z.enum(["none", "score", "metric", "metadata"]),
|
|
2600
|
+
value: import_zod.z.string()
|
|
2601
|
+
}),
|
|
2602
|
+
import_zod.z.null()
|
|
2603
|
+
]),
|
|
2604
|
+
xAxis: import_zod.z.union([
|
|
2605
|
+
import_zod.z.object({
|
|
2606
|
+
type: import_zod.z.enum(["none", "score", "metric", "metadata"]),
|
|
2607
|
+
value: import_zod.z.string()
|
|
2608
|
+
}),
|
|
2609
|
+
import_zod.z.null()
|
|
2610
|
+
]),
|
|
2611
|
+
symbolGrouping: import_zod.z.union([
|
|
2612
|
+
import_zod.z.object({
|
|
2613
|
+
type: import_zod.z.enum(["none", "score", "metric", "metadata"]),
|
|
2614
|
+
value: import_zod.z.string()
|
|
2615
|
+
}),
|
|
2616
|
+
import_zod.z.null()
|
|
2617
|
+
]),
|
|
2618
|
+
xAxisAggregation: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]),
|
|
2619
|
+
chartAnnotations: import_zod.z.union([
|
|
2620
|
+
import_zod.z.array(import_zod.z.object({ id: import_zod.z.string(), text: import_zod.z.string() })),
|
|
2621
|
+
import_zod.z.null()
|
|
2622
|
+
]),
|
|
2623
|
+
timeRangeFilter: import_zod.z.union([
|
|
2624
|
+
import_zod.z.string(),
|
|
2625
|
+
import_zod.z.object({ from: import_zod.z.string(), to: import_zod.z.string() }),
|
|
2626
|
+
import_zod.z.null()
|
|
2627
|
+
])
|
|
2628
|
+
}).partial(),
|
|
2629
|
+
import_zod.z.null()
|
|
2630
|
+
]);
|
|
2631
|
+
var View = import_zod.z.object({
|
|
2632
|
+
id: import_zod.z.string().uuid(),
|
|
2633
|
+
object_type: AclObjectType.and(import_zod.z.string()),
|
|
2634
|
+
object_id: import_zod.z.string().uuid(),
|
|
2635
|
+
view_type: import_zod.z.enum([
|
|
2636
|
+
"projects",
|
|
2637
|
+
"experiments",
|
|
2638
|
+
"experiment",
|
|
2639
|
+
"playgrounds",
|
|
2640
|
+
"playground",
|
|
2641
|
+
"datasets",
|
|
2642
|
+
"dataset",
|
|
2643
|
+
"prompts",
|
|
2644
|
+
"tools",
|
|
2645
|
+
"scorers",
|
|
2646
|
+
"logs",
|
|
2647
|
+
"agents",
|
|
2648
|
+
"monitor"
|
|
2649
|
+
]),
|
|
2650
|
+
name: import_zod.z.string(),
|
|
2651
|
+
created: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
2652
|
+
view_data: ViewData.optional(),
|
|
2653
|
+
options: ViewOptions.optional(),
|
|
2654
|
+
user_id: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional(),
|
|
2655
|
+
deleted_at: import_zod.z.union([import_zod.z.string(), import_zod.z.null()]).optional()
|
|
2656
|
+
});
|
|
2657
|
+
|
|
2658
|
+
// src/logger.ts
|
|
2659
|
+
var import_functions = require("@vercel/functions");
|
|
2660
|
+
var import_mustache2 = __toESM(require("mustache"));
|
|
2661
|
+
var import_zod3 = require("zod");
|
|
2662
|
+
|
|
2663
|
+
// src/functions/stream.ts
|
|
2664
|
+
var import_eventsource_parser = require("eventsource-parser");
|
|
2665
|
+
var import_zod2 = require("zod");
|
|
2666
|
+
var braintrustStreamChunkSchema = import_zod2.z.union([
|
|
2667
|
+
import_zod2.z.object({
|
|
2668
|
+
type: import_zod2.z.literal("text_delta"),
|
|
2669
|
+
data: import_zod2.z.string()
|
|
2670
|
+
}),
|
|
2671
|
+
import_zod2.z.object({
|
|
2672
|
+
type: import_zod2.z.literal("reasoning_delta"),
|
|
2673
|
+
data: import_zod2.z.string()
|
|
2674
|
+
}),
|
|
2675
|
+
import_zod2.z.object({
|
|
2676
|
+
type: import_zod2.z.literal("json_delta"),
|
|
2677
|
+
data: import_zod2.z.string()
|
|
2678
|
+
}),
|
|
2679
|
+
import_zod2.z.object({
|
|
2680
|
+
type: import_zod2.z.literal("error"),
|
|
2681
|
+
data: import_zod2.z.string()
|
|
2682
|
+
}),
|
|
2683
|
+
import_zod2.z.object({
|
|
2684
|
+
type: import_zod2.z.literal("console"),
|
|
2685
|
+
data: SSEConsoleEventData
|
|
2686
|
+
}),
|
|
2687
|
+
import_zod2.z.object({
|
|
2688
|
+
type: import_zod2.z.literal("progress"),
|
|
2689
|
+
data: SSEProgressEventData
|
|
2690
|
+
}),
|
|
2691
|
+
import_zod2.z.object({
|
|
2692
|
+
type: import_zod2.z.literal("start"),
|
|
2693
|
+
data: import_zod2.z.string()
|
|
2694
|
+
}),
|
|
2695
|
+
import_zod2.z.object({
|
|
2696
|
+
type: import_zod2.z.literal("done"),
|
|
2697
|
+
data: import_zod2.z.string()
|
|
1479
2698
|
})
|
|
1480
2699
|
]);
|
|
1481
2700
|
var BraintrustStream = class _BraintrustStream {
|
|
@@ -1583,12 +2802,12 @@ var BraintrustStream = class _BraintrustStream {
|
|
|
1583
2802
|
case "progress":
|
|
1584
2803
|
return {
|
|
1585
2804
|
type: "progress",
|
|
1586
|
-
data:
|
|
2805
|
+
data: SSEProgressEventData.parse(JSON.parse(event.data))
|
|
1587
2806
|
};
|
|
1588
2807
|
case "console":
|
|
1589
2808
|
return {
|
|
1590
2809
|
type: "console",
|
|
1591
|
-
data:
|
|
2810
|
+
data: SSEConsoleEventData.parse(JSON.parse(event.data))
|
|
1592
2811
|
};
|
|
1593
2812
|
case "start":
|
|
1594
2813
|
return {
|
|
@@ -1664,7 +2883,7 @@ function btStreamParser() {
|
|
|
1664
2883
|
if (event.type === "reconnect-interval") {
|
|
1665
2884
|
return;
|
|
1666
2885
|
}
|
|
1667
|
-
const parsed =
|
|
2886
|
+
const parsed = CallEvent.safeParse(event);
|
|
1668
2887
|
if (!parsed.success) {
|
|
1669
2888
|
throw new Error(`Failed to parse event: ${parsed.error}`);
|
|
1670
2889
|
}
|
|
@@ -2107,6 +3326,44 @@ function getMustacheVars(prompt) {
|
|
|
2107
3326
|
}
|
|
2108
3327
|
|
|
2109
3328
|
// src/logger.ts
|
|
3329
|
+
var import_core3 = require("@braintrust/core");
|
|
3330
|
+
var BRAINTRUST_ATTACHMENT = BraintrustAttachmentReference.shape.type.value;
|
|
3331
|
+
var EXTERNAL_ATTACHMENT = ExternalAttachmentReference.shape.type.value;
|
|
3332
|
+
var BRAINTRUST_PARAMS = Object.keys(BraintrustModelParams.shape);
|
|
3333
|
+
var REDACTION_FIELDS = [
|
|
3334
|
+
"input",
|
|
3335
|
+
"output",
|
|
3336
|
+
"expected",
|
|
3337
|
+
"metadata",
|
|
3338
|
+
"context",
|
|
3339
|
+
"scores",
|
|
3340
|
+
"metrics"
|
|
3341
|
+
];
|
|
3342
|
+
var MaskingError = class {
|
|
3343
|
+
constructor(fieldName, errorType) {
|
|
3344
|
+
this.fieldName = fieldName;
|
|
3345
|
+
this.errorType = errorType;
|
|
3346
|
+
}
|
|
3347
|
+
get errorMsg() {
|
|
3348
|
+
return `ERROR: Failed to mask field '${this.fieldName}' - ${this.errorType}`;
|
|
3349
|
+
}
|
|
3350
|
+
};
|
|
3351
|
+
function applyMaskingToField(maskingFunction, data, fieldName) {
|
|
3352
|
+
try {
|
|
3353
|
+
return maskingFunction(data);
|
|
3354
|
+
} catch (error2) {
|
|
3355
|
+
const errorType = error2 instanceof Error ? error2.constructor.name : "Error";
|
|
3356
|
+
if (fieldName === "scores" || fieldName === "metrics") {
|
|
3357
|
+
return new MaskingError(fieldName, errorType);
|
|
3358
|
+
}
|
|
3359
|
+
if (fieldName === "metadata") {
|
|
3360
|
+
return {
|
|
3361
|
+
error: `ERROR: Failed to mask field '${fieldName}' - ${errorType}`
|
|
3362
|
+
};
|
|
3363
|
+
}
|
|
3364
|
+
return `ERROR: Failed to mask field '${fieldName}' - ${errorType}`;
|
|
3365
|
+
}
|
|
3366
|
+
}
|
|
2110
3367
|
var NoopSpan = class {
|
|
2111
3368
|
id;
|
|
2112
3369
|
spanId;
|
|
@@ -2157,15 +3414,15 @@ var NoopSpan = class {
|
|
|
2157
3414
|
};
|
|
2158
3415
|
var NOOP_SPAN = new NoopSpan();
|
|
2159
3416
|
var NOOP_SPAN_PERMALINK = "https://braintrust.dev/noop-span";
|
|
2160
|
-
var loginSchema =
|
|
2161
|
-
appUrl:
|
|
2162
|
-
appPublicUrl:
|
|
2163
|
-
orgName:
|
|
2164
|
-
apiUrl:
|
|
2165
|
-
proxyUrl:
|
|
2166
|
-
loginToken:
|
|
2167
|
-
orgId:
|
|
2168
|
-
gitMetadataSettings:
|
|
3417
|
+
var loginSchema = import_zod3.z.strictObject({
|
|
3418
|
+
appUrl: import_zod3.z.string(),
|
|
3419
|
+
appPublicUrl: import_zod3.z.string(),
|
|
3420
|
+
orgName: import_zod3.z.string(),
|
|
3421
|
+
apiUrl: import_zod3.z.string(),
|
|
3422
|
+
proxyUrl: import_zod3.z.string(),
|
|
3423
|
+
loginToken: import_zod3.z.string(),
|
|
3424
|
+
orgId: import_zod3.z.string().nullish(),
|
|
3425
|
+
gitMetadataSettings: GitMetadataSettings.nullish()
|
|
2169
3426
|
});
|
|
2170
3427
|
var stateNonce = 0;
|
|
2171
3428
|
var BraintrustState = class _BraintrustState {
|
|
@@ -2307,6 +3564,9 @@ var BraintrustState = class _BraintrustState {
|
|
|
2307
3564
|
this._apiConn?.setFetch(fetch2);
|
|
2308
3565
|
this._appConn?.setFetch(fetch2);
|
|
2309
3566
|
}
|
|
3567
|
+
setMaskingFunction(maskingFunction) {
|
|
3568
|
+
this.bgLogger().setMaskingFunction(maskingFunction);
|
|
3569
|
+
}
|
|
2310
3570
|
async login(loginParams) {
|
|
2311
3571
|
if (this.apiUrl && !loginParams.forceLogin) {
|
|
2312
3572
|
return;
|
|
@@ -2548,7 +3808,7 @@ var Attachment = class extends BaseAttachment {
|
|
|
2548
3808
|
constructor({ data, filename, contentType, state }) {
|
|
2549
3809
|
super();
|
|
2550
3810
|
this.reference = {
|
|
2551
|
-
type:
|
|
3811
|
+
type: BRAINTRUST_ATTACHMENT,
|
|
2552
3812
|
filename,
|
|
2553
3813
|
content_type: contentType,
|
|
2554
3814
|
key: newId()
|
|
@@ -2614,12 +3874,12 @@ var Attachment = class extends BaseAttachment {
|
|
|
2614
3874
|
let signedUrl;
|
|
2615
3875
|
let headers;
|
|
2616
3876
|
try {
|
|
2617
|
-
({ signedUrl, headers } =
|
|
2618
|
-
signedUrl:
|
|
2619
|
-
headers:
|
|
3877
|
+
({ signedUrl, headers } = import_zod3.z.object({
|
|
3878
|
+
signedUrl: import_zod3.z.string().url(),
|
|
3879
|
+
headers: import_zod3.z.record(import_zod3.z.string())
|
|
2620
3880
|
}).parse(await metadataResponse.json()));
|
|
2621
3881
|
} catch (error2) {
|
|
2622
|
-
if (error2 instanceof
|
|
3882
|
+
if (error2 instanceof import_zod3.ZodError) {
|
|
2623
3883
|
const errorStr = JSON.stringify(error2.flatten());
|
|
2624
3884
|
throw new Error(`Invalid response from API server: ${errorStr}`);
|
|
2625
3885
|
}
|
|
@@ -2676,6 +3936,7 @@ var Attachment = class extends BaseAttachment {
|
|
|
2676
3936
|
}
|
|
2677
3937
|
initData(data) {
|
|
2678
3938
|
if (typeof data === "string") {
|
|
3939
|
+
this.ensureFileReadable(data);
|
|
2679
3940
|
const readFile3 = isomorph_default.readFile;
|
|
2680
3941
|
if (!readFile3) {
|
|
2681
3942
|
throw new Error(
|
|
@@ -2688,10 +3949,24 @@ with a Blob/ArrayBuffer, or run the program on Node.js.`
|
|
|
2688
3949
|
return new LazyValue(async () => new Blob([data]));
|
|
2689
3950
|
}
|
|
2690
3951
|
}
|
|
3952
|
+
ensureFileReadable(data) {
|
|
3953
|
+
const statSync2 = isomorph_default.statSync;
|
|
3954
|
+
if (!statSync2) {
|
|
3955
|
+
throw new Error(
|
|
3956
|
+
`This platform does not support reading the filesystem. Construct the Attachment
|
|
3957
|
+
with a Blob/ArrayBuffer, or run the program on Node.js.`
|
|
3958
|
+
);
|
|
3959
|
+
}
|
|
3960
|
+
try {
|
|
3961
|
+
statSync2(data);
|
|
3962
|
+
} catch (e) {
|
|
3963
|
+
console.warn(`Failed to read file: ${e}`);
|
|
3964
|
+
}
|
|
3965
|
+
}
|
|
2691
3966
|
};
|
|
2692
|
-
var attachmentMetadataSchema =
|
|
2693
|
-
downloadUrl:
|
|
2694
|
-
status:
|
|
3967
|
+
var attachmentMetadataSchema = import_zod3.z.object({
|
|
3968
|
+
downloadUrl: import_zod3.z.string(),
|
|
3969
|
+
status: AttachmentStatus
|
|
2695
3970
|
});
|
|
2696
3971
|
var ReadonlyAttachment = class {
|
|
2697
3972
|
/**
|
|
@@ -3216,6 +4491,7 @@ var HTTPBackgroundLogger = class _HTTPBackgroundLogger {
|
|
|
3216
4491
|
activeFlushResolved = true;
|
|
3217
4492
|
activeFlushError = void 0;
|
|
3218
4493
|
onFlushError;
|
|
4494
|
+
maskingFunction = null;
|
|
3219
4495
|
syncFlush = false;
|
|
3220
4496
|
// 6 MB for the AWS lambda gateway (from our own testing).
|
|
3221
4497
|
maxRequestSize = 6 * 1024 * 1024;
|
|
@@ -3283,6 +4559,9 @@ var HTTPBackgroundLogger = class _HTTPBackgroundLogger {
|
|
|
3283
4559
|
}
|
|
3284
4560
|
this.onFlushError = opts.onFlushError;
|
|
3285
4561
|
}
|
|
4562
|
+
setMaskingFunction(maskingFunction) {
|
|
4563
|
+
this.maskingFunction = maskingFunction;
|
|
4564
|
+
}
|
|
3286
4565
|
log(items) {
|
|
3287
4566
|
if (this._disabled) {
|
|
3288
4567
|
return;
|
|
@@ -3379,7 +4658,36 @@ var HTTPBackgroundLogger = class _HTTPBackgroundLogger {
|
|
|
3379
4658
|
const items = await Promise.all(wrappedItems.map((x) => x.get()));
|
|
3380
4659
|
const attachments = [];
|
|
3381
4660
|
items.forEach((item) => extractAttachments(item, attachments));
|
|
3382
|
-
|
|
4661
|
+
let mergedItems = (0, import_core2.mergeRowBatch)(items);
|
|
4662
|
+
if (this.maskingFunction) {
|
|
4663
|
+
mergedItems = mergedItems.map(
|
|
4664
|
+
(batch) => batch.map((item) => {
|
|
4665
|
+
const maskedItem = { ...item };
|
|
4666
|
+
for (const field of REDACTION_FIELDS) {
|
|
4667
|
+
if (item[field] !== void 0) {
|
|
4668
|
+
const maskedValue = applyMaskingToField(
|
|
4669
|
+
this.maskingFunction,
|
|
4670
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4671
|
+
item[field],
|
|
4672
|
+
field
|
|
4673
|
+
);
|
|
4674
|
+
if (maskedValue instanceof MaskingError) {
|
|
4675
|
+
delete maskedItem[field];
|
|
4676
|
+
if (maskedItem.error) {
|
|
4677
|
+
maskedItem.error = `${maskedItem.error}; ${maskedValue.errorMsg}`;
|
|
4678
|
+
} else {
|
|
4679
|
+
maskedItem.error = maskedValue.errorMsg;
|
|
4680
|
+
}
|
|
4681
|
+
} else {
|
|
4682
|
+
maskedItem[field] = maskedValue;
|
|
4683
|
+
}
|
|
4684
|
+
}
|
|
4685
|
+
}
|
|
4686
|
+
return maskedItem;
|
|
4687
|
+
})
|
|
4688
|
+
);
|
|
4689
|
+
}
|
|
4690
|
+
return [mergedItems, attachments];
|
|
3383
4691
|
} catch (e) {
|
|
3384
4692
|
let errmsg = "Encountered error when constructing records to flush";
|
|
3385
4693
|
const isRetrying = i + 1 < this.numTries;
|
|
@@ -3727,7 +5035,7 @@ function init(projectOrOptions, optionalOptions) {
|
|
|
3727
5035
|
};
|
|
3728
5036
|
}
|
|
3729
5037
|
);
|
|
3730
|
-
const ret = new
|
|
5038
|
+
const ret = new Experiment2(state, lazyMetadata, dataset);
|
|
3731
5039
|
if (options.setCurrent ?? true) {
|
|
3732
5040
|
state.currentExperiment = ret;
|
|
3733
5041
|
}
|
|
@@ -3795,7 +5103,7 @@ function initDataset(projectOrOptions, optionalOptions) {
|
|
|
3795
5103
|
};
|
|
3796
5104
|
}
|
|
3797
5105
|
);
|
|
3798
|
-
return new
|
|
5106
|
+
return new Dataset2(
|
|
3799
5107
|
stateArg ?? _globalState,
|
|
3800
5108
|
lazyMetadata,
|
|
3801
5109
|
version2,
|
|
@@ -4143,13 +5451,13 @@ function validateAndSanitizeExperimentLogPartialArgs(event) {
|
|
|
4143
5451
|
function deepCopyEvent(event) {
|
|
4144
5452
|
const attachments = [];
|
|
4145
5453
|
const IDENTIFIER = "_bt_internal_saved_attachment";
|
|
4146
|
-
const savedAttachmentSchema =
|
|
5454
|
+
const savedAttachmentSchema = import_zod3.z.strictObject({ [IDENTIFIER]: import_zod3.z.number() });
|
|
4147
5455
|
const serialized = JSON.stringify(event, (_k, v) => {
|
|
4148
5456
|
if (v instanceof SpanImpl || v instanceof NoopSpan) {
|
|
4149
5457
|
return `<span>`;
|
|
4150
|
-
} else if (v instanceof
|
|
5458
|
+
} else if (v instanceof Experiment2) {
|
|
4151
5459
|
return `<experiment>`;
|
|
4152
|
-
} else if (v instanceof
|
|
5460
|
+
} else if (v instanceof Dataset2) {
|
|
4153
5461
|
return `<dataset>`;
|
|
4154
5462
|
} else if (v instanceof Logger) {
|
|
4155
5463
|
return `<logger>`;
|
|
@@ -4180,10 +5488,10 @@ function extractAttachments(event, attachments) {
|
|
|
4180
5488
|
event[key] = value.reference;
|
|
4181
5489
|
continue;
|
|
4182
5490
|
}
|
|
4183
|
-
if (value?.type ===
|
|
5491
|
+
if (value?.type === BRAINTRUST_ATTACHMENT && value.key && !value.uploader) {
|
|
4184
5492
|
continue;
|
|
4185
5493
|
}
|
|
4186
|
-
if (value?.reference?.type ===
|
|
5494
|
+
if (value?.reference?.type === BRAINTRUST_ATTACHMENT && value?.uploader) {
|
|
4187
5495
|
const attachment = new Attachment({
|
|
4188
5496
|
data: value.dataDebugString,
|
|
4189
5497
|
filename: value.reference.filename,
|
|
@@ -4201,7 +5509,7 @@ function extractAttachments(event, attachments) {
|
|
|
4201
5509
|
}
|
|
4202
5510
|
function enrichAttachments(event, state) {
|
|
4203
5511
|
for (const [key, value] of Object.entries(event)) {
|
|
4204
|
-
const parsedValue =
|
|
5512
|
+
const parsedValue = AttachmentReference.safeParse(value);
|
|
4205
5513
|
if (parsedValue.success) {
|
|
4206
5514
|
event[key] = new ReadonlyAttachment(parsedValue.data, state);
|
|
4207
5515
|
continue;
|
|
@@ -4344,7 +5652,7 @@ var ObjectFetcher = class {
|
|
|
4344
5652
|
}
|
|
4345
5653
|
}
|
|
4346
5654
|
};
|
|
4347
|
-
var
|
|
5655
|
+
var Experiment2 = class extends ObjectFetcher {
|
|
4348
5656
|
lazyMetadata;
|
|
4349
5657
|
dataset;
|
|
4350
5658
|
lastStartTime;
|
|
@@ -4950,7 +6258,7 @@ function splitLoggingData({
|
|
|
4950
6258
|
}
|
|
4951
6259
|
return [serializableInternalData, lazyInternalData];
|
|
4952
6260
|
}
|
|
4953
|
-
var
|
|
6261
|
+
var Dataset2 = class extends ObjectFetcher {
|
|
4954
6262
|
constructor(state, lazyMetadata, pinnedVersion, legacy, _internal_btql) {
|
|
4955
6263
|
const isLegacyDataset = legacy ?? import_core2.DEFAULT_IS_LEGACY_DATASET;
|
|
4956
6264
|
if (isLegacyDataset) {
|
|
@@ -5148,8 +6456,8 @@ var Dataset = class extends ObjectFetcher {
|
|
|
5148
6456
|
)}`;
|
|
5149
6457
|
let dataSummary;
|
|
5150
6458
|
if (summarizeData) {
|
|
5151
|
-
const rawDataSummary =
|
|
5152
|
-
total_records:
|
|
6459
|
+
const rawDataSummary = import_zod3.z.object({
|
|
6460
|
+
total_records: import_zod3.z.number()
|
|
5153
6461
|
}).parse(
|
|
5154
6462
|
await state.apiConn().get_json(
|
|
5155
6463
|
"dataset-summary",
|
|
@@ -5272,11 +6580,11 @@ function renderTemplatedObject(obj, args, options) {
|
|
|
5272
6580
|
return obj;
|
|
5273
6581
|
}
|
|
5274
6582
|
function renderPromptParams(params, args, options) {
|
|
5275
|
-
const schemaParsed =
|
|
5276
|
-
response_format:
|
|
5277
|
-
type:
|
|
5278
|
-
json_schema:
|
|
5279
|
-
schema:
|
|
6583
|
+
const schemaParsed = import_zod3.z.object({
|
|
6584
|
+
response_format: import_zod3.z.object({
|
|
6585
|
+
type: import_zod3.z.literal("json_schema"),
|
|
6586
|
+
json_schema: ResponseFormatJsonSchema.omit({ schema: true }).extend({
|
|
6587
|
+
schema: import_zod3.z.unknown()
|
|
5280
6588
|
})
|
|
5281
6589
|
})
|
|
5282
6590
|
}).safeParse(params);
|
|
@@ -5297,7 +6605,7 @@ function renderPromptParams(params, args, options) {
|
|
|
5297
6605
|
}
|
|
5298
6606
|
return params;
|
|
5299
6607
|
}
|
|
5300
|
-
var
|
|
6608
|
+
var Prompt2 = class _Prompt {
|
|
5301
6609
|
constructor(metadata, defaults, noTrace) {
|
|
5302
6610
|
this.metadata = metadata;
|
|
5303
6611
|
this.defaults = defaults;
|
|
@@ -5365,7 +6673,7 @@ var Prompt = class _Prompt {
|
|
|
5365
6673
|
...this.defaults,
|
|
5366
6674
|
...Object.fromEntries(
|
|
5367
6675
|
Object.entries(this.options.params || {}).filter(
|
|
5368
|
-
([k, _v]) => !
|
|
6676
|
+
([k, _v]) => !BRAINTRUST_PARAMS.includes(k)
|
|
5369
6677
|
)
|
|
5370
6678
|
),
|
|
5371
6679
|
...!isEmpty(this.options.model) ? {
|
|
@@ -5394,7 +6702,7 @@ var Prompt = class _Prompt {
|
|
|
5394
6702
|
if (!prompt) {
|
|
5395
6703
|
throw new Error("Empty prompt");
|
|
5396
6704
|
}
|
|
5397
|
-
const dictArgParsed =
|
|
6705
|
+
const dictArgParsed = import_zod3.z.record(import_zod3.z.unknown()).safeParse(buildArgs);
|
|
5398
6706
|
const variables = {
|
|
5399
6707
|
input: buildArgs,
|
|
5400
6708
|
...dictArgParsed.success ? dictArgParsed.data : {}
|
|
@@ -5415,7 +6723,7 @@ var Prompt = class _Prompt {
|
|
|
5415
6723
|
...spanInfo,
|
|
5416
6724
|
messages: renderedPrompt.messages,
|
|
5417
6725
|
...renderedPrompt.tools ? {
|
|
5418
|
-
tools:
|
|
6726
|
+
tools: ChatCompletionTool.array().parse(JSON.parse(renderedPrompt.tools))
|
|
5419
6727
|
} : void 0
|
|
5420
6728
|
};
|
|
5421
6729
|
} else if (flavor === "completion") {
|
|
@@ -5449,7 +6757,7 @@ var Prompt = class _Prompt {
|
|
|
5449
6757
|
return JSON.stringify(v);
|
|
5450
6758
|
}
|
|
5451
6759
|
};
|
|
5452
|
-
const dictArgParsed =
|
|
6760
|
+
const dictArgParsed = import_zod3.z.record(import_zod3.z.unknown()).safeParse(buildArgs);
|
|
5453
6761
|
const variables = {
|
|
5454
6762
|
input: buildArgs,
|
|
5455
6763
|
...dictArgParsed.success ? dictArgParsed.data : {}
|
|
@@ -5502,7 +6810,7 @@ var Prompt = class _Prompt {
|
|
|
5502
6810
|
}
|
|
5503
6811
|
getParsedPromptData() {
|
|
5504
6812
|
if (!this.hasParsedPromptData) {
|
|
5505
|
-
this.parsedPromptData =
|
|
6813
|
+
this.parsedPromptData = PromptData.parse(this.metadata.prompt_data);
|
|
5506
6814
|
this.hasParsedPromptData = true;
|
|
5507
6815
|
}
|
|
5508
6816
|
return this.parsedPromptData;
|
|
@@ -5571,7 +6879,7 @@ var BarProgressReporter = class {
|
|
|
5571
6879
|
};
|
|
5572
6880
|
|
|
5573
6881
|
// src/framework.ts
|
|
5574
|
-
var
|
|
6882
|
+
var import_core5 = require("@braintrust/core");
|
|
5575
6883
|
|
|
5576
6884
|
// ../../node_modules/.pnpm/async@3.2.5/node_modules/async/dist/async.mjs
|
|
5577
6885
|
function initialParams(fn) {
|
|
@@ -6615,21 +7923,20 @@ var import_chalk = __toESM(require("chalk"));
|
|
|
6615
7923
|
var import_pluralize = __toESM(require("pluralize"));
|
|
6616
7924
|
|
|
6617
7925
|
// src/eval-parameters.ts
|
|
6618
|
-
var
|
|
7926
|
+
var import_zod5 = require("zod");
|
|
6619
7927
|
|
|
6620
7928
|
// src/framework2.ts
|
|
6621
7929
|
var import_path = __toESM(require("path"));
|
|
6622
7930
|
var import_slugify = __toESM(require("slugify"));
|
|
6623
|
-
var
|
|
6624
|
-
var
|
|
6625
|
-
var import_core3 = require("@braintrust/core");
|
|
7931
|
+
var import_zod4 = require("zod");
|
|
7932
|
+
var import_core4 = require("@braintrust/core");
|
|
6626
7933
|
var ProjectBuilder = class {
|
|
6627
7934
|
create(opts) {
|
|
6628
|
-
return new
|
|
7935
|
+
return new Project2(opts);
|
|
6629
7936
|
}
|
|
6630
7937
|
};
|
|
6631
7938
|
var projects = new ProjectBuilder();
|
|
6632
|
-
var
|
|
7939
|
+
var Project2 = class {
|
|
6633
7940
|
name;
|
|
6634
7941
|
id;
|
|
6635
7942
|
tools;
|
|
@@ -6856,23 +8163,23 @@ var CodePrompt = class {
|
|
|
6856
8163
|
};
|
|
6857
8164
|
}
|
|
6858
8165
|
};
|
|
6859
|
-
var promptContentsSchema =
|
|
6860
|
-
|
|
6861
|
-
prompt:
|
|
8166
|
+
var promptContentsSchema = import_zod4.z.union([
|
|
8167
|
+
import_zod4.z.object({
|
|
8168
|
+
prompt: import_zod4.z.string()
|
|
6862
8169
|
}),
|
|
6863
|
-
|
|
6864
|
-
messages:
|
|
8170
|
+
import_zod4.z.object({
|
|
8171
|
+
messages: import_zod4.z.array(ChatCompletionMessageParam)
|
|
6865
8172
|
})
|
|
6866
8173
|
]);
|
|
6867
8174
|
var promptDefinitionSchema = promptContentsSchema.and(
|
|
6868
|
-
|
|
6869
|
-
model:
|
|
6870
|
-
params:
|
|
8175
|
+
import_zod4.z.object({
|
|
8176
|
+
model: import_zod4.z.string(),
|
|
8177
|
+
params: ModelParams.optional()
|
|
6871
8178
|
})
|
|
6872
8179
|
);
|
|
6873
8180
|
var promptDefinitionWithToolsSchema = promptDefinitionSchema.and(
|
|
6874
|
-
|
|
6875
|
-
tools:
|
|
8181
|
+
import_zod4.z.object({
|
|
8182
|
+
tools: import_zod4.z.array(ToolFunctionDefinition).optional()
|
|
6876
8183
|
})
|
|
6877
8184
|
);
|
|
6878
8185
|
var PromptBuilder = class {
|
|
@@ -6895,13 +8202,13 @@ var PromptBuilder = class {
|
|
|
6895
8202
|
const promptData = promptDefinitionToPromptData(opts, rawTools);
|
|
6896
8203
|
const promptRow = {
|
|
6897
8204
|
id: opts.id,
|
|
6898
|
-
_xact_id: opts.version ? (0,
|
|
8205
|
+
_xact_id: opts.version ? (0, import_core4.loadPrettyXact)(opts.version) : void 0,
|
|
6899
8206
|
name: opts.name,
|
|
6900
8207
|
slug,
|
|
6901
8208
|
prompt_data: promptData,
|
|
6902
8209
|
...this.project.id !== void 0 ? { project_id: this.project.id } : {}
|
|
6903
8210
|
};
|
|
6904
|
-
const prompt = new
|
|
8211
|
+
const prompt = new Prompt2(
|
|
6905
8212
|
promptRow,
|
|
6906
8213
|
{},
|
|
6907
8214
|
// It doesn't make sense to specify defaults here.
|
|
@@ -6940,8 +8247,8 @@ var ProjectNameIdMap = class {
|
|
|
6940
8247
|
const response = await _internalGetGlobalState().appConn().post_json("api/project/register", {
|
|
6941
8248
|
project_name: projectName
|
|
6942
8249
|
});
|
|
6943
|
-
const result =
|
|
6944
|
-
project:
|
|
8250
|
+
const result = import_zod4.z.object({
|
|
8251
|
+
project: Project
|
|
6945
8252
|
}).parse(response);
|
|
6946
8253
|
const projectId = result.project.id;
|
|
6947
8254
|
this.nameToId[projectName] = projectId;
|
|
@@ -6954,7 +8261,7 @@ var ProjectNameIdMap = class {
|
|
|
6954
8261
|
const response = await _internalGetGlobalState().appConn().post_json("api/project/get", {
|
|
6955
8262
|
id: projectId
|
|
6956
8263
|
});
|
|
6957
|
-
const result =
|
|
8264
|
+
const result = import_zod4.z.array(Project).nonempty().parse(response);
|
|
6958
8265
|
const projectName = result[0].name;
|
|
6959
8266
|
this.idToName[projectId] = projectName;
|
|
6960
8267
|
this.nameToId[projectName] = projectId;
|
|
@@ -6970,16 +8277,15 @@ var ProjectNameIdMap = class {
|
|
|
6970
8277
|
};
|
|
6971
8278
|
|
|
6972
8279
|
// src/eval-parameters.ts
|
|
6973
|
-
var
|
|
6974
|
-
|
|
6975
|
-
|
|
6976
|
-
|
|
6977
|
-
|
|
6978
|
-
type: import_zod4.z.literal("prompt"),
|
|
8280
|
+
var evalParametersSchema = import_zod5.z.record(
|
|
8281
|
+
import_zod5.z.string(),
|
|
8282
|
+
import_zod5.z.union([
|
|
8283
|
+
import_zod5.z.object({
|
|
8284
|
+
type: import_zod5.z.literal("prompt"),
|
|
6979
8285
|
default: promptDefinitionWithToolsSchema.optional(),
|
|
6980
|
-
description:
|
|
8286
|
+
description: import_zod5.z.string().optional()
|
|
6981
8287
|
}),
|
|
6982
|
-
|
|
8288
|
+
import_zod5.z.instanceof(import_zod5.z.ZodType)
|
|
6983
8289
|
// For Zod schemas
|
|
6984
8290
|
])
|
|
6985
8291
|
);
|
|
@@ -6989,14 +8295,14 @@ function validateParameters(parameters, parameterSchema) {
|
|
|
6989
8295
|
const value = parameters[name];
|
|
6990
8296
|
try {
|
|
6991
8297
|
if ("type" in schema && schema.type === "prompt") {
|
|
6992
|
-
const promptData = value ?
|
|
8298
|
+
const promptData = value ? PromptData.parse(value) : schema.default ? promptDefinitionToPromptData(
|
|
6993
8299
|
schema.default,
|
|
6994
8300
|
schema.default.tools
|
|
6995
8301
|
) : void 0;
|
|
6996
8302
|
if (!promptData) {
|
|
6997
8303
|
throw new Error(`Parameter '${name}' is required`);
|
|
6998
8304
|
}
|
|
6999
|
-
return [name,
|
|
8305
|
+
return [name, Prompt2.fromPromptData(name, promptData)];
|
|
7000
8306
|
} else {
|
|
7001
8307
|
const schemaCasted = schema;
|
|
7002
8308
|
return [name, schemaCasted.parse(value)];
|
|
@@ -7113,7 +8419,7 @@ async function Eval(name, evaluator, reporterOrOpts) {
|
|
|
7113
8419
|
baseExperimentId: evaluator.baseExperimentId,
|
|
7114
8420
|
gitMetadataSettings: evaluator.gitMetadataSettings,
|
|
7115
8421
|
repoInfo: evaluator.repoInfo,
|
|
7116
|
-
dataset:
|
|
8422
|
+
dataset: Dataset2.isDataset(data) ? data : void 0
|
|
7117
8423
|
});
|
|
7118
8424
|
if (experiment && options.onStart) {
|
|
7119
8425
|
const summary = await experiment.summarize({ summarizeScores: false });
|
|
@@ -7281,11 +8587,11 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
7281
8587
|
datum,
|
|
7282
8588
|
trialIndex
|
|
7283
8589
|
}) => {
|
|
7284
|
-
const eventDataset = experiment ? experiment.dataset :
|
|
8590
|
+
const eventDataset = experiment ? experiment.dataset : Dataset2.isDataset(evaluator.data) ? evaluator.data : void 0;
|
|
7285
8591
|
const baseEvent = {
|
|
7286
8592
|
name: "eval",
|
|
7287
8593
|
spanAttributes: {
|
|
7288
|
-
type:
|
|
8594
|
+
type: import_core5.SpanTypeAttribute.EVAL
|
|
7289
8595
|
},
|
|
7290
8596
|
event: {
|
|
7291
8597
|
input: datum.input,
|
|
@@ -7308,6 +8614,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
7308
8614
|
const expected = "expected" in datum ? datum.expected : void 0;
|
|
7309
8615
|
let output = void 0;
|
|
7310
8616
|
let error2 = void 0;
|
|
8617
|
+
let tags = [...datum.tags ?? []];
|
|
7311
8618
|
const scores = {};
|
|
7312
8619
|
const scorerNames = evaluator.scores.map(scorerName);
|
|
7313
8620
|
let unhandledScores = scorerNames;
|
|
@@ -7315,7 +8622,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
7315
8622
|
const meta = (o) => metadata = { ...metadata, ...o };
|
|
7316
8623
|
await rootSpan.traced(
|
|
7317
8624
|
async (span) => {
|
|
7318
|
-
const
|
|
8625
|
+
const hooksForTask = {
|
|
7319
8626
|
meta,
|
|
7320
8627
|
metadata,
|
|
7321
8628
|
expected,
|
|
@@ -7330,22 +8637,29 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
7330
8637
|
object_type: "task"
|
|
7331
8638
|
});
|
|
7332
8639
|
},
|
|
7333
|
-
trialIndex
|
|
7334
|
-
|
|
8640
|
+
trialIndex,
|
|
8641
|
+
tags
|
|
8642
|
+
};
|
|
8643
|
+
const outputResult = evaluator.task(datum.input, hooksForTask);
|
|
7335
8644
|
if (outputResult instanceof Promise) {
|
|
7336
8645
|
output = await outputResult;
|
|
7337
8646
|
} else {
|
|
7338
8647
|
output = outputResult;
|
|
7339
8648
|
}
|
|
8649
|
+
tags = hooksForTask.tags ?? [];
|
|
7340
8650
|
span.log({ output });
|
|
7341
8651
|
},
|
|
7342
8652
|
{
|
|
7343
8653
|
name: "task",
|
|
7344
|
-
spanAttributes: { type:
|
|
8654
|
+
spanAttributes: { type: import_core5.SpanTypeAttribute.TASK },
|
|
7345
8655
|
event: { input: datum.input }
|
|
7346
8656
|
}
|
|
7347
8657
|
);
|
|
7348
|
-
|
|
8658
|
+
if (tags.length) {
|
|
8659
|
+
rootSpan.log({ output, metadata, expected, tags });
|
|
8660
|
+
} else {
|
|
8661
|
+
rootSpan.log({ output, metadata, expected });
|
|
8662
|
+
}
|
|
7349
8663
|
const scoringArgs = {
|
|
7350
8664
|
input: datum.input,
|
|
7351
8665
|
expected: "expected" in datum ? datum.expected : void 0,
|
|
@@ -7383,17 +8697,17 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
7383
8697
|
return rest;
|
|
7384
8698
|
};
|
|
7385
8699
|
const resultMetadata = results3.length === 1 ? results3[0].metadata : results3.reduce(
|
|
7386
|
-
(prev, s) => (0,
|
|
8700
|
+
(prev, s) => (0, import_core5.mergeDicts)(prev, {
|
|
7387
8701
|
[s.name]: s.metadata
|
|
7388
8702
|
}),
|
|
7389
8703
|
{}
|
|
7390
8704
|
);
|
|
7391
8705
|
const resultOutput = results3.length === 1 ? getOtherFields(results3[0]) : results3.reduce(
|
|
7392
|
-
(prev, s) => (0,
|
|
8706
|
+
(prev, s) => (0, import_core5.mergeDicts)(prev, { [s.name]: getOtherFields(s) }),
|
|
7393
8707
|
{}
|
|
7394
8708
|
);
|
|
7395
8709
|
const scores2 = results3.reduce(
|
|
7396
|
-
(prev, s) => (0,
|
|
8710
|
+
(prev, s) => (0, import_core5.mergeDicts)(prev, { [s.name]: s.score }),
|
|
7397
8711
|
{}
|
|
7398
8712
|
);
|
|
7399
8713
|
span.log({
|
|
@@ -7406,7 +8720,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
7406
8720
|
const results2 = await rootSpan.traced(runScorer, {
|
|
7407
8721
|
name: scorerNames[score_idx],
|
|
7408
8722
|
spanAttributes: {
|
|
7409
|
-
type:
|
|
8723
|
+
type: import_core5.SpanTypeAttribute.SCORE
|
|
7410
8724
|
},
|
|
7411
8725
|
event: { input: scoringArgs }
|
|
7412
8726
|
});
|
|
@@ -7457,7 +8771,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
7457
8771
|
input: datum.input,
|
|
7458
8772
|
..."expected" in datum ? { expected: datum.expected } : {},
|
|
7459
8773
|
output,
|
|
7460
|
-
tags:
|
|
8774
|
+
tags: tags.length ? tags : void 0,
|
|
7461
8775
|
metadata,
|
|
7462
8776
|
scores: {
|
|
7463
8777
|
...evaluator.errorScoreHandler && unhandledScores ? evaluator.errorScoreHandler({
|
|
@@ -7628,6 +8942,7 @@ var import_node_async_hooks = require("async_hooks");
|
|
|
7628
8942
|
var path2 = __toESM(require("path"));
|
|
7629
8943
|
var fs = __toESM(require("fs/promises"));
|
|
7630
8944
|
var os = __toESM(require("os"));
|
|
8945
|
+
var fsSync = __toESM(require("fs"));
|
|
7631
8946
|
var crypto = __toESM(require("crypto"));
|
|
7632
8947
|
|
|
7633
8948
|
// src/gitutil.ts
|
|
@@ -7863,6 +9178,7 @@ function configureNode() {
|
|
|
7863
9178
|
isomorph_default.readFile = fs.readFile;
|
|
7864
9179
|
isomorph_default.readdir = fs.readdir;
|
|
7865
9180
|
isomorph_default.stat = fs.stat;
|
|
9181
|
+
isomorph_default.statSync = fsSync.statSync;
|
|
7866
9182
|
isomorph_default.utimes = fs.utimes;
|
|
7867
9183
|
isomorph_default.unlink = fs.unlink;
|
|
7868
9184
|
isomorph_default.homedir = os.homedir;
|
|
@@ -7879,8 +9195,8 @@ var import_env2 = require("@next/env");
|
|
|
7879
9195
|
var import_fs = __toESM(require("fs"));
|
|
7880
9196
|
var import_path4 = __toESM(require("path"));
|
|
7881
9197
|
var import_zlib = require("zlib");
|
|
7882
|
-
var
|
|
7883
|
-
var
|
|
9198
|
+
var import_zod6 = require("zod");
|
|
9199
|
+
var import_core6 = require("@braintrust/core");
|
|
7884
9200
|
|
|
7885
9201
|
// src/functions/infer-source.ts
|
|
7886
9202
|
var import_source_map = require("source-map");
|
|
@@ -8136,9 +9452,9 @@ async function getTsModule() {
|
|
|
8136
9452
|
var import_slugify2 = __toESM(require("slugify"));
|
|
8137
9453
|
var import_zod_to_json_schema = require("zod-to-json-schema");
|
|
8138
9454
|
var import_pluralize2 = __toESM(require("pluralize"));
|
|
8139
|
-
var pathInfoSchema =
|
|
8140
|
-
url:
|
|
8141
|
-
bundleId:
|
|
9455
|
+
var pathInfoSchema = import_zod6.z.strictObject({
|
|
9456
|
+
url: import_zod6.z.string(),
|
|
9457
|
+
bundleId: import_zod6.z.string()
|
|
8142
9458
|
}).strip();
|
|
8143
9459
|
async function uploadHandleBundles({
|
|
8144
9460
|
buildResults,
|
|
@@ -8405,7 +9721,7 @@ async function uploadBundles({
|
|
|
8405
9721
|
function formatNameAndSlug(pieces) {
|
|
8406
9722
|
const nonEmptyPieces = pieces.filter((piece) => piece.trim() !== "");
|
|
8407
9723
|
return {
|
|
8408
|
-
name: (0,
|
|
9724
|
+
name: (0, import_core6.capitalize)(nonEmptyPieces.join(" ")),
|
|
8409
9725
|
slug: (0, import_slugify2.default)(nonEmptyPieces.join("-"))
|
|
8410
9726
|
};
|
|
8411
9727
|
}
|
|
@@ -8478,13 +9794,12 @@ async function bundleCommand(args) {
|
|
|
8478
9794
|
}
|
|
8479
9795
|
|
|
8480
9796
|
// src/cli-util/pull.ts
|
|
8481
|
-
var
|
|
8482
|
-
var import_zod6 = require("zod");
|
|
9797
|
+
var import_zod7 = require("zod");
|
|
8483
9798
|
var import_promises = __toESM(require("fs/promises"));
|
|
8484
9799
|
var import_util5 = __toESM(require("util"));
|
|
8485
9800
|
var import_slugify3 = __toESM(require("slugify"));
|
|
8486
9801
|
var import_path5 = __toESM(require("path"));
|
|
8487
|
-
var
|
|
9802
|
+
var import_core7 = require("@braintrust/core");
|
|
8488
9803
|
var import_pluralize3 = __toESM(require("pluralize"));
|
|
8489
9804
|
async function pullCommand(args) {
|
|
8490
9805
|
await loadCLIEnv(args);
|
|
@@ -8494,13 +9809,13 @@ async function pullCommand(args) {
|
|
|
8494
9809
|
...args.project_name ? { project_name: args.project_name } : {},
|
|
8495
9810
|
...args.slug ? { slug: args.slug } : {},
|
|
8496
9811
|
...args.id ? { ids: [args.id] } : {},
|
|
8497
|
-
...args.version ? { version: (0,
|
|
9812
|
+
...args.version ? { version: (0, import_core7.loadPrettyXact)(args.version) } : {}
|
|
8498
9813
|
});
|
|
8499
|
-
const functionObjects =
|
|
9814
|
+
const functionObjects = import_zod7.z.object({ objects: import_zod7.z.array(import_zod7.z.unknown()) }).parse(functions);
|
|
8500
9815
|
const projectNameToFunctions = {};
|
|
8501
9816
|
const projectNameIdMap = new ProjectNameIdMap();
|
|
8502
9817
|
for (const rawFunc of functionObjects.objects) {
|
|
8503
|
-
const parsedFunc =
|
|
9818
|
+
const parsedFunc = Function2.safeParse(rawFunc);
|
|
8504
9819
|
if (!parsedFunc.success) {
|
|
8505
9820
|
const id = typeof rawFunc === "object" && rawFunc && "id" in rawFunc ? ` ${rawFunc.id}` : "";
|
|
8506
9821
|
console.warn(
|
|
@@ -8659,7 +9974,7 @@ function makeFunctionDefinition({
|
|
|
8659
9974
|
const objectType = "prompt";
|
|
8660
9975
|
const prompt = func.prompt_data.prompt;
|
|
8661
9976
|
const promptContents = prompt.type === "completion" ? `prompt: ${doubleQuote(prompt.content)}` : `messages: ${safeStringify(prompt.messages).trimStart()}`;
|
|
8662
|
-
const rawToolsParsed = prompt.type === "chat" && prompt.tools && prompt.tools.length > 0 ?
|
|
9977
|
+
const rawToolsParsed = prompt.type === "chat" && prompt.tools && prompt.tools.length > 0 ? import_zod7.z.array(ToolFunctionDefinition).safeParse(JSON.parse(prompt.tools)) : void 0;
|
|
8663
9978
|
if (rawToolsParsed && !rawToolsParsed.success) {
|
|
8664
9979
|
console.warn(
|
|
8665
9980
|
warning(
|
|
@@ -8680,7 +9995,7 @@ function makeFunctionDefinition({
|
|
|
8680
9995
|
id: ${doubleQuote(func.id)},
|
|
8681
9996
|
name: ${doubleQuote(func.name)},
|
|
8682
9997
|
slug: ${doubleQuote(func.slug)},
|
|
8683
|
-
version: ${doubleQuote((0,
|
|
9998
|
+
version: ${doubleQuote((0, import_core7.prettifyXact)(func._xact_id))}, ${printOptionalField("description", func.description)}${printOptionalField("model", model)}
|
|
8684
9999
|
${indent(promptContents, 2)},
|
|
8685
10000
|
${indent(paramsString, 2)}
|
|
8686
10001
|
${indent(toolsString, 2)}
|
|
@@ -8700,7 +10015,7 @@ function indent(str, numSpaces) {
|
|
|
8700
10015
|
return str.replace(/^/gm, " ".repeat(numSpaces));
|
|
8701
10016
|
}
|
|
8702
10017
|
function printOptionalField(fieldName, fieldValue) {
|
|
8703
|
-
return !(0,
|
|
10018
|
+
return !(0, import_core7.isEmpty)(fieldValue) ? `
|
|
8704
10019
|
${fieldName}: ${doubleQuote(fieldValue)},` : "";
|
|
8705
10020
|
}
|
|
8706
10021
|
var prettierImportAttempted = false;
|
|
@@ -8771,7 +10086,7 @@ var import_express = __toESM(require("express"));
|
|
|
8771
10086
|
var import_cors = __toESM(require("cors"));
|
|
8772
10087
|
|
|
8773
10088
|
// dev/errorHandler.ts
|
|
8774
|
-
var
|
|
10089
|
+
var import_zod8 = require("zod");
|
|
8775
10090
|
var errorHandler = (err, req, res, next) => {
|
|
8776
10091
|
if ("status" in err) {
|
|
8777
10092
|
res.status(err.status).json({
|
|
@@ -8782,7 +10097,7 @@ var errorHandler = (err, req, res, next) => {
|
|
|
8782
10097
|
});
|
|
8783
10098
|
return;
|
|
8784
10099
|
}
|
|
8785
|
-
if (err instanceof
|
|
10100
|
+
if (err instanceof import_zod8.z.ZodError) {
|
|
8786
10101
|
res.status(400).json({
|
|
8787
10102
|
error: {
|
|
8788
10103
|
message: "Invalid request",
|
|
@@ -8911,7 +10226,7 @@ var baseAllowedHeaders = [
|
|
|
8911
10226
|
];
|
|
8912
10227
|
|
|
8913
10228
|
// dev/server.ts
|
|
8914
|
-
var
|
|
10229
|
+
var import_core8 = require("@braintrust/core");
|
|
8915
10230
|
|
|
8916
10231
|
// dev/stream.ts
|
|
8917
10232
|
function serializeSSEEvent(event) {
|
|
@@ -8919,50 +10234,49 @@ function serializeSSEEvent(event) {
|
|
|
8919
10234
|
}
|
|
8920
10235
|
|
|
8921
10236
|
// dev/types.ts
|
|
8922
|
-
var
|
|
8923
|
-
var
|
|
8924
|
-
|
|
8925
|
-
|
|
8926
|
-
|
|
8927
|
-
|
|
8928
|
-
|
|
8929
|
-
|
|
8930
|
-
|
|
8931
|
-
name: import_zod8.z.string()
|
|
10237
|
+
var import_zod9 = require("zod");
|
|
10238
|
+
var evalBodySchema = import_zod9.z.object({
|
|
10239
|
+
name: import_zod9.z.string(),
|
|
10240
|
+
parameters: import_zod9.z.record(import_zod9.z.string(), import_zod9.z.unknown()).nullish(),
|
|
10241
|
+
data: RunEval.shape.data,
|
|
10242
|
+
scores: import_zod9.z.array(
|
|
10243
|
+
import_zod9.z.object({
|
|
10244
|
+
function_id: FunctionId,
|
|
10245
|
+
name: import_zod9.z.string()
|
|
8932
10246
|
})
|
|
8933
10247
|
).nullish(),
|
|
8934
|
-
experiment_name:
|
|
8935
|
-
project_id:
|
|
8936
|
-
parent:
|
|
8937
|
-
stream:
|
|
10248
|
+
experiment_name: import_zod9.z.string().nullish(),
|
|
10249
|
+
project_id: import_zod9.z.string().nullish(),
|
|
10250
|
+
parent: InvokeParent.optional(),
|
|
10251
|
+
stream: import_zod9.z.boolean().optional()
|
|
8938
10252
|
});
|
|
8939
|
-
var evalParametersSerializedSchema =
|
|
8940
|
-
|
|
8941
|
-
|
|
8942
|
-
|
|
8943
|
-
type:
|
|
8944
|
-
default:
|
|
8945
|
-
description:
|
|
10253
|
+
var evalParametersSerializedSchema = import_zod9.z.record(
|
|
10254
|
+
import_zod9.z.string(),
|
|
10255
|
+
import_zod9.z.union([
|
|
10256
|
+
import_zod9.z.object({
|
|
10257
|
+
type: import_zod9.z.literal("prompt"),
|
|
10258
|
+
default: PromptData.optional(),
|
|
10259
|
+
description: import_zod9.z.string().optional()
|
|
8946
10260
|
}),
|
|
8947
|
-
|
|
8948
|
-
type:
|
|
8949
|
-
schema:
|
|
10261
|
+
import_zod9.z.object({
|
|
10262
|
+
type: import_zod9.z.literal("data"),
|
|
10263
|
+
schema: import_zod9.z.record(import_zod9.z.unknown()),
|
|
8950
10264
|
// JSON Schema
|
|
8951
|
-
default:
|
|
8952
|
-
description:
|
|
10265
|
+
default: import_zod9.z.unknown().optional(),
|
|
10266
|
+
description: import_zod9.z.string().optional()
|
|
8953
10267
|
})
|
|
8954
10268
|
])
|
|
8955
10269
|
);
|
|
8956
|
-
var evaluatorDefinitionSchema =
|
|
10270
|
+
var evaluatorDefinitionSchema = import_zod9.z.object({
|
|
8957
10271
|
parameters: evalParametersSerializedSchema.optional()
|
|
8958
10272
|
});
|
|
8959
|
-
var evaluatorDefinitionsSchema =
|
|
8960
|
-
|
|
10273
|
+
var evaluatorDefinitionsSchema = import_zod9.z.record(
|
|
10274
|
+
import_zod9.z.string(),
|
|
8961
10275
|
evaluatorDefinitionSchema
|
|
8962
10276
|
);
|
|
8963
10277
|
|
|
8964
10278
|
// dev/server.ts
|
|
8965
|
-
var
|
|
10279
|
+
var import_zod10 = require("zod");
|
|
8966
10280
|
var import_zod_to_json_schema2 = __toESM(require("zod-to-json-schema"));
|
|
8967
10281
|
function runDevServer(evaluators, opts) {
|
|
8968
10282
|
const allEvaluators = Object.fromEntries(
|
|
@@ -8985,8 +10299,8 @@ function runDevServer(evaluators, opts) {
|
|
|
8985
10299
|
allowedHeaders: baseAllowedHeaders,
|
|
8986
10300
|
credentials: true,
|
|
8987
10301
|
exposedHeaders: [
|
|
8988
|
-
|
|
8989
|
-
|
|
10302
|
+
import_core8.BT_CURSOR_HEADER,
|
|
10303
|
+
import_core8.BT_FOUND_EXISTING_HEADER,
|
|
8990
10304
|
"x-bt-span-id",
|
|
8991
10305
|
"x-bt-span-export"
|
|
8992
10306
|
],
|
|
@@ -9042,7 +10356,7 @@ function runDevServer(evaluators, opts) {
|
|
|
9042
10356
|
validateParameters(parameters ?? {}, evaluator.parameters);
|
|
9043
10357
|
} catch (e) {
|
|
9044
10358
|
console.error("Error validating parameters", e);
|
|
9045
|
-
if (e instanceof
|
|
10359
|
+
if (e instanceof import_zod10.z.ZodError || e instanceof Error) {
|
|
9046
10360
|
res.status(400).json({
|
|
9047
10361
|
error: e.message
|
|
9048
10362
|
});
|
|
@@ -9118,7 +10432,7 @@ function runDevServer(evaluators, opts) {
|
|
|
9118
10432
|
);
|
|
9119
10433
|
}
|
|
9120
10434
|
},
|
|
9121
|
-
parent: (0,
|
|
10435
|
+
parent: (0, import_core8.parseParent)(parent),
|
|
9122
10436
|
parameters: parameters ?? {}
|
|
9123
10437
|
}
|
|
9124
10438
|
);
|
|
@@ -9200,9 +10514,9 @@ async function getDataset(state, data) {
|
|
|
9200
10514
|
return data.data;
|
|
9201
10515
|
}
|
|
9202
10516
|
}
|
|
9203
|
-
var datasetFetchSchema =
|
|
9204
|
-
project_id:
|
|
9205
|
-
name:
|
|
10517
|
+
var datasetFetchSchema = import_zod10.z.object({
|
|
10518
|
+
project_id: import_zod10.z.string(),
|
|
10519
|
+
name: import_zod10.z.string()
|
|
9206
10520
|
});
|
|
9207
10521
|
async function getDatasetById({
|
|
9208
10522
|
state,
|
|
@@ -9211,7 +10525,7 @@ async function getDatasetById({
|
|
|
9211
10525
|
const dataset = await state.appConn().post_json("api/dataset/get", {
|
|
9212
10526
|
id: datasetId
|
|
9213
10527
|
});
|
|
9214
|
-
const parsed =
|
|
10528
|
+
const parsed = import_zod10.z.array(datasetFetchSchema).parse(dataset);
|
|
9215
10529
|
if (parsed.length === 0) {
|
|
9216
10530
|
throw new Error(`Dataset '${datasetId}' not found`);
|
|
9217
10531
|
}
|
|
@@ -9253,13 +10567,12 @@ function makeEvalParametersSchema(parameters) {
|
|
|
9253
10567
|
}
|
|
9254
10568
|
];
|
|
9255
10569
|
} else {
|
|
10570
|
+
const schema = (0, import_zod_to_json_schema2.default)(value);
|
|
9256
10571
|
return [
|
|
9257
10572
|
name,
|
|
9258
10573
|
{
|
|
9259
10574
|
type: "data",
|
|
9260
|
-
|
|
9261
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
9262
|
-
schema: (0, import_zod_to_json_schema2.default)(value),
|
|
10575
|
+
schema,
|
|
9263
10576
|
default: value.default,
|
|
9264
10577
|
description: value.description
|
|
9265
10578
|
}
|
|
@@ -9334,7 +10647,7 @@ async function initExperiment2(evaluator, evaluatorData) {
|
|
|
9334
10647
|
baseExperimentId: evaluator.baseExperimentId,
|
|
9335
10648
|
gitMetadataSettings: evaluator.gitMetadataSettings,
|
|
9336
10649
|
repoInfo: evaluator.repoInfo,
|
|
9337
|
-
dataset:
|
|
10650
|
+
dataset: Dataset2.isDataset(data) ? data : void 0,
|
|
9338
10651
|
setCurrent: false
|
|
9339
10652
|
});
|
|
9340
10653
|
const info = await logger.summarize({ summarizeScores: false });
|