braintrust 0.0.133 → 0.0.135
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/dist/browser.js +94 -8
- package/dist/cli.d.ts +33 -0
- package/dist/cli.js +932 -643
- package/dist/framework.d.ts +7 -1
- package/dist/functions.d.ts +15 -0
- package/dist/index.js +98 -10
- package/dist/logger.d.ts +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
package/dist/browser.js
CHANGED
|
@@ -5841,13 +5841,15 @@ var objectTypes = z.enum([
|
|
|
5841
5841
|
"acl",
|
|
5842
5842
|
"user",
|
|
5843
5843
|
"project_score",
|
|
5844
|
-
"project_tag"
|
|
5844
|
+
"project_tag",
|
|
5845
|
+
"function"
|
|
5845
5846
|
]);
|
|
5846
5847
|
var objectTypesWithEvent = z.enum([
|
|
5847
5848
|
"project",
|
|
5848
5849
|
"experiment",
|
|
5849
5850
|
"dataset",
|
|
5850
5851
|
"prompt",
|
|
5852
|
+
"function",
|
|
5851
5853
|
"prompt_session"
|
|
5852
5854
|
]);
|
|
5853
5855
|
function getEventObjectType(objectType2) {
|
|
@@ -6120,6 +6122,9 @@ var apiKeySchema = z.strictObject({
|
|
|
6120
6122
|
user_id: userSchema.shape.id.nullish(),
|
|
6121
6123
|
org_id: organizationSchema.shape.id.nullish()
|
|
6122
6124
|
}).openapi("ApiKey");
|
|
6125
|
+
var projectSettingsSchema = z.strictObject({
|
|
6126
|
+
comparison_key: z.string().nullish().describe("The key used to join two experiments (defaults to `input`).")
|
|
6127
|
+
}).strip();
|
|
6123
6128
|
var projectBaseSchema = generateBaseTableSchema("project");
|
|
6124
6129
|
var projectSchema = z.strictObject({
|
|
6125
6130
|
id: projectBaseSchema.shape.id,
|
|
@@ -6129,7 +6134,8 @@ var projectSchema = z.strictObject({
|
|
|
6129
6134
|
name: projectBaseSchema.shape.name,
|
|
6130
6135
|
created: projectBaseSchema.shape.created,
|
|
6131
6136
|
deleted_at: projectBaseSchema.shape.deleted_at,
|
|
6132
|
-
user_id: projectBaseSchema.shape.user_id
|
|
6137
|
+
user_id: projectBaseSchema.shape.user_id,
|
|
6138
|
+
settings: projectSettingsSchema.nullish()
|
|
6133
6139
|
}).openapi("Project");
|
|
6134
6140
|
var datasetBaseSchema = generateBaseTableSchema("dataset", {
|
|
6135
6141
|
uniqueName: true
|
|
@@ -6143,17 +6149,20 @@ var datasetSchema = z.strictObject({
|
|
|
6143
6149
|
deleted_at: datasetBaseSchema.shape.deleted_at,
|
|
6144
6150
|
user_id: datasetBaseSchema.shape.user_id
|
|
6145
6151
|
}).openapi("Dataset");
|
|
6152
|
+
var validRuntimesEnum = z.enum(["node"]);
|
|
6153
|
+
var runtimeContextSchema = z.strictObject({
|
|
6154
|
+
runtime: validRuntimesEnum,
|
|
6155
|
+
version: z.string()
|
|
6156
|
+
});
|
|
6146
6157
|
var promptBaseSchema = generateBaseTableSchema("prompt");
|
|
6147
|
-
var
|
|
6158
|
+
var promptSchemaObject = z.strictObject({
|
|
6148
6159
|
id: promptBaseSchema.shape.id,
|
|
6149
6160
|
// This has to be copy/pasted because zod blows up when there are circular dependencies
|
|
6150
6161
|
_xact_id: z.string().describe(
|
|
6151
6162
|
`The transaction id of an event is unique to the network operation that processed the event insertion. Transaction ids are monotonically increasing over time and can be used to retrieve a versioned snapshot of the prompt (see the \`version\` parameter)`
|
|
6152
6163
|
),
|
|
6153
6164
|
project_id: promptBaseSchema.shape.project_id,
|
|
6154
|
-
log_id: z.literal("p").describe(
|
|
6155
|
-
"A literal 'p' which identifies the object as a project prompt"
|
|
6156
|
-
),
|
|
6165
|
+
log_id: z.literal("p").describe("A literal 'p' which identifies the object as a project prompt"),
|
|
6157
6166
|
org_id: organizationSchema.shape.id,
|
|
6158
6167
|
name: promptBaseSchema.shape.name,
|
|
6159
6168
|
slug: z.string().describe("Unique identifier for the prompt"),
|
|
@@ -6162,7 +6171,42 @@ var promptSchema = z.strictObject({
|
|
|
6162
6171
|
prompt_data: promptDataSchema.nullish().describe("The prompt, model, and its parameters"),
|
|
6163
6172
|
tags: z.array(z.string()).nullish().describe("A list of tags for the prompt"),
|
|
6164
6173
|
metadata: promptBaseSchema.shape.metadata
|
|
6165
|
-
})
|
|
6174
|
+
});
|
|
6175
|
+
var promptSchema = promptSchemaObject.openapi("Prompt");
|
|
6176
|
+
var codeBundleSchema = z.strictObject({
|
|
6177
|
+
runtime_context: z.strictObject({
|
|
6178
|
+
runtime: validRuntimesEnum,
|
|
6179
|
+
version: z.string()
|
|
6180
|
+
}),
|
|
6181
|
+
// This should be a union, once we support code living in different places
|
|
6182
|
+
// Other options should be:
|
|
6183
|
+
// - a "handler" function that has some signature [does AWS lambda assume it's always called "handler"?]
|
|
6184
|
+
location: z.strictObject({
|
|
6185
|
+
type: z.literal("experiment"),
|
|
6186
|
+
eval_name: z.string(),
|
|
6187
|
+
position: z.union([
|
|
6188
|
+
z.literal("task"),
|
|
6189
|
+
z.strictObject({ score: z.number() })
|
|
6190
|
+
])
|
|
6191
|
+
}),
|
|
6192
|
+
bundle_id: z.string()
|
|
6193
|
+
});
|
|
6194
|
+
var functionDataSchema = z.union([
|
|
6195
|
+
z.strictObject({
|
|
6196
|
+
type: z.literal("prompt")
|
|
6197
|
+
// For backwards compatibility reasons, this is hoisted out and stored
|
|
6198
|
+
// in the outer object
|
|
6199
|
+
}),
|
|
6200
|
+
z.strictObject({
|
|
6201
|
+
type: z.literal("code"),
|
|
6202
|
+
data: codeBundleSchema
|
|
6203
|
+
})
|
|
6204
|
+
]);
|
|
6205
|
+
var functionSchema2 = promptSchemaObject.merge(
|
|
6206
|
+
z.strictObject({
|
|
6207
|
+
function_data: functionDataSchema
|
|
6208
|
+
})
|
|
6209
|
+
).openapi("Function");
|
|
6166
6210
|
var repoInfoSchema = z.strictObject({
|
|
6167
6211
|
commit: z.string().nullish().describe("SHA of most recent commit"),
|
|
6168
6212
|
branch: z.string().nullish().describe("Name of the branch the most recent commit belongs to"),
|
|
@@ -6415,7 +6459,10 @@ var createProjectSchema = z.strictObject({
|
|
|
6415
6459
|
org_name: createProjectBaseSchema.shape.org_name
|
|
6416
6460
|
}).openapi("CreateProject");
|
|
6417
6461
|
var patchProjectSchema = z.strictObject({
|
|
6418
|
-
name: projectSchema.shape.name.nullish()
|
|
6462
|
+
name: projectSchema.shape.name.nullish(),
|
|
6463
|
+
settings: projectSchema.shape.settings.describe(
|
|
6464
|
+
"Project settings. Patch operations replace all settings, so make sure you include all settings you want to keep."
|
|
6465
|
+
).nullish()
|
|
6419
6466
|
}).openapi("PatchProject");
|
|
6420
6467
|
var createExperimentSchema = z.strictObject({
|
|
6421
6468
|
project_id: experimentSchema.shape.project_id,
|
|
@@ -6449,12 +6496,27 @@ var createPromptSchema = promptSchema.omit({
|
|
|
6449
6496
|
created: true,
|
|
6450
6497
|
metadata: true
|
|
6451
6498
|
}).openapi("CreatePrompt");
|
|
6499
|
+
var createFunctionSchema = functionSchema2.omit({
|
|
6500
|
+
id: true,
|
|
6501
|
+
_xact_id: true,
|
|
6502
|
+
org_id: true,
|
|
6503
|
+
log_id: true,
|
|
6504
|
+
created: true,
|
|
6505
|
+
metadata: true
|
|
6506
|
+
}).openapi("CreateFunction");
|
|
6452
6507
|
var patchPromptSchema = z.strictObject({
|
|
6453
6508
|
name: promptSchema.shape.name.nullish(),
|
|
6454
6509
|
description: promptSchema.shape.description.nullish(),
|
|
6455
6510
|
prompt_data: promptSchema.shape.prompt_data.nullish(),
|
|
6456
6511
|
tags: promptSchema.shape.tags.nullish()
|
|
6457
6512
|
}).openapi("PatchPrompt");
|
|
6513
|
+
var patchFunctionSchema = z.strictObject({
|
|
6514
|
+
name: functionSchema2.shape.name.nullish(),
|
|
6515
|
+
description: functionSchema2.shape.description.nullish(),
|
|
6516
|
+
prompt_data: functionSchema2.shape.prompt_data.nullish(),
|
|
6517
|
+
function_data: functionSchema2.shape.function_data.nullish(),
|
|
6518
|
+
tags: functionSchema2.shape.tags.nullish()
|
|
6519
|
+
}).openapi("PatchFunction");
|
|
6458
6520
|
var createRoleBaseSchema = generateBaseTableOpSchema("role");
|
|
6459
6521
|
var createRoleSchema = z.strictObject({
|
|
6460
6522
|
name: roleSchema.shape.name,
|
|
@@ -6786,6 +6848,7 @@ var promptSessionEventSchema = z.strictObject({
|
|
|
6786
6848
|
completion: customTypes.any.describe("Data about the completion"),
|
|
6787
6849
|
tags: promptSessionEventBaseSchema.shape.tags
|
|
6788
6850
|
}).openapi("PromptSessionEvent");
|
|
6851
|
+
var functionEventBaseSchema = generateBaseEventOpSchema("function");
|
|
6789
6852
|
var projectLogsEventBaseSchema = generateBaseEventOpSchema("project");
|
|
6790
6853
|
var projectLogsEventSchema = z.strictObject({
|
|
6791
6854
|
id: projectLogsEventBaseSchema.shape.id,
|
|
@@ -6968,6 +7031,17 @@ var feedbackPromptRequestSchema = makeFeedbackRequestSchema(
|
|
|
6968
7031
|
"prompt",
|
|
6969
7032
|
feedbackPromptItemSchema
|
|
6970
7033
|
);
|
|
7034
|
+
var feedbackFunctionRequestBaseSchema = generateBaseEventFeedbackSchema("function");
|
|
7035
|
+
var feedbackFunctionItemSchema = z.strictObject({
|
|
7036
|
+
id: feedbackFunctionRequestBaseSchema.shape.id,
|
|
7037
|
+
comment: feedbackFunctionRequestBaseSchema.shape.comment,
|
|
7038
|
+
metadata: feedbackFunctionRequestBaseSchema.shape.metadata,
|
|
7039
|
+
source: feedbackFunctionRequestBaseSchema.shape.source
|
|
7040
|
+
}).openapi("FeedbackFunctionItem");
|
|
7041
|
+
var feedbackFunctionRequestSchema = makeFeedbackRequestSchema(
|
|
7042
|
+
"function",
|
|
7043
|
+
feedbackFunctionItemSchema
|
|
7044
|
+
);
|
|
6971
7045
|
var feedbackPromptSessionRequestBaseSchema = generateBaseEventFeedbackSchema("prompt_session");
|
|
6972
7046
|
var feedbackPromptSessionItemSchema = z.strictObject({
|
|
6973
7047
|
id: feedbackPromptSessionRequestBaseSchema.shape.id,
|
|
@@ -7018,6 +7092,14 @@ var eventObjectSchemas = {
|
|
|
7018
7092
|
feedbackItem: feedbackPromptItemSchema,
|
|
7019
7093
|
feedbackRequest: feedbackPromptRequestSchema
|
|
7020
7094
|
},
|
|
7095
|
+
function: {
|
|
7096
|
+
event: functionSchema2,
|
|
7097
|
+
fetchResponse: void 0,
|
|
7098
|
+
insertEvent: void 0,
|
|
7099
|
+
insertRequest: void 0,
|
|
7100
|
+
feedbackItem: feedbackFunctionItemSchema,
|
|
7101
|
+
feedbackRequest: feedbackFunctionRequestSchema
|
|
7102
|
+
},
|
|
7021
7103
|
prompt_session: {
|
|
7022
7104
|
event: promptSessionEventSchema,
|
|
7023
7105
|
fetchResponse: void 0,
|
|
@@ -9425,6 +9507,9 @@ var ReadonlyExperiment = class extends ObjectFetcher {
|
|
|
9425
9507
|
}
|
|
9426
9508
|
};
|
|
9427
9509
|
var executionCounter = 0;
|
|
9510
|
+
function newId() {
|
|
9511
|
+
return v4_default();
|
|
9512
|
+
}
|
|
9428
9513
|
var SpanImpl = class _SpanImpl {
|
|
9429
9514
|
// `internalData` contains fields that are not part of the "user-sanitized"
|
|
9430
9515
|
// set of fields which we want to log in just one of the span rows.
|
|
@@ -10230,6 +10315,7 @@ export {
|
|
|
10230
10315
|
loadPrompt,
|
|
10231
10316
|
log,
|
|
10232
10317
|
login,
|
|
10318
|
+
newId,
|
|
10233
10319
|
parseCachedHeader,
|
|
10234
10320
|
startSpan,
|
|
10235
10321
|
summarize,
|
package/dist/cli.d.ts
CHANGED
|
@@ -1,2 +1,35 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import * as esbuild from "esbuild";
|
|
3
|
+
import { EvaluatorDef, EvaluatorFile, ReporterDef } from "./framework";
|
|
4
|
+
interface BuildSuccess {
|
|
5
|
+
type: "success";
|
|
6
|
+
result: esbuild.BuildResult;
|
|
7
|
+
evaluator: EvaluatorFile;
|
|
8
|
+
sourceFile: string;
|
|
9
|
+
}
|
|
10
|
+
interface BuildFailure {
|
|
11
|
+
type: "failure";
|
|
12
|
+
error: Error;
|
|
13
|
+
sourceFile: string;
|
|
14
|
+
}
|
|
15
|
+
type BuildResult = BuildSuccess | BuildFailure;
|
|
16
|
+
export interface FileHandle {
|
|
17
|
+
inFile: string;
|
|
18
|
+
outFile: string;
|
|
19
|
+
bundleFile?: string;
|
|
20
|
+
rebuild: () => Promise<BuildResult>;
|
|
21
|
+
bundle: () => Promise<esbuild.BuildResult>;
|
|
22
|
+
watch: () => void;
|
|
23
|
+
destroy: () => Promise<void>;
|
|
24
|
+
}
|
|
25
|
+
export interface EvaluatorState {
|
|
26
|
+
evaluators: {
|
|
27
|
+
sourceFile: string;
|
|
28
|
+
evaluator: EvaluatorDef<any, any, any, any>;
|
|
29
|
+
reporter: string | ReporterDef<any> | undefined;
|
|
30
|
+
}[];
|
|
31
|
+
reporters: {
|
|
32
|
+
[reporter: string]: ReporterDef<any>;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
2
35
|
export {};
|