braintrust 3.19.0 → 3.20.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.js +7 -4
- package/dev/dist/index.mjs +7 -4
- package/dist/browser.d.mts +14 -3
- package/dist/browser.d.ts +14 -3
- package/dist/browser.js +9 -4
- package/dist/browser.mjs +9 -4
- package/dist/{chunk-VEQ2PCMC.mjs → chunk-F73OMF66.mjs} +8 -4
- package/dist/{chunk-37RLJF2U.js → chunk-POCCIJAL.js} +9 -5
- package/dist/cli.js +8 -5
- package/dist/edge-light.d.mts +1 -1
- package/dist/edge-light.d.ts +1 -1
- package/dist/edge-light.js +9 -4
- package/dist/edge-light.mjs +9 -4
- package/dist/index.d.mts +14 -3
- package/dist/index.d.ts +14 -3
- package/dist/index.js +213 -210
- package/dist/index.mjs +4 -1
- package/dist/instrumentation/index.d.mts +12 -2
- package/dist/instrumentation/index.d.ts +12 -2
- package/dist/instrumentation/index.js +9 -4
- package/dist/instrumentation/index.mjs +8 -4
- package/dist/vitest-evals-reporter.js +15 -15
- package/dist/vitest-evals-reporter.mjs +1 -1
- package/dist/workerd.d.mts +1 -1
- package/dist/workerd.d.ts +1 -1
- package/dist/workerd.js +9 -4
- package/dist/workerd.mjs +9 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -128,7 +128,8 @@
|
|
|
128
128
|
|
|
129
129
|
|
|
130
130
|
|
|
131
|
-
|
|
131
|
+
|
|
132
|
+
var _chunkPOCCIJALjs = require('./chunk-POCCIJAL.js');
|
|
132
133
|
|
|
133
134
|
|
|
134
135
|
|
|
@@ -156,135 +157,136 @@ var _chunkLPC4W2WXjs = require('./chunk-LPC4W2WX.js');
|
|
|
156
157
|
// src/exports.ts
|
|
157
158
|
var exports_exports = {};
|
|
158
159
|
_chunkLPC4W2WXjs.__export.call(void 0, exports_exports, {
|
|
159
|
-
Attachment: () =>
|
|
160
|
-
AttachmentReference: () =>
|
|
161
|
-
BRAINTRUST_CURRENT_SPAN_STORE: () =>
|
|
162
|
-
BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME: () =>
|
|
163
|
-
BaseAttachment: () =>
|
|
160
|
+
Attachment: () => _chunkPOCCIJALjs.Attachment,
|
|
161
|
+
AttachmentReference: () => _chunkPOCCIJALjs.AttachmentReference,
|
|
162
|
+
BRAINTRUST_CURRENT_SPAN_STORE: () => _chunkPOCCIJALjs.BRAINTRUST_CURRENT_SPAN_STORE,
|
|
163
|
+
BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME: () => _chunkPOCCIJALjs.BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME,
|
|
164
|
+
BaseAttachment: () => _chunkPOCCIJALjs.BaseAttachment,
|
|
164
165
|
BaseExperiment: () => BaseExperiment,
|
|
165
|
-
BraintrustLangChainCallbackHandler: () =>
|
|
166
|
+
BraintrustLangChainCallbackHandler: () => _chunkPOCCIJALjs.BraintrustLangChainCallbackHandler,
|
|
166
167
|
BraintrustMiddleware: () => BraintrustMiddleware,
|
|
167
|
-
BraintrustObservabilityExporter: () =>
|
|
168
|
-
BraintrustState: () =>
|
|
169
|
-
BraintrustStream: () =>
|
|
168
|
+
BraintrustObservabilityExporter: () => _chunkPOCCIJALjs.BraintrustObservabilityExporter,
|
|
169
|
+
BraintrustState: () => _chunkPOCCIJALjs.BraintrustState,
|
|
170
|
+
BraintrustStream: () => _chunkPOCCIJALjs.BraintrustStream,
|
|
170
171
|
CachedSpanFetcher: () => CachedSpanFetcher,
|
|
171
172
|
CodeFunction: () => CodeFunction,
|
|
172
173
|
CodePrompt: () => CodePrompt,
|
|
173
|
-
ContextManager: () =>
|
|
174
|
-
DEFAULT_FETCH_BATCH_SIZE: () =>
|
|
175
|
-
DEFAULT_MAX_REQUEST_SIZE: () =>
|
|
176
|
-
Dataset: () =>
|
|
174
|
+
ContextManager: () => _chunkPOCCIJALjs.ContextManager,
|
|
175
|
+
DEFAULT_FETCH_BATCH_SIZE: () => _chunkPOCCIJALjs.DEFAULT_FETCH_BATCH_SIZE,
|
|
176
|
+
DEFAULT_MAX_REQUEST_SIZE: () => _chunkPOCCIJALjs.DEFAULT_MAX_REQUEST_SIZE,
|
|
177
|
+
Dataset: () => _chunkPOCCIJALjs.Dataset,
|
|
177
178
|
DatasetPipeline: () => DatasetPipeline,
|
|
178
|
-
ERR_PERMALINK: () =>
|
|
179
|
+
ERR_PERMALINK: () => _chunkPOCCIJALjs.ERR_PERMALINK,
|
|
179
180
|
Eval: () => Eval,
|
|
180
181
|
EvalResultWithSummary: () => EvalResultWithSummary,
|
|
181
|
-
Experiment: () =>
|
|
182
|
-
ExternalAttachment: () =>
|
|
183
|
-
FailedHTTPResponse: () =>
|
|
184
|
-
IDGenerator: () =>
|
|
185
|
-
JSONAttachment: () =>
|
|
186
|
-
LEGACY_CACHED_HEADER: () =>
|
|
187
|
-
LOGS3_OVERFLOW_REFERENCE_TYPE: () =>
|
|
188
|
-
LazyValue: () =>
|
|
182
|
+
Experiment: () => _chunkPOCCIJALjs.Experiment,
|
|
183
|
+
ExternalAttachment: () => _chunkPOCCIJALjs.ExternalAttachment,
|
|
184
|
+
FailedHTTPResponse: () => _chunkPOCCIJALjs.FailedHTTPResponse,
|
|
185
|
+
IDGenerator: () => _chunkPOCCIJALjs.IDGenerator,
|
|
186
|
+
JSONAttachment: () => _chunkPOCCIJALjs.JSONAttachment,
|
|
187
|
+
LEGACY_CACHED_HEADER: () => _chunkPOCCIJALjs.LEGACY_CACHED_HEADER,
|
|
188
|
+
LOGS3_OVERFLOW_REFERENCE_TYPE: () => _chunkPOCCIJALjs.LOGS3_OVERFLOW_REFERENCE_TYPE,
|
|
189
|
+
LazyValue: () => _chunkPOCCIJALjs.LazyValue,
|
|
189
190
|
LocalTrace: () => LocalTrace,
|
|
190
|
-
Logger: () =>
|
|
191
|
-
LoginInvalidOrgError: () =>
|
|
192
|
-
NOOP_SPAN: () =>
|
|
193
|
-
NOOP_SPAN_PERMALINK: () =>
|
|
194
|
-
NoopSpan: () =>
|
|
195
|
-
ObjectFetcher: () =>
|
|
191
|
+
Logger: () => _chunkPOCCIJALjs.Logger,
|
|
192
|
+
LoginInvalidOrgError: () => _chunkPOCCIJALjs.LoginInvalidOrgError,
|
|
193
|
+
NOOP_SPAN: () => _chunkPOCCIJALjs.NOOP_SPAN,
|
|
194
|
+
NOOP_SPAN_PERMALINK: () => _chunkPOCCIJALjs.NOOP_SPAN_PERMALINK,
|
|
195
|
+
NoopSpan: () => _chunkPOCCIJALjs.NoopSpan,
|
|
196
|
+
ObjectFetcher: () => _chunkPOCCIJALjs.ObjectFetcher,
|
|
196
197
|
Project: () => Project2,
|
|
197
198
|
ProjectNameIdMap: () => ProjectNameIdMap,
|
|
198
|
-
Prompt: () =>
|
|
199
|
+
Prompt: () => _chunkPOCCIJALjs.Prompt,
|
|
199
200
|
PromptBuilder: () => PromptBuilder,
|
|
200
|
-
ReadonlyAttachment: () =>
|
|
201
|
-
ReadonlyExperiment: () =>
|
|
201
|
+
ReadonlyAttachment: () => _chunkPOCCIJALjs.ReadonlyAttachment,
|
|
202
|
+
ReadonlyExperiment: () => _chunkPOCCIJALjs.ReadonlyExperiment,
|
|
202
203
|
Reporter: () => Reporter,
|
|
203
204
|
ScorerBuilder: () => ScorerBuilder,
|
|
204
205
|
SpanFetcher: () => SpanFetcher,
|
|
205
|
-
SpanImpl: () =>
|
|
206
|
-
TestBackgroundLogger: () =>
|
|
206
|
+
SpanImpl: () => _chunkPOCCIJALjs.SpanImpl,
|
|
207
|
+
TestBackgroundLogger: () => _chunkPOCCIJALjs.TestBackgroundLogger,
|
|
207
208
|
ToolBuilder: () => ToolBuilder,
|
|
208
|
-
UUIDGenerator: () =>
|
|
209
|
-
X_CACHED_HEADER: () =>
|
|
210
|
-
_exportsForTestingOnly: () =>
|
|
211
|
-
_internalGetGlobalState: () =>
|
|
209
|
+
UUIDGenerator: () => _chunkPOCCIJALjs.UUIDGenerator,
|
|
210
|
+
X_CACHED_HEADER: () => _chunkPOCCIJALjs.X_CACHED_HEADER,
|
|
211
|
+
_exportsForTestingOnly: () => _chunkPOCCIJALjs._exportsForTestingOnly,
|
|
212
|
+
_internalGetGlobalState: () => _chunkPOCCIJALjs._internalGetGlobalState,
|
|
212
213
|
_internalIso: () => _chunkLPC4W2WXjs.isomorph_default,
|
|
213
|
-
_internalSetInitialState: () =>
|
|
214
|
-
addAzureBlobHeaders: () =>
|
|
215
|
-
braintrustAISDKTelemetry: () =>
|
|
216
|
-
|
|
217
|
-
|
|
214
|
+
_internalSetInitialState: () => _chunkPOCCIJALjs._internalSetInitialState,
|
|
215
|
+
addAzureBlobHeaders: () => _chunkPOCCIJALjs.addAzureBlobHeaders,
|
|
216
|
+
braintrustAISDKTelemetry: () => _chunkPOCCIJALjs.braintrustAISDKTelemetry,
|
|
217
|
+
braintrustFlueInstrumentation: () => _chunkPOCCIJALjs.braintrustFlueInstrumentation,
|
|
218
|
+
braintrustFlueObserver: () => _chunkPOCCIJALjs.braintrustFlueObserver,
|
|
219
|
+
braintrustStreamChunkSchema: () => _chunkPOCCIJALjs.braintrustStreamChunkSchema,
|
|
218
220
|
buildLocalSummary: () => buildLocalSummary,
|
|
219
|
-
configureInstrumentation: () =>
|
|
220
|
-
constructLogs3OverflowRequest: () =>
|
|
221
|
-
createFinalValuePassThroughStream: () =>
|
|
222
|
-
currentExperiment: () =>
|
|
223
|
-
currentLogger: () =>
|
|
224
|
-
currentSpan: () =>
|
|
225
|
-
deepCopyEvent: () =>
|
|
221
|
+
configureInstrumentation: () => _chunkPOCCIJALjs.configureInstrumentation,
|
|
222
|
+
constructLogs3OverflowRequest: () => _chunkPOCCIJALjs.constructLogs3OverflowRequest,
|
|
223
|
+
createFinalValuePassThroughStream: () => _chunkPOCCIJALjs.createFinalValuePassThroughStream,
|
|
224
|
+
currentExperiment: () => _chunkPOCCIJALjs.currentExperiment,
|
|
225
|
+
currentLogger: () => _chunkPOCCIJALjs.currentLogger,
|
|
226
|
+
currentSpan: () => _chunkPOCCIJALjs.currentSpan,
|
|
227
|
+
deepCopyEvent: () => _chunkPOCCIJALjs.deepCopyEvent,
|
|
226
228
|
defaultErrorScoreHandler: () => defaultErrorScoreHandler,
|
|
227
|
-
deserializePlainStringAsJSON: () =>
|
|
228
|
-
devNullWritableStream: () =>
|
|
229
|
+
deserializePlainStringAsJSON: () => _chunkPOCCIJALjs.deserializePlainStringAsJSON,
|
|
230
|
+
devNullWritableStream: () => _chunkPOCCIJALjs.devNullWritableStream,
|
|
229
231
|
evaluatorDefinitionSchema: () => evaluatorDefinitionSchema,
|
|
230
232
|
evaluatorDefinitionsSchema: () => evaluatorDefinitionsSchema,
|
|
231
|
-
flush: () =>
|
|
232
|
-
getContextManager: () =>
|
|
233
|
-
getIdGenerator: () =>
|
|
234
|
-
getPromptVersions: () =>
|
|
235
|
-
getSpanParentObject: () =>
|
|
236
|
-
getTemplateRenderer: () =>
|
|
233
|
+
flush: () => _chunkPOCCIJALjs.flush,
|
|
234
|
+
getContextManager: () => _chunkPOCCIJALjs.getContextManager,
|
|
235
|
+
getIdGenerator: () => _chunkPOCCIJALjs.getIdGenerator,
|
|
236
|
+
getPromptVersions: () => _chunkPOCCIJALjs.getPromptVersions,
|
|
237
|
+
getSpanParentObject: () => _chunkPOCCIJALjs.getSpanParentObject,
|
|
238
|
+
getTemplateRenderer: () => _chunkPOCCIJALjs.getTemplateRenderer,
|
|
237
239
|
graph: () => graph_framework_exports,
|
|
238
|
-
init: () =>
|
|
239
|
-
initDataset: () =>
|
|
240
|
-
initExperiment: () =>
|
|
240
|
+
init: () => _chunkPOCCIJALjs.init,
|
|
241
|
+
initDataset: () => _chunkPOCCIJALjs.initDataset,
|
|
242
|
+
initExperiment: () => _chunkPOCCIJALjs.initExperiment,
|
|
241
243
|
initFunction: () => initFunction,
|
|
242
|
-
initLogger: () =>
|
|
244
|
+
initLogger: () => _chunkPOCCIJALjs.initLogger,
|
|
243
245
|
initNodeTestSuite: () => initNodeTestSuite,
|
|
244
246
|
invoke: () => invoke,
|
|
245
|
-
isTemplateFormat: () =>
|
|
246
|
-
loadParameters: () =>
|
|
247
|
-
loadPrompt: () =>
|
|
248
|
-
log: () =>
|
|
249
|
-
logError: () =>
|
|
250
|
-
login: () =>
|
|
251
|
-
loginToState: () =>
|
|
252
|
-
logs3OverflowUploadSchema: () =>
|
|
253
|
-
newId: () =>
|
|
254
|
-
parseCachedHeader: () =>
|
|
255
|
-
parseTemplateFormat: () =>
|
|
256
|
-
permalink: () =>
|
|
257
|
-
pickLogs3OverflowObjectIds: () =>
|
|
247
|
+
isTemplateFormat: () => _chunkPOCCIJALjs.isTemplateFormat,
|
|
248
|
+
loadParameters: () => _chunkPOCCIJALjs.loadParameters,
|
|
249
|
+
loadPrompt: () => _chunkPOCCIJALjs.loadPrompt,
|
|
250
|
+
log: () => _chunkPOCCIJALjs.log,
|
|
251
|
+
logError: () => _chunkPOCCIJALjs.logError,
|
|
252
|
+
login: () => _chunkPOCCIJALjs.login,
|
|
253
|
+
loginToState: () => _chunkPOCCIJALjs.loginToState,
|
|
254
|
+
logs3OverflowUploadSchema: () => _chunkPOCCIJALjs.logs3OverflowUploadSchema,
|
|
255
|
+
newId: () => _chunkPOCCIJALjs.newId,
|
|
256
|
+
parseCachedHeader: () => _chunkPOCCIJALjs.parseCachedHeader,
|
|
257
|
+
parseTemplateFormat: () => _chunkPOCCIJALjs.parseTemplateFormat,
|
|
258
|
+
permalink: () => _chunkPOCCIJALjs.permalink,
|
|
259
|
+
pickLogs3OverflowObjectIds: () => _chunkPOCCIJALjs.pickLogs3OverflowObjectIds,
|
|
258
260
|
projects: () => projects,
|
|
259
261
|
promptContentsSchema: () => promptContentsSchema,
|
|
260
262
|
promptDefinitionSchema: () => promptDefinitionSchema,
|
|
261
263
|
promptDefinitionToPromptData: () => promptDefinitionToPromptData,
|
|
262
264
|
promptDefinitionWithToolsSchema: () => promptDefinitionWithToolsSchema,
|
|
263
|
-
registerOtelFlush: () =>
|
|
265
|
+
registerOtelFlush: () => _chunkPOCCIJALjs.registerOtelFlush,
|
|
264
266
|
registerSandbox: () => registerSandbox,
|
|
265
|
-
registerTemplatePlugin: () =>
|
|
266
|
-
renderMessage: () =>
|
|
267
|
-
renderPromptParams: () =>
|
|
268
|
-
renderTemplateContent: () =>
|
|
267
|
+
registerTemplatePlugin: () => _chunkPOCCIJALjs.registerTemplatePlugin,
|
|
268
|
+
renderMessage: () => _chunkPOCCIJALjs.renderMessage,
|
|
269
|
+
renderPromptParams: () => _chunkPOCCIJALjs.renderPromptParams,
|
|
270
|
+
renderTemplateContent: () => _chunkPOCCIJALjs.renderTemplateContent,
|
|
269
271
|
reportFailures: () => reportFailures,
|
|
270
272
|
runEvaluator: () => runEvaluator,
|
|
271
|
-
setFetch: () =>
|
|
272
|
-
setMaskingFunction: () =>
|
|
273
|
-
spanComponentsToObjectId: () =>
|
|
274
|
-
startSpan: () =>
|
|
275
|
-
summarize: () =>
|
|
276
|
-
templateRegistry: () =>
|
|
277
|
-
toolFunctionDefinitionSchema: () =>
|
|
278
|
-
traceable: () =>
|
|
279
|
-
traced: () =>
|
|
280
|
-
updateSpan: () =>
|
|
281
|
-
uploadLogs3OverflowPayload: () =>
|
|
282
|
-
utf8ByteLength: () =>
|
|
283
|
-
withCurrent: () =>
|
|
284
|
-
withDataset: () =>
|
|
285
|
-
withExperiment: () =>
|
|
286
|
-
withLogger: () =>
|
|
287
|
-
withParent: () =>
|
|
273
|
+
setFetch: () => _chunkPOCCIJALjs.setFetch,
|
|
274
|
+
setMaskingFunction: () => _chunkPOCCIJALjs.setMaskingFunction,
|
|
275
|
+
spanComponentsToObjectId: () => _chunkPOCCIJALjs.spanComponentsToObjectId,
|
|
276
|
+
startSpan: () => _chunkPOCCIJALjs.startSpan,
|
|
277
|
+
summarize: () => _chunkPOCCIJALjs.summarize,
|
|
278
|
+
templateRegistry: () => _chunkPOCCIJALjs.templateRegistry,
|
|
279
|
+
toolFunctionDefinitionSchema: () => _chunkPOCCIJALjs.ToolFunctionDefinition,
|
|
280
|
+
traceable: () => _chunkPOCCIJALjs.traceable,
|
|
281
|
+
traced: () => _chunkPOCCIJALjs.traced,
|
|
282
|
+
updateSpan: () => _chunkPOCCIJALjs.updateSpan,
|
|
283
|
+
uploadLogs3OverflowPayload: () => _chunkPOCCIJALjs.uploadLogs3OverflowPayload,
|
|
284
|
+
utf8ByteLength: () => _chunkPOCCIJALjs.utf8ByteLength,
|
|
285
|
+
withCurrent: () => _chunkPOCCIJALjs.withCurrent,
|
|
286
|
+
withDataset: () => _chunkPOCCIJALjs.withDataset,
|
|
287
|
+
withExperiment: () => _chunkPOCCIJALjs.withExperiment,
|
|
288
|
+
withLogger: () => _chunkPOCCIJALjs.withLogger,
|
|
289
|
+
withParent: () => _chunkPOCCIJALjs.withParent,
|
|
288
290
|
wrapAISDK: () => wrapAISDK,
|
|
289
291
|
wrapAISDKModel: () => wrapAISDKModel,
|
|
290
292
|
wrapAgentClass: () => wrapAgentClass,
|
|
@@ -299,7 +301,7 @@ _chunkLPC4W2WXjs.__export.call(void 0, exports_exports, {
|
|
|
299
301
|
wrapGoogleGenAI: () => wrapGoogleGenAI,
|
|
300
302
|
wrapGroq: () => wrapGroq,
|
|
301
303
|
wrapHuggingFace: () => wrapHuggingFace,
|
|
302
|
-
wrapMastraAgent: () =>
|
|
304
|
+
wrapMastraAgent: () => _chunkPOCCIJALjs.wrapMastraAgent,
|
|
303
305
|
wrapMistral: () => wrapMistral,
|
|
304
306
|
wrapOpenAI: () => wrapOpenAI,
|
|
305
307
|
wrapOpenAICodexSDK: () => wrapOpenAICodexSDK,
|
|
@@ -308,7 +310,7 @@ _chunkLPC4W2WXjs.__export.call(void 0, exports_exports, {
|
|
|
308
310
|
wrapOpenRouterAgent: () => wrapOpenRouterAgent,
|
|
309
311
|
wrapPiCodingAgentSDK: () => wrapPiCodingAgentSDK,
|
|
310
312
|
wrapStrandsAgentSDK: () => wrapStrandsAgentSDK,
|
|
311
|
-
wrapTraced: () =>
|
|
313
|
+
wrapTraced: () => _chunkPOCCIJALjs.wrapTraced,
|
|
312
314
|
wrapVitest: () => wrapVitest
|
|
313
315
|
});
|
|
314
316
|
|
|
@@ -316,7 +318,7 @@ _chunkLPC4W2WXjs.__export.call(void 0, exports_exports, {
|
|
|
316
318
|
var _v3 = require('zod/v3');
|
|
317
319
|
var SANDBOX_GROUP_NAME_METADATA_KEY = "_bt_sandbox_group_name";
|
|
318
320
|
async function registerSandbox(options) {
|
|
319
|
-
const state = _nullishCoalesce(options.state, () => (
|
|
321
|
+
const state = _nullishCoalesce(options.state, () => ( _chunkPOCCIJALjs._internalGetGlobalState.call(void 0, )));
|
|
320
322
|
await state.login({
|
|
321
323
|
apiKey: options.apiKey,
|
|
322
324
|
appUrl: options.appUrl,
|
|
@@ -357,7 +359,7 @@ async function registerSandbox(options) {
|
|
|
357
359
|
evaluatorDefinitions
|
|
358
360
|
)) {
|
|
359
361
|
const functionName = evalName;
|
|
360
|
-
const functionSlug =
|
|
362
|
+
const functionSlug = _chunkPOCCIJALjs.slugify.call(void 0, evalName, { lower: true, strict: true });
|
|
361
363
|
const functionDef = {
|
|
362
364
|
project_id: projectId,
|
|
363
365
|
org_name: state.orgName,
|
|
@@ -428,7 +430,7 @@ async function invoke(args) {
|
|
|
428
430
|
projectId,
|
|
429
431
|
...functionIdArgs
|
|
430
432
|
} = args;
|
|
431
|
-
const state = _nullishCoalesce(stateArg, () => (
|
|
433
|
+
const state = _nullishCoalesce(stateArg, () => ( _chunkPOCCIJALjs._internalGetGlobalState.call(void 0, )));
|
|
432
434
|
await state.login({
|
|
433
435
|
orgName,
|
|
434
436
|
apiKey,
|
|
@@ -436,8 +438,8 @@ async function invoke(args) {
|
|
|
436
438
|
forceLogin,
|
|
437
439
|
fetch
|
|
438
440
|
});
|
|
439
|
-
const parent = parentArg ? typeof parentArg === "string" ? parentArg : await parentArg.export() : await
|
|
440
|
-
const functionId =
|
|
441
|
+
const parent = parentArg ? typeof parentArg === "string" ? parentArg : await parentArg.export() : await _chunkPOCCIJALjs.getSpanParentObject.call(void 0, ).export();
|
|
442
|
+
const functionId = _chunkPOCCIJALjs.FunctionId.safeParse({
|
|
441
443
|
function_id: functionIdArgs.function_id,
|
|
442
444
|
project_name: functionIdArgs.projectName,
|
|
443
445
|
slug: functionIdArgs.slug,
|
|
@@ -480,7 +482,7 @@ async function invoke(args) {
|
|
|
480
482
|
if (!resp.body) {
|
|
481
483
|
throw new Error("Received empty stream body");
|
|
482
484
|
}
|
|
483
|
-
return new (0,
|
|
485
|
+
return new (0, _chunkPOCCIJALjs.BraintrustStream)(resp.body);
|
|
484
486
|
} else {
|
|
485
487
|
const data = await resp.json();
|
|
486
488
|
return schema ? schema.parse(data) : data;
|
|
@@ -492,7 +494,7 @@ function initFunction({
|
|
|
492
494
|
version,
|
|
493
495
|
state
|
|
494
496
|
}) {
|
|
495
|
-
const s = _nullishCoalesce(state, () => (
|
|
497
|
+
const s = _nullishCoalesce(state, () => ( _chunkPOCCIJALjs._internalGetGlobalState.call(void 0, )));
|
|
496
498
|
_optionalChain([s, 'optionalAccess', _2 => _2.spanCache, 'optionalAccess', _3 => _3.disable, 'call', _4 => _4()]);
|
|
497
499
|
const f = async (input) => {
|
|
498
500
|
return await invoke({
|
|
@@ -1130,14 +1132,14 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1130
1132
|
// For the first cut, do not support custom span_info arguments. We can
|
|
1131
1133
|
// propagate those via async local storage
|
|
1132
1134
|
async doGenerate(options) {
|
|
1133
|
-
const span =
|
|
1135
|
+
const span = _chunkPOCCIJALjs.startSpan.call(void 0, {
|
|
1134
1136
|
name: "Chat Completion",
|
|
1135
1137
|
spanAttributes: {
|
|
1136
1138
|
type: "llm"
|
|
1137
1139
|
}
|
|
1138
1140
|
});
|
|
1139
1141
|
const { prompt, mode, ...rest } = options;
|
|
1140
|
-
const startTime =
|
|
1142
|
+
const startTime = _chunkPOCCIJALjs.getCurrentUnixTimestamp.call(void 0, );
|
|
1141
1143
|
try {
|
|
1142
1144
|
const ret = await this.model.doGenerate(options);
|
|
1143
1145
|
span.log({
|
|
@@ -1149,12 +1151,12 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1149
1151
|
},
|
|
1150
1152
|
output: postProcessOutput(ret.text, ret.toolCalls, ret.finishReason),
|
|
1151
1153
|
metrics: {
|
|
1152
|
-
time_to_first_token:
|
|
1153
|
-
tokens: !
|
|
1154
|
+
time_to_first_token: _chunkPOCCIJALjs.getCurrentUnixTimestamp.call(void 0, ) - startTime,
|
|
1155
|
+
tokens: !_chunkPOCCIJALjs.isEmpty.call(void 0, ret.usage) ? ret.usage.promptTokens + ret.usage.completionTokens : void 0,
|
|
1154
1156
|
prompt_tokens: _optionalChain([ret, 'access', _20 => _20.usage, 'optionalAccess', _21 => _21.promptTokens]),
|
|
1155
1157
|
completion_tokens: _optionalChain([ret, 'access', _22 => _22.usage, 'optionalAccess', _23 => _23.completionTokens]),
|
|
1156
|
-
cached:
|
|
1157
|
-
_nullishCoalesce(_optionalChain([ret, 'access', _24 => _24.rawResponse, 'optionalAccess', _25 => _25.headers, 'optionalAccess', _26 => _26[
|
|
1158
|
+
cached: _chunkPOCCIJALjs.parseCachedHeader.call(void 0,
|
|
1159
|
+
_nullishCoalesce(_optionalChain([ret, 'access', _24 => _24.rawResponse, 'optionalAccess', _25 => _25.headers, 'optionalAccess', _26 => _26[_chunkPOCCIJALjs.X_CACHED_HEADER]]), () => ( _optionalChain([ret, 'access', _27 => _27.rawResponse, 'optionalAccess', _28 => _28.headers, 'optionalAccess', _29 => _29[_chunkPOCCIJALjs.LEGACY_CACHED_HEADER]])))
|
|
1158
1160
|
)
|
|
1159
1161
|
}
|
|
1160
1162
|
});
|
|
@@ -1165,8 +1167,8 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1165
1167
|
}
|
|
1166
1168
|
async doStream(options) {
|
|
1167
1169
|
const { prompt, mode, ...rest } = options;
|
|
1168
|
-
const startTime =
|
|
1169
|
-
const span =
|
|
1170
|
+
const startTime = _chunkPOCCIJALjs.getCurrentUnixTimestamp.call(void 0, );
|
|
1171
|
+
const span = _chunkPOCCIJALjs.startSpan.call(void 0, {
|
|
1170
1172
|
name: "Chat Completion",
|
|
1171
1173
|
spanAttributes: {
|
|
1172
1174
|
type: "llm"
|
|
@@ -1200,7 +1202,7 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1200
1202
|
new TransformStream({
|
|
1201
1203
|
transform(chunk, controller) {
|
|
1202
1204
|
if (time_to_first_token === void 0) {
|
|
1203
|
-
time_to_first_token =
|
|
1205
|
+
time_to_first_token = _chunkPOCCIJALjs.getCurrentUnixTimestamp.call(void 0, ) - startTime;
|
|
1204
1206
|
span.log({ metrics: { time_to_first_token } });
|
|
1205
1207
|
}
|
|
1206
1208
|
switch (chunk.type) {
|
|
@@ -1245,11 +1247,11 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1245
1247
|
),
|
|
1246
1248
|
metrics: {
|
|
1247
1249
|
time_to_first_token,
|
|
1248
|
-
tokens: !
|
|
1250
|
+
tokens: !_chunkPOCCIJALjs.isEmpty.call(void 0, usage) ? usage.promptTokens + usage.completionTokens : void 0,
|
|
1249
1251
|
prompt_tokens: _optionalChain([usage, 'optionalAccess', _30 => _30.promptTokens]),
|
|
1250
1252
|
completion_tokens: _optionalChain([usage, 'optionalAccess', _31 => _31.completionTokens]),
|
|
1251
|
-
cached:
|
|
1252
|
-
_nullishCoalesce(_optionalChain([ret, 'access', _32 => _32.rawResponse, 'optionalAccess', _33 => _33.headers, 'optionalAccess', _34 => _34[
|
|
1253
|
+
cached: _chunkPOCCIJALjs.parseCachedHeader.call(void 0,
|
|
1254
|
+
_nullishCoalesce(_optionalChain([ret, 'access', _32 => _32.rawResponse, 'optionalAccess', _33 => _33.headers, 'optionalAccess', _34 => _34[_chunkPOCCIJALjs.X_CACHED_HEADER]]), () => ( _optionalChain([ret, 'access', _35 => _35.rawResponse, 'optionalAccess', _36 => _36.headers, 'optionalAccess', _37 => _37[_chunkPOCCIJALjs.LEGACY_CACHED_HEADER]])))
|
|
1253
1255
|
)
|
|
1254
1256
|
}
|
|
1255
1257
|
});
|
|
@@ -1434,12 +1436,12 @@ function normalizeUsageMetrics(usage, provider, providerMetadata) {
|
|
|
1434
1436
|
anthropicMetadata.usage,
|
|
1435
1437
|
"cache_creation_input_tokens"
|
|
1436
1438
|
) || 0;
|
|
1437
|
-
const cacheTokens =
|
|
1439
|
+
const cacheTokens = _chunkPOCCIJALjs.extractAnthropicCacheTokens.call(void 0,
|
|
1438
1440
|
cacheReadTokens,
|
|
1439
1441
|
cacheCreationTokens
|
|
1440
1442
|
);
|
|
1441
1443
|
Object.assign(metrics, cacheTokens);
|
|
1442
|
-
Object.assign(metrics,
|
|
1444
|
+
Object.assign(metrics, _chunkPOCCIJALjs.finalizeAnthropicTokens.call(void 0, metrics));
|
|
1443
1445
|
}
|
|
1444
1446
|
}
|
|
1445
1447
|
return metrics;
|
|
@@ -1511,7 +1513,7 @@ function BraintrustMiddleware(config = {}) {
|
|
|
1511
1513
|
model: modelFromWrapGenerate
|
|
1512
1514
|
}) => {
|
|
1513
1515
|
const rawInput = extractInput(params);
|
|
1514
|
-
const processedInput =
|
|
1516
|
+
const processedInput = _chunkPOCCIJALjs.processInputAttachments.call(void 0, rawInput);
|
|
1515
1517
|
const spanArgs = {
|
|
1516
1518
|
name: _optionalChain([config, 'access', _54 => _54.spanInfo, 'optionalAccess', _55 => _55.name]) || "ai-sdk.doGenerate",
|
|
1517
1519
|
spanAttributes: {
|
|
@@ -1526,7 +1528,7 @@ function BraintrustMiddleware(config = {}) {
|
|
|
1526
1528
|
}
|
|
1527
1529
|
}
|
|
1528
1530
|
};
|
|
1529
|
-
const span =
|
|
1531
|
+
const span = _chunkPOCCIJALjs.startSpan.call(void 0, spanArgs);
|
|
1530
1532
|
try {
|
|
1531
1533
|
const result = await doGenerate();
|
|
1532
1534
|
const metadata = {};
|
|
@@ -1573,7 +1575,7 @@ function BraintrustMiddleware(config = {}) {
|
|
|
1573
1575
|
},
|
|
1574
1576
|
wrapStream: async ({ doStream, params }) => {
|
|
1575
1577
|
const rawInput = extractInput(params);
|
|
1576
|
-
const processedInput =
|
|
1578
|
+
const processedInput = _chunkPOCCIJALjs.processInputAttachments.call(void 0, rawInput);
|
|
1577
1579
|
const spanArgs = {
|
|
1578
1580
|
name: _optionalChain([config, 'access', _63 => _63.spanInfo, 'optionalAccess', _64 => _64.name]) || "ai-sdk.doStream",
|
|
1579
1581
|
spanAttributes: {
|
|
@@ -1588,7 +1590,7 @@ function BraintrustMiddleware(config = {}) {
|
|
|
1588
1590
|
}
|
|
1589
1591
|
}
|
|
1590
1592
|
};
|
|
1591
|
-
const span =
|
|
1593
|
+
const span = _chunkPOCCIJALjs.startSpan.call(void 0, spanArgs);
|
|
1592
1594
|
try {
|
|
1593
1595
|
const { stream, ...rest } = await doStream();
|
|
1594
1596
|
const textChunks = [];
|
|
@@ -1803,7 +1805,7 @@ function wrapClaudeAgentQuery(queryFn, defaultThis) {
|
|
|
1803
1805
|
...params,
|
|
1804
1806
|
options: {
|
|
1805
1807
|
..._nullishCoalesce(params.options, () => ( {})),
|
|
1806
|
-
[
|
|
1808
|
+
[_chunkPOCCIJALjs.CLAUDE_AGENT_SDK_SKIP_LOCAL_TOOL_HOOKS_OPTION]: true
|
|
1807
1809
|
}
|
|
1808
1810
|
};
|
|
1809
1811
|
const invocationTarget = thisArg === proxy || thisArg === void 0 ? _nullishCoalesce(defaultThis, () => ( thisArg)) : thisArg;
|
|
@@ -1835,7 +1837,7 @@ function wrapClaudeAgentTool(toolFn, localToolMetadataByTool, defaultThis) {
|
|
|
1835
1837
|
}
|
|
1836
1838
|
const localToolMetadata = { toolName };
|
|
1837
1839
|
const originalHandler = wrappedArgs[handlerIndex];
|
|
1838
|
-
wrappedArgs[handlerIndex] =
|
|
1840
|
+
wrappedArgs[handlerIndex] = _chunkPOCCIJALjs.wrapLocalClaudeToolHandler.call(void 0,
|
|
1839
1841
|
originalHandler,
|
|
1840
1842
|
() => localToolMetadata
|
|
1841
1843
|
);
|
|
@@ -2435,7 +2437,7 @@ function wrapGoogleGenAIInstance(instance) {
|
|
|
2435
2437
|
}
|
|
2436
2438
|
if (prop === "interactions") {
|
|
2437
2439
|
const interactions = Reflect.get(target, prop, receiver);
|
|
2438
|
-
if (!
|
|
2440
|
+
if (!_chunkPOCCIJALjs.isObject.call(void 0, interactions) || typeof interactions.create !== "function") {
|
|
2439
2441
|
return interactions;
|
|
2440
2442
|
}
|
|
2441
2443
|
if (interactions !== originalInteractions) {
|
|
@@ -2449,7 +2451,7 @@ function wrapGoogleGenAIInstance(instance) {
|
|
|
2449
2451
|
});
|
|
2450
2452
|
}
|
|
2451
2453
|
function patchGoogleGenAIChats(instance, wrappedModels) {
|
|
2452
|
-
if (!
|
|
2454
|
+
if (!_chunkPOCCIJALjs.isObject.call(void 0, instance.chats) || !("modelsModule" in instance.chats)) {
|
|
2453
2455
|
return;
|
|
2454
2456
|
}
|
|
2455
2457
|
Reflect.set(instance.chats, "modelsModule", wrappedModels);
|
|
@@ -2883,10 +2885,10 @@ function isHuggingFaceConstructorKey(value) {
|
|
|
2883
2885
|
return HUGGINGFACE_CONSTRUCTOR_KEY_SET.has(value);
|
|
2884
2886
|
}
|
|
2885
2887
|
function hasFunction2(value, methodName) {
|
|
2886
|
-
return
|
|
2888
|
+
return _chunkPOCCIJALjs.isObject.call(void 0, value) && methodName in value && typeof value[methodName] === "function";
|
|
2887
2889
|
}
|
|
2888
2890
|
function isSupportedHuggingFaceModule(value) {
|
|
2889
|
-
if (!
|
|
2891
|
+
if (!_chunkPOCCIJALjs.isObject.call(void 0, value)) {
|
|
2890
2892
|
return false;
|
|
2891
2893
|
}
|
|
2892
2894
|
return HUGGINGFACE_CONSTRUCTOR_KEYS.some(
|
|
@@ -3626,16 +3628,16 @@ function bedrockRuntimeProxy(client) {
|
|
|
3626
3628
|
}
|
|
3627
3629
|
function wrapSend(send) {
|
|
3628
3630
|
return (command, optionsOrCb, cb) => {
|
|
3629
|
-
if (
|
|
3631
|
+
if (_chunkPOCCIJALjs.getBedrockRuntimeOperation.call(void 0, command) === void 0 || typeof optionsOrCb === "function" || typeof cb === "function") {
|
|
3630
3632
|
return send(command, optionsOrCb, cb);
|
|
3631
3633
|
}
|
|
3632
3634
|
return _chunkLPC4W2WXjs.bedrockRuntimeChannels.clientSend.tracePromise(
|
|
3633
|
-
() =>
|
|
3635
|
+
() => _chunkPOCCIJALjs.runWithAutoInstrumentationSuppressed.call(void 0,
|
|
3634
3636
|
() => send(command, optionsOrCb)
|
|
3635
3637
|
),
|
|
3636
3638
|
{
|
|
3637
3639
|
arguments: [command, optionsOrCb],
|
|
3638
|
-
span_info:
|
|
3640
|
+
span_info: _chunkPOCCIJALjs.buildBedrockRuntimeSpanInfo.call(void 0, command)
|
|
3639
3641
|
}
|
|
3640
3642
|
);
|
|
3641
3643
|
};
|
|
@@ -3745,7 +3747,7 @@ var FlushCoordinator = (_class = class {constructor() { _class.prototype.__init.
|
|
|
3745
3747
|
if (this.activeFlushes.has(experimentId)) {
|
|
3746
3748
|
return this.activeFlushes.get(experimentId);
|
|
3747
3749
|
}
|
|
3748
|
-
const flushPromise =
|
|
3750
|
+
const flushPromise = _chunkPOCCIJALjs.summarizeAndFlush.call(void 0, context.experiment, {
|
|
3749
3751
|
displaySummary: config.displaySummary
|
|
3750
3752
|
});
|
|
3751
3753
|
this.activeFlushes.set(experimentId, flushPromise);
|
|
@@ -3843,7 +3845,7 @@ async function runTracedEval(args) {
|
|
|
3843
3845
|
}
|
|
3844
3846
|
if (testError) {
|
|
3845
3847
|
span.log({ scores: { pass: 0 } });
|
|
3846
|
-
|
|
3848
|
+
_chunkPOCCIJALjs.logError.call(void 0, span, testError);
|
|
3847
3849
|
throw testError;
|
|
3848
3850
|
}
|
|
3849
3851
|
span.log({
|
|
@@ -4017,10 +4019,10 @@ function wrapDescribe(originalDescribe, config, afterAll) {
|
|
|
4017
4019
|
const getOrCreateContext = () => {
|
|
4018
4020
|
if (!context) {
|
|
4019
4021
|
const experimentName = `${suiteName}-${(/* @__PURE__ */ new Date()).toISOString()}`;
|
|
4020
|
-
const experiment = config.projectId ?
|
|
4022
|
+
const experiment = config.projectId ? _chunkPOCCIJALjs.initExperiment.call(void 0, {
|
|
4021
4023
|
projectId: config.projectId,
|
|
4022
4024
|
experiment: experimentName
|
|
4023
|
-
}) :
|
|
4025
|
+
}) : _chunkPOCCIJALjs.initExperiment.call(void 0, config.projectName || suiteName, {
|
|
4024
4026
|
experiment: experimentName
|
|
4025
4027
|
});
|
|
4026
4028
|
context = contextManager.createChildContext(void 0, experiment);
|
|
@@ -4128,7 +4130,7 @@ function wrapExpect(originalExpect) {
|
|
|
4128
4130
|
return originalExpect(value);
|
|
4129
4131
|
}
|
|
4130
4132
|
const assertion = originalExpect(value, message);
|
|
4131
|
-
const span =
|
|
4133
|
+
const span = _chunkPOCCIJALjs.currentSpan.call(void 0, );
|
|
4132
4134
|
if (!span) {
|
|
4133
4135
|
return assertion;
|
|
4134
4136
|
}
|
|
@@ -4140,16 +4142,16 @@ function wrapExpect(originalExpect) {
|
|
|
4140
4142
|
|
|
4141
4143
|
// src/wrappers/shared/logging.ts
|
|
4142
4144
|
function logOutputs(outputs) {
|
|
4143
|
-
|
|
4145
|
+
_chunkPOCCIJALjs.currentSpan.call(void 0, ).log({ output: outputs });
|
|
4144
4146
|
}
|
|
4145
4147
|
function logFeedback(feedback) {
|
|
4146
|
-
|
|
4148
|
+
_chunkPOCCIJALjs.currentSpan.call(void 0, ).log({
|
|
4147
4149
|
scores: { [feedback.name]: feedback.score },
|
|
4148
4150
|
metadata: feedback.metadata
|
|
4149
4151
|
});
|
|
4150
4152
|
}
|
|
4151
4153
|
function getCurrentSpan() {
|
|
4152
|
-
return
|
|
4154
|
+
return _chunkPOCCIJALjs.currentSpan.call(void 0, );
|
|
4153
4155
|
}
|
|
4154
4156
|
|
|
4155
4157
|
// src/wrappers/vitest/index.ts
|
|
@@ -4197,7 +4199,7 @@ function wrapVitest(vitestMethods, config = {}) {
|
|
|
4197
4199
|
);
|
|
4198
4200
|
return;
|
|
4199
4201
|
}
|
|
4200
|
-
await
|
|
4202
|
+
await _chunkPOCCIJALjs.summarizeAndFlush.call(void 0, ctx.experiment, {
|
|
4201
4203
|
displaySummary: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _88 => _88.displaySummary]), () => ( config.displaySummary))
|
|
4202
4204
|
});
|
|
4203
4205
|
}
|
|
@@ -4212,7 +4214,7 @@ function initNodeTestSuite(config) {
|
|
|
4212
4214
|
return experiment;
|
|
4213
4215
|
}
|
|
4214
4216
|
const experimentName = config.experimentName || `${config.projectName}-${(/* @__PURE__ */ new Date()).toISOString()}`;
|
|
4215
|
-
experiment =
|
|
4217
|
+
experiment = _chunkPOCCIJALjs.initExperiment.call(void 0, config.projectName, {
|
|
4216
4218
|
experiment: experimentName
|
|
4217
4219
|
});
|
|
4218
4220
|
return experiment;
|
|
@@ -4261,7 +4263,7 @@ function initNodeTestSuite(config) {
|
|
|
4261
4263
|
if (!experiment) {
|
|
4262
4264
|
return;
|
|
4263
4265
|
}
|
|
4264
|
-
await
|
|
4266
|
+
await _chunkPOCCIJALjs.summarizeAndFlush.call(void 0, experiment, {
|
|
4265
4267
|
displaySummary: config.displaySummary
|
|
4266
4268
|
});
|
|
4267
4269
|
experiment = void 0;
|
|
@@ -4352,7 +4354,7 @@ var GraphBuilder = (_class2 = class {
|
|
|
4352
4354
|
};
|
|
4353
4355
|
}
|
|
4354
4356
|
resolveNode(node) {
|
|
4355
|
-
if (node instanceof
|
|
4357
|
+
if (node instanceof _chunkPOCCIJALjs.Prompt) {
|
|
4356
4358
|
const cached = this.nodeLikeNodes.get(node);
|
|
4357
4359
|
if (cached) {
|
|
4358
4360
|
return [cached, []];
|
|
@@ -4402,7 +4404,7 @@ var GraphBuilder = (_class2 = class {
|
|
|
4402
4404
|
// }
|
|
4403
4405
|
// Helper to generate node IDs
|
|
4404
4406
|
generateId(name) {
|
|
4405
|
-
const uuid =
|
|
4407
|
+
const uuid = _chunkPOCCIJALjs.newId.call(void 0, );
|
|
4406
4408
|
if (name) {
|
|
4407
4409
|
return `${name}-${uuid.slice(0, 8)}`;
|
|
4408
4410
|
} else {
|
|
@@ -5596,7 +5598,7 @@ function waterfall(tasks, callback) {
|
|
|
5596
5598
|
var waterfall$1 = awaitify(waterfall);
|
|
5597
5599
|
|
|
5598
5600
|
// src/trace.ts
|
|
5599
|
-
var SpanFetcher = class _SpanFetcher extends
|
|
5601
|
+
var SpanFetcher = class _SpanFetcher extends _chunkPOCCIJALjs.ObjectFetcher {
|
|
5600
5602
|
constructor(objectType, _objectId, rootSpanId, _state, spanTypeFilter, includeScorers = false) {
|
|
5601
5603
|
const filterExpr = _SpanFetcher.buildFilter(
|
|
5602
5604
|
rootSpanId,
|
|
@@ -5902,20 +5904,20 @@ var promptContentsSchema = _v3.z.union([
|
|
|
5902
5904
|
prompt: _v3.z.string()
|
|
5903
5905
|
}),
|
|
5904
5906
|
_v3.z.object({
|
|
5905
|
-
messages: _v3.z.array(
|
|
5907
|
+
messages: _v3.z.array(_chunkPOCCIJALjs.ChatCompletionMessageParam)
|
|
5906
5908
|
})
|
|
5907
5909
|
]);
|
|
5908
5910
|
var promptDefinitionSchema = promptContentsSchema.and(
|
|
5909
5911
|
_v3.z.object({
|
|
5910
5912
|
model: _v3.z.string(),
|
|
5911
|
-
params:
|
|
5913
|
+
params: _chunkPOCCIJALjs.ModelParams.optional(),
|
|
5912
5914
|
templateFormat: _v3.z.enum(["mustache", "nunjucks", "none"]).optional(),
|
|
5913
5915
|
environments: _v3.z.array(_v3.z.string()).optional()
|
|
5914
5916
|
})
|
|
5915
5917
|
);
|
|
5916
5918
|
var promptDefinitionWithToolsSchema = promptDefinitionSchema.and(
|
|
5917
5919
|
_v3.z.object({
|
|
5918
|
-
tools: _v3.z.array(
|
|
5920
|
+
tools: _v3.z.array(_chunkPOCCIJALjs.ToolFunctionDefinition).optional()
|
|
5919
5921
|
})
|
|
5920
5922
|
);
|
|
5921
5923
|
function promptDefinitionToPromptData(promptDefinition, rawTools) {
|
|
@@ -5963,7 +5965,7 @@ async function validateParameters(parameters, parameterSchema) {
|
|
|
5963
5965
|
if (resolvedSchema === void 0 || resolvedSchema === null) {
|
|
5964
5966
|
return parameters;
|
|
5965
5967
|
}
|
|
5966
|
-
if (
|
|
5968
|
+
if (_chunkPOCCIJALjs.RemoteEvalParameters.isParameters(resolvedSchema)) {
|
|
5967
5969
|
const mergedParameters = parameters && Object.keys(parameters).length > 0 ? {
|
|
5968
5970
|
...resolvedSchema.data,
|
|
5969
5971
|
...parameters
|
|
@@ -5985,14 +5987,14 @@ function validateParametersWithZod(parameters, parameterSchema) {
|
|
|
5985
5987
|
const value = parameters[name];
|
|
5986
5988
|
try {
|
|
5987
5989
|
if ("type" in schema && schema.type === "prompt") {
|
|
5988
|
-
const promptData = value ?
|
|
5990
|
+
const promptData = value ? _chunkPOCCIJALjs.PromptData.parse(value) : schema.default ? promptDefinitionToPromptData(
|
|
5989
5991
|
schema.default,
|
|
5990
5992
|
schema.default.tools
|
|
5991
5993
|
) : void 0;
|
|
5992
5994
|
if (!promptData) {
|
|
5993
5995
|
throw new Error(`Parameter '${name}' is required`);
|
|
5994
5996
|
}
|
|
5995
|
-
return [name,
|
|
5997
|
+
return [name, _chunkPOCCIJALjs.Prompt.fromPromptData(name, promptData)];
|
|
5996
5998
|
} else if ("type" in schema && schema.type === "model") {
|
|
5997
5999
|
const model = _nullishCoalesce(value, () => ( schema.default));
|
|
5998
6000
|
if (model === void 0) {
|
|
@@ -6043,7 +6045,7 @@ function rehydrateRemoteParameters(parameters, schema) {
|
|
|
6043
6045
|
if (Reflect.get(propertySchema, "x-bt-type") === "prompt") {
|
|
6044
6046
|
return [
|
|
6045
6047
|
name,
|
|
6046
|
-
|
|
6048
|
+
_chunkPOCCIJALjs.Prompt.fromPromptData(name, _chunkPOCCIJALjs.PromptData.parse(value))
|
|
6047
6049
|
];
|
|
6048
6050
|
}
|
|
6049
6051
|
return [name, value];
|
|
@@ -6091,7 +6093,7 @@ function makeEvalName(projectName, experimentName) {
|
|
|
6091
6093
|
return out;
|
|
6092
6094
|
}
|
|
6093
6095
|
function initExperiment2(state, options = {}) {
|
|
6094
|
-
return
|
|
6096
|
+
return _chunkPOCCIJALjs.init.call(void 0, {
|
|
6095
6097
|
state,
|
|
6096
6098
|
...options,
|
|
6097
6099
|
setCurrent: false
|
|
@@ -6102,7 +6104,7 @@ async function getExperimentParametersRef(parameters) {
|
|
|
6102
6104
|
return void 0;
|
|
6103
6105
|
}
|
|
6104
6106
|
const resolvedParameters = parameters instanceof Promise ? await parameters : parameters;
|
|
6105
|
-
if (!
|
|
6107
|
+
if (!_chunkPOCCIJALjs.RemoteEvalParameters.isParameters(resolvedParameters)) {
|
|
6106
6108
|
return void 0;
|
|
6107
6109
|
}
|
|
6108
6110
|
if (resolvedParameters.id === void 0) {
|
|
@@ -6138,10 +6140,10 @@ globalThis._evals = {
|
|
|
6138
6140
|
reporters: {}
|
|
6139
6141
|
};
|
|
6140
6142
|
function _initializeSpanContext() {
|
|
6141
|
-
globalThis._spanContext = { currentSpan:
|
|
6143
|
+
globalThis._spanContext = { currentSpan: _chunkPOCCIJALjs.currentSpan, withCurrent: _chunkPOCCIJALjs.withCurrent, startSpan: _chunkPOCCIJALjs.startSpan, NOOP_SPAN: _chunkPOCCIJALjs.NOOP_SPAN };
|
|
6142
6144
|
}
|
|
6143
6145
|
async function Eval(name, evaluator, reporterOrOpts) {
|
|
6144
|
-
const options =
|
|
6146
|
+
const options = _chunkPOCCIJALjs.isEmpty.call(void 0, reporterOrOpts) ? {} : typeof reporterOrOpts === "string" ? { reporter: reporterOrOpts } : "name" in reporterOrOpts ? { reporter: reporterOrOpts } : reporterOrOpts;
|
|
6145
6147
|
let evalName = makeEvalName(name, evaluator.experimentName);
|
|
6146
6148
|
if (globalThis._evals.evaluators[evalName]) {
|
|
6147
6149
|
evalName = `${evalName}_${Object.keys(_evals).length}`;
|
|
@@ -6192,7 +6194,7 @@ async function Eval(name, evaluator, reporterOrOpts) {
|
|
|
6192
6194
|
baseExperimentId: evaluator.baseExperimentId,
|
|
6193
6195
|
gitMetadataSettings: evaluator.gitMetadataSettings,
|
|
6194
6196
|
repoInfo: evaluator.repoInfo,
|
|
6195
|
-
dataset:
|
|
6197
|
+
dataset: _chunkPOCCIJALjs.Dataset.isDataset(data) ? data : void 0,
|
|
6196
6198
|
parameters
|
|
6197
6199
|
});
|
|
6198
6200
|
if (experiment && typeof process !== "undefined" && globalThis.BRAINTRUST_CONTEXT_MANAGER !== void 0) {
|
|
@@ -6212,7 +6214,7 @@ async function Eval(name, evaluator, reporterOrOpts) {
|
|
|
6212
6214
|
const enableCache = _nullishCoalesce(options.enableCache, () => ( true));
|
|
6213
6215
|
let ret;
|
|
6214
6216
|
if (options.parent) {
|
|
6215
|
-
ret = await
|
|
6217
|
+
ret = await _chunkPOCCIJALjs.withParent.call(void 0,
|
|
6216
6218
|
options.parent,
|
|
6217
6219
|
() => runEvaluator(
|
|
6218
6220
|
null,
|
|
@@ -6248,7 +6250,7 @@ async function Eval(name, evaluator, reporterOrOpts) {
|
|
|
6248
6250
|
if (experiment) {
|
|
6249
6251
|
await experiment.flush().catch(console.error);
|
|
6250
6252
|
} else if (options.parent) {
|
|
6251
|
-
await
|
|
6253
|
+
await _chunkPOCCIJALjs.flush.call(void 0, { state: evaluator.state }).catch(console.error);
|
|
6252
6254
|
}
|
|
6253
6255
|
}
|
|
6254
6256
|
} finally {
|
|
@@ -6294,13 +6296,13 @@ function classifierName(classifier, classifier_idx) {
|
|
|
6294
6296
|
}
|
|
6295
6297
|
function buildSpanMetadata(results) {
|
|
6296
6298
|
return results.length === 1 ? results[0].metadata : results.reduce(
|
|
6297
|
-
(prev, s) =>
|
|
6299
|
+
(prev, s) => _chunkPOCCIJALjs.mergeDicts.call(void 0, prev, { [s.name]: s.metadata }),
|
|
6298
6300
|
{}
|
|
6299
6301
|
);
|
|
6300
6302
|
}
|
|
6301
6303
|
function buildSpanScores(results) {
|
|
6302
6304
|
const scoresRecord = results.reduce(
|
|
6303
|
-
(prev, s) =>
|
|
6305
|
+
(prev, s) => _chunkPOCCIJALjs.mergeDicts.call(void 0, prev, { [s.name]: s.score }),
|
|
6304
6306
|
{}
|
|
6305
6307
|
);
|
|
6306
6308
|
return { resultMetadata: buildSpanMetadata(results), scoresRecord };
|
|
@@ -6330,7 +6332,7 @@ function collectScoringResults(runResults, names, onResult) {
|
|
|
6330
6332
|
return failing;
|
|
6331
6333
|
}
|
|
6332
6334
|
function validateClassificationResult(value, scorerName2) {
|
|
6333
|
-
if (!(typeof value === "object" && value !== null && !
|
|
6335
|
+
if (!(typeof value === "object" && value !== null && !_chunkPOCCIJALjs.isEmpty.call(void 0, value))) {
|
|
6334
6336
|
throw new Error(
|
|
6335
6337
|
`When returning structured classifier results, each classification must be a non-empty object. Got: ${JSON.stringify(value)}`
|
|
6336
6338
|
);
|
|
@@ -6359,7 +6361,7 @@ function logScoringFailures(kind, failures, metadata, rootSpan, state) {
|
|
|
6359
6361
|
);
|
|
6360
6362
|
metadata[`${kind}_errors`] = errorMap;
|
|
6361
6363
|
rootSpan.log({ metadata: { [`${kind}_errors`]: errorMap } });
|
|
6362
|
-
|
|
6364
|
+
_chunkPOCCIJALjs.debugLogger.forState(state).warn(
|
|
6363
6365
|
`Found exceptions for the following ${kind}s: ${Object.keys(errorMap).join(", ")}`,
|
|
6364
6366
|
failures.map((f) => f.error)
|
|
6365
6367
|
);
|
|
@@ -6393,7 +6395,7 @@ var defaultErrorScoreHandler = ({
|
|
|
6393
6395
|
};
|
|
6394
6396
|
async function runEvaluatorInternal(experiment, evaluator, progressReporter, filters, stream, parameters, collectResults, enableCache) {
|
|
6395
6397
|
if (enableCache) {
|
|
6396
|
-
_optionalChain([(_nullishCoalesce(evaluator.state, () => (
|
|
6398
|
+
_optionalChain([(_nullishCoalesce(evaluator.state, () => ( _chunkPOCCIJALjs._internalGetGlobalState.call(void 0, )))), 'optionalAccess', _102 => _102.spanCache, 'optionalAccess', _103 => _103.start, 'call', _104 => _104()]);
|
|
6397
6399
|
}
|
|
6398
6400
|
try {
|
|
6399
6401
|
if (typeof evaluator.data === "string") {
|
|
@@ -6414,7 +6416,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6414
6416
|
);
|
|
6415
6417
|
}
|
|
6416
6418
|
let name = dataResult.name;
|
|
6417
|
-
if (
|
|
6419
|
+
if (_chunkPOCCIJALjs.isEmpty.call(void 0, name)) {
|
|
6418
6420
|
const baseExperiment = await experiment.fetchBaseExperiment();
|
|
6419
6421
|
if (!baseExperiment) {
|
|
6420
6422
|
throw new Error("BaseExperiment() failed to fetch base experiment");
|
|
@@ -6464,7 +6466,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6464
6466
|
if (cancelled) {
|
|
6465
6467
|
return;
|
|
6466
6468
|
}
|
|
6467
|
-
const eventDataset = experiment ? experiment.dataset :
|
|
6469
|
+
const eventDataset = experiment ? experiment.dataset : _chunkPOCCIJALjs.Dataset.isDataset(evaluator.data) ? evaluator.data : void 0;
|
|
6468
6470
|
const inlineDatasetOrigin = eventDataset && datum.id && datum._xact_id ? {
|
|
6469
6471
|
object_type: "dataset",
|
|
6470
6472
|
object_id: await eventDataset.id,
|
|
@@ -6472,7 +6474,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6472
6474
|
created: datum.created,
|
|
6473
6475
|
_xact_id: datum._xact_id
|
|
6474
6476
|
} : void 0;
|
|
6475
|
-
const parsedDatumOrigin =
|
|
6477
|
+
const parsedDatumOrigin = _chunkPOCCIJALjs.ObjectReference.safeParse(datum.origin);
|
|
6476
6478
|
const origin = _nullishCoalesce(inlineDatasetOrigin, () => ( (_optionalChain([parsedDatumOrigin, 'optionalAccess', _105 => _105.success]) ? parsedDatumOrigin.data : void 0)));
|
|
6477
6479
|
const baseEvent = {
|
|
6478
6480
|
name: "eval",
|
|
@@ -6488,23 +6490,23 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6488
6490
|
}
|
|
6489
6491
|
};
|
|
6490
6492
|
const callback = async (rootSpan) => {
|
|
6491
|
-
const state = _nullishCoalesce(evaluator.state, () => (
|
|
6493
|
+
const state = _nullishCoalesce(evaluator.state, () => ( _chunkPOCCIJALjs._internalGetGlobalState.call(void 0, )));
|
|
6492
6494
|
const ensureSpansFlushed = async () => {
|
|
6493
6495
|
if (experiment) {
|
|
6494
|
-
await
|
|
6496
|
+
await _chunkPOCCIJALjs.flush.call(void 0, { state: experiment.loggingState });
|
|
6495
6497
|
} else if (state) {
|
|
6496
|
-
await
|
|
6498
|
+
await _chunkPOCCIJALjs.flush.call(void 0, { state });
|
|
6497
6499
|
} else {
|
|
6498
|
-
await
|
|
6500
|
+
await _chunkPOCCIJALjs.flush.call(void 0, );
|
|
6499
6501
|
}
|
|
6500
6502
|
if (state) {
|
|
6501
6503
|
await state.flushOtel();
|
|
6502
6504
|
}
|
|
6503
6505
|
};
|
|
6504
6506
|
const parentStr = state.currentParent.getStore();
|
|
6505
|
-
const parentComponents = parentStr ?
|
|
6507
|
+
const parentComponents = parentStr ? _chunkPOCCIJALjs.SpanComponentsV3.fromStr(parentStr) : null;
|
|
6506
6508
|
const trace = state ? new LocalTrace({
|
|
6507
|
-
objectType: parentComponents ?
|
|
6509
|
+
objectType: parentComponents ? _chunkPOCCIJALjs.spanObjectTypeV3ToTypedString.call(void 0,
|
|
6508
6510
|
parentComponents.data.object_type
|
|
6509
6511
|
) : "experiment",
|
|
6510
6512
|
objectId: await _asyncNullishCoalesce(await _asyncOptionalChain([parentComponents, 'optionalAccess', async _106 => _106.data, 'access', async _107 => _107.object_id]), async () => ( (experimentIdPromise ? await _asyncNullishCoalesce(await experimentIdPromise, async () => ( "")) : ""))),
|
|
@@ -6579,7 +6581,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6579
6581
|
trace
|
|
6580
6582
|
};
|
|
6581
6583
|
const { trace: _trace, ...scoringArgsForLogging } = scoringArgs;
|
|
6582
|
-
const propagatedEvent =
|
|
6584
|
+
const propagatedEvent = _chunkPOCCIJALjs.makeScorerPropagatedEvent.call(void 0,
|
|
6583
6585
|
await rootSpan.export()
|
|
6584
6586
|
);
|
|
6585
6587
|
const getOtherFields = (s) => {
|
|
@@ -6602,14 +6604,14 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6602
6604
|
if (scoreValue === null) return null;
|
|
6603
6605
|
if (Array.isArray(scoreValue)) {
|
|
6604
6606
|
for (const s of scoreValue) {
|
|
6605
|
-
if (!(typeof s === "object" && !
|
|
6607
|
+
if (!(typeof s === "object" && !_chunkPOCCIJALjs.isEmpty.call(void 0, s))) {
|
|
6606
6608
|
throw new Error(
|
|
6607
6609
|
`When returning an array of scores, each score must be a non-empty object. Got: ${JSON.stringify(s)}`
|
|
6608
6610
|
);
|
|
6609
6611
|
}
|
|
6610
6612
|
}
|
|
6611
6613
|
}
|
|
6612
|
-
const results = Array.isArray(scoreValue) ? scoreValue : typeof scoreValue === "object" && !
|
|
6614
|
+
const results = Array.isArray(scoreValue) ? scoreValue : typeof scoreValue === "object" && !_chunkPOCCIJALjs.isEmpty.call(void 0, scoreValue) ? [scoreValue] : [
|
|
6613
6615
|
{
|
|
6614
6616
|
name: scorerNames[score_idx],
|
|
6615
6617
|
score: scoreValue
|
|
@@ -6617,7 +6619,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6617
6619
|
];
|
|
6618
6620
|
const { resultMetadata, scoresRecord } = buildSpanScores(results);
|
|
6619
6621
|
const resultOutput = results.length === 1 ? getOtherFields(results[0]) : results.reduce(
|
|
6620
|
-
(prev, s) =>
|
|
6622
|
+
(prev, s) => _chunkPOCCIJALjs.mergeDicts.call(void 0, prev, {
|
|
6621
6623
|
[s.name]: getOtherFields(s)
|
|
6622
6624
|
}),
|
|
6623
6625
|
{}
|
|
@@ -6652,7 +6654,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6652
6654
|
)
|
|
6653
6655
|
);
|
|
6654
6656
|
const resultOutput = rawResults.length === 1 ? toClassificationItem(rawResults[0]) : rawResults.reduce(
|
|
6655
|
-
(prev, r) =>
|
|
6657
|
+
(prev, r) => _chunkPOCCIJALjs.mergeDicts.call(void 0, prev, {
|
|
6656
6658
|
[r.name]: toClassificationItem(r)
|
|
6657
6659
|
}),
|
|
6658
6660
|
{}
|
|
@@ -6704,7 +6706,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6704
6706
|
evaluator.state
|
|
6705
6707
|
);
|
|
6706
6708
|
} catch (e) {
|
|
6707
|
-
|
|
6709
|
+
_chunkPOCCIJALjs.logError.call(void 0, rootSpan, e);
|
|
6708
6710
|
error = e;
|
|
6709
6711
|
} finally {
|
|
6710
6712
|
progressReporter.increment(evaluator.evalName);
|
|
@@ -6738,7 +6740,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6738
6740
|
}
|
|
6739
6741
|
};
|
|
6740
6742
|
if (!experiment) {
|
|
6741
|
-
return await
|
|
6743
|
+
return await _chunkPOCCIJALjs.traced.call(void 0, callback, {
|
|
6742
6744
|
...baseEvent,
|
|
6743
6745
|
state: evaluator.state
|
|
6744
6746
|
});
|
|
@@ -6780,7 +6782,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6780
6782
|
const cancel = async () => {
|
|
6781
6783
|
await new Promise((_, reject2) => {
|
|
6782
6784
|
if (cancelled) {
|
|
6783
|
-
reject2(new (0,
|
|
6785
|
+
reject2(new (0, _chunkPOCCIJALjs.InternalAbortError)("Evaluator already cancelled"));
|
|
6784
6786
|
return;
|
|
6785
6787
|
}
|
|
6786
6788
|
let timeoutId;
|
|
@@ -6801,12 +6803,12 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6801
6803
|
};
|
|
6802
6804
|
if (evaluator.timeout) {
|
|
6803
6805
|
timeoutId = setTimeout(() => {
|
|
6804
|
-
rejectOnce(new (0,
|
|
6806
|
+
rejectOnce(new (0, _chunkPOCCIJALjs.InternalAbortError)("Evaluator timed out"));
|
|
6805
6807
|
}, evaluator.timeout);
|
|
6806
6808
|
}
|
|
6807
6809
|
if (evaluator.signal) {
|
|
6808
6810
|
abortHandler = () => {
|
|
6809
|
-
rejectOnce(new (0,
|
|
6811
|
+
rejectOnce(new (0, _chunkPOCCIJALjs.InternalAbortError)("Evaluator aborted"));
|
|
6810
6812
|
};
|
|
6811
6813
|
evaluator.signal.addEventListener("abort", abortHandler);
|
|
6812
6814
|
}
|
|
@@ -6829,9 +6831,9 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6829
6831
|
}
|
|
6830
6832
|
} catch (e) {
|
|
6831
6833
|
q.kill();
|
|
6832
|
-
if (e instanceof
|
|
6834
|
+
if (e instanceof _chunkPOCCIJALjs.InternalAbortError) {
|
|
6833
6835
|
if (_chunkLPC4W2WXjs.isomorph_default.getEnv("BRAINTRUST_VERBOSE")) {
|
|
6834
|
-
|
|
6836
|
+
_chunkPOCCIJALjs.debugLogger.forState(evaluator.state).warn("Evaluator cancelled:", e.message);
|
|
6835
6837
|
}
|
|
6836
6838
|
}
|
|
6837
6839
|
throw e;
|
|
@@ -6855,7 +6857,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6855
6857
|
);
|
|
6856
6858
|
} finally {
|
|
6857
6859
|
if (enableCache) {
|
|
6858
|
-
const spanCache = _optionalChain([(_nullishCoalesce(evaluator.state, () => (
|
|
6860
|
+
const spanCache = _optionalChain([(_nullishCoalesce(evaluator.state, () => ( _chunkPOCCIJALjs._internalGetGlobalState.call(void 0, )))), 'optionalAccess', _115 => _115.spanCache]);
|
|
6859
6861
|
_optionalChain([spanCache, 'optionalAccess', _116 => _116.dispose, 'call', _117 => _117()]);
|
|
6860
6862
|
_optionalChain([spanCache, 'optionalAccess', _118 => _118.stop, 'call', _119 => _119()]);
|
|
6861
6863
|
}
|
|
@@ -6977,7 +6979,7 @@ var defaultReporter = {
|
|
|
6977
6979
|
const scoreValue = `${scorePercent}%`;
|
|
6978
6980
|
if (hasComparison) {
|
|
6979
6981
|
let diffString = "-";
|
|
6980
|
-
if (!
|
|
6982
|
+
if (!_chunkPOCCIJALjs.isEmpty.call(void 0, score.diff)) {
|
|
6981
6983
|
const diffPercent = (score.diff * 100).toFixed(2);
|
|
6982
6984
|
const diffSign = score.diff > 0 ? "+" : "";
|
|
6983
6985
|
diffString = `${diffSign}${diffPercent}%`;
|
|
@@ -6997,7 +6999,7 @@ var defaultReporter = {
|
|
|
6997
6999
|
const metricValue = metric.unit === "$" ? `${metric.unit}${formattedValue}` : `${formattedValue}${metric.unit}`;
|
|
6998
7000
|
if (hasComparison) {
|
|
6999
7001
|
let diffString = "-";
|
|
7000
|
-
if (!
|
|
7002
|
+
if (!_chunkPOCCIJALjs.isEmpty.call(void 0, metric.diff)) {
|
|
7001
7003
|
const diffPercent = (metric.diff * 100).toFixed(2);
|
|
7002
7004
|
const diffSign = metric.diff > 0 ? "+" : "";
|
|
7003
7005
|
diffString = `${diffSign}${diffPercent}%`;
|
|
@@ -7111,7 +7113,7 @@ var Project2 = (_class6 = class {
|
|
|
7111
7113
|
console.warn("publish() is a no-op when running `braintrust push`.");
|
|
7112
7114
|
return;
|
|
7113
7115
|
}
|
|
7114
|
-
await
|
|
7116
|
+
await _chunkPOCCIJALjs.login.call(void 0, );
|
|
7115
7117
|
const projectMap = new ProjectNameIdMap();
|
|
7116
7118
|
const functionDefinitions = [];
|
|
7117
7119
|
if (this._publishableCodeFunctions.length > 0) {
|
|
@@ -7125,7 +7127,7 @@ var Project2 = (_class6 = class {
|
|
|
7125
7127
|
functionDefinitions.push(functionDefinition);
|
|
7126
7128
|
}
|
|
7127
7129
|
}
|
|
7128
|
-
await
|
|
7130
|
+
await _chunkPOCCIJALjs._internalGetGlobalState.call(void 0, ).apiConn().post_json("insert-functions", {
|
|
7129
7131
|
functions: functionDefinitions
|
|
7130
7132
|
});
|
|
7131
7133
|
}
|
|
@@ -7148,7 +7150,7 @@ var ToolBuilder = (_class7 = class {
|
|
|
7148
7150
|
const tool = new CodeFunction(this.project, {
|
|
7149
7151
|
handler,
|
|
7150
7152
|
name: resolvedName,
|
|
7151
|
-
slug: _nullishCoalesce(slug, () => (
|
|
7153
|
+
slug: _nullishCoalesce(slug, () => ( _chunkPOCCIJALjs.slugify.call(void 0, resolvedName, { lower: true, strict: true }))),
|
|
7152
7154
|
type: "tool",
|
|
7153
7155
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/consistent-type-assertions
|
|
7154
7156
|
parameters,
|
|
@@ -7174,7 +7176,7 @@ var ScorerBuilder = (_class8 = class {
|
|
|
7174
7176
|
if (!resolvedName || resolvedName.trim().length === 0) {
|
|
7175
7177
|
resolvedName = `Scorer ${_chunkLPC4W2WXjs.isomorph_default.basename(currentFilename)} ${this.taskCounter}`;
|
|
7176
7178
|
}
|
|
7177
|
-
const slug = _nullishCoalesce(opts.slug, () => (
|
|
7179
|
+
const slug = _nullishCoalesce(opts.slug, () => ( _chunkPOCCIJALjs.slugify.call(void 0, resolvedName, { lower: true, strict: true })));
|
|
7178
7180
|
if ("handler" in opts) {
|
|
7179
7181
|
const scorer = new CodeFunction(this.project, {
|
|
7180
7182
|
...opts,
|
|
@@ -7230,7 +7232,7 @@ var ClassifierBuilder = (_class9 = class {
|
|
|
7230
7232
|
if (!resolvedName || resolvedName.trim().length === 0) {
|
|
7231
7233
|
resolvedName = `Classifier ${_chunkLPC4W2WXjs.isomorph_default.basename(currentFilename)} ${this.taskCounter}`;
|
|
7232
7234
|
}
|
|
7233
|
-
const slug = _nullishCoalesce(opts.slug, () => (
|
|
7235
|
+
const slug = _nullishCoalesce(opts.slug, () => ( _chunkPOCCIJALjs.slugify.call(void 0, resolvedName, { lower: true, strict: true })));
|
|
7234
7236
|
const classifier = new CodeFunction(this.project, {
|
|
7235
7237
|
...opts,
|
|
7236
7238
|
name: resolvedName,
|
|
@@ -7357,18 +7359,18 @@ var PromptBuilder = class {
|
|
|
7357
7359
|
rawTools.push(tool);
|
|
7358
7360
|
}
|
|
7359
7361
|
}
|
|
7360
|
-
const slug = _nullishCoalesce(opts.slug, () => (
|
|
7362
|
+
const slug = _nullishCoalesce(opts.slug, () => ( _chunkPOCCIJALjs.slugify.call(void 0, opts.name, { lower: true, strict: true })));
|
|
7361
7363
|
const promptData = promptDefinitionToPromptData(opts, rawTools);
|
|
7362
7364
|
const promptRow = {
|
|
7363
7365
|
id: opts.id,
|
|
7364
|
-
_xact_id: opts.version ?
|
|
7366
|
+
_xact_id: opts.version ? _chunkPOCCIJALjs.loadPrettyXact.call(void 0, opts.version) : void 0,
|
|
7365
7367
|
name: opts.name,
|
|
7366
7368
|
slug,
|
|
7367
7369
|
prompt_data: promptData,
|
|
7368
7370
|
tags: opts.tags,
|
|
7369
7371
|
...this.project.id !== void 0 ? { project_id: this.project.id } : {}
|
|
7370
7372
|
};
|
|
7371
|
-
const prompt = new (0,
|
|
7373
|
+
const prompt = new (0, _chunkPOCCIJALjs.Prompt)(
|
|
7372
7374
|
promptRow,
|
|
7373
7375
|
{},
|
|
7374
7376
|
// It doesn't make sense to specify defaults here.
|
|
@@ -7422,7 +7424,7 @@ var ParametersBuilder = class {
|
|
|
7422
7424
|
this.project = project;
|
|
7423
7425
|
}
|
|
7424
7426
|
create(opts) {
|
|
7425
|
-
const slug = _nullishCoalesce(opts.slug, () => (
|
|
7427
|
+
const slug = _nullishCoalesce(opts.slug, () => ( _chunkPOCCIJALjs.slugify.call(void 0, opts.name, { lower: true, strict: true })));
|
|
7426
7428
|
const codeParameters = new CodeParameters(this.project, {
|
|
7427
7429
|
name: opts.name,
|
|
7428
7430
|
slug,
|
|
@@ -7461,7 +7463,7 @@ function serializeEvalParameterstoParametersSchema(parameters) {
|
|
|
7461
7463
|
required.push(name);
|
|
7462
7464
|
}
|
|
7463
7465
|
} else {
|
|
7464
|
-
const schemaObj =
|
|
7466
|
+
const schemaObj = _chunkPOCCIJALjs.zodToJsonSchema.call(void 0, value);
|
|
7465
7467
|
properties[name] = schemaObj;
|
|
7466
7468
|
if (!("default" in schemaObj)) {
|
|
7467
7469
|
required.push(name);
|
|
@@ -7490,11 +7492,11 @@ var ProjectNameIdMap = (_class10 = class {constructor() { _class10.prototype.__i
|
|
|
7490
7492
|
__init19() {this.idToName = {}}
|
|
7491
7493
|
async getId(projectName) {
|
|
7492
7494
|
if (!(projectName in this.nameToId)) {
|
|
7493
|
-
const response = await
|
|
7495
|
+
const response = await _chunkPOCCIJALjs._internalGetGlobalState.call(void 0, ).appConn().post_json("api/project/register", {
|
|
7494
7496
|
project_name: projectName
|
|
7495
7497
|
});
|
|
7496
7498
|
const result = _v3.z.object({
|
|
7497
|
-
project:
|
|
7499
|
+
project: _chunkPOCCIJALjs.Project
|
|
7498
7500
|
}).parse(response);
|
|
7499
7501
|
const projectId = result.project.id;
|
|
7500
7502
|
this.nameToId[projectName] = projectId;
|
|
@@ -7504,10 +7506,10 @@ var ProjectNameIdMap = (_class10 = class {constructor() { _class10.prototype.__i
|
|
|
7504
7506
|
}
|
|
7505
7507
|
async getName(projectId) {
|
|
7506
7508
|
if (!(projectId in this.idToName)) {
|
|
7507
|
-
const response = await
|
|
7509
|
+
const response = await _chunkPOCCIJALjs._internalGetGlobalState.call(void 0, ).appConn().post_json("api/project/get", {
|
|
7508
7510
|
id: projectId
|
|
7509
7511
|
});
|
|
7510
|
-
const result = _v3.z.array(
|
|
7512
|
+
const result = _v3.z.array(_chunkPOCCIJALjs.Project).nonempty().parse(response);
|
|
7511
7513
|
const projectName = result[0].name;
|
|
7512
7514
|
this.idToName[projectId] = projectName;
|
|
7513
7515
|
this.nameToId[projectName] = projectId;
|
|
@@ -7527,16 +7529,16 @@ var ProjectNameIdMap = (_class10 = class {constructor() { _class10.prototype.__i
|
|
|
7527
7529
|
var evalBodySchema = _v3.z.object({
|
|
7528
7530
|
name: _v3.z.string(),
|
|
7529
7531
|
parameters: _v3.z.record(_v3.z.string(), _v3.z.unknown()).nullish(),
|
|
7530
|
-
data:
|
|
7532
|
+
data: _chunkPOCCIJALjs.RunEval.shape.data,
|
|
7531
7533
|
scores: _v3.z.array(
|
|
7532
7534
|
_v3.z.object({
|
|
7533
|
-
function_id:
|
|
7535
|
+
function_id: _chunkPOCCIJALjs.FunctionId,
|
|
7534
7536
|
name: _v3.z.string()
|
|
7535
7537
|
})
|
|
7536
7538
|
).nullish(),
|
|
7537
7539
|
experiment_name: _v3.z.string().nullish(),
|
|
7538
7540
|
project_id: _v3.z.string().nullish(),
|
|
7539
|
-
parent:
|
|
7541
|
+
parent: _chunkPOCCIJALjs.InvokeParent.optional(),
|
|
7540
7542
|
stream: _v3.z.boolean().optional()
|
|
7541
7543
|
});
|
|
7542
7544
|
var staticParametersSchema = _v3.z.record(
|
|
@@ -7544,7 +7546,7 @@ var staticParametersSchema = _v3.z.record(
|
|
|
7544
7546
|
_v3.z.union([
|
|
7545
7547
|
_v3.z.object({
|
|
7546
7548
|
type: _v3.z.literal("prompt"),
|
|
7547
|
-
default:
|
|
7549
|
+
default: _chunkPOCCIJALjs.PromptData.optional(),
|
|
7548
7550
|
description: _v3.z.string().optional()
|
|
7549
7551
|
}),
|
|
7550
7552
|
_v3.z.object({
|
|
@@ -7600,7 +7602,8 @@ var evaluatorDefinitionsSchema = _v3.z.record(
|
|
|
7600
7602
|
);
|
|
7601
7603
|
|
|
7602
7604
|
// src/node/index.ts
|
|
7603
|
-
|
|
7605
|
+
_chunkPOCCIJALjs.configureNode.call(void 0, );
|
|
7606
|
+
|
|
7604
7607
|
|
|
7605
7608
|
|
|
7606
7609
|
|
|
@@ -7757,4 +7760,4 @@ _chunk37RLJF2Ujs.configureNode.call(void 0, );
|
|
|
7757
7760
|
|
|
7758
7761
|
|
|
7759
7762
|
|
|
7760
|
-
exports.Attachment =
|
|
7763
|
+
exports.Attachment = _chunkPOCCIJALjs.Attachment; exports.AttachmentReference = _chunkPOCCIJALjs.AttachmentReference; exports.BRAINTRUST_CURRENT_SPAN_STORE = _chunkPOCCIJALjs.BRAINTRUST_CURRENT_SPAN_STORE; exports.BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME = _chunkPOCCIJALjs.BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME; exports.BaseAttachment = _chunkPOCCIJALjs.BaseAttachment; exports.BaseExperiment = BaseExperiment; exports.BraintrustLangChainCallbackHandler = _chunkPOCCIJALjs.BraintrustLangChainCallbackHandler; exports.BraintrustMiddleware = BraintrustMiddleware; exports.BraintrustObservabilityExporter = _chunkPOCCIJALjs.BraintrustObservabilityExporter; exports.BraintrustState = _chunkPOCCIJALjs.BraintrustState; exports.BraintrustStream = _chunkPOCCIJALjs.BraintrustStream; exports.CachedSpanFetcher = CachedSpanFetcher; exports.CodeFunction = CodeFunction; exports.CodePrompt = CodePrompt; exports.ContextManager = _chunkPOCCIJALjs.ContextManager; exports.DEFAULT_FETCH_BATCH_SIZE = _chunkPOCCIJALjs.DEFAULT_FETCH_BATCH_SIZE; exports.DEFAULT_MAX_REQUEST_SIZE = _chunkPOCCIJALjs.DEFAULT_MAX_REQUEST_SIZE; exports.Dataset = _chunkPOCCIJALjs.Dataset; exports.DatasetPipeline = DatasetPipeline; exports.ERR_PERMALINK = _chunkPOCCIJALjs.ERR_PERMALINK; exports.Eval = Eval; exports.EvalResultWithSummary = EvalResultWithSummary; exports.Experiment = _chunkPOCCIJALjs.Experiment; exports.ExternalAttachment = _chunkPOCCIJALjs.ExternalAttachment; exports.FailedHTTPResponse = _chunkPOCCIJALjs.FailedHTTPResponse; exports.IDGenerator = _chunkPOCCIJALjs.IDGenerator; exports.JSONAttachment = _chunkPOCCIJALjs.JSONAttachment; exports.LEGACY_CACHED_HEADER = _chunkPOCCIJALjs.LEGACY_CACHED_HEADER; exports.LOGS3_OVERFLOW_REFERENCE_TYPE = _chunkPOCCIJALjs.LOGS3_OVERFLOW_REFERENCE_TYPE; exports.LazyValue = _chunkPOCCIJALjs.LazyValue; exports.LocalTrace = LocalTrace; exports.Logger = _chunkPOCCIJALjs.Logger; exports.LoginInvalidOrgError = _chunkPOCCIJALjs.LoginInvalidOrgError; exports.NOOP_SPAN = _chunkPOCCIJALjs.NOOP_SPAN; exports.NOOP_SPAN_PERMALINK = _chunkPOCCIJALjs.NOOP_SPAN_PERMALINK; exports.NoopSpan = _chunkPOCCIJALjs.NoopSpan; exports.ObjectFetcher = _chunkPOCCIJALjs.ObjectFetcher; exports.Project = Project2; exports.ProjectNameIdMap = ProjectNameIdMap; exports.Prompt = _chunkPOCCIJALjs.Prompt; exports.PromptBuilder = PromptBuilder; exports.ReadonlyAttachment = _chunkPOCCIJALjs.ReadonlyAttachment; exports.ReadonlyExperiment = _chunkPOCCIJALjs.ReadonlyExperiment; exports.Reporter = Reporter; exports.ScorerBuilder = ScorerBuilder; exports.SpanFetcher = SpanFetcher; exports.SpanImpl = _chunkPOCCIJALjs.SpanImpl; exports.TestBackgroundLogger = _chunkPOCCIJALjs.TestBackgroundLogger; exports.ToolBuilder = ToolBuilder; exports.UUIDGenerator = _chunkPOCCIJALjs.UUIDGenerator; exports.X_CACHED_HEADER = _chunkPOCCIJALjs.X_CACHED_HEADER; exports._exportsForTestingOnly = _chunkPOCCIJALjs._exportsForTestingOnly; exports._internalGetGlobalState = _chunkPOCCIJALjs._internalGetGlobalState; exports._internalIso = _chunkLPC4W2WXjs.isomorph_default; exports._internalSetInitialState = _chunkPOCCIJALjs._internalSetInitialState; exports.addAzureBlobHeaders = _chunkPOCCIJALjs.addAzureBlobHeaders; exports.braintrustAISDKTelemetry = _chunkPOCCIJALjs.braintrustAISDKTelemetry; exports.braintrustFlueInstrumentation = _chunkPOCCIJALjs.braintrustFlueInstrumentation; exports.braintrustFlueObserver = _chunkPOCCIJALjs.braintrustFlueObserver; exports.braintrustStreamChunkSchema = _chunkPOCCIJALjs.braintrustStreamChunkSchema; exports.buildLocalSummary = buildLocalSummary; exports.configureInstrumentation = _chunkPOCCIJALjs.configureInstrumentation; exports.constructLogs3OverflowRequest = _chunkPOCCIJALjs.constructLogs3OverflowRequest; exports.createFinalValuePassThroughStream = _chunkPOCCIJALjs.createFinalValuePassThroughStream; exports.currentExperiment = _chunkPOCCIJALjs.currentExperiment; exports.currentLogger = _chunkPOCCIJALjs.currentLogger; exports.currentSpan = _chunkPOCCIJALjs.currentSpan; exports.deepCopyEvent = _chunkPOCCIJALjs.deepCopyEvent; exports.default = exports_exports; exports.defaultErrorScoreHandler = defaultErrorScoreHandler; exports.deserializePlainStringAsJSON = _chunkPOCCIJALjs.deserializePlainStringAsJSON; exports.devNullWritableStream = _chunkPOCCIJALjs.devNullWritableStream; exports.evaluatorDefinitionSchema = evaluatorDefinitionSchema; exports.evaluatorDefinitionsSchema = evaluatorDefinitionsSchema; exports.flush = _chunkPOCCIJALjs.flush; exports.getContextManager = _chunkPOCCIJALjs.getContextManager; exports.getIdGenerator = _chunkPOCCIJALjs.getIdGenerator; exports.getPromptVersions = _chunkPOCCIJALjs.getPromptVersions; exports.getSpanParentObject = _chunkPOCCIJALjs.getSpanParentObject; exports.getTemplateRenderer = _chunkPOCCIJALjs.getTemplateRenderer; exports.graph = graph_framework_exports; exports.init = _chunkPOCCIJALjs.init; exports.initDataset = _chunkPOCCIJALjs.initDataset; exports.initExperiment = _chunkPOCCIJALjs.initExperiment; exports.initFunction = initFunction; exports.initLogger = _chunkPOCCIJALjs.initLogger; exports.initNodeTestSuite = initNodeTestSuite; exports.invoke = invoke; exports.isTemplateFormat = _chunkPOCCIJALjs.isTemplateFormat; exports.loadParameters = _chunkPOCCIJALjs.loadParameters; exports.loadPrompt = _chunkPOCCIJALjs.loadPrompt; exports.log = _chunkPOCCIJALjs.log; exports.logError = _chunkPOCCIJALjs.logError; exports.login = _chunkPOCCIJALjs.login; exports.loginToState = _chunkPOCCIJALjs.loginToState; exports.logs3OverflowUploadSchema = _chunkPOCCIJALjs.logs3OverflowUploadSchema; exports.newId = _chunkPOCCIJALjs.newId; exports.parseCachedHeader = _chunkPOCCIJALjs.parseCachedHeader; exports.parseTemplateFormat = _chunkPOCCIJALjs.parseTemplateFormat; exports.permalink = _chunkPOCCIJALjs.permalink; exports.pickLogs3OverflowObjectIds = _chunkPOCCIJALjs.pickLogs3OverflowObjectIds; exports.projects = projects; exports.promptContentsSchema = promptContentsSchema; exports.promptDefinitionSchema = promptDefinitionSchema; exports.promptDefinitionToPromptData = promptDefinitionToPromptData; exports.promptDefinitionWithToolsSchema = promptDefinitionWithToolsSchema; exports.registerOtelFlush = _chunkPOCCIJALjs.registerOtelFlush; exports.registerSandbox = registerSandbox; exports.registerTemplatePlugin = _chunkPOCCIJALjs.registerTemplatePlugin; exports.renderMessage = _chunkPOCCIJALjs.renderMessage; exports.renderPromptParams = _chunkPOCCIJALjs.renderPromptParams; exports.renderTemplateContent = _chunkPOCCIJALjs.renderTemplateContent; exports.reportFailures = reportFailures; exports.runEvaluator = runEvaluator; exports.setFetch = _chunkPOCCIJALjs.setFetch; exports.setMaskingFunction = _chunkPOCCIJALjs.setMaskingFunction; exports.spanComponentsToObjectId = _chunkPOCCIJALjs.spanComponentsToObjectId; exports.startSpan = _chunkPOCCIJALjs.startSpan; exports.summarize = _chunkPOCCIJALjs.summarize; exports.templateRegistry = _chunkPOCCIJALjs.templateRegistry; exports.toolFunctionDefinitionSchema = _chunkPOCCIJALjs.ToolFunctionDefinition; exports.traceable = _chunkPOCCIJALjs.traceable; exports.traced = _chunkPOCCIJALjs.traced; exports.updateSpan = _chunkPOCCIJALjs.updateSpan; exports.uploadLogs3OverflowPayload = _chunkPOCCIJALjs.uploadLogs3OverflowPayload; exports.utf8ByteLength = _chunkPOCCIJALjs.utf8ByteLength; exports.withCurrent = _chunkPOCCIJALjs.withCurrent; exports.withDataset = _chunkPOCCIJALjs.withDataset; exports.withExperiment = _chunkPOCCIJALjs.withExperiment; exports.withLogger = _chunkPOCCIJALjs.withLogger; exports.withParent = _chunkPOCCIJALjs.withParent; exports.wrapAISDK = wrapAISDK; exports.wrapAISDKModel = wrapAISDKModel; exports.wrapAgentClass = wrapAgentClass; exports.wrapAnthropic = wrapAnthropic; exports.wrapBedrockRuntime = wrapBedrockRuntime; exports.wrapClaudeAgentSDK = wrapClaudeAgentSDK; exports.wrapCohere = wrapCohere; exports.wrapCopilotClient = wrapCopilotClient; exports.wrapCursorSDK = wrapCursorSDK; exports.wrapGenkit = wrapGenkit; exports.wrapGoogleADK = wrapGoogleADK; exports.wrapGoogleGenAI = wrapGoogleGenAI; exports.wrapGroq = wrapGroq; exports.wrapHuggingFace = wrapHuggingFace; exports.wrapMastraAgent = _chunkPOCCIJALjs.wrapMastraAgent; exports.wrapMistral = wrapMistral; exports.wrapOpenAI = wrapOpenAI; exports.wrapOpenAICodexSDK = wrapOpenAICodexSDK; exports.wrapOpenAIv4 = wrapOpenAIv4; exports.wrapOpenRouter = wrapOpenRouter; exports.wrapOpenRouterAgent = wrapOpenRouterAgent; exports.wrapPiCodingAgentSDK = wrapPiCodingAgentSDK; exports.wrapStrandsAgentSDK = wrapStrandsAgentSDK; exports.wrapTraced = _chunkPOCCIJALjs.wrapTraced; exports.wrapVitest = wrapVitest;
|