braintrust 1.1.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dev/dist/index.d.mts +29 -6
- package/dev/dist/index.d.ts +29 -6
- package/dev/dist/index.js +66 -10
- package/dev/dist/index.mjs +66 -10
- package/dist/browser.d.mts +107 -18
- package/dist/browser.d.ts +107 -18
- package/dist/browser.js +201 -101
- package/dist/browser.mjs +138 -38
- package/dist/cli.js +74 -19
- package/dist/index.d.mts +107 -18
- package/dist/index.d.ts +107 -18
- package/dist/index.js +201 -101
- package/dist/index.mjs +138 -38
- package/package.json +8 -6
- package/util/dist/index.d.mts +10 -1
- package/util/dist/index.d.ts +10 -1
- package/util/dist/index.js +9 -1
- package/util/dist/index.mjs +8 -0
package/dev/dist/index.mjs
CHANGED
|
@@ -1589,6 +1589,13 @@ function parseParent(parent) {
|
|
|
1589
1589
|
propagated_event: parent.propagated_event
|
|
1590
1590
|
}).toStr() : void 0;
|
|
1591
1591
|
}
|
|
1592
|
+
function makeScorerPropagatedEvent(parent) {
|
|
1593
|
+
const parentPropagatedEvent = parent ? SpanComponentsV4.fromStr(parent).data.propagated_event ?? {} : {};
|
|
1594
|
+
return mergeDicts(
|
|
1595
|
+
{ ...parentPropagatedEvent },
|
|
1596
|
+
{ span_attributes: { purpose: "scorer" } }
|
|
1597
|
+
);
|
|
1598
|
+
}
|
|
1592
1599
|
|
|
1593
1600
|
// util/git_fields.ts
|
|
1594
1601
|
function mergeGitMetadataSettings(s1, s2) {
|
|
@@ -2091,9 +2098,25 @@ var ExperimentEvent = z6.object({
|
|
|
2091
2098
|
comments: z6.union([z6.array(z6.unknown()), z6.null()]).optional(),
|
|
2092
2099
|
audit_data: z6.union([z6.array(z6.unknown()), z6.null()]).optional()
|
|
2093
2100
|
});
|
|
2101
|
+
var NullableFunctionTypeEnum = z6.union([
|
|
2102
|
+
z6.enum([
|
|
2103
|
+
"llm",
|
|
2104
|
+
"scorer",
|
|
2105
|
+
"task",
|
|
2106
|
+
"tool",
|
|
2107
|
+
"custom_view",
|
|
2108
|
+
"preprocessor",
|
|
2109
|
+
"facet"
|
|
2110
|
+
]),
|
|
2111
|
+
z6.null()
|
|
2112
|
+
]);
|
|
2094
2113
|
var ExtendedSavedFunctionId = z6.union([
|
|
2095
2114
|
z6.object({ type: z6.literal("function"), id: z6.string() }),
|
|
2096
|
-
z6.object({
|
|
2115
|
+
z6.object({
|
|
2116
|
+
type: z6.literal("global"),
|
|
2117
|
+
name: z6.string(),
|
|
2118
|
+
function_type: NullableFunctionTypeEnum.optional()
|
|
2119
|
+
}),
|
|
2097
2120
|
z6.object({
|
|
2098
2121
|
type: z6.literal("slug"),
|
|
2099
2122
|
project_id: z6.string(),
|
|
@@ -2102,7 +2125,11 @@ var ExtendedSavedFunctionId = z6.union([
|
|
|
2102
2125
|
]);
|
|
2103
2126
|
var NullableSavedFunctionId = z6.union([
|
|
2104
2127
|
z6.object({ type: z6.literal("function"), id: z6.string() }),
|
|
2105
|
-
z6.object({
|
|
2128
|
+
z6.object({
|
|
2129
|
+
type: z6.literal("global"),
|
|
2130
|
+
name: z6.string(),
|
|
2131
|
+
function_type: NullableFunctionTypeEnum.optional()
|
|
2132
|
+
}),
|
|
2106
2133
|
z6.null()
|
|
2107
2134
|
]);
|
|
2108
2135
|
var FacetData = z6.object({
|
|
@@ -2199,7 +2226,11 @@ var PromptParserNullish = z6.union([
|
|
|
2199
2226
|
]);
|
|
2200
2227
|
var SavedFunctionId = z6.union([
|
|
2201
2228
|
z6.object({ type: z6.literal("function"), id: z6.string() }),
|
|
2202
|
-
z6.object({
|
|
2229
|
+
z6.object({
|
|
2230
|
+
type: z6.literal("global"),
|
|
2231
|
+
name: z6.string(),
|
|
2232
|
+
function_type: NullableFunctionTypeEnum.optional()
|
|
2233
|
+
})
|
|
2203
2234
|
]);
|
|
2204
2235
|
var PromptDataNullish = z6.union([
|
|
2205
2236
|
z6.object({
|
|
@@ -2346,6 +2377,7 @@ var FunctionData = z6.union([
|
|
|
2346
2377
|
z6.object({
|
|
2347
2378
|
type: z6.literal("global"),
|
|
2348
2379
|
name: z6.string(),
|
|
2380
|
+
function_type: NullableFunctionTypeEnum.optional(),
|
|
2349
2381
|
config: z6.union([z6.object({}).partial().passthrough(), z6.null()]).optional()
|
|
2350
2382
|
}),
|
|
2351
2383
|
FacetData
|
|
@@ -2432,7 +2464,10 @@ var FunctionId = z6.union([
|
|
|
2432
2464
|
slug: z6.string(),
|
|
2433
2465
|
version: z6.string().optional()
|
|
2434
2466
|
}),
|
|
2435
|
-
z6.object({
|
|
2467
|
+
z6.object({
|
|
2468
|
+
global_function: z6.string(),
|
|
2469
|
+
function_type: NullableFunctionTypeEnum.optional()
|
|
2470
|
+
}),
|
|
2436
2471
|
z6.object({
|
|
2437
2472
|
prompt_session_id: z6.string(),
|
|
2438
2473
|
prompt_session_function_id: z6.string(),
|
|
@@ -2643,6 +2678,7 @@ var Project = z6.object({
|
|
|
2643
2678
|
id: z6.string().uuid(),
|
|
2644
2679
|
org_id: z6.string().uuid(),
|
|
2645
2680
|
name: z6.string(),
|
|
2681
|
+
description: z6.union([z6.string(), z6.null()]).optional(),
|
|
2646
2682
|
created: z6.union([z6.string(), z6.null()]).optional(),
|
|
2647
2683
|
deleted_at: z6.union([z6.string(), z6.null()]).optional(),
|
|
2648
2684
|
user_id: z6.union([z6.string(), z6.null()]).optional(),
|
|
@@ -9458,8 +9494,12 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
9458
9494
|
const results = await rootSpan.traced(runScorer, {
|
|
9459
9495
|
name: scorerNames[score_idx],
|
|
9460
9496
|
spanAttributes: {
|
|
9461
|
-
type: "score" /* SCORE
|
|
9497
|
+
type: "score" /* SCORE */,
|
|
9498
|
+
purpose: "scorer"
|
|
9462
9499
|
},
|
|
9500
|
+
propagatedEvent: makeScorerPropagatedEvent(
|
|
9501
|
+
await rootSpan.export()
|
|
9502
|
+
),
|
|
9463
9503
|
event: { input: scoringArgs }
|
|
9464
9504
|
});
|
|
9465
9505
|
return { kind: "score", value: results };
|
|
@@ -10017,7 +10057,23 @@ var evaluatorDefinitionsSchema = z12.record(
|
|
|
10017
10057
|
|
|
10018
10058
|
// dev/server.ts
|
|
10019
10059
|
import { z as z13 } from "zod/v3";
|
|
10020
|
-
|
|
10060
|
+
|
|
10061
|
+
// src/zod/utils.ts
|
|
10062
|
+
import { zodToJsonSchema as zodToJsonSchemaV3 } from "zod-to-json-schema";
|
|
10063
|
+
import * as z42 from "zod/v4";
|
|
10064
|
+
function isZodV4(zodObject) {
|
|
10065
|
+
return typeof zodObject === "object" && zodObject !== null && "_zod" in zodObject && zodObject._zod !== void 0;
|
|
10066
|
+
}
|
|
10067
|
+
function zodToJsonSchema(schema) {
|
|
10068
|
+
if (isZodV4(schema)) {
|
|
10069
|
+
return z42.toJSONSchema(schema, {
|
|
10070
|
+
target: "draft-7"
|
|
10071
|
+
});
|
|
10072
|
+
}
|
|
10073
|
+
return zodToJsonSchemaV3(schema);
|
|
10074
|
+
}
|
|
10075
|
+
|
|
10076
|
+
// dev/server.ts
|
|
10021
10077
|
function runDevServer(evaluators, opts) {
|
|
10022
10078
|
const allEvaluators = Object.fromEntries(
|
|
10023
10079
|
evaluators.map((evaluator) => [evaluator.evalName, evaluator])
|
|
@@ -10307,14 +10363,14 @@ function makeEvalParametersSchema(parameters) {
|
|
|
10307
10363
|
}
|
|
10308
10364
|
];
|
|
10309
10365
|
} else {
|
|
10310
|
-
const
|
|
10366
|
+
const schemaObj = zodToJsonSchema(value);
|
|
10311
10367
|
return [
|
|
10312
10368
|
name,
|
|
10313
10369
|
{
|
|
10314
10370
|
type: "data",
|
|
10315
|
-
schema,
|
|
10316
|
-
default:
|
|
10317
|
-
description:
|
|
10371
|
+
schema: schemaObj,
|
|
10372
|
+
default: schemaObj.default,
|
|
10373
|
+
description: schemaObj.description
|
|
10318
10374
|
}
|
|
10319
10375
|
];
|
|
10320
10376
|
}
|