braintrust 3.27.0 → 3.28.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 +519 -186
- package/dev/dist/index.d.ts +519 -186
- package/dev/dist/index.js +1837 -1009
- package/dev/dist/index.mjs +1172 -344
- package/dist/apply-auto-instrumentation.js +262 -210
- package/dist/apply-auto-instrumentation.mjs +54 -2
- package/dist/auto-instrumentations/bundler/esbuild.cjs +81 -2
- package/dist/auto-instrumentations/bundler/esbuild.mjs +2 -2
- package/dist/auto-instrumentations/bundler/next.cjs +81 -2
- package/dist/auto-instrumentations/bundler/next.mjs +3 -3
- package/dist/auto-instrumentations/bundler/rollup.cjs +81 -2
- package/dist/auto-instrumentations/bundler/rollup.mjs +2 -2
- package/dist/auto-instrumentations/bundler/vite.cjs +81 -2
- package/dist/auto-instrumentations/bundler/vite.mjs +2 -2
- package/dist/auto-instrumentations/bundler/webpack-loader.cjs +81 -2
- package/dist/auto-instrumentations/bundler/webpack.cjs +81 -2
- package/dist/auto-instrumentations/bundler/webpack.mjs +3 -3
- package/dist/auto-instrumentations/{chunk-XEYKUBLY.mjs → chunk-26PKVUKB.mjs} +80 -2
- package/dist/auto-instrumentations/{chunk-BW33ULMW.mjs → chunk-HD35AM3M.mjs} +1 -1
- package/dist/auto-instrumentations/{chunk-ZNHTSSGI.mjs → chunk-NP7V4XB2.mjs} +2 -1
- package/dist/auto-instrumentations/hook.mjs +236 -30
- package/dist/auto-instrumentations/index.cjs +2 -1
- package/dist/auto-instrumentations/index.mjs +1 -1
- package/dist/browser.d.mts +628 -53
- package/dist/browser.d.ts +628 -53
- package/dist/browser.js +2301 -284
- package/dist/browser.mjs +2301 -284
- package/dist/{chunk-MF7NU6BT.js → chunk-BBE7SNRV.js} +34 -4
- package/dist/{chunk-QRHGVBKU.js → chunk-OBBWQW6K.js} +1799 -1023
- package/dist/{chunk-YKD22IMR.mjs → chunk-UPFNQCGB.mjs} +966 -190
- package/dist/{chunk-CZM5JIQL.mjs → chunk-ZHUHZWFY.mjs} +33 -3
- package/dist/cli.js +1224 -398
- package/dist/edge-light.d.mts +1 -1
- package/dist/edge-light.d.ts +1 -1
- package/dist/edge-light.js +2301 -284
- package/dist/edge-light.mjs +2301 -284
- package/dist/index.d.mts +1212 -637
- package/dist/index.d.ts +1212 -637
- package/dist/index.js +1880 -590
- package/dist/index.mjs +1450 -160
- package/dist/instrumentation/index.d.mts +190 -6
- package/dist/instrumentation/index.d.ts +190 -6
- package/dist/instrumentation/index.js +823 -116
- package/dist/instrumentation/index.mjs +823 -116
- package/dist/vitest-evals-reporter.js +16 -16
- package/dist/vitest-evals-reporter.mjs +2 -2
- package/dist/workerd.d.mts +1 -1
- package/dist/workerd.d.ts +1 -1
- package/dist/workerd.js +2301 -284
- package/dist/workerd.mjs +2301 -284
- package/package.json +2 -3
- package/util/dist/index.d.mts +1545 -100
- package/util/dist/index.d.ts +1545 -100
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } async function _asyncOptionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = await fn(value); } else if (op === 'call' || op === 'optionalCall') { value = await fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7; var _class8; var _class9; var _class10; var _class11;
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } async function _asyncOptionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = await fn(value); } else if (op === 'call' || op === 'optionalCall') { value = await fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7; var _class8; var _class9; var _class10; var _class11; var _class12; var _class13; var _class14;
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
@@ -141,10 +141,10 @@
|
|
|
141
141
|
|
|
142
142
|
|
|
143
143
|
|
|
144
|
-
var _chunkQRHGVBKUjs = require('./chunk-QRHGVBKU.js');
|
|
145
144
|
|
|
146
145
|
|
|
147
146
|
|
|
147
|
+
var _chunkOBBWQW6Kjs = require('./chunk-OBBWQW6K.js');
|
|
148
148
|
|
|
149
149
|
|
|
150
150
|
|
|
@@ -173,152 +173,161 @@ var _chunkQRHGVBKUjs = require('./chunk-QRHGVBKU.js');
|
|
|
173
173
|
|
|
174
174
|
|
|
175
175
|
|
|
176
|
-
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
var _chunkBBE7SNRVjs = require('./chunk-BBE7SNRV.js');
|
|
177
181
|
|
|
178
182
|
// src/exports.ts
|
|
179
183
|
var exports_exports = {};
|
|
180
|
-
|
|
181
|
-
Attachment: () =>
|
|
182
|
-
AttachmentReference: () =>
|
|
183
|
-
BAGGAGE_HEADER: () =>
|
|
184
|
-
BRAINTRUST_CURRENT_SPAN_STORE: () =>
|
|
185
|
-
BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME: () =>
|
|
186
|
-
BRAINTRUST_PARENT_KEY: () =>
|
|
187
|
-
BaseAttachment: () =>
|
|
184
|
+
_chunkBBE7SNRVjs.__export.call(void 0, exports_exports, {
|
|
185
|
+
Attachment: () => _chunkOBBWQW6Kjs.Attachment,
|
|
186
|
+
AttachmentReference: () => _chunkOBBWQW6Kjs.AttachmentReference,
|
|
187
|
+
BAGGAGE_HEADER: () => _chunkOBBWQW6Kjs.BAGGAGE_HEADER,
|
|
188
|
+
BRAINTRUST_CURRENT_SPAN_STORE: () => _chunkOBBWQW6Kjs.BRAINTRUST_CURRENT_SPAN_STORE,
|
|
189
|
+
BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME: () => _chunkOBBWQW6Kjs.BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME,
|
|
190
|
+
BRAINTRUST_PARENT_KEY: () => _chunkOBBWQW6Kjs.BRAINTRUST_PARENT_KEY,
|
|
191
|
+
BaseAttachment: () => _chunkOBBWQW6Kjs.BaseAttachment,
|
|
188
192
|
BaseExperiment: () => BaseExperiment,
|
|
189
|
-
|
|
193
|
+
BatchScorer: () => BatchScorer,
|
|
194
|
+
BatchTask: () => BatchTask,
|
|
195
|
+
BraintrustLangChainCallbackHandler: () => _chunkOBBWQW6Kjs.BraintrustLangChainCallbackHandler,
|
|
190
196
|
BraintrustMiddleware: () => BraintrustMiddleware,
|
|
191
|
-
BraintrustObservabilityExporter: () =>
|
|
192
|
-
BraintrustState: () =>
|
|
193
|
-
BraintrustStream: () =>
|
|
197
|
+
BraintrustObservabilityExporter: () => _chunkOBBWQW6Kjs.BraintrustObservabilityExporter,
|
|
198
|
+
BraintrustState: () => _chunkOBBWQW6Kjs.BraintrustState,
|
|
199
|
+
BraintrustStream: () => _chunkOBBWQW6Kjs.BraintrustStream,
|
|
194
200
|
CachedSpanFetcher: () => CachedSpanFetcher,
|
|
195
201
|
CodeFunction: () => CodeFunction,
|
|
196
202
|
CodePrompt: () => CodePrompt,
|
|
197
|
-
ContextManager: () =>
|
|
198
|
-
DEFAULT_FETCH_BATCH_SIZE: () =>
|
|
199
|
-
DEFAULT_MAX_REQUEST_SIZE: () =>
|
|
200
|
-
Dataset: () =>
|
|
203
|
+
ContextManager: () => _chunkOBBWQW6Kjs.ContextManager,
|
|
204
|
+
DEFAULT_FETCH_BATCH_SIZE: () => _chunkOBBWQW6Kjs.DEFAULT_FETCH_BATCH_SIZE,
|
|
205
|
+
DEFAULT_MAX_REQUEST_SIZE: () => _chunkOBBWQW6Kjs.DEFAULT_MAX_REQUEST_SIZE,
|
|
206
|
+
Dataset: () => _chunkOBBWQW6Kjs.Dataset,
|
|
201
207
|
DatasetPipeline: () => DatasetPipeline,
|
|
202
|
-
|
|
208
|
+
DurableEvalMemoryStore: () => DurableEvalMemoryStore,
|
|
209
|
+
DurableEvalRedisStore: () => DurableEvalRedisStore,
|
|
210
|
+
ERR_PERMALINK: () => _chunkOBBWQW6Kjs.ERR_PERMALINK,
|
|
203
211
|
Eval: () => Eval,
|
|
204
212
|
EvalResultWithSummary: () => EvalResultWithSummary,
|
|
205
|
-
Experiment: () =>
|
|
206
|
-
ExternalAttachment: () =>
|
|
207
|
-
FailedHTTPResponse: () =>
|
|
208
|
-
IDGenerator: () =>
|
|
209
|
-
JSONAttachment: () =>
|
|
210
|
-
LEGACY_CACHED_HEADER: () =>
|
|
211
|
-
LOGS3_OVERFLOW_REFERENCE_TYPE: () =>
|
|
212
|
-
LazyValue: () =>
|
|
213
|
+
Experiment: () => _chunkOBBWQW6Kjs.Experiment,
|
|
214
|
+
ExternalAttachment: () => _chunkOBBWQW6Kjs.ExternalAttachment,
|
|
215
|
+
FailedHTTPResponse: () => _chunkOBBWQW6Kjs.FailedHTTPResponse,
|
|
216
|
+
IDGenerator: () => _chunkOBBWQW6Kjs.IDGenerator,
|
|
217
|
+
JSONAttachment: () => _chunkOBBWQW6Kjs.JSONAttachment,
|
|
218
|
+
LEGACY_CACHED_HEADER: () => _chunkOBBWQW6Kjs.LEGACY_CACHED_HEADER,
|
|
219
|
+
LOGS3_OVERFLOW_REFERENCE_TYPE: () => _chunkOBBWQW6Kjs.LOGS3_OVERFLOW_REFERENCE_TYPE,
|
|
220
|
+
LazyValue: () => _chunkOBBWQW6Kjs.LazyValue,
|
|
213
221
|
LocalTrace: () => LocalTrace,
|
|
214
|
-
Logger: () =>
|
|
215
|
-
LoginInvalidOrgError: () =>
|
|
216
|
-
NOOP_SPAN: () =>
|
|
217
|
-
NOOP_SPAN_PERMALINK: () =>
|
|
218
|
-
NoopSpan: () =>
|
|
219
|
-
OTELIDGenerator: () =>
|
|
220
|
-
ObjectFetcher: () =>
|
|
222
|
+
Logger: () => _chunkOBBWQW6Kjs.Logger,
|
|
223
|
+
LoginInvalidOrgError: () => _chunkOBBWQW6Kjs.LoginInvalidOrgError,
|
|
224
|
+
NOOP_SPAN: () => _chunkOBBWQW6Kjs.NOOP_SPAN,
|
|
225
|
+
NOOP_SPAN_PERMALINK: () => _chunkOBBWQW6Kjs.NOOP_SPAN_PERMALINK,
|
|
226
|
+
NoopSpan: () => _chunkOBBWQW6Kjs.NoopSpan,
|
|
227
|
+
OTELIDGenerator: () => _chunkOBBWQW6Kjs.OTELIDGenerator,
|
|
228
|
+
ObjectFetcher: () => _chunkOBBWQW6Kjs.ObjectFetcher,
|
|
221
229
|
Project: () => Project2,
|
|
222
230
|
ProjectNameIdMap: () => ProjectNameIdMap,
|
|
223
|
-
Prompt: () =>
|
|
231
|
+
Prompt: () => _chunkOBBWQW6Kjs.Prompt,
|
|
224
232
|
PromptBuilder: () => PromptBuilder,
|
|
225
|
-
ReadonlyAttachment: () =>
|
|
226
|
-
ReadonlyExperiment: () =>
|
|
233
|
+
ReadonlyAttachment: () => _chunkOBBWQW6Kjs.ReadonlyAttachment,
|
|
234
|
+
ReadonlyExperiment: () => _chunkOBBWQW6Kjs.ReadonlyExperiment,
|
|
227
235
|
Reporter: () => Reporter,
|
|
228
236
|
ScorerBuilder: () => ScorerBuilder,
|
|
229
237
|
SpanFetcher: () => SpanFetcher,
|
|
230
|
-
SpanImpl: () =>
|
|
231
|
-
TRACEPARENT_HEADER: () =>
|
|
232
|
-
TRACESTATE_HEADER: () =>
|
|
233
|
-
TestBackgroundLogger: () =>
|
|
238
|
+
SpanImpl: () => _chunkOBBWQW6Kjs.SpanImpl,
|
|
239
|
+
TRACEPARENT_HEADER: () => _chunkOBBWQW6Kjs.TRACEPARENT_HEADER,
|
|
240
|
+
TRACESTATE_HEADER: () => _chunkOBBWQW6Kjs.TRACESTATE_HEADER,
|
|
241
|
+
TestBackgroundLogger: () => _chunkOBBWQW6Kjs.TestBackgroundLogger,
|
|
234
242
|
ToolBuilder: () => ToolBuilder,
|
|
235
|
-
UUIDGenerator: () =>
|
|
236
|
-
X_CACHED_HEADER: () =>
|
|
237
|
-
_exportsForTestingOnly: () =>
|
|
238
|
-
_internalGetGlobalState: () =>
|
|
239
|
-
_internalIso: () =>
|
|
240
|
-
_internalSetInitialState: () =>
|
|
241
|
-
addAzureBlobHeaders: () =>
|
|
243
|
+
UUIDGenerator: () => _chunkOBBWQW6Kjs.UUIDGenerator,
|
|
244
|
+
X_CACHED_HEADER: () => _chunkOBBWQW6Kjs.X_CACHED_HEADER,
|
|
245
|
+
_exportsForTestingOnly: () => _chunkOBBWQW6Kjs._exportsForTestingOnly,
|
|
246
|
+
_internalGetGlobalState: () => _chunkOBBWQW6Kjs._internalGetGlobalState,
|
|
247
|
+
_internalIso: () => _chunkBBE7SNRVjs.isomorph_default,
|
|
248
|
+
_internalSetInitialState: () => _chunkOBBWQW6Kjs._internalSetInitialState,
|
|
249
|
+
addAzureBlobHeaders: () => _chunkOBBWQW6Kjs.addAzureBlobHeaders,
|
|
242
250
|
agentAssertionScorer: () => agentAssertionScorer,
|
|
243
|
-
braintrustAISDKTelemetry: () =>
|
|
251
|
+
braintrustAISDKTelemetry: () => _chunkOBBWQW6Kjs.braintrustAISDKTelemetry,
|
|
244
252
|
braintrustEveHook: () => braintrustEveHook,
|
|
245
253
|
braintrustEveInstrumentation: () => braintrustEveInstrumentation,
|
|
246
|
-
braintrustFlueInstrumentation: () =>
|
|
247
|
-
braintrustFlueObserver: () =>
|
|
248
|
-
braintrustStreamChunkSchema: () =>
|
|
254
|
+
braintrustFlueInstrumentation: () => _chunkOBBWQW6Kjs.braintrustFlueInstrumentation,
|
|
255
|
+
braintrustFlueObserver: () => _chunkOBBWQW6Kjs.braintrustFlueObserver,
|
|
256
|
+
braintrustStreamChunkSchema: () => _chunkOBBWQW6Kjs.braintrustStreamChunkSchema,
|
|
249
257
|
buildLocalSummary: () => buildLocalSummary,
|
|
250
|
-
collectAnthropicSession: () =>
|
|
251
|
-
configureInstrumentation: () =>
|
|
252
|
-
constructLogs3OverflowRequest: () =>
|
|
253
|
-
createFinalValuePassThroughStream: () =>
|
|
254
|
-
currentExperiment: () =>
|
|
255
|
-
currentLogger: () =>
|
|
256
|
-
currentSpan: () =>
|
|
257
|
-
deepCopyEvent: () =>
|
|
258
|
+
collectAnthropicSession: () => _chunkOBBWQW6Kjs.collectAnthropicSession,
|
|
259
|
+
configureInstrumentation: () => _chunkOBBWQW6Kjs.configureInstrumentation,
|
|
260
|
+
constructLogs3OverflowRequest: () => _chunkOBBWQW6Kjs.constructLogs3OverflowRequest,
|
|
261
|
+
createFinalValuePassThroughStream: () => _chunkOBBWQW6Kjs.createFinalValuePassThroughStream,
|
|
262
|
+
currentExperiment: () => _chunkOBBWQW6Kjs.currentExperiment,
|
|
263
|
+
currentLogger: () => _chunkOBBWQW6Kjs.currentLogger,
|
|
264
|
+
currentSpan: () => _chunkOBBWQW6Kjs.currentSpan,
|
|
265
|
+
deepCopyEvent: () => _chunkOBBWQW6Kjs.deepCopyEvent,
|
|
258
266
|
defaultErrorScoreHandler: () => defaultErrorScoreHandler,
|
|
259
|
-
|
|
260
|
-
|
|
267
|
+
defineDurableEval: () => defineDurableEval,
|
|
268
|
+
deserializePlainStringAsJSON: () => _chunkOBBWQW6Kjs.deserializePlainStringAsJSON,
|
|
269
|
+
devNullWritableStream: () => _chunkOBBWQW6Kjs.devNullWritableStream,
|
|
261
270
|
evaluatorDefinitionSchema: () => evaluatorDefinitionSchema,
|
|
262
271
|
evaluatorDefinitionsSchema: () => evaluatorDefinitionsSchema,
|
|
263
|
-
extractTraceContextFromHeaders: () =>
|
|
264
|
-
flush: () =>
|
|
265
|
-
getContextManager: () =>
|
|
266
|
-
getIdGenerator: () =>
|
|
267
|
-
getPromptVersions: () =>
|
|
268
|
-
getSpanParentObject: () =>
|
|
269
|
-
getTemplateRenderer: () =>
|
|
272
|
+
extractTraceContextFromHeaders: () => _chunkOBBWQW6Kjs.extractTraceContextFromHeaders,
|
|
273
|
+
flush: () => _chunkOBBWQW6Kjs.flush,
|
|
274
|
+
getContextManager: () => _chunkOBBWQW6Kjs.getContextManager,
|
|
275
|
+
getIdGenerator: () => _chunkOBBWQW6Kjs.getIdGenerator,
|
|
276
|
+
getPromptVersions: () => _chunkOBBWQW6Kjs.getPromptVersions,
|
|
277
|
+
getSpanParentObject: () => _chunkOBBWQW6Kjs.getSpanParentObject,
|
|
278
|
+
getTemplateRenderer: () => _chunkOBBWQW6Kjs.getTemplateRenderer,
|
|
270
279
|
graph: () => graph_framework_exports,
|
|
271
|
-
init: () =>
|
|
272
|
-
initDataset: () =>
|
|
273
|
-
initExperiment: () =>
|
|
280
|
+
init: () => _chunkOBBWQW6Kjs.init,
|
|
281
|
+
initDataset: () => _chunkOBBWQW6Kjs.initDataset,
|
|
282
|
+
initExperiment: () => _chunkOBBWQW6Kjs.initExperiment,
|
|
274
283
|
initFunction: () => initFunction,
|
|
275
|
-
initLogger: () =>
|
|
284
|
+
initLogger: () => _chunkOBBWQW6Kjs.initLogger,
|
|
276
285
|
initNodeTestSuite: () => initNodeTestSuite,
|
|
277
|
-
injectTraceContext: () =>
|
|
286
|
+
injectTraceContext: () => _chunkOBBWQW6Kjs.injectTraceContext,
|
|
278
287
|
invoke: () => invoke,
|
|
279
|
-
isTemplateFormat: () =>
|
|
280
|
-
loadParameters: () =>
|
|
281
|
-
loadPrompt: () =>
|
|
282
|
-
log: () =>
|
|
283
|
-
logError: () =>
|
|
284
|
-
login: () =>
|
|
285
|
-
loginToState: () =>
|
|
286
|
-
logs3OverflowUploadSchema: () =>
|
|
287
|
-
newId: () =>
|
|
288
|
-
parseCachedHeader: () =>
|
|
289
|
-
parseTemplateFormat: () =>
|
|
290
|
-
permalink: () =>
|
|
291
|
-
pickLogs3OverflowObjectIds: () =>
|
|
288
|
+
isTemplateFormat: () => _chunkOBBWQW6Kjs.isTemplateFormat,
|
|
289
|
+
loadParameters: () => _chunkOBBWQW6Kjs.loadParameters,
|
|
290
|
+
loadPrompt: () => _chunkOBBWQW6Kjs.loadPrompt,
|
|
291
|
+
log: () => _chunkOBBWQW6Kjs.log,
|
|
292
|
+
logError: () => _chunkOBBWQW6Kjs.logError,
|
|
293
|
+
login: () => _chunkOBBWQW6Kjs.login,
|
|
294
|
+
loginToState: () => _chunkOBBWQW6Kjs.loginToState,
|
|
295
|
+
logs3OverflowUploadSchema: () => _chunkOBBWQW6Kjs.logs3OverflowUploadSchema,
|
|
296
|
+
newId: () => _chunkOBBWQW6Kjs.newId,
|
|
297
|
+
parseCachedHeader: () => _chunkOBBWQW6Kjs.parseCachedHeader,
|
|
298
|
+
parseTemplateFormat: () => _chunkOBBWQW6Kjs.parseTemplateFormat,
|
|
299
|
+
permalink: () => _chunkOBBWQW6Kjs.permalink,
|
|
300
|
+
pickLogs3OverflowObjectIds: () => _chunkOBBWQW6Kjs.pickLogs3OverflowObjectIds,
|
|
292
301
|
projects: () => projects,
|
|
293
302
|
promptContentsSchema: () => promptContentsSchema,
|
|
294
303
|
promptDefinitionSchema: () => promptDefinitionSchema,
|
|
295
304
|
promptDefinitionToPromptData: () => promptDefinitionToPromptData,
|
|
296
305
|
promptDefinitionWithToolsSchema: () => promptDefinitionWithToolsSchema,
|
|
297
|
-
registerOtelFlush: () =>
|
|
306
|
+
registerOtelFlush: () => _chunkOBBWQW6Kjs.registerOtelFlush,
|
|
298
307
|
registerSandbox: () => registerSandbox,
|
|
299
|
-
registerTemplatePlugin: () =>
|
|
300
|
-
renderMessage: () =>
|
|
301
|
-
renderPromptParams: () =>
|
|
302
|
-
renderTemplateContent: () =>
|
|
308
|
+
registerTemplatePlugin: () => _chunkOBBWQW6Kjs.registerTemplatePlugin,
|
|
309
|
+
renderMessage: () => _chunkOBBWQW6Kjs.renderMessage,
|
|
310
|
+
renderPromptParams: () => _chunkOBBWQW6Kjs.renderPromptParams,
|
|
311
|
+
renderTemplateContent: () => _chunkOBBWQW6Kjs.renderTemplateContent,
|
|
303
312
|
reportFailures: () => reportFailures,
|
|
304
313
|
runEvaluator: () => runEvaluator,
|
|
305
|
-
setFetch: () =>
|
|
306
|
-
setMaskingFunction: () =>
|
|
307
|
-
spanComponentsToObjectId: () =>
|
|
308
|
-
startSpan: () =>
|
|
309
|
-
summarize: () =>
|
|
310
|
-
templateRegistry: () =>
|
|
311
|
-
toolFunctionDefinitionSchema: () =>
|
|
312
|
-
traceable: () =>
|
|
313
|
-
traced: () =>
|
|
314
|
-
updateSpan: () =>
|
|
315
|
-
uploadLogs3OverflowPayload: () =>
|
|
316
|
-
utf8ByteLength: () =>
|
|
317
|
-
withCurrent: () =>
|
|
318
|
-
withDataset: () =>
|
|
319
|
-
withExperiment: () =>
|
|
320
|
-
withLogger: () =>
|
|
321
|
-
withParent: () =>
|
|
314
|
+
setFetch: () => _chunkOBBWQW6Kjs.setFetch,
|
|
315
|
+
setMaskingFunction: () => _chunkOBBWQW6Kjs.setMaskingFunction,
|
|
316
|
+
spanComponentsToObjectId: () => _chunkOBBWQW6Kjs.spanComponentsToObjectId,
|
|
317
|
+
startSpan: () => _chunkOBBWQW6Kjs.startSpan,
|
|
318
|
+
summarize: () => _chunkOBBWQW6Kjs.summarize,
|
|
319
|
+
templateRegistry: () => _chunkOBBWQW6Kjs.templateRegistry,
|
|
320
|
+
toolFunctionDefinitionSchema: () => _chunkOBBWQW6Kjs.ToolFunctionDefinition,
|
|
321
|
+
traceable: () => _chunkOBBWQW6Kjs.traceable,
|
|
322
|
+
traced: () => _chunkOBBWQW6Kjs.traced,
|
|
323
|
+
updateSpan: () => _chunkOBBWQW6Kjs.updateSpan,
|
|
324
|
+
uploadLogs3OverflowPayload: () => _chunkOBBWQW6Kjs.uploadLogs3OverflowPayload,
|
|
325
|
+
utf8ByteLength: () => _chunkOBBWQW6Kjs.utf8ByteLength,
|
|
326
|
+
withCurrent: () => _chunkOBBWQW6Kjs.withCurrent,
|
|
327
|
+
withDataset: () => _chunkOBBWQW6Kjs.withDataset,
|
|
328
|
+
withExperiment: () => _chunkOBBWQW6Kjs.withExperiment,
|
|
329
|
+
withLogger: () => _chunkOBBWQW6Kjs.withLogger,
|
|
330
|
+
withParent: () => _chunkOBBWQW6Kjs.withParent,
|
|
322
331
|
wrapAISDK: () => wrapAISDK,
|
|
323
332
|
wrapAISDKModel: () => wrapAISDKModel,
|
|
324
333
|
wrapAgentClass: () => wrapAgentClass,
|
|
@@ -340,7 +349,7 @@ _chunkMF7NU6BTjs.__export.call(void 0, exports_exports, {
|
|
|
340
349
|
wrapLangSmithClient: () => wrapLangSmithClient,
|
|
341
350
|
wrapLangSmithRunTrees: () => wrapLangSmithRunTrees,
|
|
342
351
|
wrapLangSmithTraceable: () => wrapLangSmithTraceable,
|
|
343
|
-
wrapMastraAgent: () =>
|
|
352
|
+
wrapMastraAgent: () => _chunkOBBWQW6Kjs.wrapMastraAgent,
|
|
344
353
|
wrapMistral: () => wrapMistral,
|
|
345
354
|
wrapOllama: () => wrapOllama,
|
|
346
355
|
wrapOpenAI: () => wrapOpenAI,
|
|
@@ -350,15 +359,16 @@ _chunkMF7NU6BTjs.__export.call(void 0, exports_exports, {
|
|
|
350
359
|
wrapOpenRouterAgent: () => wrapOpenRouterAgent,
|
|
351
360
|
wrapPiCodingAgentSDK: () => wrapPiCodingAgentSDK,
|
|
352
361
|
wrapStrandsAgentSDK: () => wrapStrandsAgentSDK,
|
|
353
|
-
wrapTraced: () =>
|
|
354
|
-
wrapVitest: () => wrapVitest
|
|
362
|
+
wrapTraced: () => _chunkOBBWQW6Kjs.wrapTraced,
|
|
363
|
+
wrapVitest: () => wrapVitest,
|
|
364
|
+
wrapVoyageAI: () => wrapVoyageAI
|
|
355
365
|
});
|
|
356
366
|
|
|
357
367
|
// src/sandbox.ts
|
|
358
368
|
var _v3 = require('zod/v3');
|
|
359
369
|
var SANDBOX_GROUP_NAME_METADATA_KEY = "_bt_sandbox_group_name";
|
|
360
370
|
async function registerSandbox(options) {
|
|
361
|
-
const state = _nullishCoalesce(options.state, () => (
|
|
371
|
+
const state = _nullishCoalesce(options.state, () => ( _chunkOBBWQW6Kjs._internalGetGlobalState.call(void 0, )));
|
|
362
372
|
await state.login({
|
|
363
373
|
apiKey: options.apiKey,
|
|
364
374
|
appUrl: options.appUrl,
|
|
@@ -399,7 +409,7 @@ async function registerSandbox(options) {
|
|
|
399
409
|
evaluatorDefinitions
|
|
400
410
|
)) {
|
|
401
411
|
const functionName = evalName;
|
|
402
|
-
const functionSlug =
|
|
412
|
+
const functionSlug = _chunkOBBWQW6Kjs.slugify.call(void 0, evalName, { lower: true, strict: true });
|
|
403
413
|
const functionDef = {
|
|
404
414
|
project_id: projectId,
|
|
405
415
|
org_name: state.orgName,
|
|
@@ -470,7 +480,7 @@ async function invoke(args) {
|
|
|
470
480
|
projectId,
|
|
471
481
|
...functionIdArgs
|
|
472
482
|
} = args;
|
|
473
|
-
const state = _nullishCoalesce(stateArg, () => (
|
|
483
|
+
const state = _nullishCoalesce(stateArg, () => ( _chunkOBBWQW6Kjs._internalGetGlobalState.call(void 0, )));
|
|
474
484
|
await state.login({
|
|
475
485
|
orgName,
|
|
476
486
|
apiKey,
|
|
@@ -478,8 +488,8 @@ async function invoke(args) {
|
|
|
478
488
|
forceLogin,
|
|
479
489
|
fetch
|
|
480
490
|
});
|
|
481
|
-
const parent = parentArg ? typeof parentArg === "string" ? parentArg : await parentArg.export() : await
|
|
482
|
-
const functionId =
|
|
491
|
+
const parent = parentArg ? typeof parentArg === "string" ? parentArg : await parentArg.export() : await _chunkOBBWQW6Kjs.getSpanParentObject.call(void 0, ).export();
|
|
492
|
+
const functionId = _chunkOBBWQW6Kjs.FunctionId.safeParse({
|
|
483
493
|
function_id: functionIdArgs.function_id,
|
|
484
494
|
project_name: functionIdArgs.projectName,
|
|
485
495
|
slug: functionIdArgs.slug,
|
|
@@ -522,7 +532,7 @@ async function invoke(args) {
|
|
|
522
532
|
if (!resp.body) {
|
|
523
533
|
throw new Error("Received empty stream body");
|
|
524
534
|
}
|
|
525
|
-
return new (0,
|
|
535
|
+
return new (0, _chunkOBBWQW6Kjs.BraintrustStream)(resp.body);
|
|
526
536
|
} else {
|
|
527
537
|
const data = await resp.json();
|
|
528
538
|
return schema ? schema.parse(data) : data;
|
|
@@ -534,7 +544,7 @@ function initFunction({
|
|
|
534
544
|
version,
|
|
535
545
|
state
|
|
536
546
|
}) {
|
|
537
|
-
const s = _nullishCoalesce(state, () => (
|
|
547
|
+
const s = _nullishCoalesce(state, () => ( _chunkOBBWQW6Kjs._internalGetGlobalState.call(void 0, )));
|
|
538
548
|
_optionalChain([s, 'optionalAccess', _2 => _2.spanCache, 'optionalAccess', _3 => _3.disable, 'call', _4 => _4()]);
|
|
539
549
|
const f = async (input) => {
|
|
540
550
|
return await invoke({
|
|
@@ -612,22 +622,22 @@ function responsesProxy(openai) {
|
|
|
612
622
|
if (name === "create" && typeof target.create === "function") {
|
|
613
623
|
return wrapResponsesAsync(
|
|
614
624
|
target.create.bind(target),
|
|
615
|
-
|
|
625
|
+
_chunkBBE7SNRVjs.openAIChannels.responsesCreate
|
|
616
626
|
);
|
|
617
627
|
} else if (name === "stream" && typeof target.stream === "function") {
|
|
618
628
|
return wrapResponsesSyncStream(
|
|
619
629
|
target.stream.bind(target),
|
|
620
|
-
|
|
630
|
+
_chunkBBE7SNRVjs.openAIChannels.responsesStream
|
|
621
631
|
);
|
|
622
632
|
} else if (name === "parse" && typeof target.parse === "function") {
|
|
623
633
|
return wrapResponsesAsync(
|
|
624
634
|
target.parse.bind(target),
|
|
625
|
-
|
|
635
|
+
_chunkBBE7SNRVjs.openAIChannels.responsesParse
|
|
626
636
|
);
|
|
627
637
|
} else if (name === "compact" && typeof target.compact === "function") {
|
|
628
638
|
return wrapResponsesAsync(
|
|
629
639
|
target.compact.bind(target),
|
|
630
|
-
|
|
640
|
+
_chunkBBE7SNRVjs.openAIChannels.responsesCompact
|
|
631
641
|
);
|
|
632
642
|
}
|
|
633
643
|
return Reflect.get(target, name, receiver);
|
|
@@ -771,7 +781,7 @@ function wrapBetaChatCompletionParse(completion) {
|
|
|
771
781
|
const { span_info, params } = splitSpanInfo(
|
|
772
782
|
allParams
|
|
773
783
|
);
|
|
774
|
-
return
|
|
784
|
+
return _chunkBBE7SNRVjs.openAIChannels.betaChatCompletionsParse.tracePromise(
|
|
775
785
|
async () => await completion(params),
|
|
776
786
|
{ arguments: [params], span_info }
|
|
777
787
|
);
|
|
@@ -782,7 +792,7 @@ function wrapBetaChatCompletionStream(completion) {
|
|
|
782
792
|
const { span_info, params } = splitSpanInfo(
|
|
783
793
|
allParams
|
|
784
794
|
);
|
|
785
|
-
return
|
|
795
|
+
return _chunkBBE7SNRVjs.openAIChannels.betaChatCompletionsStream.traceSync(
|
|
786
796
|
() => completion(params),
|
|
787
797
|
{ arguments: [params], span_info }
|
|
788
798
|
);
|
|
@@ -798,7 +808,7 @@ function wrapChatCompletion(completion) {
|
|
|
798
808
|
if (!executionPromise) {
|
|
799
809
|
executionPromise = (async () => {
|
|
800
810
|
const traceContext = createChannelContext(
|
|
801
|
-
|
|
811
|
+
_chunkBBE7SNRVjs.openAIChannels.chatCompletionsCreate,
|
|
802
812
|
params,
|
|
803
813
|
span_info
|
|
804
814
|
);
|
|
@@ -808,7 +818,7 @@ function wrapChatCompletion(completion) {
|
|
|
808
818
|
options
|
|
809
819
|
);
|
|
810
820
|
const { data: data2, response: response2 } = await tracePromiseWithResponse(
|
|
811
|
-
|
|
821
|
+
_chunkBBE7SNRVjs.openAIChannels.chatCompletionsCreate,
|
|
812
822
|
traceContext,
|
|
813
823
|
completionPromise
|
|
814
824
|
);
|
|
@@ -819,7 +829,7 @@ function wrapChatCompletion(completion) {
|
|
|
819
829
|
options
|
|
820
830
|
);
|
|
821
831
|
const { data, response } = await tracePromiseWithResponse(
|
|
822
|
-
|
|
832
|
+
_chunkBBE7SNRVjs.openAIChannels.chatCompletionsCreate,
|
|
823
833
|
traceContext,
|
|
824
834
|
completionResponse
|
|
825
835
|
);
|
|
@@ -862,8 +872,8 @@ function wrapApiCreateWithChannel(create, channel) {
|
|
|
862
872
|
return createLazyAPIPromise(ensureExecuted);
|
|
863
873
|
};
|
|
864
874
|
}
|
|
865
|
-
var wrapEmbeddings = (create) => wrapApiCreateWithChannel(create,
|
|
866
|
-
var wrapModerations = (create) => wrapApiCreateWithChannel(create,
|
|
875
|
+
var wrapEmbeddings = (create) => wrapApiCreateWithChannel(create, _chunkBBE7SNRVjs.openAIChannels.embeddingsCreate);
|
|
876
|
+
var wrapModerations = (create) => wrapApiCreateWithChannel(create, _chunkBBE7SNRVjs.openAIChannels.moderationsCreate);
|
|
867
877
|
|
|
868
878
|
// src/wrappers/ai-sdk/ai-sdk.ts
|
|
869
879
|
function isModuleNamespace(obj) {
|
|
@@ -966,7 +976,7 @@ var wrapAgentClass = (AgentClass, options = {}) => {
|
|
|
966
976
|
return wrapHarnessAgentGenerate(
|
|
967
977
|
original,
|
|
968
978
|
harnessAgent,
|
|
969
|
-
|
|
979
|
+
_chunkBBE7SNRVjs.harnessAgentChannels.generate,
|
|
970
980
|
"HarnessAgent.generate",
|
|
971
981
|
options
|
|
972
982
|
);
|
|
@@ -974,7 +984,7 @@ var wrapAgentClass = (AgentClass, options = {}) => {
|
|
|
974
984
|
return wrapHarnessAgentStream(
|
|
975
985
|
original,
|
|
976
986
|
harnessAgent,
|
|
977
|
-
|
|
987
|
+
_chunkBBE7SNRVjs.harnessAgentChannels.stream,
|
|
978
988
|
"HarnessAgent.stream",
|
|
979
989
|
options
|
|
980
990
|
);
|
|
@@ -982,7 +992,7 @@ var wrapAgentClass = (AgentClass, options = {}) => {
|
|
|
982
992
|
return wrapHarnessAgentGenerate(
|
|
983
993
|
original,
|
|
984
994
|
harnessAgent,
|
|
985
|
-
|
|
995
|
+
_chunkBBE7SNRVjs.harnessAgentChannels.continueGenerate,
|
|
986
996
|
"HarnessAgent.continueGenerate",
|
|
987
997
|
options
|
|
988
998
|
);
|
|
@@ -990,7 +1000,7 @@ var wrapAgentClass = (AgentClass, options = {}) => {
|
|
|
990
1000
|
return wrapHarnessAgentStream(
|
|
991
1001
|
original,
|
|
992
1002
|
harnessAgent,
|
|
993
|
-
|
|
1003
|
+
_chunkBBE7SNRVjs.harnessAgentChannels.continueStream,
|
|
994
1004
|
"HarnessAgent.continueStream",
|
|
995
1005
|
options
|
|
996
1006
|
);
|
|
@@ -1013,7 +1023,7 @@ var wrapAgentClass = (AgentClass, options = {}) => {
|
|
|
1013
1023
|
};
|
|
1014
1024
|
var wrapHarnessAgentCreateSession = (createSession, instance) => {
|
|
1015
1025
|
const wrapper = function(params) {
|
|
1016
|
-
return
|
|
1026
|
+
return _chunkBBE7SNRVjs.harnessAgentChannels.createSession.tracePromise(
|
|
1017
1027
|
() => params === void 0 ? createSession.call(instance) : createSession.call(instance, params),
|
|
1018
1028
|
createAISDKChannelContext(_nullishCoalesce(params, () => ( {})), { self: instance })
|
|
1019
1029
|
);
|
|
@@ -1059,15 +1069,15 @@ var wrapAgentGenerate = (generate, instance, options = {}) => {
|
|
|
1059
1069
|
};
|
|
1060
1070
|
function generateChannelForAgent(agentName) {
|
|
1061
1071
|
if (agentName === "ToolLoopAgent") {
|
|
1062
|
-
return
|
|
1072
|
+
return _chunkBBE7SNRVjs.aiSDKChannels.toolLoopAgentGenerate;
|
|
1063
1073
|
}
|
|
1064
|
-
return
|
|
1074
|
+
return _chunkBBE7SNRVjs.aiSDKChannels.agentGenerate;
|
|
1065
1075
|
}
|
|
1066
1076
|
var wrapAgentStream = (stream, instance, options = {}) => {
|
|
1067
1077
|
const defaultName = `${instance.constructor.name}.stream`;
|
|
1068
1078
|
return (params) => {
|
|
1069
1079
|
const workflowAgent = instance.constructor.name === "WorkflowAgent";
|
|
1070
|
-
if (workflowAgent &&
|
|
1080
|
+
if (workflowAgent && _chunkOBBWQW6Kjs.currentWorkflowAgentWrapperSpan.call(void 0, )) {
|
|
1071
1081
|
const { span_info: _spanInfo, ...cleanParams } = params;
|
|
1072
1082
|
return stream.call(instance, { ...instance.settings, ...cleanParams });
|
|
1073
1083
|
}
|
|
@@ -1086,12 +1096,12 @@ var wrapAgentStream = (stream, instance, options = {}) => {
|
|
|
1086
1096
|
};
|
|
1087
1097
|
function streamChannelForAgent(agentName) {
|
|
1088
1098
|
if (agentName === "ToolLoopAgent") {
|
|
1089
|
-
return
|
|
1099
|
+
return _chunkBBE7SNRVjs.aiSDKChannels.toolLoopAgentStream;
|
|
1090
1100
|
}
|
|
1091
1101
|
if (agentName === "WorkflowAgent") {
|
|
1092
|
-
return
|
|
1102
|
+
return _chunkBBE7SNRVjs.aiSDKChannels.workflowAgentStream;
|
|
1093
1103
|
}
|
|
1094
|
-
return
|
|
1104
|
+
return _chunkBBE7SNRVjs.aiSDKChannels.agentStream;
|
|
1095
1105
|
}
|
|
1096
1106
|
var makeGenerateTextWrapper = (channel, name, generateText, contextOptions = {}, options = {}) => {
|
|
1097
1107
|
const wrapper = async function(allParams) {
|
|
@@ -1115,7 +1125,7 @@ var makeGenerateTextWrapper = (channel, name, generateText, contextOptions = {},
|
|
|
1115
1125
|
};
|
|
1116
1126
|
var wrapGenerateText = (generateText, options = {}, aiSDK) => {
|
|
1117
1127
|
return makeGenerateTextWrapper(
|
|
1118
|
-
|
|
1128
|
+
_chunkBBE7SNRVjs.aiSDKChannels.generateText,
|
|
1119
1129
|
"generateText",
|
|
1120
1130
|
generateText,
|
|
1121
1131
|
{ aiSDK },
|
|
@@ -1124,7 +1134,7 @@ var wrapGenerateText = (generateText, options = {}, aiSDK) => {
|
|
|
1124
1134
|
};
|
|
1125
1135
|
var wrapGenerateObject = (generateObject, options = {}, aiSDK) => {
|
|
1126
1136
|
return makeGenerateTextWrapper(
|
|
1127
|
-
|
|
1137
|
+
_chunkBBE7SNRVjs.aiSDKChannels.generateObject,
|
|
1128
1138
|
"generateObject",
|
|
1129
1139
|
generateObject,
|
|
1130
1140
|
{ aiSDK },
|
|
@@ -1153,7 +1163,7 @@ var makeEmbedWrapper = (channel, name, embed, contextOptions = {}, options = {})
|
|
|
1153
1163
|
};
|
|
1154
1164
|
var wrapEmbed = (embed, options = {}, aiSDK) => {
|
|
1155
1165
|
return makeEmbedWrapper(
|
|
1156
|
-
|
|
1166
|
+
_chunkBBE7SNRVjs.aiSDKChannels.embed,
|
|
1157
1167
|
"embed",
|
|
1158
1168
|
embed,
|
|
1159
1169
|
{ aiSDK },
|
|
@@ -1162,7 +1172,7 @@ var wrapEmbed = (embed, options = {}, aiSDK) => {
|
|
|
1162
1172
|
};
|
|
1163
1173
|
var wrapEmbedMany = (embedMany, options = {}, aiSDK) => {
|
|
1164
1174
|
return makeEmbedWrapper(
|
|
1165
|
-
|
|
1175
|
+
_chunkBBE7SNRVjs.aiSDKChannels.embedMany,
|
|
1166
1176
|
"embedMany",
|
|
1167
1177
|
embedMany,
|
|
1168
1178
|
{ aiSDK },
|
|
@@ -1173,7 +1183,7 @@ var makeRerankWrapper = (rerank, contextOptions = {}, options = {}) => {
|
|
|
1173
1183
|
const wrapper = async function(allParams) {
|
|
1174
1184
|
const { span_info, ...params } = allParams;
|
|
1175
1185
|
const tracedParams = { ...params };
|
|
1176
|
-
return
|
|
1186
|
+
return _chunkBBE7SNRVjs.aiSDKChannels.rerank.tracePromise(
|
|
1177
1187
|
() => rerank(tracedParams),
|
|
1178
1188
|
createAISDKChannelContext(tracedParams, {
|
|
1179
1189
|
aiSDK: contextOptions.aiSDK,
|
|
@@ -1212,7 +1222,7 @@ var makeStreamWrapper = (channel, name, streamText, contextOptions = {}, options
|
|
|
1212
1222
|
};
|
|
1213
1223
|
var wrapStreamText = (streamText, options = {}, aiSDK) => {
|
|
1214
1224
|
return makeStreamWrapper(
|
|
1215
|
-
|
|
1225
|
+
_chunkBBE7SNRVjs.aiSDKChannels.streamText,
|
|
1216
1226
|
"streamText",
|
|
1217
1227
|
streamText,
|
|
1218
1228
|
{ aiSDK },
|
|
@@ -1221,7 +1231,7 @@ var wrapStreamText = (streamText, options = {}, aiSDK) => {
|
|
|
1221
1231
|
};
|
|
1222
1232
|
var wrapStreamObject = (streamObject, options = {}, aiSDK) => {
|
|
1223
1233
|
return makeStreamWrapper(
|
|
1224
|
-
|
|
1234
|
+
_chunkBBE7SNRVjs.aiSDKChannels.streamObject,
|
|
1225
1235
|
"streamObject",
|
|
1226
1236
|
streamObject,
|
|
1227
1237
|
{ aiSDK },
|
|
@@ -1293,19 +1303,19 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1293
1303
|
// For the first cut, do not support custom span_info arguments. We can
|
|
1294
1304
|
// propagate those via async local storage
|
|
1295
1305
|
async doGenerate(options) {
|
|
1296
|
-
const span =
|
|
1297
|
-
|
|
1306
|
+
const span = _chunkOBBWQW6Kjs.startSpan.call(void 0,
|
|
1307
|
+
_chunkBBE7SNRVjs.withSpanInstrumentationName.call(void 0,
|
|
1298
1308
|
{
|
|
1299
1309
|
name: "Chat Completion",
|
|
1300
1310
|
spanAttributes: {
|
|
1301
1311
|
type: "llm"
|
|
1302
1312
|
}
|
|
1303
1313
|
},
|
|
1304
|
-
|
|
1314
|
+
_chunkBBE7SNRVjs.INSTRUMENTATION_NAMES.AI_SDK
|
|
1305
1315
|
)
|
|
1306
1316
|
);
|
|
1307
1317
|
const { prompt, mode, ...rest } = options;
|
|
1308
|
-
const startTime =
|
|
1318
|
+
const startTime = _chunkOBBWQW6Kjs.getCurrentUnixTimestamp.call(void 0, );
|
|
1309
1319
|
try {
|
|
1310
1320
|
const ret = await this.model.doGenerate(options);
|
|
1311
1321
|
span.log({
|
|
@@ -1317,12 +1327,12 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1317
1327
|
},
|
|
1318
1328
|
output: postProcessOutput(ret.text, ret.toolCalls, ret.finishReason),
|
|
1319
1329
|
metrics: {
|
|
1320
|
-
time_to_first_token:
|
|
1321
|
-
tokens: !
|
|
1330
|
+
time_to_first_token: _chunkOBBWQW6Kjs.getCurrentUnixTimestamp.call(void 0, ) - startTime,
|
|
1331
|
+
tokens: !_chunkOBBWQW6Kjs.isEmpty.call(void 0, ret.usage) ? ret.usage.promptTokens + ret.usage.completionTokens : void 0,
|
|
1322
1332
|
prompt_tokens: _optionalChain([ret, 'access', _26 => _26.usage, 'optionalAccess', _27 => _27.promptTokens]),
|
|
1323
1333
|
completion_tokens: _optionalChain([ret, 'access', _28 => _28.usage, 'optionalAccess', _29 => _29.completionTokens]),
|
|
1324
|
-
cached:
|
|
1325
|
-
_nullishCoalesce(_optionalChain([ret, 'access', _30 => _30.rawResponse, 'optionalAccess', _31 => _31.headers, 'optionalAccess', _32 => _32[
|
|
1334
|
+
cached: _chunkOBBWQW6Kjs.parseCachedHeader.call(void 0,
|
|
1335
|
+
_nullishCoalesce(_optionalChain([ret, 'access', _30 => _30.rawResponse, 'optionalAccess', _31 => _31.headers, 'optionalAccess', _32 => _32[_chunkOBBWQW6Kjs.X_CACHED_HEADER]]), () => ( _optionalChain([ret, 'access', _33 => _33.rawResponse, 'optionalAccess', _34 => _34.headers, 'optionalAccess', _35 => _35[_chunkOBBWQW6Kjs.LEGACY_CACHED_HEADER]])))
|
|
1326
1336
|
)
|
|
1327
1337
|
}
|
|
1328
1338
|
});
|
|
@@ -1333,16 +1343,16 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1333
1343
|
}
|
|
1334
1344
|
async doStream(options) {
|
|
1335
1345
|
const { prompt, mode, ...rest } = options;
|
|
1336
|
-
const startTime =
|
|
1337
|
-
const span =
|
|
1338
|
-
|
|
1346
|
+
const startTime = _chunkOBBWQW6Kjs.getCurrentUnixTimestamp.call(void 0, );
|
|
1347
|
+
const span = _chunkOBBWQW6Kjs.startSpan.call(void 0,
|
|
1348
|
+
_chunkBBE7SNRVjs.withSpanInstrumentationName.call(void 0,
|
|
1339
1349
|
{
|
|
1340
1350
|
name: "Chat Completion",
|
|
1341
1351
|
spanAttributes: {
|
|
1342
1352
|
type: "llm"
|
|
1343
1353
|
}
|
|
1344
1354
|
},
|
|
1345
|
-
|
|
1355
|
+
_chunkBBE7SNRVjs.INSTRUMENTATION_NAMES.AI_SDK
|
|
1346
1356
|
)
|
|
1347
1357
|
);
|
|
1348
1358
|
span.log({
|
|
@@ -1373,7 +1383,7 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1373
1383
|
new TransformStream({
|
|
1374
1384
|
transform(chunk, controller) {
|
|
1375
1385
|
if (time_to_first_token === void 0) {
|
|
1376
|
-
time_to_first_token =
|
|
1386
|
+
time_to_first_token = _chunkOBBWQW6Kjs.getCurrentUnixTimestamp.call(void 0, ) - startTime;
|
|
1377
1387
|
span.log({ metrics: { time_to_first_token } });
|
|
1378
1388
|
}
|
|
1379
1389
|
switch (chunk.type) {
|
|
@@ -1418,11 +1428,11 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1418
1428
|
),
|
|
1419
1429
|
metrics: {
|
|
1420
1430
|
time_to_first_token,
|
|
1421
|
-
tokens: !
|
|
1431
|
+
tokens: !_chunkOBBWQW6Kjs.isEmpty.call(void 0, usage) ? usage.promptTokens + usage.completionTokens : void 0,
|
|
1422
1432
|
prompt_tokens: _optionalChain([usage, 'optionalAccess', _36 => _36.promptTokens]),
|
|
1423
1433
|
completion_tokens: _optionalChain([usage, 'optionalAccess', _37 => _37.completionTokens]),
|
|
1424
|
-
cached:
|
|
1425
|
-
_nullishCoalesce(_optionalChain([ret, 'access', _38 => _38.rawResponse, 'optionalAccess', _39 => _39.headers, 'optionalAccess', _40 => _40[
|
|
1434
|
+
cached: _chunkOBBWQW6Kjs.parseCachedHeader.call(void 0,
|
|
1435
|
+
_nullishCoalesce(_optionalChain([ret, 'access', _38 => _38.rawResponse, 'optionalAccess', _39 => _39.headers, 'optionalAccess', _40 => _40[_chunkOBBWQW6Kjs.X_CACHED_HEADER]]), () => ( _optionalChain([ret, 'access', _41 => _41.rawResponse, 'optionalAccess', _42 => _42.headers, 'optionalAccess', _43 => _43[_chunkOBBWQW6Kjs.LEGACY_CACHED_HEADER]])))
|
|
1426
1436
|
)
|
|
1427
1437
|
}
|
|
1428
1438
|
});
|
|
@@ -1607,12 +1617,12 @@ function normalizeUsageMetrics(usage, provider, providerMetadata) {
|
|
|
1607
1617
|
anthropicMetadata.usage,
|
|
1608
1618
|
"cache_creation_input_tokens"
|
|
1609
1619
|
) || 0;
|
|
1610
|
-
const cacheTokens =
|
|
1620
|
+
const cacheTokens = _chunkOBBWQW6Kjs.extractAnthropicCacheTokens.call(void 0,
|
|
1611
1621
|
cacheReadTokens,
|
|
1612
1622
|
cacheCreationTokens
|
|
1613
1623
|
);
|
|
1614
1624
|
Object.assign(metrics, cacheTokens);
|
|
1615
|
-
|
|
1625
|
+
return _chunkOBBWQW6Kjs.toNumericMetrics.call(void 0, _chunkOBBWQW6Kjs.finalizeAnthropicTokens.call(void 0, metrics));
|
|
1616
1626
|
}
|
|
1617
1627
|
}
|
|
1618
1628
|
return metrics;
|
|
@@ -1684,7 +1694,7 @@ function BraintrustMiddleware(config = {}) {
|
|
|
1684
1694
|
model: modelFromWrapGenerate
|
|
1685
1695
|
}) => {
|
|
1686
1696
|
const rawInput = extractInput(params);
|
|
1687
|
-
const processedInput =
|
|
1697
|
+
const processedInput = _chunkOBBWQW6Kjs.processInputAttachments.call(void 0, rawInput);
|
|
1688
1698
|
const spanArgs = {
|
|
1689
1699
|
name: _optionalChain([config, 'access', _60 => _60.spanInfo, 'optionalAccess', _61 => _61.name]) || "ai-sdk.doGenerate",
|
|
1690
1700
|
spanAttributes: {
|
|
@@ -1699,8 +1709,8 @@ function BraintrustMiddleware(config = {}) {
|
|
|
1699
1709
|
}
|
|
1700
1710
|
}
|
|
1701
1711
|
};
|
|
1702
|
-
const span =
|
|
1703
|
-
|
|
1712
|
+
const span = _chunkOBBWQW6Kjs.startSpan.call(void 0,
|
|
1713
|
+
_chunkBBE7SNRVjs.withSpanInstrumentationName.call(void 0, spanArgs, _chunkBBE7SNRVjs.INSTRUMENTATION_NAMES.AI_SDK)
|
|
1704
1714
|
);
|
|
1705
1715
|
try {
|
|
1706
1716
|
const result = await doGenerate();
|
|
@@ -1748,7 +1758,7 @@ function BraintrustMiddleware(config = {}) {
|
|
|
1748
1758
|
},
|
|
1749
1759
|
wrapStream: async ({ doStream, params }) => {
|
|
1750
1760
|
const rawInput = extractInput(params);
|
|
1751
|
-
const processedInput =
|
|
1761
|
+
const processedInput = _chunkOBBWQW6Kjs.processInputAttachments.call(void 0, rawInput);
|
|
1752
1762
|
const spanArgs = {
|
|
1753
1763
|
name: _optionalChain([config, 'access', _69 => _69.spanInfo, 'optionalAccess', _70 => _70.name]) || "ai-sdk.doStream",
|
|
1754
1764
|
spanAttributes: {
|
|
@@ -1763,8 +1773,8 @@ function BraintrustMiddleware(config = {}) {
|
|
|
1763
1773
|
}
|
|
1764
1774
|
}
|
|
1765
1775
|
};
|
|
1766
|
-
const span =
|
|
1767
|
-
|
|
1776
|
+
const span = _chunkOBBWQW6Kjs.startSpan.call(void 0,
|
|
1777
|
+
_chunkBBE7SNRVjs.withSpanInstrumentationName.call(void 0, spanArgs, _chunkBBE7SNRVjs.INSTRUMENTATION_NAMES.AI_SDK)
|
|
1768
1778
|
);
|
|
1769
1779
|
try {
|
|
1770
1780
|
const { stream, ...rest } = await doStream();
|
|
@@ -1889,7 +1899,7 @@ function braintrustEveInstrumentation(options) {
|
|
|
1889
1899
|
try {
|
|
1890
1900
|
captureEveModelInput(state, input);
|
|
1891
1901
|
} catch (error) {
|
|
1892
|
-
|
|
1902
|
+
_chunkOBBWQW6Kjs.debugLogger.warn("Error in Eve LLM input capture:", error);
|
|
1893
1903
|
}
|
|
1894
1904
|
}
|
|
1895
1905
|
},
|
|
@@ -1899,7 +1909,7 @@ function braintrustEveInstrumentation(options) {
|
|
|
1899
1909
|
};
|
|
1900
1910
|
}
|
|
1901
1911
|
function isEveHandleMessageStreamEvent(event) {
|
|
1902
|
-
return
|
|
1912
|
+
return _chunkOBBWQW6Kjs.isObject.call(void 0, event) && typeof event["type"] === "string";
|
|
1903
1913
|
}
|
|
1904
1914
|
var ResumedEveSpan = class {
|
|
1905
1915
|
constructor(reference) {
|
|
@@ -1920,7 +1930,7 @@ var ResumedEveSpan = class {
|
|
|
1920
1930
|
...this.endTime === void 0 ? {} : { end: this.endTime },
|
|
1921
1931
|
...event.metrics
|
|
1922
1932
|
};
|
|
1923
|
-
|
|
1933
|
+
_chunkOBBWQW6Kjs.updateSpan.call(void 0, {
|
|
1924
1934
|
exported: this.reference.exported,
|
|
1925
1935
|
...this.reference.startEvent,
|
|
1926
1936
|
...event,
|
|
@@ -1929,7 +1939,7 @@ var ResumedEveSpan = class {
|
|
|
1929
1939
|
}
|
|
1930
1940
|
end(args) {
|
|
1931
1941
|
if (this.endTime === void 0) {
|
|
1932
|
-
this.endTime = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _78 => _78.endTime]), () => (
|
|
1942
|
+
this.endTime = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _78 => _78.endTime]), () => ( _chunkOBBWQW6Kjs.getCurrentUnixTimestamp.call(void 0, )));
|
|
1933
1943
|
this.log({ metrics: { end: this.endTime } });
|
|
1934
1944
|
}
|
|
1935
1945
|
return this.endTime;
|
|
@@ -1941,13 +1951,13 @@ var EveBridge = (_class = class {
|
|
|
1941
1951
|
}
|
|
1942
1952
|
|
|
1943
1953
|
__init() {this.eventQueuesBySession = /* @__PURE__ */ new Map()}
|
|
1944
|
-
__init2() {this.completedToolKeys = new (0,
|
|
1954
|
+
__init2() {this.completedToolKeys = new (0, _chunkOBBWQW6Kjs.LRUCache)({
|
|
1945
1955
|
max: MAX_EVE_CACHE_ENTRIES
|
|
1946
1956
|
})}
|
|
1947
|
-
__init3() {this.toolsByCallKey = new (0,
|
|
1957
|
+
__init3() {this.toolsByCallKey = new (0, _chunkOBBWQW6Kjs.LRUCache)({
|
|
1948
1958
|
max: MAX_EVE_CACHE_ENTRIES
|
|
1949
1959
|
})}
|
|
1950
|
-
__init4() {this.turnsByKey = new (0,
|
|
1960
|
+
__init4() {this.turnsByKey = new (0, _chunkOBBWQW6Kjs.LRUCache)({
|
|
1951
1961
|
max: MAX_EVE_CACHE_ENTRIES
|
|
1952
1962
|
})}
|
|
1953
1963
|
async startEveSpan(args) {
|
|
@@ -1958,7 +1968,7 @@ var EveBridge = (_class = class {
|
|
|
1958
1968
|
if (reference) {
|
|
1959
1969
|
return new ResumedEveSpan(reference);
|
|
1960
1970
|
}
|
|
1961
|
-
const startTime = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _81 => _81.startTime]), () => (
|
|
1971
|
+
const startTime = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _81 => _81.startTime]), () => ( _chunkOBBWQW6Kjs.getCurrentUnixTimestamp.call(void 0, )));
|
|
1962
1972
|
const parentSpanIds = _optionalChain([args, 'optionalAccess', _82 => _82.parentSpanIds]);
|
|
1963
1973
|
const startEvent = {
|
|
1964
1974
|
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -1970,12 +1980,12 @@ var EveBridge = (_class = class {
|
|
|
1970
1980
|
},
|
|
1971
1981
|
span_parents: parentSpanIds ? "spanId" in parentSpanIds ? [parentSpanIds.spanId] : parentSpanIds.parentSpanIds : []
|
|
1972
1982
|
};
|
|
1973
|
-
const span =
|
|
1974
|
-
|
|
1975
|
-
() =>
|
|
1976
|
-
|
|
1983
|
+
const span = _chunkOBBWQW6Kjs.withCurrent.call(void 0,
|
|
1984
|
+
_chunkOBBWQW6Kjs.NOOP_SPAN,
|
|
1985
|
+
() => _chunkOBBWQW6Kjs._internalStartSpanWithInitialMerge.call(void 0,
|
|
1986
|
+
_chunkBBE7SNRVjs.withSpanInstrumentationName.call(void 0,
|
|
1977
1987
|
{ ...args, startTime },
|
|
1978
|
-
|
|
1988
|
+
_chunkBBE7SNRVjs.INSTRUMENTATION_NAMES.EVE
|
|
1979
1989
|
)
|
|
1980
1990
|
)
|
|
1981
1991
|
);
|
|
@@ -2003,7 +2013,7 @@ var EveBridge = (_class = class {
|
|
|
2003
2013
|
};
|
|
2004
2014
|
});
|
|
2005
2015
|
} catch (error) {
|
|
2006
|
-
|
|
2016
|
+
_chunkOBBWQW6Kjs.debugLogger.warn("Error exporting Eve span for resumption:", error);
|
|
2007
2017
|
}
|
|
2008
2018
|
return span;
|
|
2009
2019
|
}
|
|
@@ -2090,7 +2100,7 @@ var EveBridge = (_class = class {
|
|
|
2090
2100
|
}
|
|
2091
2101
|
}
|
|
2092
2102
|
} catch (error) {
|
|
2093
|
-
|
|
2103
|
+
_chunkOBBWQW6Kjs.debugLogger.warn("Error in Eve hook instrumentation:", error);
|
|
2094
2104
|
}
|
|
2095
2105
|
};
|
|
2096
2106
|
const sessionId = event.type === "session.failed" ? event.data.sessionId || sessionIdFromContext(ctx) : sessionIdFromContext(ctx);
|
|
@@ -2318,7 +2328,7 @@ var EveBridge = (_class = class {
|
|
|
2318
2328
|
return;
|
|
2319
2329
|
}
|
|
2320
2330
|
const existingMessage = eveOutputMessage(step.output);
|
|
2321
|
-
const existingToolCalls =
|
|
2331
|
+
const existingToolCalls = _chunkOBBWQW6Kjs.isObject.call(void 0, existingMessage) ? existingMessage.tool_calls : void 0;
|
|
2322
2332
|
step.output = mergeEveReasoning(
|
|
2323
2333
|
[
|
|
2324
2334
|
{
|
|
@@ -2382,11 +2392,11 @@ var EveBridge = (_class = class {
|
|
|
2382
2392
|
return;
|
|
2383
2393
|
}
|
|
2384
2394
|
const toolCallsById = /* @__PURE__ */ new Map();
|
|
2385
|
-
if (Array.isArray(step.output) &&
|
|
2395
|
+
if (Array.isArray(step.output) && _chunkOBBWQW6Kjs.isObject.call(void 0, step.output[0])) {
|
|
2386
2396
|
const message = step.output[0]["message"];
|
|
2387
|
-
if (
|
|
2397
|
+
if (_chunkOBBWQW6Kjs.isObject.call(void 0, message) && Array.isArray(message["tool_calls"])) {
|
|
2388
2398
|
for (const toolCall of message["tool_calls"]) {
|
|
2389
|
-
if (
|
|
2399
|
+
if (_chunkOBBWQW6Kjs.isObject.call(void 0, toolCall) && typeof toolCall["id"] === "string") {
|
|
2390
2400
|
toolCallsById.set(toolCall["id"], toolCall);
|
|
2391
2401
|
}
|
|
2392
2402
|
}
|
|
@@ -2595,7 +2605,7 @@ var EveBridge = (_class = class {
|
|
|
2595
2605
|
};
|
|
2596
2606
|
step.metrics = { ...step.metrics, ...metrics };
|
|
2597
2607
|
const sessionId = sessionIdFromContext(ctx);
|
|
2598
|
-
if (Array.isArray(step.output) &&
|
|
2608
|
+
if (Array.isArray(step.output) && _chunkOBBWQW6Kjs.isObject.call(void 0, step.output[0])) {
|
|
2599
2609
|
const finishReason = step.output[0].finish_reason;
|
|
2600
2610
|
if (typeof finishReason !== "string") {
|
|
2601
2611
|
step.output[0].finish_reason = normalizedFinishReason(
|
|
@@ -2933,10 +2943,10 @@ var EveBridge = (_class = class {
|
|
|
2933
2943
|
return state;
|
|
2934
2944
|
}
|
|
2935
2945
|
async startTurnSpan(sessionId, event, ctx, metadata) {
|
|
2936
|
-
const session =
|
|
2937
|
-
const parent =
|
|
2938
|
-
const parentTurn =
|
|
2939
|
-
const parentLineage =
|
|
2946
|
+
const session = _chunkOBBWQW6Kjs.isObject.call(void 0, ctx) ? ctx["session"] : void 0;
|
|
2947
|
+
const parent = _chunkOBBWQW6Kjs.isObject.call(void 0, session) ? session["parent"] : void 0;
|
|
2948
|
+
const parentTurn = _chunkOBBWQW6Kjs.isObject.call(void 0, parent) ? parent["turn"] : void 0;
|
|
2949
|
+
const parentLineage = _chunkOBBWQW6Kjs.isObject.call(void 0, parent) && typeof parent["callId"] === "string" && typeof parent["sessionId"] === "string" && _chunkOBBWQW6Kjs.isObject.call(void 0, parentTurn) && typeof parentTurn["id"] === "string" ? {
|
|
2940
2950
|
callId: parent["callId"],
|
|
2941
2951
|
sessionId: parent["sessionId"],
|
|
2942
2952
|
turnId: parentTurn["id"]
|
|
@@ -3043,10 +3053,10 @@ var EveBridge = (_class = class {
|
|
|
3043
3053
|
}
|
|
3044
3054
|
async flushInstrumentation() {
|
|
3045
3055
|
try {
|
|
3046
|
-
await
|
|
3056
|
+
await _chunkOBBWQW6Kjs.flush.call(void 0, );
|
|
3047
3057
|
return true;
|
|
3048
3058
|
} catch (error) {
|
|
3049
|
-
|
|
3059
|
+
_chunkOBBWQW6Kjs.debugLogger.warn("Error in Eve flush instrumentation:", error);
|
|
3050
3060
|
return false;
|
|
3051
3061
|
}
|
|
3052
3062
|
}
|
|
@@ -3061,12 +3071,12 @@ function emptyEveTraceState() {
|
|
|
3061
3071
|
};
|
|
3062
3072
|
}
|
|
3063
3073
|
function normalizeEveTraceState(state) {
|
|
3064
|
-
if (!
|
|
3074
|
+
if (!_chunkOBBWQW6Kjs.isObject.call(void 0, state)) {
|
|
3065
3075
|
return emptyEveTraceState();
|
|
3066
3076
|
}
|
|
3067
|
-
const metadata =
|
|
3077
|
+
const metadata = _chunkOBBWQW6Kjs.isObject.call(void 0, state["metadata"]) ? state["metadata"] : {};
|
|
3068
3078
|
const spanReferences = Array.isArray(state["spanReferences"]) ? state["spanReferences"].flatMap((entry) => {
|
|
3069
|
-
if (!
|
|
3079
|
+
if (!_chunkOBBWQW6Kjs.isObject.call(void 0, entry)) {
|
|
3070
3080
|
return [];
|
|
3071
3081
|
}
|
|
3072
3082
|
const exported = entry["exported"];
|
|
@@ -3075,11 +3085,11 @@ function normalizeEveTraceState(state) {
|
|
|
3075
3085
|
const rowId = entry["rowId"];
|
|
3076
3086
|
const spanId = entry["spanId"];
|
|
3077
3087
|
const startEvent = entry["startEvent"];
|
|
3078
|
-
const startEventCreated =
|
|
3079
|
-
const startEventMetrics =
|
|
3080
|
-
const startEventSpanAttributes =
|
|
3081
|
-
const startEventSpanParents =
|
|
3082
|
-
const normalizedStartEvent = typeof startEventCreated === "string" &&
|
|
3088
|
+
const startEventCreated = _chunkOBBWQW6Kjs.isObject.call(void 0, startEvent) ? startEvent["created"] : void 0;
|
|
3089
|
+
const startEventMetrics = _chunkOBBWQW6Kjs.isObject.call(void 0, startEvent) ? startEvent["metrics"] : void 0;
|
|
3090
|
+
const startEventSpanAttributes = _chunkOBBWQW6Kjs.isObject.call(void 0, startEvent) ? startEvent["span_attributes"] : void 0;
|
|
3091
|
+
const startEventSpanParents = _chunkOBBWQW6Kjs.isObject.call(void 0, startEvent) ? startEvent["span_parents"] : void 0;
|
|
3092
|
+
const normalizedStartEvent = typeof startEventCreated === "string" && _chunkOBBWQW6Kjs.isObject.call(void 0, startEventMetrics) && typeof startEventMetrics["start"] === "number" && Number.isFinite(startEventMetrics["start"]) && _chunkOBBWQW6Kjs.isObject.call(void 0, startEventSpanAttributes) && Array.isArray(startEventSpanParents) && startEventSpanParents.every(
|
|
3083
3093
|
(parent) => typeof parent === "string"
|
|
3084
3094
|
) ? {
|
|
3085
3095
|
created: startEventCreated,
|
|
@@ -3099,7 +3109,7 @@ function normalizeEveTraceState(state) {
|
|
|
3099
3109
|
] : [];
|
|
3100
3110
|
}).slice(-MAX_STORED_SPAN_REFERENCES) : [];
|
|
3101
3111
|
const llmInputs = Array.isArray(state["llmInputs"]) ? state["llmInputs"].flatMap((entry) => {
|
|
3102
|
-
if (!
|
|
3112
|
+
if (!_chunkOBBWQW6Kjs.isObject.call(void 0, entry)) {
|
|
3103
3113
|
return [];
|
|
3104
3114
|
}
|
|
3105
3115
|
const key = entry["key"];
|
|
@@ -3107,7 +3117,7 @@ function normalizeEveTraceState(state) {
|
|
|
3107
3117
|
return typeof key === "string" && isCapturedModelInput(input) ? [{ input, key }] : [];
|
|
3108
3118
|
}).slice(-MAX_STORED_LLM_INPUTS) : [];
|
|
3109
3119
|
const reasoningBlocks = Array.isArray(state["reasoningBlocks"]) ? state["reasoningBlocks"].flatMap((entry) => {
|
|
3110
|
-
if (!
|
|
3120
|
+
if (!_chunkOBBWQW6Kjs.isObject.call(void 0, entry)) {
|
|
3111
3121
|
return [];
|
|
3112
3122
|
}
|
|
3113
3123
|
const content = entry["content"];
|
|
@@ -3122,7 +3132,7 @@ function normalizeEveTraceState(state) {
|
|
|
3122
3132
|
] : [];
|
|
3123
3133
|
}).slice(-MAX_STORED_REASONING_BLOCKS) : [];
|
|
3124
3134
|
const stepStarts = Array.isArray(state["stepStarts"]) ? state["stepStarts"].flatMap((entry) => {
|
|
3125
|
-
if (!
|
|
3135
|
+
if (!_chunkOBBWQW6Kjs.isObject.call(void 0, entry)) {
|
|
3126
3136
|
return [];
|
|
3127
3137
|
}
|
|
3128
3138
|
const ordinal = entry["ordinal"];
|
|
@@ -3199,14 +3209,14 @@ function clearStoredEveReasoning(state, sessionId, turnId, stepIndex) {
|
|
|
3199
3209
|
});
|
|
3200
3210
|
}
|
|
3201
3211
|
function eveOutputMessage(output) {
|
|
3202
|
-
return Array.isArray(output) &&
|
|
3212
|
+
return Array.isArray(output) && _chunkOBBWQW6Kjs.isObject.call(void 0, output[0]) ? output[0]["message"] : void 0;
|
|
3203
3213
|
}
|
|
3204
3214
|
function mergeEveReasoning(output, reasoning) {
|
|
3205
3215
|
if (reasoning.length === 0) {
|
|
3206
3216
|
return output;
|
|
3207
3217
|
}
|
|
3208
|
-
const choice = Array.isArray(output) &&
|
|
3209
|
-
const message =
|
|
3218
|
+
const choice = Array.isArray(output) && _chunkOBBWQW6Kjs.isObject.call(void 0, output[0]) ? output[0] : {};
|
|
3219
|
+
const message = _chunkOBBWQW6Kjs.isObject.call(void 0, choice["message"]) ? choice["message"] : {};
|
|
3210
3220
|
return [
|
|
3211
3221
|
{
|
|
3212
3222
|
...choice,
|
|
@@ -3260,7 +3270,7 @@ function consumeCapturedEveModelInput(state, sessionId, turnId, stepIndex) {
|
|
|
3260
3270
|
});
|
|
3261
3271
|
return input;
|
|
3262
3272
|
} catch (error) {
|
|
3263
|
-
|
|
3273
|
+
_chunkOBBWQW6Kjs.debugLogger.warn("Error in Eve LLM input consumption:", error);
|
|
3264
3274
|
return void 0;
|
|
3265
3275
|
}
|
|
3266
3276
|
}
|
|
@@ -3398,14 +3408,14 @@ function capturedEveModelContentPart(part) {
|
|
|
3398
3408
|
}
|
|
3399
3409
|
function isCapturedModelInput(input) {
|
|
3400
3410
|
return Array.isArray(input) && input.every(
|
|
3401
|
-
(message) =>
|
|
3411
|
+
(message) => _chunkOBBWQW6Kjs.isObject.call(void 0, message) && (message["role"] === "system" || message["role"] === "user" || message["role"] === "assistant" || message["role"] === "tool") && (typeof message["content"] === "string" || Array.isArray(message["content"]) && message["content"].every(_chunkOBBWQW6Kjs.isObject))
|
|
3402
3412
|
);
|
|
3403
3413
|
}
|
|
3404
3414
|
function llmInputKey(sessionId, turnId, stepIndex) {
|
|
3405
3415
|
return `${sessionId}\0${turnId}\0${stepIndex}`;
|
|
3406
3416
|
}
|
|
3407
3417
|
function modelMetadataFromRuntime(runtime) {
|
|
3408
|
-
if (!
|
|
3418
|
+
if (!_chunkOBBWQW6Kjs.isObject.call(void 0, runtime)) {
|
|
3409
3419
|
return {};
|
|
3410
3420
|
}
|
|
3411
3421
|
const modelId = runtime["modelId"];
|
|
@@ -3428,11 +3438,11 @@ function modelMetadataFromModelId(modelId) {
|
|
|
3428
3438
|
};
|
|
3429
3439
|
}
|
|
3430
3440
|
function sessionIdFromContext(ctx) {
|
|
3431
|
-
if (!
|
|
3441
|
+
if (!_chunkOBBWQW6Kjs.isObject.call(void 0, ctx)) {
|
|
3432
3442
|
return void 0;
|
|
3433
3443
|
}
|
|
3434
3444
|
const session = ctx["session"];
|
|
3435
|
-
if (!
|
|
3445
|
+
if (!_chunkOBBWQW6Kjs.isObject.call(void 0, session)) {
|
|
3436
3446
|
return void 0;
|
|
3437
3447
|
}
|
|
3438
3448
|
const id = session["id"];
|
|
@@ -3443,19 +3453,19 @@ function toolMetadataFromTurn(turn) {
|
|
|
3443
3453
|
return metadata;
|
|
3444
3454
|
}
|
|
3445
3455
|
function isToolCallAction(action) {
|
|
3446
|
-
return
|
|
3456
|
+
return _chunkOBBWQW6Kjs.isObject.call(void 0, action) && action["kind"] === "tool-call" && typeof action["callId"] === "string" && typeof action["toolName"] === "string" && _chunkOBBWQW6Kjs.isObject.call(void 0, action["input"]);
|
|
3447
3457
|
}
|
|
3448
3458
|
function isLocalSubagentCallAction(action) {
|
|
3449
|
-
return
|
|
3459
|
+
return _chunkOBBWQW6Kjs.isObject.call(void 0, action) && action["kind"] === "subagent-call" && typeof action["callId"] === "string" && _chunkOBBWQW6Kjs.isObject.call(void 0, action["input"]);
|
|
3450
3460
|
}
|
|
3451
3461
|
function isTraceableActionRequest(action) {
|
|
3452
3462
|
return isToolCallAction(action) || isLocalSubagentCallAction(action);
|
|
3453
3463
|
}
|
|
3454
3464
|
function isToolResult(result) {
|
|
3455
|
-
return
|
|
3465
|
+
return _chunkOBBWQW6Kjs.isObject.call(void 0, result) && result["kind"] === "tool-result" && typeof result["callId"] === "string" && typeof result["toolName"] === "string";
|
|
3456
3466
|
}
|
|
3457
3467
|
function isSubagentResult(result) {
|
|
3458
|
-
return
|
|
3468
|
+
return _chunkOBBWQW6Kjs.isObject.call(void 0, result) && result["kind"] === "subagent-result" && typeof result["callId"] === "string" && typeof result["subagentName"] === "string";
|
|
3459
3469
|
}
|
|
3460
3470
|
function normalizedFinishReason(finishReason) {
|
|
3461
3471
|
switch (finishReason) {
|
|
@@ -3573,7 +3583,7 @@ function betaSessionEventsProxy(events) {
|
|
|
3573
3583
|
if (prop === "stream") {
|
|
3574
3584
|
return new TypedApplyProxy(target.stream, {
|
|
3575
3585
|
apply(stream, thisArg, argArray) {
|
|
3576
|
-
return
|
|
3586
|
+
return _chunkBBE7SNRVjs.anthropicChannels.betaSessionsEventsStream.tracePromise(
|
|
3577
3587
|
() => Reflect.apply(stream, thisArg, argArray),
|
|
3578
3588
|
{ arguments: argArray }
|
|
3579
3589
|
);
|
|
@@ -3600,7 +3610,7 @@ function betaSessionThreadEventsProxy(events) {
|
|
|
3600
3610
|
if (prop === "stream") {
|
|
3601
3611
|
return new TypedApplyProxy(target.stream, {
|
|
3602
3612
|
apply(stream, thisArg, argArray) {
|
|
3603
|
-
return
|
|
3613
|
+
return _chunkBBE7SNRVjs.anthropicChannels.betaSessionsThreadsEventsStream.tracePromise(
|
|
3604
3614
|
() => Reflect.apply(stream, thisArg, argArray),
|
|
3605
3615
|
{ arguments: argArray }
|
|
3606
3616
|
);
|
|
@@ -3615,7 +3625,7 @@ function messagesProxy(messages) {
|
|
|
3615
3625
|
return new Proxy(messages, {
|
|
3616
3626
|
get(target, prop, receiver) {
|
|
3617
3627
|
if (prop === "create") {
|
|
3618
|
-
return createProxy(target.create,
|
|
3628
|
+
return createProxy(target.create, _chunkBBE7SNRVjs.anthropicChannels.messagesCreate);
|
|
3619
3629
|
}
|
|
3620
3630
|
return Reflect.get(target, prop, receiver);
|
|
3621
3631
|
}
|
|
@@ -3625,7 +3635,7 @@ function betaMessagesProxy(messages, anthropic) {
|
|
|
3625
3635
|
return new Proxy(messages, {
|
|
3626
3636
|
get(target, prop, receiver) {
|
|
3627
3637
|
if (prop === "create") {
|
|
3628
|
-
return createProxy(target.create,
|
|
3638
|
+
return createProxy(target.create, _chunkBBE7SNRVjs.anthropicChannels.betaMessagesCreate);
|
|
3629
3639
|
}
|
|
3630
3640
|
if (prop === "toolRunner") {
|
|
3631
3641
|
if (typeof target.toolRunner !== "function") {
|
|
@@ -3634,7 +3644,7 @@ function betaMessagesProxy(messages, anthropic) {
|
|
|
3634
3644
|
return toolRunnerProxy(
|
|
3635
3645
|
target.toolRunner,
|
|
3636
3646
|
anthropic,
|
|
3637
|
-
|
|
3647
|
+
_chunkBBE7SNRVjs.anthropicChannels.betaMessagesToolRunner
|
|
3638
3648
|
);
|
|
3639
3649
|
}
|
|
3640
3650
|
return Reflect.get(target, prop, receiver);
|
|
@@ -3691,11 +3701,11 @@ function wrapClaudeAgentQuery(queryFn, defaultThis) {
|
|
|
3691
3701
|
...params,
|
|
3692
3702
|
options: {
|
|
3693
3703
|
..._nullishCoalesce(params.options, () => ( {})),
|
|
3694
|
-
[
|
|
3704
|
+
[_chunkOBBWQW6Kjs.CLAUDE_AGENT_SDK_SKIP_LOCAL_TOOL_HOOKS_OPTION]: true
|
|
3695
3705
|
}
|
|
3696
3706
|
};
|
|
3697
3707
|
const invocationTarget = thisArg === proxy || thisArg === void 0 ? _nullishCoalesce(defaultThis, () => ( thisArg)) : thisArg;
|
|
3698
|
-
return
|
|
3708
|
+
return _chunkBBE7SNRVjs.claudeAgentSDKChannels.query.traceSync(
|
|
3699
3709
|
() => Reflect.apply(target, invocationTarget, [wrappedParams]),
|
|
3700
3710
|
// The channel carries no extra context fields, but the generated
|
|
3701
3711
|
// StartOf<> type for Record<string, never> is overly strict here.
|
|
@@ -3723,7 +3733,7 @@ function wrapClaudeAgentTool(toolFn, localToolMetadataByTool, defaultThis) {
|
|
|
3723
3733
|
}
|
|
3724
3734
|
const localToolMetadata = { toolName };
|
|
3725
3735
|
const originalHandler = wrappedArgs[handlerIndex];
|
|
3726
|
-
wrappedArgs[handlerIndex] =
|
|
3736
|
+
wrappedArgs[handlerIndex] = _chunkOBBWQW6Kjs.wrapLocalClaudeToolHandler.call(void 0,
|
|
3727
3737
|
originalHandler,
|
|
3728
3738
|
() => localToolMetadata
|
|
3729
3739
|
);
|
|
@@ -3830,7 +3840,7 @@ function patchThinkClass(Think) {
|
|
|
3830
3840
|
...descriptor,
|
|
3831
3841
|
value: function wrappedCloudflareThinkRunInferenceLoop(input) {
|
|
3832
3842
|
const args = [input];
|
|
3833
|
-
return
|
|
3843
|
+
return _chunkBBE7SNRVjs.cloudflareThinkChannels.runInferenceLoop.tracePromise(
|
|
3834
3844
|
() => Reflect.apply(original, this, args),
|
|
3835
3845
|
{
|
|
3836
3846
|
arguments: args,
|
|
@@ -3952,7 +3962,7 @@ function wrapCodexThread(thread) {
|
|
|
3952
3962
|
if (prop === "run" && typeof value === "function") {
|
|
3953
3963
|
return function(input, turnOptions) {
|
|
3954
3964
|
const args = [input, turnOptions];
|
|
3955
|
-
return
|
|
3965
|
+
return _chunkBBE7SNRVjs.openAICodexChannels.run.tracePromise(
|
|
3956
3966
|
() => Reflect.apply(value, target, args),
|
|
3957
3967
|
{
|
|
3958
3968
|
arguments: args,
|
|
@@ -3965,7 +3975,7 @@ function wrapCodexThread(thread) {
|
|
|
3965
3975
|
if (prop === "runStreamed" && typeof value === "function") {
|
|
3966
3976
|
return function(input, turnOptions) {
|
|
3967
3977
|
const args = [input, turnOptions];
|
|
3968
|
-
return
|
|
3978
|
+
return _chunkBBE7SNRVjs.openAICodexChannels.runStreamed.tracePromise(
|
|
3969
3979
|
() => Reflect.apply(value, target, args),
|
|
3970
3980
|
{
|
|
3971
3981
|
arguments: args,
|
|
@@ -4033,7 +4043,7 @@ function wrapCursorAgentClass(Agent) {
|
|
|
4033
4043
|
if (prop === "create" && typeof value === "function") {
|
|
4034
4044
|
const wrapped = async function(options) {
|
|
4035
4045
|
const args = [options];
|
|
4036
|
-
return
|
|
4046
|
+
return _chunkBBE7SNRVjs.cursorSDKChannels.create.tracePromise(
|
|
4037
4047
|
async () => wrapCursorAgent(await Reflect.apply(value, target, args)),
|
|
4038
4048
|
{ arguments: args }
|
|
4039
4049
|
);
|
|
@@ -4044,7 +4054,7 @@ function wrapCursorAgentClass(Agent) {
|
|
|
4044
4054
|
if (prop === "resume" && typeof value === "function") {
|
|
4045
4055
|
const wrapped = async function(agentId, options) {
|
|
4046
4056
|
const args = [agentId, options];
|
|
4047
|
-
return
|
|
4057
|
+
return _chunkBBE7SNRVjs.cursorSDKChannels.resume.tracePromise(
|
|
4048
4058
|
async () => wrapCursorAgent(await Reflect.apply(value, target, args)),
|
|
4049
4059
|
{ arguments: args }
|
|
4050
4060
|
);
|
|
@@ -4055,7 +4065,7 @@ function wrapCursorAgentClass(Agent) {
|
|
|
4055
4065
|
if (prop === "prompt" && typeof value === "function") {
|
|
4056
4066
|
const wrapped = async function(message, options) {
|
|
4057
4067
|
const args = [message, options];
|
|
4058
|
-
return
|
|
4068
|
+
return _chunkBBE7SNRVjs.cursorSDKChannels.prompt.tracePromise(
|
|
4059
4069
|
() => Reflect.apply(value, target, args),
|
|
4060
4070
|
{ arguments: args }
|
|
4061
4071
|
);
|
|
@@ -4088,7 +4098,7 @@ function wrapCursorAgent(agent) {
|
|
|
4088
4098
|
if (prop === "send" && typeof value === "function") {
|
|
4089
4099
|
return function(message, options) {
|
|
4090
4100
|
const args = [message, options];
|
|
4091
|
-
return
|
|
4101
|
+
return _chunkBBE7SNRVjs.cursorSDKChannels.send.tracePromise(
|
|
4092
4102
|
() => Reflect.apply(value, target, args),
|
|
4093
4103
|
{
|
|
4094
4104
|
agent: target,
|
|
@@ -4138,7 +4148,7 @@ function patchAgentSessionClass(AgentSession) {
|
|
|
4138
4148
|
...descriptor,
|
|
4139
4149
|
value: function wrappedPiCodingAgentPrompt(text, options) {
|
|
4140
4150
|
const args = [text, options];
|
|
4141
|
-
return
|
|
4151
|
+
return _chunkBBE7SNRVjs.piCodingAgentChannels.prompt.invoke(originalPrompt, this, args, {
|
|
4142
4152
|
session: this
|
|
4143
4153
|
});
|
|
4144
4154
|
}
|
|
@@ -4184,7 +4194,7 @@ function wrapCloudflareAgent(Agent) {
|
|
|
4184
4194
|
if (ownValue(options, "detached")) {
|
|
4185
4195
|
return Reflect.apply(originalRunAgentTool, this, args);
|
|
4186
4196
|
}
|
|
4187
|
-
return
|
|
4197
|
+
return _chunkBBE7SNRVjs.cloudflareAgentsChannels.runAgentTool.tracePromise(
|
|
4188
4198
|
() => Reflect.apply(originalRunAgentTool, this, args),
|
|
4189
4199
|
{ arguments: args, self: this }
|
|
4190
4200
|
);
|
|
@@ -4208,7 +4218,7 @@ function isObjectLike(value) {
|
|
|
4208
4218
|
return typeof value === "object" && value !== null || typeof value === "function";
|
|
4209
4219
|
}
|
|
4210
4220
|
function warnUnsupportedAgent() {
|
|
4211
|
-
|
|
4221
|
+
_chunkOBBWQW6Kjs.debugLogger.warn("Unsupported Cloudflare Agents Agent class. Not wrapping.");
|
|
4212
4222
|
}
|
|
4213
4223
|
|
|
4214
4224
|
// src/wrappers/strands-agent-sdk.ts
|
|
@@ -4314,7 +4324,7 @@ function wrapAgentInstance(agent) {
|
|
|
4314
4324
|
if (prop === "stream" && typeof value === "function") {
|
|
4315
4325
|
return function(args, options) {
|
|
4316
4326
|
const callArgs = [args, options];
|
|
4317
|
-
return
|
|
4327
|
+
return _chunkBBE7SNRVjs.strandsAgentSDKChannels.agentStream.traceSync(
|
|
4318
4328
|
() => Reflect.apply(value, target, callArgs),
|
|
4319
4329
|
{
|
|
4320
4330
|
agent: proxy,
|
|
@@ -4350,7 +4360,7 @@ function wrapMultiAgentInstance(orchestrator, kind) {
|
|
|
4350
4360
|
if (prop === "stream" && typeof value === "function") {
|
|
4351
4361
|
return function(input, options) {
|
|
4352
4362
|
const callArgs = [input, options];
|
|
4353
|
-
const channel = kind === "graph" ?
|
|
4363
|
+
const channel = kind === "graph" ? _chunkBBE7SNRVjs.strandsAgentSDKChannels.graphStream : _chunkBBE7SNRVjs.strandsAgentSDKChannels.swarmStream;
|
|
4354
4364
|
return channel.traceSync(
|
|
4355
4365
|
() => Reflect.apply(value, target, callArgs),
|
|
4356
4366
|
{
|
|
@@ -4390,11 +4400,11 @@ function wrapCloudflareAIChat(module) {
|
|
|
4390
4400
|
try {
|
|
4391
4401
|
AIChatAgent = Reflect.get(candidate, "AIChatAgent");
|
|
4392
4402
|
} catch (error) {
|
|
4393
|
-
|
|
4403
|
+
_chunkOBBWQW6Kjs.debugLogger.debug("Failed to inspect @cloudflare/ai-chat module:", error);
|
|
4394
4404
|
return module;
|
|
4395
4405
|
}
|
|
4396
4406
|
if (typeof AIChatAgent !== "function") {
|
|
4397
|
-
|
|
4407
|
+
_chunkOBBWQW6Kjs.debugLogger.warn(
|
|
4398
4408
|
"Unsupported @cloudflare/ai-chat module. AIChatAgent was not found; not wrapping."
|
|
4399
4409
|
);
|
|
4400
4410
|
return module;
|
|
@@ -4428,7 +4438,7 @@ function wrapAIChatAgentClass(AgentClass) {
|
|
|
4428
4438
|
args,
|
|
4429
4439
|
newTarget
|
|
4430
4440
|
);
|
|
4431
|
-
return
|
|
4441
|
+
return _chunkOBBWQW6Kjs.instrumentCloudflareAIChatAgent.call(void 0, instance);
|
|
4432
4442
|
}
|
|
4433
4443
|
});
|
|
4434
4444
|
wrappedClasses.set(AgentClass, wrapped);
|
|
@@ -4500,7 +4510,7 @@ function wrapGoogleGenAIInstance(instance) {
|
|
|
4500
4510
|
}
|
|
4501
4511
|
if (prop === "interactions") {
|
|
4502
4512
|
const interactions = Reflect.get(target, prop, receiver);
|
|
4503
|
-
if (!
|
|
4513
|
+
if (!_chunkOBBWQW6Kjs.isObject.call(void 0, interactions) || typeof interactions.create !== "function") {
|
|
4504
4514
|
return interactions;
|
|
4505
4515
|
}
|
|
4506
4516
|
if (interactions !== originalInteractions) {
|
|
@@ -4514,7 +4524,7 @@ function wrapGoogleGenAIInstance(instance) {
|
|
|
4514
4524
|
});
|
|
4515
4525
|
}
|
|
4516
4526
|
function patchGoogleGenAIChats(instance, wrappedModels) {
|
|
4517
|
-
if (!
|
|
4527
|
+
if (!_chunkOBBWQW6Kjs.isObject.call(void 0, instance.chats) || !("modelsModule" in instance.chats)) {
|
|
4518
4528
|
return;
|
|
4519
4529
|
}
|
|
4520
4530
|
Reflect.set(instance.chats, "modelsModule", wrappedModels);
|
|
@@ -4547,7 +4557,7 @@ function wrapInteractions(interactions) {
|
|
|
4547
4557
|
}
|
|
4548
4558
|
function wrapGenerateContent(original) {
|
|
4549
4559
|
return function(params) {
|
|
4550
|
-
return
|
|
4560
|
+
return _chunkBBE7SNRVjs.googleGenAIChannels.generateContent.tracePromise(
|
|
4551
4561
|
() => original(params),
|
|
4552
4562
|
{ arguments: [params] }
|
|
4553
4563
|
);
|
|
@@ -4555,7 +4565,7 @@ function wrapGenerateContent(original) {
|
|
|
4555
4565
|
}
|
|
4556
4566
|
function wrapGenerateContentStream(original) {
|
|
4557
4567
|
return function(params) {
|
|
4558
|
-
return
|
|
4568
|
+
return _chunkBBE7SNRVjs.googleGenAIChannels.generateContentStream.tracePromise(
|
|
4559
4569
|
() => original(params),
|
|
4560
4570
|
{ arguments: [params] }
|
|
4561
4571
|
);
|
|
@@ -4563,7 +4573,7 @@ function wrapGenerateContentStream(original) {
|
|
|
4563
4573
|
}
|
|
4564
4574
|
function wrapEmbedContent(original) {
|
|
4565
4575
|
return function(params) {
|
|
4566
|
-
return
|
|
4576
|
+
return _chunkBBE7SNRVjs.googleGenAIChannels.embedContent.tracePromise(
|
|
4567
4577
|
() => original(params),
|
|
4568
4578
|
{ arguments: [params] }
|
|
4569
4579
|
);
|
|
@@ -4575,7 +4585,7 @@ function wrapInteractionCreate(original) {
|
|
|
4575
4585
|
return options === void 0 ? original(params) : original(params, options);
|
|
4576
4586
|
}
|
|
4577
4587
|
const traceContext = options === void 0 ? { arguments: [params] } : { arguments: [params, options] };
|
|
4578
|
-
return
|
|
4588
|
+
return _chunkBBE7SNRVjs.googleGenAIChannels.interactionsCreate.tracePromise(
|
|
4579
4589
|
() => options === void 0 ? original(params) : original(params, options),
|
|
4580
4590
|
traceContext
|
|
4581
4591
|
);
|
|
@@ -4636,7 +4646,7 @@ function wrapRunnerInstance(runner) {
|
|
|
4636
4646
|
function wrapRunnerRunAsync(runner) {
|
|
4637
4647
|
const original = runner.runAsync.bind(runner);
|
|
4638
4648
|
return function(params) {
|
|
4639
|
-
return
|
|
4649
|
+
return _chunkBBE7SNRVjs.googleADKChannels.runnerRunAsync.traceSync(() => original(params), {
|
|
4640
4650
|
arguments: [params],
|
|
4641
4651
|
self: runner
|
|
4642
4652
|
});
|
|
@@ -4663,7 +4673,7 @@ function wrapAgentInstance2(agent) {
|
|
|
4663
4673
|
function wrapAgentRunAsync(agent) {
|
|
4664
4674
|
const original = agent.runAsync.bind(agent);
|
|
4665
4675
|
return function(parentContext) {
|
|
4666
|
-
return
|
|
4676
|
+
return _chunkBBE7SNRVjs.googleADKChannels.agentRunAsync.traceSync(
|
|
4667
4677
|
() => original(parentContext),
|
|
4668
4678
|
{ arguments: [parentContext], self: agent }
|
|
4669
4679
|
);
|
|
@@ -4690,7 +4700,7 @@ function wrapToolInstance(tool) {
|
|
|
4690
4700
|
function wrapToolRunAsync(tool) {
|
|
4691
4701
|
const original = tool.runAsync.bind(tool);
|
|
4692
4702
|
return function(req) {
|
|
4693
|
-
return
|
|
4703
|
+
return _chunkBBE7SNRVjs.googleADKChannels.toolRunAsync.tracePromise(() => original(req), {
|
|
4694
4704
|
arguments: [req],
|
|
4695
4705
|
self: tool
|
|
4696
4706
|
});
|
|
@@ -4837,27 +4847,27 @@ function patchGenkitRegistryConstructor(registry) {
|
|
|
4837
4847
|
}
|
|
4838
4848
|
}
|
|
4839
4849
|
function wrapGenerate(generate) {
|
|
4840
|
-
return (input) =>
|
|
4850
|
+
return (input) => _chunkBBE7SNRVjs.genkitChannels.generate.tracePromise(() => generate(input), {
|
|
4841
4851
|
arguments: [input]
|
|
4842
4852
|
});
|
|
4843
4853
|
}
|
|
4844
4854
|
function wrapGenerateStream(generateStream) {
|
|
4845
|
-
return (input) =>
|
|
4855
|
+
return (input) => _chunkBBE7SNRVjs.genkitChannels.generateStream.traceSync(() => generateStream(input), {
|
|
4846
4856
|
arguments: [input]
|
|
4847
4857
|
});
|
|
4848
4858
|
}
|
|
4849
4859
|
function wrapEmbed2(embed) {
|
|
4850
|
-
return (params) =>
|
|
4860
|
+
return (params) => _chunkBBE7SNRVjs.genkitChannels.embed.tracePromise(() => embed(params), {
|
|
4851
4861
|
arguments: [params]
|
|
4852
4862
|
});
|
|
4853
4863
|
}
|
|
4854
4864
|
function wrapEmbedMany2(embedMany) {
|
|
4855
|
-
return (params) =>
|
|
4865
|
+
return (params) => _chunkBBE7SNRVjs.genkitChannels.embedMany.tracePromise(() => embedMany(params), {
|
|
4856
4866
|
arguments: [params]
|
|
4857
4867
|
});
|
|
4858
4868
|
}
|
|
4859
4869
|
function wrapRun(run) {
|
|
4860
|
-
return (name, inputOrFn, maybeFn) =>
|
|
4870
|
+
return (name, inputOrFn, maybeFn) => _chunkBBE7SNRVjs.genkitChannels.actionRun.tracePromise(() => run(name, inputOrFn, maybeFn), {
|
|
4861
4871
|
arguments: [name, inputOrFn, maybeFn]
|
|
4862
4872
|
});
|
|
4863
4873
|
}
|
|
@@ -4896,13 +4906,13 @@ function isGenkitAction(value) {
|
|
|
4896
4906
|
return typeof value === "function" && "__action" in value;
|
|
4897
4907
|
}
|
|
4898
4908
|
function traceActionRun(action, run) {
|
|
4899
|
-
return (input, options) =>
|
|
4909
|
+
return (input, options) => _chunkBBE7SNRVjs.genkitChannels.actionRun.tracePromise(() => run(input, options), {
|
|
4900
4910
|
arguments: [input, options],
|
|
4901
4911
|
self: action
|
|
4902
4912
|
});
|
|
4903
4913
|
}
|
|
4904
4914
|
function traceActionStream(action, stream) {
|
|
4905
|
-
return (input, options) =>
|
|
4915
|
+
return (input, options) => _chunkBBE7SNRVjs.genkitChannels.actionStream.traceSync(() => stream(input, options), {
|
|
4906
4916
|
arguments: [input, options],
|
|
4907
4917
|
self: action
|
|
4908
4918
|
});
|
|
@@ -4948,10 +4958,10 @@ function isHuggingFaceConstructorKey(value) {
|
|
|
4948
4958
|
return HUGGINGFACE_CONSTRUCTOR_KEY_SET.has(value);
|
|
4949
4959
|
}
|
|
4950
4960
|
function hasFunction2(value, methodName) {
|
|
4951
|
-
return
|
|
4961
|
+
return _chunkOBBWQW6Kjs.isObject.call(void 0, value) && methodName in value && typeof value[methodName] === "function";
|
|
4952
4962
|
}
|
|
4953
4963
|
function isSupportedHuggingFaceModule(value) {
|
|
4954
|
-
if (!
|
|
4964
|
+
if (!_chunkOBBWQW6Kjs.isObject.call(void 0, value)) {
|
|
4955
4965
|
return false;
|
|
4956
4966
|
}
|
|
4957
4967
|
return HUGGINGFACE_CONSTRUCTOR_KEYS.some(
|
|
@@ -5059,14 +5069,14 @@ function wrapChatCompletion2(original, endpointUrl) {
|
|
|
5059
5069
|
const context = {
|
|
5060
5070
|
arguments: [traceParams]
|
|
5061
5071
|
};
|
|
5062
|
-
return
|
|
5072
|
+
return _chunkBBE7SNRVjs.huggingFaceChannels.chatCompletion.tracePromise(
|
|
5063
5073
|
() => original(params, options),
|
|
5064
5074
|
context
|
|
5065
5075
|
);
|
|
5066
5076
|
};
|
|
5067
5077
|
}
|
|
5068
5078
|
function wrapChatCompletionStream(original, endpointUrl) {
|
|
5069
|
-
return (params, options) =>
|
|
5079
|
+
return (params, options) => _chunkBBE7SNRVjs.huggingFaceChannels.chatCompletionStream.traceSync(
|
|
5070
5080
|
() => original(params, options),
|
|
5071
5081
|
{
|
|
5072
5082
|
arguments: [withEndpointUrl(params, endpointUrl)]
|
|
@@ -5079,14 +5089,14 @@ function wrapTextGeneration(original, endpointUrl) {
|
|
|
5079
5089
|
const context = {
|
|
5080
5090
|
arguments: [traceParams]
|
|
5081
5091
|
};
|
|
5082
|
-
return
|
|
5092
|
+
return _chunkBBE7SNRVjs.huggingFaceChannels.textGeneration.tracePromise(
|
|
5083
5093
|
() => original(params, options),
|
|
5084
5094
|
context
|
|
5085
5095
|
);
|
|
5086
5096
|
};
|
|
5087
5097
|
}
|
|
5088
5098
|
function wrapTextGenerationStream(original, endpointUrl) {
|
|
5089
|
-
return (params, options) =>
|
|
5099
|
+
return (params, options) => _chunkBBE7SNRVjs.huggingFaceChannels.textGenerationStream.traceSync(
|
|
5090
5100
|
() => original(params, options),
|
|
5091
5101
|
{
|
|
5092
5102
|
arguments: [withEndpointUrl(params, endpointUrl)]
|
|
@@ -5099,7 +5109,7 @@ function wrapFeatureExtraction(original, endpointUrl) {
|
|
|
5099
5109
|
const context = {
|
|
5100
5110
|
arguments: [traceParams]
|
|
5101
5111
|
};
|
|
5102
|
-
return
|
|
5112
|
+
return _chunkBBE7SNRVjs.huggingFaceChannels.featureExtraction.tracePromise(
|
|
5103
5113
|
() => original(params, options),
|
|
5104
5114
|
context
|
|
5105
5115
|
);
|
|
@@ -5117,7 +5127,7 @@ var PIPELINE_CONSTRUCTOR_KEYS = /* @__PURE__ */ new Set([
|
|
|
5117
5127
|
var wrappedValues = /* @__PURE__ */ new WeakMap();
|
|
5118
5128
|
function wrapHuggingFaceTransformers(transformers) {
|
|
5119
5129
|
const pipelineTask = _optionalChain([transformers, 'optionalAccess', _124 => _124.task]);
|
|
5120
|
-
if (typeof transformers === "function" &&
|
|
5130
|
+
if (typeof transformers === "function" && _chunkBBE7SNRVjs.isSupportedHuggingFaceTransformersTask.call(void 0, pipelineTask)) {
|
|
5121
5131
|
return wrapPipeline(transformers);
|
|
5122
5132
|
}
|
|
5123
5133
|
if (!isSupportedModule(transformers)) {
|
|
@@ -5169,8 +5179,8 @@ function wrapPipelineFactory(factory) {
|
|
|
5169
5179
|
const context = {
|
|
5170
5180
|
arguments: args
|
|
5171
5181
|
};
|
|
5172
|
-
return
|
|
5173
|
-
if (
|
|
5182
|
+
return _chunkBBE7SNRVjs.huggingFaceTransformersChannels.pipeline.tracePromise(() => Reflect.apply(factory, this, args), context).then((pipeline) => {
|
|
5183
|
+
if (_chunkBBE7SNRVjs.isSupportedHuggingFaceTransformersTask.call(void 0, _nullishCoalesce(pipeline.task, () => ( task)))) {
|
|
5174
5184
|
return wrapPipeline(pipeline);
|
|
5175
5185
|
}
|
|
5176
5186
|
return pipeline;
|
|
@@ -5188,7 +5198,7 @@ function wrapPipelineConstructor(constructor) {
|
|
|
5188
5198
|
const proxy = new Proxy(constructor, {
|
|
5189
5199
|
construct(target, args, newTarget) {
|
|
5190
5200
|
const pipeline = Reflect.construct(target, args, newTarget);
|
|
5191
|
-
if (
|
|
5201
|
+
if (_chunkBBE7SNRVjs.isSupportedHuggingFaceTransformersTask.call(void 0, pipeline.task)) {
|
|
5192
5202
|
return wrapPipeline(pipeline);
|
|
5193
5203
|
}
|
|
5194
5204
|
return pipeline;
|
|
@@ -5209,7 +5219,7 @@ function wrapPipeline(pipeline) {
|
|
|
5209
5219
|
arguments: args,
|
|
5210
5220
|
self: target
|
|
5211
5221
|
};
|
|
5212
|
-
return
|
|
5222
|
+
return _chunkBBE7SNRVjs.huggingFaceTransformersChannels.pipelineCall.tracePromise(
|
|
5213
5223
|
() => Reflect.apply(target, thisArg, args),
|
|
5214
5224
|
context
|
|
5215
5225
|
);
|
|
@@ -5260,7 +5270,7 @@ function wrapCallModel(callModelFn, defaultThis) {
|
|
|
5260
5270
|
const request = cloneCallModelRequest(argArray[0]);
|
|
5261
5271
|
const options = argArray[1];
|
|
5262
5272
|
const invocationTarget = thisArg === void 0 ? _nullishCoalesce(defaultThis, () => ( thisArg)) : thisArg;
|
|
5263
|
-
return
|
|
5273
|
+
return _chunkBBE7SNRVjs.openRouterAgentChannels.callModel.traceSync(
|
|
5264
5274
|
() => Reflect.apply(target, invocationTarget, [request, options]),
|
|
5265
5275
|
{
|
|
5266
5276
|
arguments: [request]
|
|
@@ -5356,24 +5366,24 @@ function rerankProxy(rerank) {
|
|
|
5356
5366
|
});
|
|
5357
5367
|
}
|
|
5358
5368
|
function wrapChatSend(send) {
|
|
5359
|
-
return (request, options) =>
|
|
5369
|
+
return (request, options) => _chunkBBE7SNRVjs.openRouterChannels.chatSend.tracePromise(() => send(request, options), {
|
|
5360
5370
|
arguments: [request]
|
|
5361
5371
|
});
|
|
5362
5372
|
}
|
|
5363
5373
|
function wrapEmbeddingsGenerate(generate) {
|
|
5364
|
-
return (request, options) =>
|
|
5374
|
+
return (request, options) => _chunkBBE7SNRVjs.openRouterChannels.embeddingsGenerate.tracePromise(
|
|
5365
5375
|
() => generate(request, options),
|
|
5366
5376
|
{ arguments: [request] }
|
|
5367
5377
|
);
|
|
5368
5378
|
}
|
|
5369
5379
|
function wrapResponsesSend(send) {
|
|
5370
|
-
return (request, options) =>
|
|
5380
|
+
return (request, options) => _chunkBBE7SNRVjs.openRouterChannels.betaResponsesSend.tracePromise(
|
|
5371
5381
|
() => send(request, options),
|
|
5372
5382
|
{ arguments: [request] }
|
|
5373
5383
|
);
|
|
5374
5384
|
}
|
|
5375
5385
|
function wrapRerank2(rerank) {
|
|
5376
|
-
return (request, options) =>
|
|
5386
|
+
return (request, options) => _chunkBBE7SNRVjs.openRouterChannels.rerankRerank.tracePromise(
|
|
5377
5387
|
() => rerank(request, options),
|
|
5378
5388
|
{ arguments: [request] }
|
|
5379
5389
|
);
|
|
@@ -5381,7 +5391,7 @@ function wrapRerank2(rerank) {
|
|
|
5381
5391
|
function wrapCallModel2(callModel) {
|
|
5382
5392
|
return (request, options) => {
|
|
5383
5393
|
const tracedRequest = { ...request };
|
|
5384
|
-
return
|
|
5394
|
+
return _chunkBBE7SNRVjs.openRouterChannels.callModel.traceSync(
|
|
5385
5395
|
() => callModel(tracedRequest, options),
|
|
5386
5396
|
{
|
|
5387
5397
|
arguments: [tracedRequest]
|
|
@@ -5514,7 +5524,7 @@ function classifiersProxy(classifiers) {
|
|
|
5514
5524
|
});
|
|
5515
5525
|
}
|
|
5516
5526
|
function wrapChatComplete(complete) {
|
|
5517
|
-
return (request, options) =>
|
|
5527
|
+
return (request, options) => _chunkBBE7SNRVjs.mistralChannels.chatComplete.tracePromise(
|
|
5518
5528
|
() => complete(request, options),
|
|
5519
5529
|
{
|
|
5520
5530
|
arguments: [request]
|
|
@@ -5522,52 +5532,52 @@ function wrapChatComplete(complete) {
|
|
|
5522
5532
|
);
|
|
5523
5533
|
}
|
|
5524
5534
|
function wrapChatStream(stream) {
|
|
5525
|
-
return (request, options) =>
|
|
5535
|
+
return (request, options) => _chunkBBE7SNRVjs.mistralChannels.chatStream.tracePromise(() => stream(request, options), {
|
|
5526
5536
|
arguments: [request]
|
|
5527
5537
|
});
|
|
5528
5538
|
}
|
|
5529
5539
|
function wrapEmbeddingsCreate(create) {
|
|
5530
|
-
return (request, options) =>
|
|
5540
|
+
return (request, options) => _chunkBBE7SNRVjs.mistralChannels.embeddingsCreate.tracePromise(
|
|
5531
5541
|
() => create(request, options),
|
|
5532
5542
|
{ arguments: [request] }
|
|
5533
5543
|
);
|
|
5534
5544
|
}
|
|
5535
5545
|
function wrapClassifiersModerate(moderate) {
|
|
5536
|
-
return (request, options) =>
|
|
5546
|
+
return (request, options) => _chunkBBE7SNRVjs.mistralChannels.classifiersModerate.tracePromise(
|
|
5537
5547
|
() => moderate(request, options),
|
|
5538
5548
|
{ arguments: [request] }
|
|
5539
5549
|
);
|
|
5540
5550
|
}
|
|
5541
5551
|
function wrapClassifiersModerateChat(moderateChat) {
|
|
5542
|
-
return (request, options) =>
|
|
5552
|
+
return (request, options) => _chunkBBE7SNRVjs.mistralChannels.classifiersModerateChat.tracePromise(
|
|
5543
5553
|
() => moderateChat(request, options),
|
|
5544
5554
|
{ arguments: [request] }
|
|
5545
5555
|
);
|
|
5546
5556
|
}
|
|
5547
5557
|
function wrapClassifiersClassify(classify) {
|
|
5548
|
-
return (request, options) =>
|
|
5558
|
+
return (request, options) => _chunkBBE7SNRVjs.mistralChannels.classifiersClassify.tracePromise(
|
|
5549
5559
|
() => classify(request, options),
|
|
5550
5560
|
{ arguments: [request] }
|
|
5551
5561
|
);
|
|
5552
5562
|
}
|
|
5553
5563
|
function wrapClassifiersClassifyChat(classifyChat) {
|
|
5554
|
-
return (request, options) =>
|
|
5564
|
+
return (request, options) => _chunkBBE7SNRVjs.mistralChannels.classifiersClassifyChat.tracePromise(
|
|
5555
5565
|
() => classifyChat(request, options),
|
|
5556
5566
|
{ arguments: [request] }
|
|
5557
5567
|
);
|
|
5558
5568
|
}
|
|
5559
5569
|
function wrapFimComplete(complete) {
|
|
5560
|
-
return (request, options) =>
|
|
5570
|
+
return (request, options) => _chunkBBE7SNRVjs.mistralChannels.fimComplete.tracePromise(() => complete(request, options), {
|
|
5561
5571
|
arguments: [request]
|
|
5562
5572
|
});
|
|
5563
5573
|
}
|
|
5564
5574
|
function wrapFimStream(stream) {
|
|
5565
|
-
return (request, options) =>
|
|
5575
|
+
return (request, options) => _chunkBBE7SNRVjs.mistralChannels.fimStream.tracePromise(() => stream(request, options), {
|
|
5566
5576
|
arguments: [request]
|
|
5567
5577
|
});
|
|
5568
5578
|
}
|
|
5569
5579
|
function wrapAgentsComplete(complete) {
|
|
5570
|
-
return (request, options) =>
|
|
5580
|
+
return (request, options) => _chunkBBE7SNRVjs.mistralChannels.agentsComplete.tracePromise(
|
|
5571
5581
|
() => complete(request, options),
|
|
5572
5582
|
{
|
|
5573
5583
|
arguments: [request]
|
|
@@ -5575,7 +5585,7 @@ function wrapAgentsComplete(complete) {
|
|
|
5575
5585
|
);
|
|
5576
5586
|
}
|
|
5577
5587
|
function wrapAgentsStream(stream) {
|
|
5578
|
-
return (request, options) =>
|
|
5588
|
+
return (request, options) => _chunkBBE7SNRVjs.mistralChannels.agentsStream.tracePromise(() => stream(request, options), {
|
|
5579
5589
|
arguments: [request]
|
|
5580
5590
|
});
|
|
5581
5591
|
}
|
|
@@ -5585,12 +5595,12 @@ function wrapOllama(ollama) {
|
|
|
5585
5595
|
if (isSupportedOllamaClient(ollama)) {
|
|
5586
5596
|
return ollamaProxy(ollama);
|
|
5587
5597
|
}
|
|
5588
|
-
|
|
5598
|
+
_chunkOBBWQW6Kjs.debugLogger.warn("Unsupported Ollama library. Not wrapping.");
|
|
5589
5599
|
return ollama;
|
|
5590
5600
|
}
|
|
5591
5601
|
var ollamaProxyCache = /* @__PURE__ */ new WeakMap();
|
|
5592
5602
|
function isSupportedOllamaClient(value) {
|
|
5593
|
-
return
|
|
5603
|
+
return _chunkOBBWQW6Kjs.isObject.call(void 0, value) && ["chat", "generate", "embed"].some(
|
|
5594
5604
|
(name) => typeof value[name] === "function"
|
|
5595
5605
|
);
|
|
5596
5606
|
}
|
|
@@ -5642,17 +5652,17 @@ function ollamaProxy(ollama) {
|
|
|
5642
5652
|
return proxy;
|
|
5643
5653
|
}
|
|
5644
5654
|
function wrapChat(chat) {
|
|
5645
|
-
return (request) =>
|
|
5655
|
+
return (request) => _chunkBBE7SNRVjs.ollamaChannels.chat.tracePromise(() => chat(request), {
|
|
5646
5656
|
arguments: [request]
|
|
5647
5657
|
});
|
|
5648
5658
|
}
|
|
5649
5659
|
function wrapGenerate2(generate) {
|
|
5650
|
-
return (request) =>
|
|
5660
|
+
return (request) => _chunkBBE7SNRVjs.ollamaChannels.generate.tracePromise(() => generate(request), {
|
|
5651
5661
|
arguments: [request]
|
|
5652
5662
|
});
|
|
5653
5663
|
}
|
|
5654
5664
|
function wrapEmbed3(embed) {
|
|
5655
|
-
return (request) =>
|
|
5665
|
+
return (request) => _chunkBBE7SNRVjs.ollamaChannels.embed.tracePromise(() => embed(request), {
|
|
5656
5666
|
arguments: [request]
|
|
5657
5667
|
});
|
|
5658
5668
|
}
|
|
@@ -5705,26 +5715,104 @@ function cohereProxy(cohere) {
|
|
|
5705
5715
|
return proxy;
|
|
5706
5716
|
}
|
|
5707
5717
|
function wrapChat2(chat) {
|
|
5708
|
-
return (request, options) =>
|
|
5718
|
+
return (request, options) => _chunkBBE7SNRVjs.cohereChannels.chat.tracePromise(() => chat(request, options), {
|
|
5709
5719
|
arguments: [request]
|
|
5710
5720
|
});
|
|
5711
5721
|
}
|
|
5712
5722
|
function wrapChatStream2(chatStream) {
|
|
5713
|
-
return (request, options) =>
|
|
5723
|
+
return (request, options) => _chunkBBE7SNRVjs.cohereChannels.chatStream.tracePromise(() => chatStream(request, options), {
|
|
5714
5724
|
arguments: [request]
|
|
5715
5725
|
});
|
|
5716
5726
|
}
|
|
5717
5727
|
function wrapEmbed4(embed) {
|
|
5718
|
-
return (request, options) =>
|
|
5728
|
+
return (request, options) => _chunkBBE7SNRVjs.cohereChannels.embed.tracePromise(() => embed(request, options), {
|
|
5719
5729
|
arguments: [request]
|
|
5720
5730
|
});
|
|
5721
5731
|
}
|
|
5722
5732
|
function wrapRerank3(rerank) {
|
|
5723
|
-
return (request, options) =>
|
|
5733
|
+
return (request, options) => _chunkBBE7SNRVjs.cohereChannels.rerank.tracePromise(() => rerank(request, options), {
|
|
5724
5734
|
arguments: [request]
|
|
5725
5735
|
});
|
|
5726
5736
|
}
|
|
5727
5737
|
|
|
5738
|
+
// src/wrappers/voyageai.ts
|
|
5739
|
+
function wrapVoyageAI(client) {
|
|
5740
|
+
if (!isSupportedVoyageAIClient(client)) {
|
|
5741
|
+
console.warn("Unsupported Voyage AI library. Not wrapping.");
|
|
5742
|
+
return client;
|
|
5743
|
+
}
|
|
5744
|
+
return voyageAIProxy(client);
|
|
5745
|
+
}
|
|
5746
|
+
var voyageAIProxyCache = /* @__PURE__ */ new WeakMap();
|
|
5747
|
+
function isObject2(value) {
|
|
5748
|
+
return typeof value === "object" && value !== null;
|
|
5749
|
+
}
|
|
5750
|
+
function hasFunction5(value, name) {
|
|
5751
|
+
return typeof Reflect.get(value, name) === "function";
|
|
5752
|
+
}
|
|
5753
|
+
function isSupportedVoyageAIClient(value) {
|
|
5754
|
+
if (!isObject2(value)) {
|
|
5755
|
+
return false;
|
|
5756
|
+
}
|
|
5757
|
+
return hasFunction5(value, "embed") || hasFunction5(value, "multimodalEmbed") || hasFunction5(value, "rerank") || hasFunction5(value, "contextualizedEmbed");
|
|
5758
|
+
}
|
|
5759
|
+
function voyageAIProxy(client) {
|
|
5760
|
+
const cached = voyageAIProxyCache.get(client);
|
|
5761
|
+
if (cached) {
|
|
5762
|
+
return cached;
|
|
5763
|
+
}
|
|
5764
|
+
const proxy = new Proxy(client, {
|
|
5765
|
+
get(target, prop, receiver) {
|
|
5766
|
+
switch (prop) {
|
|
5767
|
+
case "embed":
|
|
5768
|
+
if (typeof target.embed !== "function") {
|
|
5769
|
+
return target.embed;
|
|
5770
|
+
}
|
|
5771
|
+
return (request, options) => _chunkBBE7SNRVjs.voyageAIChannels.embed.invoke(
|
|
5772
|
+
target.embed,
|
|
5773
|
+
target,
|
|
5774
|
+
[request, options],
|
|
5775
|
+
{}
|
|
5776
|
+
);
|
|
5777
|
+
case "multimodalEmbed":
|
|
5778
|
+
if (typeof target.multimodalEmbed !== "function") {
|
|
5779
|
+
return target.multimodalEmbed;
|
|
5780
|
+
}
|
|
5781
|
+
return (request, options) => _chunkBBE7SNRVjs.voyageAIChannels.multimodalEmbed.invoke(
|
|
5782
|
+
target.multimodalEmbed,
|
|
5783
|
+
target,
|
|
5784
|
+
[request, options],
|
|
5785
|
+
{}
|
|
5786
|
+
);
|
|
5787
|
+
case "rerank":
|
|
5788
|
+
if (typeof target.rerank !== "function") {
|
|
5789
|
+
return target.rerank;
|
|
5790
|
+
}
|
|
5791
|
+
return (request, options) => _chunkBBE7SNRVjs.voyageAIChannels.rerank.invoke(
|
|
5792
|
+
target.rerank,
|
|
5793
|
+
target,
|
|
5794
|
+
[request, options],
|
|
5795
|
+
{}
|
|
5796
|
+
);
|
|
5797
|
+
case "contextualizedEmbed":
|
|
5798
|
+
if (typeof target.contextualizedEmbed !== "function") {
|
|
5799
|
+
return target.contextualizedEmbed;
|
|
5800
|
+
}
|
|
5801
|
+
return (request, options) => _chunkBBE7SNRVjs.voyageAIChannels.contextualizedEmbed.invoke(
|
|
5802
|
+
target.contextualizedEmbed,
|
|
5803
|
+
target,
|
|
5804
|
+
[request, options],
|
|
5805
|
+
{}
|
|
5806
|
+
);
|
|
5807
|
+
default:
|
|
5808
|
+
return Reflect.get(target, prop, receiver);
|
|
5809
|
+
}
|
|
5810
|
+
}
|
|
5811
|
+
});
|
|
5812
|
+
voyageAIProxyCache.set(client, proxy);
|
|
5813
|
+
return proxy;
|
|
5814
|
+
}
|
|
5815
|
+
|
|
5728
5816
|
// src/wrappers/groq.ts
|
|
5729
5817
|
function wrapGroq(groq) {
|
|
5730
5818
|
if (isSupportedGroqClient(groq)) {
|
|
@@ -5736,14 +5824,14 @@ function wrapGroq(groq) {
|
|
|
5736
5824
|
function isRecord4(value) {
|
|
5737
5825
|
return typeof value === "object" && value !== null;
|
|
5738
5826
|
}
|
|
5739
|
-
function
|
|
5827
|
+
function hasFunction6(value, methodName) {
|
|
5740
5828
|
return isRecord4(value) && methodName in value && typeof value[methodName] === "function";
|
|
5741
5829
|
}
|
|
5742
5830
|
function hasChat2(value) {
|
|
5743
|
-
return isRecord4(value) && isRecord4(value.completions) &&
|
|
5831
|
+
return isRecord4(value) && isRecord4(value.completions) && hasFunction6(value.completions, "create");
|
|
5744
5832
|
}
|
|
5745
5833
|
function hasEmbeddings2(value) {
|
|
5746
|
-
return
|
|
5834
|
+
return hasFunction6(value, "create");
|
|
5747
5835
|
}
|
|
5748
5836
|
function isSupportedGroqClient(value) {
|
|
5749
5837
|
return isRecord4(value) && (value.chat !== void 0 && hasChat2(value.chat) || value.embeddings !== void 0 && hasEmbeddings2(value.embeddings));
|
|
@@ -5802,13 +5890,13 @@ function groqProxy(groq) {
|
|
|
5802
5890
|
return topLevelProxy;
|
|
5803
5891
|
}
|
|
5804
5892
|
function wrapChatCompletionsCreate(create) {
|
|
5805
|
-
return (request, options) =>
|
|
5893
|
+
return (request, options) => _chunkBBE7SNRVjs.groqChannels.chatCompletionsCreate.tracePromise(
|
|
5806
5894
|
() => create(request, options),
|
|
5807
5895
|
{ arguments: [request] }
|
|
5808
5896
|
);
|
|
5809
5897
|
}
|
|
5810
5898
|
function wrapEmbeddingsCreate2(create) {
|
|
5811
|
-
return (request, options) =>
|
|
5899
|
+
return (request, options) => _chunkBBE7SNRVjs.groqChannels.embeddingsCreate.tracePromise(() => create(request, options), {
|
|
5812
5900
|
arguments: [request]
|
|
5813
5901
|
});
|
|
5814
5902
|
}
|
|
@@ -5882,16 +5970,16 @@ function bedrockRuntimeProxy(client) {
|
|
|
5882
5970
|
}
|
|
5883
5971
|
function wrapSend(send) {
|
|
5884
5972
|
return (command, optionsOrCb, cb) => {
|
|
5885
|
-
if (
|
|
5973
|
+
if (_chunkOBBWQW6Kjs.getBedrockRuntimeOperation.call(void 0, command) === void 0 || typeof optionsOrCb === "function" || typeof cb === "function") {
|
|
5886
5974
|
return send(command, optionsOrCb, cb);
|
|
5887
5975
|
}
|
|
5888
|
-
return
|
|
5889
|
-
() =>
|
|
5976
|
+
return _chunkBBE7SNRVjs.bedrockRuntimeChannels.clientSend.tracePromise(
|
|
5977
|
+
() => _chunkOBBWQW6Kjs.runWithAutoInstrumentationSuppressed.call(void 0,
|
|
5890
5978
|
() => send(command, optionsOrCb)
|
|
5891
5979
|
),
|
|
5892
5980
|
{
|
|
5893
5981
|
arguments: [command, optionsOrCb],
|
|
5894
|
-
span_info:
|
|
5982
|
+
span_info: _chunkOBBWQW6Kjs.buildBedrockRuntimeSpanInfo.call(void 0, command)
|
|
5895
5983
|
}
|
|
5896
5984
|
);
|
|
5897
5985
|
};
|
|
@@ -5940,13 +6028,13 @@ function copilotClientProxy(client) {
|
|
|
5940
6028
|
return proxy;
|
|
5941
6029
|
}
|
|
5942
6030
|
function wrappedCreateSession(client) {
|
|
5943
|
-
return (config) =>
|
|
6031
|
+
return (config) => _chunkBBE7SNRVjs.gitHubCopilotChannels.createSession.tracePromise(
|
|
5944
6032
|
() => client.createSession(config),
|
|
5945
6033
|
{ arguments: [config] }
|
|
5946
6034
|
);
|
|
5947
6035
|
}
|
|
5948
6036
|
function wrappedResumeSession(client) {
|
|
5949
|
-
return (sessionId, config) =>
|
|
6037
|
+
return (sessionId, config) => _chunkBBE7SNRVjs.gitHubCopilotChannels.resumeSession.tracePromise(
|
|
5950
6038
|
() => client.resumeSession(sessionId, config),
|
|
5951
6039
|
{ arguments: [sessionId, config] }
|
|
5952
6040
|
);
|
|
@@ -6124,13 +6212,13 @@ function wrapRunTreeInstance(runTree) {
|
|
|
6124
6212
|
wrapped = (...args) => wrapRunTreeInstance(Reflect.apply(value, target, args));
|
|
6125
6213
|
} else if (prop === "postRun") {
|
|
6126
6214
|
const method = value;
|
|
6127
|
-
wrapped = (...args) =>
|
|
6215
|
+
wrapped = (...args) => _chunkBBE7SNRVjs.langSmithChannels.createRun.tracePromise(
|
|
6128
6216
|
() => Reflect.apply(method, target, args),
|
|
6129
6217
|
{ arguments: [target] }
|
|
6130
6218
|
);
|
|
6131
6219
|
} else if (prop === "patchRun") {
|
|
6132
6220
|
const method = value;
|
|
6133
|
-
wrapped = (...args) =>
|
|
6221
|
+
wrapped = (...args) => _chunkBBE7SNRVjs.langSmithChannels.updateRun.tracePromise(
|
|
6134
6222
|
() => Reflect.apply(method, target, args),
|
|
6135
6223
|
{
|
|
6136
6224
|
arguments: [
|
|
@@ -6179,19 +6267,19 @@ function wrapClientInstance(client) {
|
|
|
6179
6267
|
let wrapped;
|
|
6180
6268
|
if (prop === "createRun") {
|
|
6181
6269
|
const method = value;
|
|
6182
|
-
wrapped = (...args) =>
|
|
6270
|
+
wrapped = (...args) => _chunkBBE7SNRVjs.langSmithChannels.createRun.tracePromise(
|
|
6183
6271
|
() => Reflect.apply(method, target, args),
|
|
6184
6272
|
{ arguments: args }
|
|
6185
6273
|
);
|
|
6186
6274
|
} else if (prop === "updateRun") {
|
|
6187
6275
|
const method = value;
|
|
6188
|
-
wrapped = (...args) =>
|
|
6276
|
+
wrapped = (...args) => _chunkBBE7SNRVjs.langSmithChannels.updateRun.tracePromise(
|
|
6189
6277
|
() => Reflect.apply(method, target, args),
|
|
6190
6278
|
{ arguments: args }
|
|
6191
6279
|
);
|
|
6192
6280
|
} else if (prop === "batchIngestRuns") {
|
|
6193
6281
|
const method = value;
|
|
6194
|
-
wrapped = (...args) =>
|
|
6282
|
+
wrapped = (...args) => _chunkBBE7SNRVjs.langSmithChannels.batchIngestRuns.tracePromise(
|
|
6195
6283
|
() => Reflect.apply(method, target, args),
|
|
6196
6284
|
{ arguments: args }
|
|
6197
6285
|
);
|
|
@@ -6207,13 +6295,13 @@ function publishRunUpdate(runTree) {
|
|
|
6207
6295
|
return;
|
|
6208
6296
|
}
|
|
6209
6297
|
try {
|
|
6210
|
-
void
|
|
6298
|
+
void _chunkBBE7SNRVjs.langSmithChannels.updateRun.tracePromise(() => Promise.resolve(void 0), {
|
|
6211
6299
|
arguments: [runTree.id, runTree]
|
|
6212
6300
|
}).catch((error) => {
|
|
6213
|
-
|
|
6301
|
+
_chunkOBBWQW6Kjs.debugLogger.error("LangSmith traceable instrumentation failed:", error);
|
|
6214
6302
|
});
|
|
6215
6303
|
} catch (error) {
|
|
6216
|
-
|
|
6304
|
+
_chunkOBBWQW6Kjs.debugLogger.error("LangSmith traceable instrumentation failed:", error);
|
|
6217
6305
|
}
|
|
6218
6306
|
}
|
|
6219
6307
|
|
|
@@ -6225,7 +6313,7 @@ var VitestContextManager = class {
|
|
|
6225
6313
|
*/
|
|
6226
6314
|
|
|
6227
6315
|
constructor() {
|
|
6228
|
-
this.contextStorage =
|
|
6316
|
+
this.contextStorage = _chunkBBE7SNRVjs.isomorph_default.newAsyncLocalStorage();
|
|
6229
6317
|
}
|
|
6230
6318
|
getCurrentContext() {
|
|
6231
6319
|
return this.contextStorage.getStore();
|
|
@@ -6266,7 +6354,7 @@ var FlushCoordinator = (_class2 = class {constructor() { _class2.prototype.__ini
|
|
|
6266
6354
|
if (this.activeFlushes.has(experimentId)) {
|
|
6267
6355
|
return this.activeFlushes.get(experimentId);
|
|
6268
6356
|
}
|
|
6269
|
-
const flushPromise =
|
|
6357
|
+
const flushPromise = _chunkOBBWQW6Kjs.summarizeAndFlush.call(void 0, context.experiment, {
|
|
6270
6358
|
displaySummary: config.displaySummary
|
|
6271
6359
|
});
|
|
6272
6360
|
this.activeFlushes.set(experimentId, flushPromise);
|
|
@@ -6285,7 +6373,7 @@ async function flushExperimentWithSync(context, config) {
|
|
|
6285
6373
|
// src/wrappers/shared/scorers.ts
|
|
6286
6374
|
async function runScorers(args) {
|
|
6287
6375
|
const { scorers, output, expected, input, metadata, span } = args;
|
|
6288
|
-
const
|
|
6376
|
+
const scorerArgs2 = {
|
|
6289
6377
|
output,
|
|
6290
6378
|
expected,
|
|
6291
6379
|
input,
|
|
@@ -6294,7 +6382,7 @@ async function runScorers(args) {
|
|
|
6294
6382
|
await Promise.all(
|
|
6295
6383
|
scorers.map(async (scorer) => {
|
|
6296
6384
|
try {
|
|
6297
|
-
const result = await scorer(
|
|
6385
|
+
const result = await scorer(scorerArgs2);
|
|
6298
6386
|
const scores = normalizeScores(result);
|
|
6299
6387
|
if (scores.length > 0) {
|
|
6300
6388
|
const accScores = {};
|
|
@@ -6364,7 +6452,7 @@ async function runTracedEval(args) {
|
|
|
6364
6452
|
}
|
|
6365
6453
|
if (testError) {
|
|
6366
6454
|
span.log({ scores: { pass: 0 } });
|
|
6367
|
-
|
|
6455
|
+
_chunkOBBWQW6Kjs.logError.call(void 0, span, testError);
|
|
6368
6456
|
throw testError;
|
|
6369
6457
|
}
|
|
6370
6458
|
span.log({
|
|
@@ -6538,10 +6626,10 @@ function wrapDescribe(originalDescribe, config, afterAll) {
|
|
|
6538
6626
|
const getOrCreateContext = () => {
|
|
6539
6627
|
if (!context) {
|
|
6540
6628
|
const experimentName = `${suiteName}-${(/* @__PURE__ */ new Date()).toISOString()}`;
|
|
6541
|
-
const experiment = config.projectId ?
|
|
6629
|
+
const experiment = config.projectId ? _chunkOBBWQW6Kjs.initExperiment.call(void 0, {
|
|
6542
6630
|
projectId: config.projectId,
|
|
6543
6631
|
experiment: experimentName
|
|
6544
|
-
}) :
|
|
6632
|
+
}) : _chunkOBBWQW6Kjs.initExperiment.call(void 0, config.projectName || suiteName, {
|
|
6545
6633
|
experiment: experimentName
|
|
6546
6634
|
});
|
|
6547
6635
|
context = contextManager.createChildContext(void 0, experiment);
|
|
@@ -6649,7 +6737,7 @@ function wrapExpect(originalExpect) {
|
|
|
6649
6737
|
return originalExpect(value);
|
|
6650
6738
|
}
|
|
6651
6739
|
const assertion = originalExpect(value, message);
|
|
6652
|
-
const span =
|
|
6740
|
+
const span = _chunkOBBWQW6Kjs.currentSpan.call(void 0, );
|
|
6653
6741
|
if (!span) {
|
|
6654
6742
|
return assertion;
|
|
6655
6743
|
}
|
|
@@ -6661,16 +6749,16 @@ function wrapExpect(originalExpect) {
|
|
|
6661
6749
|
|
|
6662
6750
|
// src/wrappers/shared/logging.ts
|
|
6663
6751
|
function logOutputs(outputs) {
|
|
6664
|
-
|
|
6752
|
+
_chunkOBBWQW6Kjs.currentSpan.call(void 0, ).log({ output: outputs });
|
|
6665
6753
|
}
|
|
6666
6754
|
function logFeedback(feedback) {
|
|
6667
|
-
|
|
6755
|
+
_chunkOBBWQW6Kjs.currentSpan.call(void 0, ).log({
|
|
6668
6756
|
scores: { [feedback.name]: feedback.score },
|
|
6669
6757
|
metadata: feedback.metadata
|
|
6670
6758
|
});
|
|
6671
6759
|
}
|
|
6672
6760
|
function getCurrentSpan() {
|
|
6673
|
-
return
|
|
6761
|
+
return _chunkOBBWQW6Kjs.currentSpan.call(void 0, );
|
|
6674
6762
|
}
|
|
6675
6763
|
|
|
6676
6764
|
// src/wrappers/vitest/index.ts
|
|
@@ -6718,7 +6806,7 @@ function wrapVitest(vitestMethods, config = {}) {
|
|
|
6718
6806
|
);
|
|
6719
6807
|
return;
|
|
6720
6808
|
}
|
|
6721
|
-
await
|
|
6809
|
+
await _chunkOBBWQW6Kjs.summarizeAndFlush.call(void 0, ctx.experiment, {
|
|
6722
6810
|
displaySummary: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _139 => _139.displaySummary]), () => ( config.displaySummary))
|
|
6723
6811
|
});
|
|
6724
6812
|
}
|
|
@@ -6733,7 +6821,7 @@ function initNodeTestSuite(config) {
|
|
|
6733
6821
|
return experiment;
|
|
6734
6822
|
}
|
|
6735
6823
|
const experimentName = config.experimentName || `${config.projectName}-${(/* @__PURE__ */ new Date()).toISOString()}`;
|
|
6736
|
-
experiment =
|
|
6824
|
+
experiment = _chunkOBBWQW6Kjs.initExperiment.call(void 0, config.projectName, {
|
|
6737
6825
|
experiment: experimentName
|
|
6738
6826
|
});
|
|
6739
6827
|
return experiment;
|
|
@@ -6782,7 +6870,7 @@ function initNodeTestSuite(config) {
|
|
|
6782
6870
|
if (!experiment) {
|
|
6783
6871
|
return;
|
|
6784
6872
|
}
|
|
6785
|
-
await
|
|
6873
|
+
await _chunkOBBWQW6Kjs.summarizeAndFlush.call(void 0, experiment, {
|
|
6786
6874
|
displaySummary: config.displaySummary
|
|
6787
6875
|
});
|
|
6788
6876
|
experiment = void 0;
|
|
@@ -6799,7 +6887,7 @@ function initNodeTestSuite(config) {
|
|
|
6799
6887
|
|
|
6800
6888
|
// src/graph-framework.ts
|
|
6801
6889
|
var graph_framework_exports = {};
|
|
6802
|
-
|
|
6890
|
+
_chunkBBE7SNRVjs.__export.call(void 0, graph_framework_exports, {
|
|
6803
6891
|
AggregatorNode: () => AggregatorNode,
|
|
6804
6892
|
GateNode: () => GateNode,
|
|
6805
6893
|
GraphBuilder: () => GraphBuilder,
|
|
@@ -6873,7 +6961,7 @@ var GraphBuilder = (_class3 = class {
|
|
|
6873
6961
|
};
|
|
6874
6962
|
}
|
|
6875
6963
|
resolveNode(node) {
|
|
6876
|
-
if (node instanceof
|
|
6964
|
+
if (node instanceof _chunkOBBWQW6Kjs.Prompt) {
|
|
6877
6965
|
const cached = this.nodeLikeNodes.get(node);
|
|
6878
6966
|
if (cached) {
|
|
6879
6967
|
return [cached, []];
|
|
@@ -6923,7 +7011,7 @@ var GraphBuilder = (_class3 = class {
|
|
|
6923
7011
|
// }
|
|
6924
7012
|
// Helper to generate node IDs
|
|
6925
7013
|
generateId(name) {
|
|
6926
|
-
const uuid =
|
|
7014
|
+
const uuid = _chunkOBBWQW6Kjs.newId.call(void 0, );
|
|
6927
7015
|
if (name) {
|
|
6928
7016
|
return `${name}-${uuid.slice(0, 8)}`;
|
|
6929
7017
|
} else {
|
|
@@ -8123,7 +8211,7 @@ function waterfall(tasks, callback) {
|
|
|
8123
8211
|
var waterfall$1 = awaitify(waterfall);
|
|
8124
8212
|
|
|
8125
8213
|
// src/trace.ts
|
|
8126
|
-
var SpanFetcher = class _SpanFetcher extends
|
|
8214
|
+
var SpanFetcher = class _SpanFetcher extends _chunkOBBWQW6Kjs.ObjectFetcher {
|
|
8127
8215
|
constructor(objectType, _objectId, rootSpanId, _state, spanTypeFilter, includeScorers = false, brainstoreRealtime = true) {
|
|
8128
8216
|
const filterExpr = _SpanFetcher.buildFilter(
|
|
8129
8217
|
rootSpanId,
|
|
@@ -8440,20 +8528,20 @@ var promptContentsSchema = _v3.z.union([
|
|
|
8440
8528
|
prompt: _v3.z.string()
|
|
8441
8529
|
}),
|
|
8442
8530
|
_v3.z.object({
|
|
8443
|
-
messages: _v3.z.array(
|
|
8531
|
+
messages: _v3.z.array(_chunkOBBWQW6Kjs.ChatCompletionMessageParam)
|
|
8444
8532
|
})
|
|
8445
8533
|
]);
|
|
8446
8534
|
var promptDefinitionSchema = promptContentsSchema.and(
|
|
8447
8535
|
_v3.z.object({
|
|
8448
8536
|
model: _v3.z.string(),
|
|
8449
|
-
params:
|
|
8537
|
+
params: _chunkOBBWQW6Kjs.ModelParams.optional(),
|
|
8450
8538
|
templateFormat: _v3.z.enum(["mustache", "nunjucks", "none"]).optional(),
|
|
8451
8539
|
environments: _v3.z.array(_v3.z.string()).optional()
|
|
8452
8540
|
})
|
|
8453
8541
|
);
|
|
8454
8542
|
var promptDefinitionWithToolsSchema = promptDefinitionSchema.and(
|
|
8455
8543
|
_v3.z.object({
|
|
8456
|
-
tools: _v3.z.array(
|
|
8544
|
+
tools: _v3.z.array(_chunkOBBWQW6Kjs.ToolFunctionDefinition).optional()
|
|
8457
8545
|
})
|
|
8458
8546
|
);
|
|
8459
8547
|
function promptDefinitionToPromptData(promptDefinition, rawTools) {
|
|
@@ -8501,7 +8589,7 @@ async function validateParameters(parameters, parameterSchema) {
|
|
|
8501
8589
|
if (resolvedSchema === void 0 || resolvedSchema === null) {
|
|
8502
8590
|
return parameters;
|
|
8503
8591
|
}
|
|
8504
|
-
if (
|
|
8592
|
+
if (_chunkOBBWQW6Kjs.RemoteEvalParameters.isParameters(resolvedSchema)) {
|
|
8505
8593
|
const mergedParameters = parameters && Object.keys(parameters).length > 0 ? {
|
|
8506
8594
|
...resolvedSchema.data,
|
|
8507
8595
|
...parameters
|
|
@@ -8523,14 +8611,14 @@ function validateParametersWithZod(parameters, parameterSchema) {
|
|
|
8523
8611
|
const value = parameters[name];
|
|
8524
8612
|
try {
|
|
8525
8613
|
if ("type" in schema && schema.type === "prompt") {
|
|
8526
|
-
const promptData = value ?
|
|
8614
|
+
const promptData = value ? _chunkOBBWQW6Kjs.PromptData.parse(value) : schema.default ? promptDefinitionToPromptData(
|
|
8527
8615
|
schema.default,
|
|
8528
8616
|
schema.default.tools
|
|
8529
8617
|
) : void 0;
|
|
8530
8618
|
if (!promptData) {
|
|
8531
8619
|
throw new Error(`Parameter '${name}' is required`);
|
|
8532
8620
|
}
|
|
8533
|
-
return [name,
|
|
8621
|
+
return [name, _chunkOBBWQW6Kjs.Prompt.fromPromptData(name, promptData)];
|
|
8534
8622
|
} else if ("type" in schema && schema.type === "model") {
|
|
8535
8623
|
const model = _nullishCoalesce(value, () => ( schema.default));
|
|
8536
8624
|
if (model === void 0) {
|
|
@@ -8581,7 +8669,7 @@ function rehydrateRemoteParameters(parameters, schema) {
|
|
|
8581
8669
|
if (Reflect.get(propertySchema, "x-bt-type") === "prompt") {
|
|
8582
8670
|
return [
|
|
8583
8671
|
name,
|
|
8584
|
-
|
|
8672
|
+
_chunkOBBWQW6Kjs.Prompt.fromPromptData(name, _chunkOBBWQW6Kjs.PromptData.parse(value))
|
|
8585
8673
|
];
|
|
8586
8674
|
}
|
|
8587
8675
|
return [name, value];
|
|
@@ -8631,7 +8719,7 @@ function makeEvalName(projectName, experimentName) {
|
|
|
8631
8719
|
return out;
|
|
8632
8720
|
}
|
|
8633
8721
|
function initExperiment2(state, options = {}) {
|
|
8634
|
-
return
|
|
8722
|
+
return _chunkOBBWQW6Kjs.init.call(void 0, {
|
|
8635
8723
|
state,
|
|
8636
8724
|
...options,
|
|
8637
8725
|
setCurrent: false
|
|
@@ -8642,7 +8730,7 @@ async function getExperimentParametersRef(parameters) {
|
|
|
8642
8730
|
return void 0;
|
|
8643
8731
|
}
|
|
8644
8732
|
const resolvedParameters = parameters instanceof Promise ? await parameters : parameters;
|
|
8645
|
-
if (!
|
|
8733
|
+
if (!_chunkOBBWQW6Kjs.RemoteEvalParameters.isParameters(resolvedParameters)) {
|
|
8646
8734
|
return void 0;
|
|
8647
8735
|
}
|
|
8648
8736
|
if (resolvedParameters.id === void 0) {
|
|
@@ -8653,6 +8741,26 @@ async function getExperimentParametersRef(parameters) {
|
|
|
8653
8741
|
version: resolvedParameters.version
|
|
8654
8742
|
};
|
|
8655
8743
|
}
|
|
8744
|
+
async function _internalInitEvaluatorExperiment(projectName, evaluator, data, options = {}) {
|
|
8745
|
+
if (options.disabled) return null;
|
|
8746
|
+
const { baseExperiment } = callEvaluatorData(data);
|
|
8747
|
+
const parameters = await getExperimentParametersRef(evaluator.parameters);
|
|
8748
|
+
return initExperiment2(evaluator.state, {
|
|
8749
|
+
...evaluator.projectId ? { projectId: evaluator.projectId } : { project: projectName },
|
|
8750
|
+
experiment: _nullishCoalesce(options.experimentName, () => ( evaluator.experimentName)),
|
|
8751
|
+
description: evaluator.description,
|
|
8752
|
+
metadata: evaluator.metadata,
|
|
8753
|
+
tags: evaluator.tags,
|
|
8754
|
+
isPublic: evaluator.isPublic,
|
|
8755
|
+
update: _nullishCoalesce(options.update, () => ( evaluator.update)),
|
|
8756
|
+
baseExperiment: _nullishCoalesce(evaluator.baseExperimentName, () => ( baseExperiment)),
|
|
8757
|
+
baseExperimentId: evaluator.baseExperimentId,
|
|
8758
|
+
gitMetadataSettings: evaluator.gitMetadataSettings,
|
|
8759
|
+
repoInfo: evaluator.repoInfo,
|
|
8760
|
+
dataset: _chunkOBBWQW6Kjs.Dataset.isDataset(data) ? data : void 0,
|
|
8761
|
+
parameters
|
|
8762
|
+
});
|
|
8763
|
+
}
|
|
8656
8764
|
function callEvaluatorData(data) {
|
|
8657
8765
|
const dataResult = typeof data === "function" ? data() : data;
|
|
8658
8766
|
let baseExperiment = void 0;
|
|
@@ -8670,6 +8778,48 @@ function isAsyncIterable2(value) {
|
|
|
8670
8778
|
function isIterable(value) {
|
|
8671
8779
|
return typeof value === "object" && value !== null && Symbol.iterator in value && typeof value[Symbol.iterator] === "function";
|
|
8672
8780
|
}
|
|
8781
|
+
async function _internalResolveEvaluatorData(evaluator, experiment) {
|
|
8782
|
+
if (typeof evaluator.data === "string") {
|
|
8783
|
+
throw new Error("Unimplemented: string data paths");
|
|
8784
|
+
}
|
|
8785
|
+
let dataResult = typeof evaluator.data === "function" ? evaluator.data() : evaluator.data;
|
|
8786
|
+
if ("_type" in dataResult) {
|
|
8787
|
+
if (dataResult._type !== "BaseExperiment") {
|
|
8788
|
+
throw new Error("Invalid _type");
|
|
8789
|
+
}
|
|
8790
|
+
if (!experiment) {
|
|
8791
|
+
throw new Error(
|
|
8792
|
+
"Cannot use BaseExperiment() without connecting to Braintrust (you most likely set --no-send-logs)"
|
|
8793
|
+
);
|
|
8794
|
+
}
|
|
8795
|
+
let name = dataResult.name;
|
|
8796
|
+
if (_chunkOBBWQW6Kjs.isEmpty.call(void 0, name)) {
|
|
8797
|
+
const baseExperiment = await experiment.fetchBaseExperiment();
|
|
8798
|
+
if (!baseExperiment) {
|
|
8799
|
+
throw new Error("BaseExperiment() failed to fetch base experiment");
|
|
8800
|
+
}
|
|
8801
|
+
name = baseExperiment.name;
|
|
8802
|
+
}
|
|
8803
|
+
dataResult = initExperiment2(evaluator.state, {
|
|
8804
|
+
...evaluator.projectId ? { projectId: evaluator.projectId } : { project: evaluator.projectName },
|
|
8805
|
+
experiment: name,
|
|
8806
|
+
open: true
|
|
8807
|
+
}).asDataset();
|
|
8808
|
+
}
|
|
8809
|
+
const resolvedDataResult = dataResult instanceof Promise ? await dataResult : dataResult;
|
|
8810
|
+
if (isAsyncIterable2(resolvedDataResult)) {
|
|
8811
|
+
return resolvedDataResult;
|
|
8812
|
+
}
|
|
8813
|
+
if (Array.isArray(resolvedDataResult) || isIterable(resolvedDataResult)) {
|
|
8814
|
+
const iterable = resolvedDataResult;
|
|
8815
|
+
return (async function* () {
|
|
8816
|
+
for (const datum of iterable) yield datum;
|
|
8817
|
+
})();
|
|
8818
|
+
}
|
|
8819
|
+
throw new Error(
|
|
8820
|
+
"Evaluator data must be an array, iterable, or async iterable"
|
|
8821
|
+
);
|
|
8822
|
+
}
|
|
8673
8823
|
globalThis._evals = {
|
|
8674
8824
|
functions: [],
|
|
8675
8825
|
prompts: [],
|
|
@@ -8678,10 +8828,10 @@ globalThis._evals = {
|
|
|
8678
8828
|
reporters: {}
|
|
8679
8829
|
};
|
|
8680
8830
|
function _initializeSpanContext() {
|
|
8681
|
-
globalThis._spanContext = { currentSpan:
|
|
8831
|
+
globalThis._spanContext = { currentSpan: _chunkOBBWQW6Kjs.currentSpan, withCurrent: _chunkOBBWQW6Kjs.withCurrent, startSpan: _chunkOBBWQW6Kjs.startSpan, NOOP_SPAN: _chunkOBBWQW6Kjs.NOOP_SPAN };
|
|
8682
8832
|
}
|
|
8683
8833
|
async function Eval(name, evaluator, reporterOrOpts) {
|
|
8684
|
-
const options =
|
|
8834
|
+
const options = _chunkOBBWQW6Kjs.isEmpty.call(void 0, reporterOrOpts) ? {} : typeof reporterOrOpts === "string" ? { reporter: reporterOrOpts } : "name" in reporterOrOpts ? { reporter: reporterOrOpts } : reporterOrOpts;
|
|
8685
8835
|
let evalName = makeEvalName(name, evaluator.experimentName);
|
|
8686
8836
|
if (globalThis._evals.evaluators[evalName]) {
|
|
8687
8837
|
evalName = `${evalName}_${Object.keys(_evals).length}`;
|
|
@@ -8716,25 +8866,13 @@ async function Eval(name, evaluator, reporterOrOpts) {
|
|
|
8716
8866
|
}
|
|
8717
8867
|
const resolvedReporter = options.reporter || defaultReporter;
|
|
8718
8868
|
try {
|
|
8719
|
-
const { data
|
|
8720
|
-
|
|
8869
|
+
const { data } = callEvaluatorData(evaluator.data);
|
|
8870
|
+
const experiment = await _internalInitEvaluatorExperiment(
|
|
8871
|
+
name,
|
|
8872
|
+
evaluator,
|
|
8873
|
+
data,
|
|
8874
|
+
{ disabled: Boolean(options.parent || options.noSendLogs) }
|
|
8721
8875
|
);
|
|
8722
|
-
const parameters = await getExperimentParametersRef(evaluator.parameters);
|
|
8723
|
-
const experiment = options.parent || options.noSendLogs ? null : initExperiment2(evaluator.state, {
|
|
8724
|
-
...evaluator.projectId ? { projectId: evaluator.projectId } : { project: name },
|
|
8725
|
-
experiment: evaluator.experimentName,
|
|
8726
|
-
description: evaluator.description,
|
|
8727
|
-
metadata: evaluator.metadata,
|
|
8728
|
-
tags: evaluator.tags,
|
|
8729
|
-
isPublic: evaluator.isPublic,
|
|
8730
|
-
update: evaluator.update,
|
|
8731
|
-
baseExperiment: _nullishCoalesce(evaluator.baseExperimentName, () => ( defaultBaseExperiment)),
|
|
8732
|
-
baseExperimentId: evaluator.baseExperimentId,
|
|
8733
|
-
gitMetadataSettings: evaluator.gitMetadataSettings,
|
|
8734
|
-
repoInfo: evaluator.repoInfo,
|
|
8735
|
-
dataset: _chunkQRHGVBKUjs.Dataset.isDataset(data) ? data : void 0,
|
|
8736
|
-
parameters
|
|
8737
|
-
});
|
|
8738
8876
|
if (experiment && typeof process !== "undefined" && globalThis.BRAINTRUST_CONTEXT_MANAGER !== void 0) {
|
|
8739
8877
|
await experiment._waitForId();
|
|
8740
8878
|
}
|
|
@@ -8752,7 +8890,7 @@ async function Eval(name, evaluator, reporterOrOpts) {
|
|
|
8752
8890
|
const enableCache = _nullishCoalesce(options.enableCache, () => ( true));
|
|
8753
8891
|
let ret;
|
|
8754
8892
|
if (options.parent) {
|
|
8755
|
-
ret = await
|
|
8893
|
+
ret = await _chunkOBBWQW6Kjs.withParent.call(void 0,
|
|
8756
8894
|
options.parent,
|
|
8757
8895
|
() => runEvaluator(
|
|
8758
8896
|
null,
|
|
@@ -8788,7 +8926,7 @@ async function Eval(name, evaluator, reporterOrOpts) {
|
|
|
8788
8926
|
if (experiment) {
|
|
8789
8927
|
await experiment.flush().catch(console.error);
|
|
8790
8928
|
} else if (options.parent) {
|
|
8791
|
-
await
|
|
8929
|
+
await _chunkOBBWQW6Kjs.flush.call(void 0, { state: evaluator.state }).catch(console.error);
|
|
8792
8930
|
}
|
|
8793
8931
|
}
|
|
8794
8932
|
} finally {
|
|
@@ -8832,19 +8970,74 @@ function scorerName(scorer, scorer_idx) {
|
|
|
8832
8970
|
function classifierName(classifier, classifier_idx) {
|
|
8833
8971
|
return classifier.name || `classifier_${classifier_idx}`;
|
|
8834
8972
|
}
|
|
8973
|
+
async function _internalRunEvaluatorTask(task, datum, trialIndex, parameters, span, reportProgress = () => void 0) {
|
|
8974
|
+
const metadata = {
|
|
8975
|
+
..."metadata" in datum ? datum.metadata : {}
|
|
8976
|
+
};
|
|
8977
|
+
const hooks = {
|
|
8978
|
+
meta(value) {
|
|
8979
|
+
Object.assign(metadata, value);
|
|
8980
|
+
},
|
|
8981
|
+
metadata,
|
|
8982
|
+
expected: "expected" in datum ? datum.expected : void 0,
|
|
8983
|
+
span,
|
|
8984
|
+
parameters,
|
|
8985
|
+
reportProgress,
|
|
8986
|
+
trialIndex,
|
|
8987
|
+
tags: [..._nullishCoalesce(datum.tags, () => ( []))]
|
|
8988
|
+
};
|
|
8989
|
+
const output = await task(datum.input, hooks);
|
|
8990
|
+
span.log({ output });
|
|
8991
|
+
return {
|
|
8992
|
+
output,
|
|
8993
|
+
metadata: hooks.metadata,
|
|
8994
|
+
tags: _nullishCoalesce(hooks.tags, () => ( []))
|
|
8995
|
+
};
|
|
8996
|
+
}
|
|
8835
8997
|
function buildSpanMetadata(results) {
|
|
8836
|
-
return results.length === 1 ? results[0].metadata :
|
|
8837
|
-
(
|
|
8838
|
-
{}
|
|
8998
|
+
return results.length === 1 ? results[0].metadata : Object.fromEntries(
|
|
8999
|
+
results.map((result) => [result.name, result.metadata])
|
|
8839
9000
|
);
|
|
8840
9001
|
}
|
|
8841
9002
|
function buildSpanScores(results) {
|
|
8842
|
-
const scoresRecord =
|
|
8843
|
-
(
|
|
8844
|
-
{}
|
|
9003
|
+
const scoresRecord = Object.fromEntries(
|
|
9004
|
+
results.map((result) => [result.name, result.score])
|
|
8845
9005
|
);
|
|
8846
9006
|
return { resultMetadata: buildSpanMetadata(results), scoresRecord };
|
|
8847
9007
|
}
|
|
9008
|
+
function _internalPrepareEvaluatorScore(scoreValue, name) {
|
|
9009
|
+
if (scoreValue === null) return { results: null };
|
|
9010
|
+
if (Array.isArray(scoreValue)) {
|
|
9011
|
+
for (const score of scoreValue) {
|
|
9012
|
+
if (!(typeof score === "object" && !_chunkOBBWQW6Kjs.isEmpty.call(void 0, score))) {
|
|
9013
|
+
throw new Error(
|
|
9014
|
+
`When returning an array of scores, each score must be a non-empty object. Got: ${JSON.stringify(score)}`
|
|
9015
|
+
);
|
|
9016
|
+
}
|
|
9017
|
+
}
|
|
9018
|
+
}
|
|
9019
|
+
let results;
|
|
9020
|
+
if (Array.isArray(scoreValue)) {
|
|
9021
|
+
results = scoreValue;
|
|
9022
|
+
} else if (typeof scoreValue === "object" && !_chunkOBBWQW6Kjs.isEmpty.call(void 0, scoreValue)) {
|
|
9023
|
+
results = [scoreValue];
|
|
9024
|
+
} else {
|
|
9025
|
+
results = [{ name, score: scoreValue }];
|
|
9026
|
+
}
|
|
9027
|
+
const { resultMetadata, scoresRecord } = buildSpanScores(results);
|
|
9028
|
+
const fields = (score) => {
|
|
9029
|
+
const { metadata: _metadata, name: _name, ...rest } = score;
|
|
9030
|
+
return rest;
|
|
9031
|
+
};
|
|
9032
|
+
return {
|
|
9033
|
+
results,
|
|
9034
|
+
output: results.length === 1 ? fields(results[0]) : Object.fromEntries(
|
|
9035
|
+
results.map((score) => [_nullishCoalesce(score.name, () => ( name)), fields(score)])
|
|
9036
|
+
),
|
|
9037
|
+
metadata: resultMetadata,
|
|
9038
|
+
scores: scoresRecord
|
|
9039
|
+
};
|
|
9040
|
+
}
|
|
8848
9041
|
async function runInScorerSpan(rootSpan, spanName, spanType, propagatedEvent, eventInput, fn) {
|
|
8849
9042
|
try {
|
|
8850
9043
|
const value = await rootSpan.traced(fn, {
|
|
@@ -8870,7 +9063,7 @@ function collectScoringResults(runResults, names, onResult) {
|
|
|
8870
9063
|
return failing;
|
|
8871
9064
|
}
|
|
8872
9065
|
function validateClassificationResult(value, scorerName2) {
|
|
8873
|
-
if (!(typeof value === "object" && value !== null && !
|
|
9066
|
+
if (!(typeof value === "object" && value !== null && !_chunkOBBWQW6Kjs.isEmpty.call(void 0, value))) {
|
|
8874
9067
|
throw new Error(
|
|
8875
9068
|
`When returning structured classifier results, each classification must be a non-empty object. Got: ${JSON.stringify(value)}`
|
|
8876
9069
|
);
|
|
@@ -8889,6 +9082,27 @@ function toClassificationItem(c) {
|
|
|
8889
9082
|
...c.metadata !== void 0 ? { metadata: c.metadata } : {}
|
|
8890
9083
|
};
|
|
8891
9084
|
}
|
|
9085
|
+
function _internalPrepareEvaluatorClassification(value, name) {
|
|
9086
|
+
if (value === null) return { results: null };
|
|
9087
|
+
const results = (Array.isArray(value) ? value : [value]).map(
|
|
9088
|
+
(result) => validateClassificationResult(result, name)
|
|
9089
|
+
);
|
|
9090
|
+
const classifications = /* @__PURE__ */ Object.create(null);
|
|
9091
|
+
for (const result of results) {
|
|
9092
|
+
(classifications[result.name] ??= []).push(toClassificationItem(result));
|
|
9093
|
+
}
|
|
9094
|
+
return {
|
|
9095
|
+
results,
|
|
9096
|
+
output: results.length === 1 ? toClassificationItem(results[0]) : Object.fromEntries(
|
|
9097
|
+
results.map((result) => [
|
|
9098
|
+
result.name,
|
|
9099
|
+
toClassificationItem(result)
|
|
9100
|
+
])
|
|
9101
|
+
),
|
|
9102
|
+
metadata: buildSpanMetadata(results),
|
|
9103
|
+
classifications
|
|
9104
|
+
};
|
|
9105
|
+
}
|
|
8892
9106
|
function logScoringFailures(kind, failures, metadata, rootSpan, state) {
|
|
8893
9107
|
if (!failures.length) return [];
|
|
8894
9108
|
const errorMap = Object.fromEntries(
|
|
@@ -8899,7 +9113,7 @@ function logScoringFailures(kind, failures, metadata, rootSpan, state) {
|
|
|
8899
9113
|
);
|
|
8900
9114
|
metadata[`${kind}_errors`] = errorMap;
|
|
8901
9115
|
rootSpan.log({ metadata: { [`${kind}_errors`]: errorMap } });
|
|
8902
|
-
|
|
9116
|
+
_chunkOBBWQW6Kjs.debugLogger.forState(state).warn(
|
|
8903
9117
|
`Found exceptions for the following ${kind}s: ${Object.keys(errorMap).join(", ")}`,
|
|
8904
9118
|
failures.map((f) => f.error)
|
|
8905
9119
|
);
|
|
@@ -8933,57 +9147,17 @@ var defaultErrorScoreHandler = ({
|
|
|
8933
9147
|
};
|
|
8934
9148
|
async function runEvaluatorInternal(experiment, evaluator, progressReporter, filters, stream, parameters, collectResults, enableCache) {
|
|
8935
9149
|
if (enableCache) {
|
|
8936
|
-
_optionalChain([(_nullishCoalesce(evaluator.state, () => (
|
|
9150
|
+
_optionalChain([(_nullishCoalesce(evaluator.state, () => ( _chunkOBBWQW6Kjs._internalGetGlobalState.call(void 0, )))), 'optionalAccess', _153 => _153.spanCache, 'optionalAccess', _154 => _154.start, 'call', _155 => _155()]);
|
|
8937
9151
|
}
|
|
8938
9152
|
try {
|
|
8939
|
-
if (typeof evaluator.data === "string") {
|
|
8940
|
-
throw new Error("Unimplemented: string data paths");
|
|
8941
|
-
}
|
|
8942
|
-
let dataResult = typeof evaluator.data === "function" ? evaluator.data() : evaluator.data;
|
|
8943
9153
|
parameters = await validateParameters(
|
|
8944
9154
|
_nullishCoalesce(parameters, () => ( {})),
|
|
8945
9155
|
evaluator.parameters
|
|
8946
9156
|
);
|
|
8947
|
-
|
|
8948
|
-
|
|
8949
|
-
|
|
8950
|
-
|
|
8951
|
-
if (!experiment) {
|
|
8952
|
-
throw new Error(
|
|
8953
|
-
"Cannot use BaseExperiment() without connecting to Braintrust (you most likely set --no-send-logs)"
|
|
8954
|
-
);
|
|
8955
|
-
}
|
|
8956
|
-
let name = dataResult.name;
|
|
8957
|
-
if (_chunkQRHGVBKUjs.isEmpty.call(void 0, name)) {
|
|
8958
|
-
const baseExperiment = await experiment.fetchBaseExperiment();
|
|
8959
|
-
if (!baseExperiment) {
|
|
8960
|
-
throw new Error("BaseExperiment() failed to fetch base experiment");
|
|
8961
|
-
}
|
|
8962
|
-
name = baseExperiment.name;
|
|
8963
|
-
}
|
|
8964
|
-
dataResult = initExperiment2(evaluator.state, {
|
|
8965
|
-
...evaluator.projectId ? { projectId: evaluator.projectId } : { project: evaluator.projectName },
|
|
8966
|
-
experiment: name,
|
|
8967
|
-
open: true
|
|
8968
|
-
}).asDataset();
|
|
8969
|
-
}
|
|
8970
|
-
const resolvedDataResult = dataResult instanceof Promise ? await dataResult : dataResult;
|
|
8971
|
-
const dataIterable = (() => {
|
|
8972
|
-
if (isAsyncIterable2(resolvedDataResult)) {
|
|
8973
|
-
return resolvedDataResult;
|
|
8974
|
-
}
|
|
8975
|
-
if (Array.isArray(resolvedDataResult) || isIterable(resolvedDataResult)) {
|
|
8976
|
-
const iterable = resolvedDataResult;
|
|
8977
|
-
return (async function* () {
|
|
8978
|
-
for (const datum of iterable) {
|
|
8979
|
-
yield datum;
|
|
8980
|
-
}
|
|
8981
|
-
})();
|
|
8982
|
-
}
|
|
8983
|
-
throw new Error(
|
|
8984
|
-
"Evaluator data must be an array, iterable, or async iterable"
|
|
8985
|
-
);
|
|
8986
|
-
})();
|
|
9157
|
+
const dataIterable = await _internalResolveEvaluatorData(
|
|
9158
|
+
evaluator,
|
|
9159
|
+
experiment
|
|
9160
|
+
);
|
|
8987
9161
|
progressReporter.start(evaluator.evalName, 0);
|
|
8988
9162
|
const experimentIdPromise = experiment ? (async () => {
|
|
8989
9163
|
try {
|
|
@@ -9004,7 +9178,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
9004
9178
|
if (cancelled) {
|
|
9005
9179
|
return;
|
|
9006
9180
|
}
|
|
9007
|
-
const eventDataset = experiment ? experiment.dataset :
|
|
9181
|
+
const eventDataset = experiment ? experiment.dataset : _chunkOBBWQW6Kjs.Dataset.isDataset(evaluator.data) ? evaluator.data : void 0;
|
|
9008
9182
|
const inlineDatasetOrigin = eventDataset && datum.id && datum._xact_id ? {
|
|
9009
9183
|
object_type: "dataset",
|
|
9010
9184
|
object_id: await eventDataset.id,
|
|
@@ -9012,7 +9186,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
9012
9186
|
created: datum.created,
|
|
9013
9187
|
_xact_id: datum._xact_id
|
|
9014
9188
|
} : void 0;
|
|
9015
|
-
const parsedDatumOrigin =
|
|
9189
|
+
const parsedDatumOrigin = _chunkOBBWQW6Kjs.ObjectReference.safeParse(datum.origin);
|
|
9016
9190
|
const origin = _nullishCoalesce(inlineDatasetOrigin, () => ( (_optionalChain([parsedDatumOrigin, 'optionalAccess', _156 => _156.success]) ? parsedDatumOrigin.data : void 0)));
|
|
9017
9191
|
const baseEvent = {
|
|
9018
9192
|
name: "eval",
|
|
@@ -9028,23 +9202,23 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
9028
9202
|
}
|
|
9029
9203
|
};
|
|
9030
9204
|
const callback = async (rootSpan) => {
|
|
9031
|
-
const state = _nullishCoalesce(evaluator.state, () => (
|
|
9205
|
+
const state = _nullishCoalesce(evaluator.state, () => ( _chunkOBBWQW6Kjs._internalGetGlobalState.call(void 0, )));
|
|
9032
9206
|
const ensureSpansFlushed = async () => {
|
|
9033
9207
|
if (experiment) {
|
|
9034
|
-
await
|
|
9208
|
+
await _chunkOBBWQW6Kjs.flush.call(void 0, { state: experiment.loggingState });
|
|
9035
9209
|
} else if (state) {
|
|
9036
|
-
await
|
|
9210
|
+
await _chunkOBBWQW6Kjs.flush.call(void 0, { state });
|
|
9037
9211
|
} else {
|
|
9038
|
-
await
|
|
9212
|
+
await _chunkOBBWQW6Kjs.flush.call(void 0, );
|
|
9039
9213
|
}
|
|
9040
9214
|
if (state) {
|
|
9041
9215
|
await state.flushOtel();
|
|
9042
9216
|
}
|
|
9043
9217
|
};
|
|
9044
9218
|
const parentStr = state.currentParent.getStore();
|
|
9045
|
-
const parentComponents = typeof parentStr === "string" ?
|
|
9219
|
+
const parentComponents = typeof parentStr === "string" ? _chunkOBBWQW6Kjs.SpanComponentsV4.fromStr(parentStr) : null;
|
|
9046
9220
|
const trace = state ? new LocalTrace({
|
|
9047
|
-
objectType: parentComponents ?
|
|
9221
|
+
objectType: parentComponents ? _chunkOBBWQW6Kjs.spanObjectTypeV3ToTypedString.call(void 0,
|
|
9048
9222
|
parentComponents.data.object_type
|
|
9049
9223
|
) : "experiment",
|
|
9050
9224
|
objectId: await _asyncNullishCoalesce(await _asyncOptionalChain([parentComponents, 'optionalAccess', async _157 => _157.data, 'access', async _158 => _158.object_id]), async () => ( (experimentIdPromise ? await _asyncNullishCoalesce(await experimentIdPromise, async () => ( "")) : ""))),
|
|
@@ -9052,57 +9226,45 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
9052
9226
|
ensureSpansFlushed,
|
|
9053
9227
|
state
|
|
9054
9228
|
}) : void 0;
|
|
9055
|
-
let metadata = {
|
|
9056
|
-
..."metadata" in datum ? datum.metadata : {}
|
|
9057
|
-
};
|
|
9229
|
+
let metadata = {};
|
|
9058
9230
|
const expected = "expected" in datum ? datum.expected : void 0;
|
|
9059
9231
|
let output = void 0;
|
|
9060
9232
|
let error = void 0;
|
|
9061
|
-
let tags = [
|
|
9062
|
-
const scores =
|
|
9063
|
-
const classifications =
|
|
9233
|
+
let tags = [];
|
|
9234
|
+
const scores = /* @__PURE__ */ Object.create(null);
|
|
9235
|
+
const classifications = /* @__PURE__ */ Object.create(null);
|
|
9064
9236
|
const scorerNames = (_nullishCoalesce(evaluator.scores, () => ( []))).map(scorerName);
|
|
9065
9237
|
const classifierNames = (_nullishCoalesce(evaluator.classifiers, () => ( []))).map(
|
|
9066
9238
|
classifierName
|
|
9067
9239
|
);
|
|
9068
9240
|
let unhandledScores = scorerNames;
|
|
9069
9241
|
try {
|
|
9070
|
-
const
|
|
9071
|
-
|
|
9072
|
-
|
|
9073
|
-
|
|
9074
|
-
|
|
9075
|
-
|
|
9076
|
-
|
|
9077
|
-
|
|
9078
|
-
|
|
9079
|
-
|
|
9080
|
-
|
|
9081
|
-
|
|
9082
|
-
|
|
9083
|
-
|
|
9084
|
-
|
|
9085
|
-
object_type: "task"
|
|
9086
|
-
})]);
|
|
9087
|
-
},
|
|
9088
|
-
trialIndex,
|
|
9089
|
-
tags
|
|
9090
|
-
};
|
|
9091
|
-
const outputResult = evaluator.task(datum.input, hooksForTask);
|
|
9092
|
-
if (outputResult instanceof Promise) {
|
|
9093
|
-
output = await outputResult;
|
|
9094
|
-
} else {
|
|
9095
|
-
output = outputResult;
|
|
9242
|
+
const taskResult = await rootSpan.traced(
|
|
9243
|
+
(span) => _internalRunEvaluatorTask(
|
|
9244
|
+
evaluator.task,
|
|
9245
|
+
datum,
|
|
9246
|
+
trialIndex,
|
|
9247
|
+
_nullishCoalesce(parameters, () => ( {})),
|
|
9248
|
+
span,
|
|
9249
|
+
(event) => {
|
|
9250
|
+
_optionalChain([stream, 'optionalCall', _159 => _159({
|
|
9251
|
+
...event,
|
|
9252
|
+
id: rootSpan.id,
|
|
9253
|
+
origin: _optionalChain([baseEvent, 'access', _160 => _160.event, 'optionalAccess', _161 => _161.origin]),
|
|
9254
|
+
name: evaluator.evalName,
|
|
9255
|
+
object_type: "task"
|
|
9256
|
+
})]);
|
|
9096
9257
|
}
|
|
9097
|
-
|
|
9098
|
-
span.log({ output });
|
|
9099
|
-
},
|
|
9258
|
+
),
|
|
9100
9259
|
{
|
|
9101
9260
|
name: "task",
|
|
9102
9261
|
spanAttributes: { type: "task" /* TASK */ },
|
|
9103
9262
|
event: { input: datum.input }
|
|
9104
9263
|
}
|
|
9105
9264
|
);
|
|
9265
|
+
output = taskResult.output;
|
|
9266
|
+
metadata = taskResult.metadata;
|
|
9267
|
+
tags = taskResult.tags;
|
|
9106
9268
|
if (tags.length) {
|
|
9107
9269
|
rootSpan.log({ output, metadata, expected, tags });
|
|
9108
9270
|
} else {
|
|
@@ -9112,20 +9274,18 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
9112
9274
|
await rootSpan.flush();
|
|
9113
9275
|
}
|
|
9114
9276
|
const scoringArgs = {
|
|
9277
|
+
id: datum.id,
|
|
9115
9278
|
input: datum.input,
|
|
9116
9279
|
expected: "expected" in datum ? datum.expected : void 0,
|
|
9117
9280
|
metadata,
|
|
9118
9281
|
output,
|
|
9282
|
+
tags,
|
|
9119
9283
|
trace
|
|
9120
9284
|
};
|
|
9121
9285
|
const { trace: _trace, ...scoringArgsForLogging } = scoringArgs;
|
|
9122
|
-
const propagatedEvent =
|
|
9286
|
+
const propagatedEvent = _chunkOBBWQW6Kjs.makeScorerPropagatedEvent.call(void 0,
|
|
9123
9287
|
await rootSpan.export()
|
|
9124
9288
|
);
|
|
9125
|
-
const getOtherFields = (s) => {
|
|
9126
|
-
const { metadata: _metadata, name: _name, ...rest } = s;
|
|
9127
|
-
return rest;
|
|
9128
|
-
};
|
|
9129
9289
|
const [scoreResults, classificationResults] = await Promise.all([
|
|
9130
9290
|
Promise.all(
|
|
9131
9291
|
(_nullishCoalesce(evaluator.scores, () => ( []))).map(
|
|
@@ -9139,35 +9299,17 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
9139
9299
|
const scoreValue = await Promise.resolve(
|
|
9140
9300
|
score(scoringArgs)
|
|
9141
9301
|
);
|
|
9142
|
-
|
|
9143
|
-
|
|
9144
|
-
|
|
9145
|
-
if (!(typeof s === "object" && !_chunkQRHGVBKUjs.isEmpty.call(void 0, s))) {
|
|
9146
|
-
throw new Error(
|
|
9147
|
-
`When returning an array of scores, each score must be a non-empty object. Got: ${JSON.stringify(s)}`
|
|
9148
|
-
);
|
|
9149
|
-
}
|
|
9150
|
-
}
|
|
9151
|
-
}
|
|
9152
|
-
const results = Array.isArray(scoreValue) ? scoreValue : typeof scoreValue === "object" && !_chunkQRHGVBKUjs.isEmpty.call(void 0, scoreValue) ? [scoreValue] : [
|
|
9153
|
-
{
|
|
9154
|
-
name: scorerNames[score_idx],
|
|
9155
|
-
score: scoreValue
|
|
9156
|
-
}
|
|
9157
|
-
];
|
|
9158
|
-
const { resultMetadata, scoresRecord } = buildSpanScores(results);
|
|
9159
|
-
const resultOutput = results.length === 1 ? getOtherFields(results[0]) : results.reduce(
|
|
9160
|
-
(prev, s) => _chunkQRHGVBKUjs.mergeDicts.call(void 0, prev, {
|
|
9161
|
-
[s.name]: getOtherFields(s)
|
|
9162
|
-
}),
|
|
9163
|
-
{}
|
|
9302
|
+
const prepared = _internalPrepareEvaluatorScore(
|
|
9303
|
+
scoreValue,
|
|
9304
|
+
scorerNames[score_idx]
|
|
9164
9305
|
);
|
|
9306
|
+
if (prepared.results === null) return null;
|
|
9165
9307
|
span.log({
|
|
9166
|
-
output:
|
|
9167
|
-
metadata:
|
|
9168
|
-
scores:
|
|
9308
|
+
output: prepared.output,
|
|
9309
|
+
metadata: prepared.metadata,
|
|
9310
|
+
scores: prepared.scores
|
|
9169
9311
|
});
|
|
9170
|
-
return results;
|
|
9312
|
+
return prepared.results;
|
|
9171
9313
|
}
|
|
9172
9314
|
)
|
|
9173
9315
|
)
|
|
@@ -9184,24 +9326,16 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
9184
9326
|
const classifierValue = await Promise.resolve(
|
|
9185
9327
|
classifier(scoringArgs)
|
|
9186
9328
|
);
|
|
9187
|
-
|
|
9188
|
-
|
|
9189
|
-
|
|
9190
|
-
result,
|
|
9191
|
-
classifierNames[idx]
|
|
9192
|
-
)
|
|
9193
|
-
);
|
|
9194
|
-
const resultOutput = rawResults.length === 1 ? toClassificationItem(rawResults[0]) : rawResults.reduce(
|
|
9195
|
-
(prev, r) => _chunkQRHGVBKUjs.mergeDicts.call(void 0, prev, {
|
|
9196
|
-
[r.name]: toClassificationItem(r)
|
|
9197
|
-
}),
|
|
9198
|
-
{}
|
|
9329
|
+
const prepared = _internalPrepareEvaluatorClassification(
|
|
9330
|
+
classifierValue,
|
|
9331
|
+
classifierNames[idx]
|
|
9199
9332
|
);
|
|
9333
|
+
if (prepared.results === null) return null;
|
|
9200
9334
|
span.log({
|
|
9201
|
-
output:
|
|
9202
|
-
metadata:
|
|
9335
|
+
output: prepared.output,
|
|
9336
|
+
metadata: prepared.metadata
|
|
9203
9337
|
});
|
|
9204
|
-
return
|
|
9338
|
+
return prepared.results;
|
|
9205
9339
|
}
|
|
9206
9340
|
)
|
|
9207
9341
|
)
|
|
@@ -9244,7 +9378,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
9244
9378
|
evaluator.state
|
|
9245
9379
|
);
|
|
9246
9380
|
} catch (e) {
|
|
9247
|
-
|
|
9381
|
+
_chunkOBBWQW6Kjs.logError.call(void 0, rootSpan, e);
|
|
9248
9382
|
error = e;
|
|
9249
9383
|
} finally {
|
|
9250
9384
|
progressReporter.increment(evaluator.evalName);
|
|
@@ -9278,7 +9412,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
9278
9412
|
}
|
|
9279
9413
|
};
|
|
9280
9414
|
if (!experiment) {
|
|
9281
|
-
return await
|
|
9415
|
+
return await _chunkOBBWQW6Kjs.traced.call(void 0, callback, {
|
|
9282
9416
|
...baseEvent,
|
|
9283
9417
|
state: evaluator.state
|
|
9284
9418
|
});
|
|
@@ -9332,7 +9466,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
9332
9466
|
const cancel = async () => {
|
|
9333
9467
|
await new Promise((_, reject2) => {
|
|
9334
9468
|
if (cancelled) {
|
|
9335
|
-
reject2(new (0,
|
|
9469
|
+
reject2(new (0, _chunkOBBWQW6Kjs.InternalAbortError)("Evaluator already cancelled"));
|
|
9336
9470
|
return;
|
|
9337
9471
|
}
|
|
9338
9472
|
const rejectOnce = (error) => {
|
|
@@ -9345,12 +9479,12 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
9345
9479
|
};
|
|
9346
9480
|
if (evaluator.timeout) {
|
|
9347
9481
|
timeoutId = setTimeout(() => {
|
|
9348
|
-
rejectOnce(new (0,
|
|
9482
|
+
rejectOnce(new (0, _chunkOBBWQW6Kjs.InternalAbortError)("Evaluator timed out"));
|
|
9349
9483
|
}, evaluator.timeout);
|
|
9350
9484
|
}
|
|
9351
9485
|
if (evaluator.signal) {
|
|
9352
9486
|
abortHandler = () => {
|
|
9353
|
-
rejectOnce(new (0,
|
|
9487
|
+
rejectOnce(new (0, _chunkOBBWQW6Kjs.InternalAbortError)("Evaluator aborted"));
|
|
9354
9488
|
};
|
|
9355
9489
|
evaluator.signal.addEventListener("abort", abortHandler);
|
|
9356
9490
|
}
|
|
@@ -9373,9 +9507,9 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
9373
9507
|
}
|
|
9374
9508
|
} catch (e) {
|
|
9375
9509
|
q.kill();
|
|
9376
|
-
if (e instanceof
|
|
9377
|
-
if (
|
|
9378
|
-
|
|
9510
|
+
if (e instanceof _chunkOBBWQW6Kjs.InternalAbortError) {
|
|
9511
|
+
if (_chunkBBE7SNRVjs.isomorph_default.getEnv("BRAINTRUST_VERBOSE")) {
|
|
9512
|
+
_chunkOBBWQW6Kjs.debugLogger.forState(evaluator.state).warn("Evaluator cancelled:", e.message);
|
|
9379
9513
|
}
|
|
9380
9514
|
}
|
|
9381
9515
|
throw e;
|
|
@@ -9400,7 +9534,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
9400
9534
|
);
|
|
9401
9535
|
} finally {
|
|
9402
9536
|
if (enableCache) {
|
|
9403
|
-
const spanCache = _optionalChain([(_nullishCoalesce(evaluator.state, () => (
|
|
9537
|
+
const spanCache = _optionalChain([(_nullishCoalesce(evaluator.state, () => ( _chunkOBBWQW6Kjs._internalGetGlobalState.call(void 0, )))), 'optionalAccess', _166 => _166.spanCache]);
|
|
9404
9538
|
_optionalChain([spanCache, 'optionalAccess', _167 => _167.dispose, 'call', _168 => _168()]);
|
|
9405
9539
|
_optionalChain([spanCache, 'optionalAccess', _169 => _169.stop, 'call', _170 => _170()]);
|
|
9406
9540
|
}
|
|
@@ -9430,7 +9564,7 @@ function accumulateScores(accumulator, scores) {
|
|
|
9430
9564
|
}
|
|
9431
9565
|
}
|
|
9432
9566
|
function ensureScoreAccumulator(results) {
|
|
9433
|
-
const accumulator =
|
|
9567
|
+
const accumulator = /* @__PURE__ */ Object.create(null);
|
|
9434
9568
|
for (const result of results) {
|
|
9435
9569
|
accumulateScores(accumulator, result.scores);
|
|
9436
9570
|
}
|
|
@@ -9495,25 +9629,25 @@ var defaultReporter = {
|
|
|
9495
9629
|
reportFailures(evaluator, failingResults, { verbose, jsonl });
|
|
9496
9630
|
}
|
|
9497
9631
|
if (jsonl) {
|
|
9498
|
-
|
|
9632
|
+
_chunkBBE7SNRVjs.isomorph_default.writeln(JSON.stringify(summary));
|
|
9499
9633
|
} else {
|
|
9500
|
-
|
|
9501
|
-
|
|
9634
|
+
_chunkBBE7SNRVjs.isomorph_default.writeln("Experiment summary");
|
|
9635
|
+
_chunkBBE7SNRVjs.isomorph_default.writeln("==================");
|
|
9502
9636
|
if (summary.comparisonExperimentName) {
|
|
9503
|
-
|
|
9637
|
+
_chunkBBE7SNRVjs.isomorph_default.writeln(
|
|
9504
9638
|
`${summary.comparisonExperimentName} (baseline) <- ${summary.experimentName} (comparison)`
|
|
9505
9639
|
);
|
|
9506
|
-
|
|
9640
|
+
_chunkBBE7SNRVjs.isomorph_default.writeln("");
|
|
9507
9641
|
}
|
|
9508
9642
|
const hasScores = Object.keys(summary.scores).length > 0;
|
|
9509
9643
|
const hasMetrics = Object.keys(_nullishCoalesce(summary.metrics, () => ( {}))).length > 0;
|
|
9510
9644
|
const hasComparison = !!summary.comparisonExperimentName;
|
|
9511
9645
|
if (hasScores || hasMetrics) {
|
|
9512
9646
|
if (hasComparison) {
|
|
9513
|
-
|
|
9647
|
+
_chunkBBE7SNRVjs.isomorph_default.writeln(
|
|
9514
9648
|
"Name Value Change Improvements Regressions"
|
|
9515
9649
|
);
|
|
9516
|
-
|
|
9650
|
+
_chunkBBE7SNRVjs.isomorph_default.writeln(
|
|
9517
9651
|
"----------------------------------------------------------------"
|
|
9518
9652
|
);
|
|
9519
9653
|
}
|
|
@@ -9522,18 +9656,18 @@ var defaultReporter = {
|
|
|
9522
9656
|
const scoreValue = `${scorePercent}%`;
|
|
9523
9657
|
if (hasComparison) {
|
|
9524
9658
|
let diffString = "-";
|
|
9525
|
-
if (!
|
|
9659
|
+
if (!_chunkOBBWQW6Kjs.isEmpty.call(void 0, score.diff)) {
|
|
9526
9660
|
const diffPercent = (score.diff * 100).toFixed(2);
|
|
9527
9661
|
const diffSign = score.diff > 0 ? "+" : "";
|
|
9528
9662
|
diffString = `${diffSign}${diffPercent}%`;
|
|
9529
9663
|
}
|
|
9530
9664
|
const improvements = score.improvements > 0 ? score.improvements.toString() : "-";
|
|
9531
9665
|
const regressions = score.regressions > 0 ? score.regressions.toString() : "-";
|
|
9532
|
-
|
|
9666
|
+
_chunkBBE7SNRVjs.isomorph_default.writeln(
|
|
9533
9667
|
`${score.name.padEnd(18)} ${scoreValue.padStart(10)} ${diffString.padStart(10)} ${improvements.padStart(12)} ${regressions.padStart(11)}`
|
|
9534
9668
|
);
|
|
9535
9669
|
} else {
|
|
9536
|
-
|
|
9670
|
+
_chunkBBE7SNRVjs.isomorph_default.writeln(`${score.name.padEnd(20)} ${scoreValue.padStart(15)}`);
|
|
9537
9671
|
}
|
|
9538
9672
|
}
|
|
9539
9673
|
for (const metric of Object.values(_nullishCoalesce(summary.metrics, () => ( {})))) {
|
|
@@ -9542,30 +9676,30 @@ var defaultReporter = {
|
|
|
9542
9676
|
const metricValue = metric.unit === "$" ? `${metric.unit}${formattedValue}` : `${formattedValue}${metric.unit}`;
|
|
9543
9677
|
if (hasComparison) {
|
|
9544
9678
|
let diffString = "-";
|
|
9545
|
-
if (!
|
|
9679
|
+
if (!_chunkOBBWQW6Kjs.isEmpty.call(void 0, metric.diff)) {
|
|
9546
9680
|
const diffPercent = (metric.diff * 100).toFixed(2);
|
|
9547
9681
|
const diffSign = metric.diff > 0 ? "+" : "";
|
|
9548
9682
|
diffString = `${diffSign}${diffPercent}%`;
|
|
9549
9683
|
}
|
|
9550
9684
|
const improvements = metric.improvements > 0 ? metric.improvements.toString() : "-";
|
|
9551
9685
|
const regressions = metric.regressions > 0 ? metric.regressions.toString() : "-";
|
|
9552
|
-
|
|
9686
|
+
_chunkBBE7SNRVjs.isomorph_default.writeln(
|
|
9553
9687
|
`${metric.name.padEnd(18)} ${metricValue.padStart(10)} ${diffString.padStart(10)} ${improvements.padStart(12)} ${regressions.padStart(11)}`
|
|
9554
9688
|
);
|
|
9555
9689
|
} else {
|
|
9556
|
-
|
|
9690
|
+
_chunkBBE7SNRVjs.isomorph_default.writeln(
|
|
9557
9691
|
`${metric.name.padEnd(20)} ${metricValue.padStart(15)}`
|
|
9558
9692
|
);
|
|
9559
9693
|
}
|
|
9560
9694
|
}
|
|
9561
9695
|
}
|
|
9562
9696
|
if (summary.experimentUrl) {
|
|
9563
|
-
|
|
9564
|
-
|
|
9565
|
-
|
|
9697
|
+
_chunkBBE7SNRVjs.isomorph_default.writeln("");
|
|
9698
|
+
_chunkBBE7SNRVjs.isomorph_default.writeln(`View results for ${summary.experimentName}`);
|
|
9699
|
+
_chunkBBE7SNRVjs.isomorph_default.writeln(`See results at ${summary.experimentUrl}`);
|
|
9566
9700
|
}
|
|
9567
9701
|
}
|
|
9568
|
-
|
|
9702
|
+
_chunkBBE7SNRVjs.isomorph_default.writeln("");
|
|
9569
9703
|
return failingResults.length === 0;
|
|
9570
9704
|
},
|
|
9571
9705
|
async reportRun(evalReports) {
|
|
@@ -9573,6 +9707,1156 @@ var defaultReporter = {
|
|
|
9573
9707
|
}
|
|
9574
9708
|
};
|
|
9575
9709
|
|
|
9710
|
+
// src/durable-eval.ts
|
|
9711
|
+
var encoder = new TextEncoder();
|
|
9712
|
+
var decoder = new TextDecoder();
|
|
9713
|
+
var BATCH_TASK_KIND = "braintrust.durable.batch-task";
|
|
9714
|
+
var BATCH_SCORER_KIND = "braintrust.durable.batch-scorer";
|
|
9715
|
+
var DEFAULT_BATCH_SIZE = 1e3;
|
|
9716
|
+
var DurableEvalMemoryStore = (_class7 = class {constructor() { _class7.prototype.__init16.call(this); }
|
|
9717
|
+
__init16() {this.values = /* @__PURE__ */ new Map()}
|
|
9718
|
+
async read(key) {
|
|
9719
|
+
return _optionalChain([this, 'access', _171 => _171.values, 'access', _172 => _172.get, 'call', _173 => _173(key), 'optionalAccess', _174 => _174.slice, 'call', _175 => _175()]);
|
|
9720
|
+
}
|
|
9721
|
+
async write(key, value) {
|
|
9722
|
+
this.values.set(key, value.slice());
|
|
9723
|
+
}
|
|
9724
|
+
async getOrSet(key, value) {
|
|
9725
|
+
const existing = this.values.get(key);
|
|
9726
|
+
if (existing) return { value: existing.slice(), created: false };
|
|
9727
|
+
this.values.set(key, value.slice());
|
|
9728
|
+
return { value: value.slice(), created: true };
|
|
9729
|
+
}
|
|
9730
|
+
}, _class7);
|
|
9731
|
+
var DurableEvalRedisStore = class {
|
|
9732
|
+
|
|
9733
|
+
|
|
9734
|
+
|
|
9735
|
+
constructor(options) {
|
|
9736
|
+
this.client = options.client;
|
|
9737
|
+
this.keyPrefix = _nullishCoalesce(options.keyPrefix, () => ( "braintrust-eval:"));
|
|
9738
|
+
this.ttlMs = _nullishCoalesce(options.ttlMs, () => ( 1e3 * 60 * 60 * 24 * 7));
|
|
9739
|
+
if (!Number.isInteger(this.ttlMs) || this.ttlMs < 1) {
|
|
9740
|
+
throw new Error("DurableEvalRedisStore ttlMs must be a positive integer");
|
|
9741
|
+
}
|
|
9742
|
+
}
|
|
9743
|
+
async read(key) {
|
|
9744
|
+
const value = await this.client.get(`${this.keyPrefix}${key}`);
|
|
9745
|
+
if (value == null) return void 0;
|
|
9746
|
+
if (typeof value !== "string") {
|
|
9747
|
+
throw new Error("DurableEvalRedisStore expected GET to return a string");
|
|
9748
|
+
}
|
|
9749
|
+
return _chunkOBBWQW6Kjs.base64ToUint8Array.call(void 0, value);
|
|
9750
|
+
}
|
|
9751
|
+
async write(key, value) {
|
|
9752
|
+
const client = this.client;
|
|
9753
|
+
const set = client.set;
|
|
9754
|
+
const redisKey = `${this.keyPrefix}${key}`;
|
|
9755
|
+
const encoded = _chunkOBBWQW6Kjs.uint8ArrayToBase64.call(void 0, value);
|
|
9756
|
+
if (typeof client.defineCommand === "function") {
|
|
9757
|
+
await set.call(client, redisKey, encoded, "PX", this.ttlMs);
|
|
9758
|
+
} else if (typeof client.sendCommand === "function") {
|
|
9759
|
+
await set.call(client, redisKey, encoded, { PX: this.ttlMs });
|
|
9760
|
+
} else if (typeof client.createScript === "function") {
|
|
9761
|
+
await set.call(client, redisKey, encoded, { px: this.ttlMs });
|
|
9762
|
+
} else {
|
|
9763
|
+
throw new Error(
|
|
9764
|
+
"DurableEvalRedisStore requires a node-redis, ioredis, or @upstash/redis client"
|
|
9765
|
+
);
|
|
9766
|
+
}
|
|
9767
|
+
}
|
|
9768
|
+
async getOrSet(key, value) {
|
|
9769
|
+
const redisKey = `${this.keyPrefix}${key}`;
|
|
9770
|
+
const encoded = _chunkOBBWQW6Kjs.uint8ArrayToBase64.call(void 0, value);
|
|
9771
|
+
const client = this.client;
|
|
9772
|
+
const set = client.set;
|
|
9773
|
+
let setOptions;
|
|
9774
|
+
if (typeof client.defineCommand === "function") {
|
|
9775
|
+
setOptions = ["PX", this.ttlMs, "NX", "GET"];
|
|
9776
|
+
} else if (typeof client.sendCommand === "function") {
|
|
9777
|
+
setOptions = [{ PX: this.ttlMs, NX: true, GET: true }];
|
|
9778
|
+
} else if (typeof client.createScript === "function") {
|
|
9779
|
+
setOptions = [{ px: this.ttlMs, nx: true, get: true }];
|
|
9780
|
+
} else {
|
|
9781
|
+
throw new Error(
|
|
9782
|
+
"DurableEvalRedisStore getOrSet requires a node-redis, ioredis, or @upstash/redis client"
|
|
9783
|
+
);
|
|
9784
|
+
}
|
|
9785
|
+
const existing = await set.call(client, redisKey, encoded, ...setOptions);
|
|
9786
|
+
if (existing === null) return { value: value.slice(), created: true };
|
|
9787
|
+
if (typeof existing !== "string") {
|
|
9788
|
+
throw new Error(
|
|
9789
|
+
"DurableEvalRedisStore expected atomic SET to return a string or null"
|
|
9790
|
+
);
|
|
9791
|
+
}
|
|
9792
|
+
return { value: _chunkOBBWQW6Kjs.base64ToUint8Array.call(void 0, existing), created: false };
|
|
9793
|
+
}
|
|
9794
|
+
};
|
|
9795
|
+
var BatchTask = (_class8 = class {
|
|
9796
|
+
constructor(processor) {;_class8.prototype.__init17.call(this);
|
|
9797
|
+
this.processor = processor;
|
|
9798
|
+
}
|
|
9799
|
+
|
|
9800
|
+
__init17() {this.kind = BATCH_TASK_KIND}
|
|
9801
|
+
}, _class8);
|
|
9802
|
+
var BatchScorer = (_class9 = class {
|
|
9803
|
+
constructor(processor) {;_class9.prototype.__init18.call(this);
|
|
9804
|
+
this.processor = processor;
|
|
9805
|
+
this.name = processor.name;
|
|
9806
|
+
}
|
|
9807
|
+
|
|
9808
|
+
__init18() {this.kind = BATCH_SCORER_KIND}
|
|
9809
|
+
|
|
9810
|
+
}, _class9);
|
|
9811
|
+
function defineDurableEval(projectName, evaluator) {
|
|
9812
|
+
const definition = {
|
|
9813
|
+
projectName,
|
|
9814
|
+
evalName: _nullishCoalesce(evaluator.experimentName, () => ( projectName)),
|
|
9815
|
+
evaluator
|
|
9816
|
+
};
|
|
9817
|
+
return {
|
|
9818
|
+
start: (options = {}) => startDurableEval(definition, options),
|
|
9819
|
+
status: (options) => getDurableEvalStatus(definition, options),
|
|
9820
|
+
poll: (options) => pollDurableEval(definition, options),
|
|
9821
|
+
processBatchResult: (result) => processDurableBatchResult(definition, result)
|
|
9822
|
+
};
|
|
9823
|
+
}
|
|
9824
|
+
async function startDurableEval(definition, options) {
|
|
9825
|
+
const store = definition.evaluator.store;
|
|
9826
|
+
const runId = _chunkOBBWQW6Kjs.newId.call(void 0, );
|
|
9827
|
+
const key = runKey(definition.projectName, definition.evalName, runId);
|
|
9828
|
+
const { data } = callEvaluatorData(definition.evaluator.data);
|
|
9829
|
+
const parameters = await validateParameters(
|
|
9830
|
+
_nullishCoalesce(options.parameters, () => ( {})),
|
|
9831
|
+
definition.evaluator.parameters
|
|
9832
|
+
);
|
|
9833
|
+
const experimentName = _nullishCoalesce(definition.evaluator.experimentName, () => ( `${definition.evalName}-${runId}`));
|
|
9834
|
+
const experiment = await _internalInitEvaluatorExperiment(
|
|
9835
|
+
definition.projectName,
|
|
9836
|
+
{ ...definition.evaluator, data },
|
|
9837
|
+
data,
|
|
9838
|
+
{
|
|
9839
|
+
disabled: _nullishCoalesce(options.noSendLogs, () => ( false)),
|
|
9840
|
+
experimentName,
|
|
9841
|
+
update: true
|
|
9842
|
+
}
|
|
9843
|
+
);
|
|
9844
|
+
if (!isBatchTask(definition.evaluator.task) && !(_nullishCoalesce(definition.evaluator.scores, () => ( []))).some(isBatchScorer)) {
|
|
9845
|
+
const result = await runEvaluator(
|
|
9846
|
+
experiment,
|
|
9847
|
+
{
|
|
9848
|
+
...definition.evaluator,
|
|
9849
|
+
projectName: definition.projectName,
|
|
9850
|
+
evalName: definition.evalName,
|
|
9851
|
+
data
|
|
9852
|
+
},
|
|
9853
|
+
{
|
|
9854
|
+
start: () => void 0,
|
|
9855
|
+
stop: () => void 0,
|
|
9856
|
+
increment: () => void 0
|
|
9857
|
+
},
|
|
9858
|
+
[],
|
|
9859
|
+
void 0,
|
|
9860
|
+
parameters,
|
|
9861
|
+
true,
|
|
9862
|
+
true
|
|
9863
|
+
);
|
|
9864
|
+
const state2 = {
|
|
9865
|
+
runId,
|
|
9866
|
+
experimentName,
|
|
9867
|
+
noSendLogs: _nullishCoalesce(options.noSendLogs, () => ( false)),
|
|
9868
|
+
parameters: assertJsonValue(parameters, "eval parameters"),
|
|
9869
|
+
status: "completed",
|
|
9870
|
+
summary: result.summary,
|
|
9871
|
+
cases: [],
|
|
9872
|
+
batches: []
|
|
9873
|
+
};
|
|
9874
|
+
await _optionalChain([experiment, 'optionalAccess', _176 => _176.flush, 'call', _177 => _177()]);
|
|
9875
|
+
await writeRunRecord(store, key, state2);
|
|
9876
|
+
return currentStatus(definition, state2);
|
|
9877
|
+
}
|
|
9878
|
+
const state = {
|
|
9879
|
+
runId,
|
|
9880
|
+
experimentName,
|
|
9881
|
+
noSendLogs: _nullishCoalesce(options.noSendLogs, () => ( false)),
|
|
9882
|
+
parameters: assertJsonValue(parameters, "eval parameters"),
|
|
9883
|
+
status: "running",
|
|
9884
|
+
cases: await materializeCases(definition, data, experiment),
|
|
9885
|
+
batches: []
|
|
9886
|
+
};
|
|
9887
|
+
await writeCaseBaseRecords(store, key, state.cases);
|
|
9888
|
+
await writeRunRecord(store, key, state);
|
|
9889
|
+
return advanceDurableEval(definition, state, store, key, experiment);
|
|
9890
|
+
}
|
|
9891
|
+
async function getDurableEvalStatus(definition, options) {
|
|
9892
|
+
const store = definition.evaluator.store;
|
|
9893
|
+
const state = await readRunState(
|
|
9894
|
+
definition,
|
|
9895
|
+
store,
|
|
9896
|
+
runKey(definition.projectName, definition.evalName, options.runId)
|
|
9897
|
+
);
|
|
9898
|
+
if (!state) throw new Error(`Durable eval run ${options.runId} is missing`);
|
|
9899
|
+
return currentStatus(definition, state);
|
|
9900
|
+
}
|
|
9901
|
+
async function processDurableBatchResult(definition, result) {
|
|
9902
|
+
if (!result.batchId && !result.externalId) {
|
|
9903
|
+
throw new Error("Batch results require batchId or externalId");
|
|
9904
|
+
}
|
|
9905
|
+
const store = definition.evaluator.store;
|
|
9906
|
+
const key = runKey(definition.projectName, definition.evalName, result.runId);
|
|
9907
|
+
const state = await readRunState(definition, store, key);
|
|
9908
|
+
if (!state) throw new Error(`Durable eval run ${result.runId} is missing`);
|
|
9909
|
+
const byBatch = result.batchId ? state.batches.find((candidate) => candidate.id === result.batchId) : void 0;
|
|
9910
|
+
const byExternal = result.externalId ? state.batches.find(
|
|
9911
|
+
(candidate) => candidate.externalId === result.externalId
|
|
9912
|
+
) : void 0;
|
|
9913
|
+
if (byBatch && byExternal && byBatch.id !== byExternal.id) {
|
|
9914
|
+
throw new Error("batchId and externalId identify different batches");
|
|
9915
|
+
}
|
|
9916
|
+
const batch = _nullishCoalesce(byBatch, () => ( byExternal));
|
|
9917
|
+
if (!batch) throw new Error("No submitted batch matches this result");
|
|
9918
|
+
if (batch.status !== "complete") {
|
|
9919
|
+
const records = await collectBatch(definition, state, batch);
|
|
9920
|
+
batch.status = "complete";
|
|
9921
|
+
await writeCaseRecords(store, key, records);
|
|
9922
|
+
await writeBatchRecords(store, key, [batch]);
|
|
9923
|
+
}
|
|
9924
|
+
return advanceDurableEval(
|
|
9925
|
+
definition,
|
|
9926
|
+
await readRunState(definition, store, key),
|
|
9927
|
+
store,
|
|
9928
|
+
key
|
|
9929
|
+
);
|
|
9930
|
+
}
|
|
9931
|
+
async function pollDurableEval(definition, options) {
|
|
9932
|
+
const store = definition.evaluator.store;
|
|
9933
|
+
const key = runKey(
|
|
9934
|
+
definition.projectName,
|
|
9935
|
+
definition.evalName,
|
|
9936
|
+
options.runId
|
|
9937
|
+
);
|
|
9938
|
+
const state = await readRunState(definition, store, key);
|
|
9939
|
+
if (!state) throw new Error(`Durable eval run ${options.runId} is missing`);
|
|
9940
|
+
const batches = state.batches.filter((batch) => {
|
|
9941
|
+
if (batch.status === "complete") return false;
|
|
9942
|
+
return processorForStage(definition, batch.kind, batch.scorerName).completion.mode === "poll";
|
|
9943
|
+
});
|
|
9944
|
+
const results = await Promise.all(
|
|
9945
|
+
batches.map(async (batch) => ({
|
|
9946
|
+
batch,
|
|
9947
|
+
result: await processorForStage(definition, batch.kind, batch.scorerName).completion.poll(batch.submissionData, {
|
|
9948
|
+
runId: state.runId,
|
|
9949
|
+
batchId: batch.id
|
|
9950
|
+
})
|
|
9951
|
+
}))
|
|
9952
|
+
);
|
|
9953
|
+
const changedCases = /* @__PURE__ */ new Map();
|
|
9954
|
+
const changedBatches = [];
|
|
9955
|
+
for (const { batch, result } of results) {
|
|
9956
|
+
if (result.status === "failed") throw asError(result.error);
|
|
9957
|
+
if (result.status !== "complete") continue;
|
|
9958
|
+
for (const record of await collectBatch(definition, state, batch)) {
|
|
9959
|
+
changedCases.set(record.id, record);
|
|
9960
|
+
}
|
|
9961
|
+
batch.status = "complete";
|
|
9962
|
+
changedBatches.push(batch);
|
|
9963
|
+
}
|
|
9964
|
+
if (changedBatches.length > 0) {
|
|
9965
|
+
await writeCaseRecords(store, key, [...changedCases.values()]);
|
|
9966
|
+
await writeBatchRecords(store, key, changedBatches);
|
|
9967
|
+
}
|
|
9968
|
+
const currentState = changedBatches.length > 0 ? await readRunState(definition, store, key) : state;
|
|
9969
|
+
return advanceDurableEval(definition, currentState, store, key);
|
|
9970
|
+
}
|
|
9971
|
+
async function openDurableExperiment(definition, state) {
|
|
9972
|
+
const data = [];
|
|
9973
|
+
return await _internalInitEvaluatorExperiment(
|
|
9974
|
+
definition.projectName,
|
|
9975
|
+
{ ...definition.evaluator, data },
|
|
9976
|
+
data,
|
|
9977
|
+
{
|
|
9978
|
+
disabled: state.noSendLogs,
|
|
9979
|
+
experimentName: state.experimentName,
|
|
9980
|
+
update: true
|
|
9981
|
+
}
|
|
9982
|
+
);
|
|
9983
|
+
}
|
|
9984
|
+
async function advanceDurableEval(definition, state, store, key, existingExperiment) {
|
|
9985
|
+
if (state.status === "completed") return currentStatus(definition, state);
|
|
9986
|
+
const experiment = existingExperiment === void 0 ? await openDurableExperiment(definition, state) : existingExperiment;
|
|
9987
|
+
await runTaskStage(definition, state, store, key, experiment);
|
|
9988
|
+
await logCompletedTasks(definition, state, store, key, experiment);
|
|
9989
|
+
state = await _asyncNullishCoalesce(await readRunState(definition, store, key), async () => ( state));
|
|
9990
|
+
if (state.cases.some((record) => !record.taskComplete || !record.taskLogged)) {
|
|
9991
|
+
return currentStatus(definition, state);
|
|
9992
|
+
}
|
|
9993
|
+
await runScoreStages(definition, state, store, key, experiment);
|
|
9994
|
+
state = await _asyncNullishCoalesce(await readRunState(definition, store, key), async () => ( state));
|
|
9995
|
+
const scorerNames = resolveScorers(_nullishCoalesce(definition.evaluator.scores, () => ( []))).map(
|
|
9996
|
+
({ name }) => name
|
|
9997
|
+
);
|
|
9998
|
+
const classifierNames = (_nullishCoalesce(definition.evaluator.classifiers, () => ( []))).map(
|
|
9999
|
+
classifierName
|
|
10000
|
+
);
|
|
10001
|
+
if (state.cases.some(
|
|
10002
|
+
(record) => scorerNames.some(
|
|
10003
|
+
(name) => !Object.hasOwn(record.scores, name) || !Object.hasOwn(record.loggedScores, name)
|
|
10004
|
+
) || classifierNames.some(
|
|
10005
|
+
(name) => !Object.hasOwn(record.loggedClassifications, name)
|
|
10006
|
+
)
|
|
10007
|
+
)) {
|
|
10008
|
+
return currentStatus(definition, state);
|
|
10009
|
+
}
|
|
10010
|
+
if (!await claimAction(store, key, "finish")) {
|
|
10011
|
+
const latest = await readRunState(definition, store, key);
|
|
10012
|
+
return currentStatus(definition, _nullishCoalesce(latest, () => ( state)));
|
|
10013
|
+
}
|
|
10014
|
+
state.summary = await finishExperiment(definition, state, experiment);
|
|
10015
|
+
state.status = "completed";
|
|
10016
|
+
await writeRunRecord(store, key, state);
|
|
10017
|
+
return currentStatus(definition, state);
|
|
10018
|
+
}
|
|
10019
|
+
function currentStatus(definition, state) {
|
|
10020
|
+
if (state.status === "completed") {
|
|
10021
|
+
if (!state.summary) {
|
|
10022
|
+
throw new Error(`Durable eval run ${state.runId} has no saved summary`);
|
|
10023
|
+
}
|
|
10024
|
+
return {
|
|
10025
|
+
status: "completed",
|
|
10026
|
+
runId: state.runId,
|
|
10027
|
+
pending: { poll: 0, webhook: 0 },
|
|
10028
|
+
summary: state.summary
|
|
10029
|
+
};
|
|
10030
|
+
}
|
|
10031
|
+
const pending = { poll: 0, webhook: 0 };
|
|
10032
|
+
for (const batch of state.batches) {
|
|
10033
|
+
if (batch.status === "complete") continue;
|
|
10034
|
+
pending[processorForStage(definition, batch.kind, batch.scorerName).completion.mode]++;
|
|
10035
|
+
}
|
|
10036
|
+
return { status: "waiting", runId: state.runId, pending };
|
|
10037
|
+
}
|
|
10038
|
+
async function startCaseRoot(definition, state, record, experiment) {
|
|
10039
|
+
if (!experiment) return _chunkOBBWQW6Kjs.NOOP_SPAN;
|
|
10040
|
+
const datum = record.datum;
|
|
10041
|
+
return _chunkOBBWQW6Kjs._internalStartSpanWithInitialMerge.call(void 0, {
|
|
10042
|
+
...definition.evaluator.state ? { state: definition.evaluator.state } : {},
|
|
10043
|
+
parent: await experiment.export(),
|
|
10044
|
+
name: "eval",
|
|
10045
|
+
spanId: deterministicId(`${state.runId}:${record.id}:span`),
|
|
10046
|
+
spanAttributes: { type: "eval" /* EVAL */ },
|
|
10047
|
+
event: {
|
|
10048
|
+
id: deterministicId(`${state.runId}:${record.id}:row`),
|
|
10049
|
+
input: datum.input,
|
|
10050
|
+
expected: "expected" in datum ? datum.expected : void 0,
|
|
10051
|
+
tags: datum.tags,
|
|
10052
|
+
origin: datum.origin
|
|
10053
|
+
}
|
|
10054
|
+
});
|
|
10055
|
+
}
|
|
10056
|
+
async function logTaskResult(definition, state, record, experiment, task) {
|
|
10057
|
+
const datum = record.datum;
|
|
10058
|
+
const root = await startCaseRoot(definition, state, record, experiment);
|
|
10059
|
+
try {
|
|
10060
|
+
if (task) {
|
|
10061
|
+
const result = await root.traced(
|
|
10062
|
+
(span) => _internalRunEvaluatorTask(
|
|
10063
|
+
task,
|
|
10064
|
+
datum,
|
|
10065
|
+
record.trialIndex,
|
|
10066
|
+
state.parameters,
|
|
10067
|
+
span
|
|
10068
|
+
),
|
|
10069
|
+
{
|
|
10070
|
+
name: "task",
|
|
10071
|
+
spanId: deterministicId(`${state.runId}:${record.id}:task`),
|
|
10072
|
+
spanAttributes: { type: "task" /* TASK */ },
|
|
10073
|
+
event: { input: datum.input }
|
|
10074
|
+
}
|
|
10075
|
+
);
|
|
10076
|
+
record.output = assertJsonValue(
|
|
10077
|
+
result.output,
|
|
10078
|
+
`task output for ${record.caseId}`
|
|
10079
|
+
);
|
|
10080
|
+
record.metadata = assertJsonValue(result.metadata, "task metadata");
|
|
10081
|
+
record.tags = result.tags;
|
|
10082
|
+
record.taskComplete = true;
|
|
10083
|
+
} else {
|
|
10084
|
+
await root.traced((span) => span.log({ output: record.output }), {
|
|
10085
|
+
name: "task",
|
|
10086
|
+
spanId: deterministicId(`${state.runId}:${record.id}:task`),
|
|
10087
|
+
spanAttributes: { type: "task" /* TASK */ },
|
|
10088
|
+
event: { input: datum.input }
|
|
10089
|
+
});
|
|
10090
|
+
}
|
|
10091
|
+
root.log({
|
|
10092
|
+
output: record.output,
|
|
10093
|
+
expected: "expected" in datum ? datum.expected : void 0,
|
|
10094
|
+
metadata: {
|
|
10095
|
+
...record.metadata,
|
|
10096
|
+
durable_eval: {
|
|
10097
|
+
run_id: state.runId,
|
|
10098
|
+
case_id: record.caseId,
|
|
10099
|
+
trial_index: record.trialIndex
|
|
10100
|
+
}
|
|
10101
|
+
},
|
|
10102
|
+
tags: record.tags
|
|
10103
|
+
});
|
|
10104
|
+
record.rootSpan = await root.export();
|
|
10105
|
+
record.taskLogged = true;
|
|
10106
|
+
} catch (error) {
|
|
10107
|
+
_chunkOBBWQW6Kjs.logError.call(void 0, root, error);
|
|
10108
|
+
throw error;
|
|
10109
|
+
} finally {
|
|
10110
|
+
root.end();
|
|
10111
|
+
}
|
|
10112
|
+
}
|
|
10113
|
+
async function logCompletedTasks(definition, state, store, key, experiment) {
|
|
10114
|
+
const changed = [];
|
|
10115
|
+
for (const record of state.cases) {
|
|
10116
|
+
if (!record.taskComplete || record.taskLogged) continue;
|
|
10117
|
+
if (!await claimAction(store, key, "task-log", record.id)) continue;
|
|
10118
|
+
await logTaskResult(definition, state, record, experiment);
|
|
10119
|
+
changed.push(record);
|
|
10120
|
+
}
|
|
10121
|
+
if (changed.length > 0) {
|
|
10122
|
+
await _optionalChain([experiment, 'optionalAccess', _178 => _178.flush, 'call', _179 => _179()]);
|
|
10123
|
+
await writeCaseRecords(store, key, changed);
|
|
10124
|
+
}
|
|
10125
|
+
}
|
|
10126
|
+
async function runTaskStage(definition, state, store, key, experiment) {
|
|
10127
|
+
if (isBatchTask(definition.evaluator.task)) {
|
|
10128
|
+
await ensureBatches(definition, state, store, key, "task");
|
|
10129
|
+
return;
|
|
10130
|
+
}
|
|
10131
|
+
const task = definition.evaluator.task;
|
|
10132
|
+
const changed = [];
|
|
10133
|
+
for (const record of state.cases) {
|
|
10134
|
+
if (record.taskComplete) continue;
|
|
10135
|
+
if (!await claimAction(store, key, "task", record.id)) continue;
|
|
10136
|
+
await logTaskResult(definition, state, record, experiment, task);
|
|
10137
|
+
changed.push(record);
|
|
10138
|
+
}
|
|
10139
|
+
if (changed.length > 0) {
|
|
10140
|
+
await _optionalChain([experiment, 'optionalAccess', _180 => _180.flush, 'call', _181 => _181()]);
|
|
10141
|
+
await writeCaseRecords(store, key, changed);
|
|
10142
|
+
}
|
|
10143
|
+
}
|
|
10144
|
+
async function runScoreStages(definition, state, store, key, experiment) {
|
|
10145
|
+
const scorers = resolveScorers(_nullishCoalesce(definition.evaluator.scores, () => ( [])));
|
|
10146
|
+
const changed = /* @__PURE__ */ new Map();
|
|
10147
|
+
const persistChangedCases = async () => {
|
|
10148
|
+
if (changed.size === 0) return;
|
|
10149
|
+
await _optionalChain([experiment, 'optionalAccess', _182 => _182.flush, 'call', _183 => _183()]);
|
|
10150
|
+
await writeCaseRecords(store, key, [...changed.values()]);
|
|
10151
|
+
changed.clear();
|
|
10152
|
+
};
|
|
10153
|
+
for (const { name, scorer } of scorers) {
|
|
10154
|
+
if (isBatchScorer(scorer)) {
|
|
10155
|
+
for (const record of state.cases) {
|
|
10156
|
+
if (Object.hasOwn(record.scores, name) && !Object.hasOwn(record.loggedScores, name)) {
|
|
10157
|
+
if (!await claimAction(store, key, "score-log", record.id, name)) {
|
|
10158
|
+
continue;
|
|
10159
|
+
}
|
|
10160
|
+
await evaluateAndLogScore(
|
|
10161
|
+
definition,
|
|
10162
|
+
state,
|
|
10163
|
+
record,
|
|
10164
|
+
name,
|
|
10165
|
+
experiment
|
|
10166
|
+
);
|
|
10167
|
+
changed.set(record.id, record);
|
|
10168
|
+
}
|
|
10169
|
+
}
|
|
10170
|
+
await persistChangedCases();
|
|
10171
|
+
await ensureBatches(definition, state, store, key, "score", name);
|
|
10172
|
+
continue;
|
|
10173
|
+
}
|
|
10174
|
+
for (const record of state.cases) {
|
|
10175
|
+
if (Object.hasOwn(record.loggedScores, name)) continue;
|
|
10176
|
+
if (!await claimAction(store, key, "score", record.id, name)) continue;
|
|
10177
|
+
await evaluateAndLogScore(
|
|
10178
|
+
definition,
|
|
10179
|
+
state,
|
|
10180
|
+
record,
|
|
10181
|
+
name,
|
|
10182
|
+
experiment,
|
|
10183
|
+
scorer
|
|
10184
|
+
);
|
|
10185
|
+
changed.set(record.id, record);
|
|
10186
|
+
}
|
|
10187
|
+
}
|
|
10188
|
+
for (const [index, classifier] of (_nullishCoalesce(definition.evaluator.classifiers, () => ( []))).entries()) {
|
|
10189
|
+
const name = classifierName(classifier, index);
|
|
10190
|
+
for (const record of state.cases) {
|
|
10191
|
+
if (Object.hasOwn(record.loggedClassifications, name)) continue;
|
|
10192
|
+
if (!await claimAction(store, key, "classification", record.id, name)) {
|
|
10193
|
+
continue;
|
|
10194
|
+
}
|
|
10195
|
+
await evaluateAndLogClassification(
|
|
10196
|
+
definition,
|
|
10197
|
+
state,
|
|
10198
|
+
record,
|
|
10199
|
+
name,
|
|
10200
|
+
classifier,
|
|
10201
|
+
experiment
|
|
10202
|
+
);
|
|
10203
|
+
changed.set(record.id, record);
|
|
10204
|
+
}
|
|
10205
|
+
}
|
|
10206
|
+
await persistChangedCases();
|
|
10207
|
+
}
|
|
10208
|
+
function scorerArgs(record) {
|
|
10209
|
+
const datum = record.datum;
|
|
10210
|
+
return {
|
|
10211
|
+
...datum,
|
|
10212
|
+
metadata: record.metadata,
|
|
10213
|
+
output: record.output
|
|
10214
|
+
};
|
|
10215
|
+
}
|
|
10216
|
+
function resumeCaseRoot(definition, record, experiment) {
|
|
10217
|
+
if (!experiment) return _chunkOBBWQW6Kjs.NOOP_SPAN;
|
|
10218
|
+
if (!record.rootSpan) {
|
|
10219
|
+
throw new Error(`Durable eval case ${record.caseId} has no root span`);
|
|
10220
|
+
}
|
|
10221
|
+
return _chunkOBBWQW6Kjs._internalResumeSpan.call(void 0, {
|
|
10222
|
+
exported: record.rootSpan,
|
|
10223
|
+
state: definition.evaluator.state
|
|
10224
|
+
});
|
|
10225
|
+
}
|
|
10226
|
+
async function evaluateAndLogScore(definition, state, record, name, experiment, scorer) {
|
|
10227
|
+
const root = resumeCaseRoot(definition, record, experiment);
|
|
10228
|
+
try {
|
|
10229
|
+
const rootExport = await root.export();
|
|
10230
|
+
const prepared = await root.traced(
|
|
10231
|
+
async (span) => {
|
|
10232
|
+
const value = scorer ? await scorer(scorerArgs(record)) : record.scores[name];
|
|
10233
|
+
if (scorer) {
|
|
10234
|
+
record.scores[name] = assertJsonValue(value, `scorer ${name} output`);
|
|
10235
|
+
}
|
|
10236
|
+
const result = _internalPrepareEvaluatorScore(value, name);
|
|
10237
|
+
if (result.results !== null) {
|
|
10238
|
+
span.log({
|
|
10239
|
+
output: result.output,
|
|
10240
|
+
metadata: result.metadata,
|
|
10241
|
+
scores: result.scores
|
|
10242
|
+
});
|
|
10243
|
+
}
|
|
10244
|
+
return result;
|
|
10245
|
+
},
|
|
10246
|
+
{
|
|
10247
|
+
name,
|
|
10248
|
+
spanId: deterministicId(`${state.runId}:${record.id}:score:${name}`),
|
|
10249
|
+
spanAttributes: {
|
|
10250
|
+
type: "score" /* SCORE */,
|
|
10251
|
+
purpose: "scorer"
|
|
10252
|
+
},
|
|
10253
|
+
propagatedEvent: _chunkOBBWQW6Kjs.makeScorerPropagatedEvent.call(void 0, rootExport || void 0),
|
|
10254
|
+
event: { input: scorerArgs(record) }
|
|
10255
|
+
}
|
|
10256
|
+
);
|
|
10257
|
+
if (prepared.scores) root.log({ scores: prepared.scores });
|
|
10258
|
+
record.loggedScores[name] = true;
|
|
10259
|
+
} catch (error) {
|
|
10260
|
+
_chunkOBBWQW6Kjs.logError.call(void 0, root, error);
|
|
10261
|
+
throw error;
|
|
10262
|
+
} finally {
|
|
10263
|
+
root.end();
|
|
10264
|
+
}
|
|
10265
|
+
}
|
|
10266
|
+
async function evaluateAndLogClassification(definition, state, record, name, classifier, experiment) {
|
|
10267
|
+
const root = resumeCaseRoot(definition, record, experiment);
|
|
10268
|
+
try {
|
|
10269
|
+
const rootExport = await root.export();
|
|
10270
|
+
const prepared = await root.traced(
|
|
10271
|
+
async (span) => {
|
|
10272
|
+
const value = await classifier(scorerArgs(record));
|
|
10273
|
+
record.classifications[name] = assertJsonValue(
|
|
10274
|
+
value,
|
|
10275
|
+
`classifier ${name} output`
|
|
10276
|
+
);
|
|
10277
|
+
const result = _internalPrepareEvaluatorClassification(value, name);
|
|
10278
|
+
if (result.results !== null) {
|
|
10279
|
+
span.log({ output: result.output, metadata: result.metadata });
|
|
10280
|
+
}
|
|
10281
|
+
return result;
|
|
10282
|
+
},
|
|
10283
|
+
{
|
|
10284
|
+
name,
|
|
10285
|
+
spanId: deterministicId(
|
|
10286
|
+
`${state.runId}:${record.id}:classification:${name}`
|
|
10287
|
+
),
|
|
10288
|
+
spanAttributes: {
|
|
10289
|
+
type: "classifier" /* CLASSIFIER */,
|
|
10290
|
+
purpose: "scorer"
|
|
10291
|
+
},
|
|
10292
|
+
propagatedEvent: _chunkOBBWQW6Kjs.makeScorerPropagatedEvent.call(void 0, rootExport || void 0),
|
|
10293
|
+
event: { input: scorerArgs(record) }
|
|
10294
|
+
}
|
|
10295
|
+
);
|
|
10296
|
+
if (prepared.classifications) {
|
|
10297
|
+
root.log({ classifications: prepared.classifications });
|
|
10298
|
+
}
|
|
10299
|
+
record.loggedClassifications[name] = true;
|
|
10300
|
+
} catch (error) {
|
|
10301
|
+
_chunkOBBWQW6Kjs.logError.call(void 0, root, error);
|
|
10302
|
+
throw error;
|
|
10303
|
+
} finally {
|
|
10304
|
+
root.end();
|
|
10305
|
+
}
|
|
10306
|
+
}
|
|
10307
|
+
async function ensureBatches(definition, state, store, key, kind, scorerName2) {
|
|
10308
|
+
const processor = processorForStage(definition, kind, scorerName2);
|
|
10309
|
+
const plans = plannedBatches(
|
|
10310
|
+
definition,
|
|
10311
|
+
state.runId,
|
|
10312
|
+
state.cases.map(({ id }) => id)
|
|
10313
|
+
);
|
|
10314
|
+
const casesById = new Map(state.cases.map((record) => [record.id, record]));
|
|
10315
|
+
for (const plan of plans) {
|
|
10316
|
+
if (plan.kind !== kind || plan.scorerName !== scorerName2) continue;
|
|
10317
|
+
if (state.batches.some(({ id }) => id === plan.id)) continue;
|
|
10318
|
+
const records = plan.itemIds.map((id) => casesById.get(id));
|
|
10319
|
+
const ready = records.every(
|
|
10320
|
+
(record) => kind === "task" ? !record.taskComplete : !Object.hasOwn(record.scores, scorerName2)
|
|
10321
|
+
);
|
|
10322
|
+
if (!ready) continue;
|
|
10323
|
+
const batchId = plan.id;
|
|
10324
|
+
const claim = await store.getOrSet(
|
|
10325
|
+
claimRecordKey(key, "batch", batchId),
|
|
10326
|
+
encoder.encode(batchId)
|
|
10327
|
+
);
|
|
10328
|
+
if (!claim.created) continue;
|
|
10329
|
+
const context = { runId: state.runId, batchId };
|
|
10330
|
+
const items = records.map(
|
|
10331
|
+
(record) => kind === "task" ? taskBatchItem(record, state.parameters) : scorerBatchItem(record)
|
|
10332
|
+
);
|
|
10333
|
+
const submissionData = assertJsonValue(
|
|
10334
|
+
await processor.submit(items, context),
|
|
10335
|
+
`submission data for batch ${batchId}`
|
|
10336
|
+
);
|
|
10337
|
+
const externalId = processor.completion.mode === "webhook" ? processor.completion.getExternalId(submissionData, context) : void 0;
|
|
10338
|
+
if (externalId !== void 0 && !externalId.trim()) {
|
|
10339
|
+
throw new Error(`Batch ${batchId} produced an empty externalId`);
|
|
10340
|
+
}
|
|
10341
|
+
const batch = {
|
|
10342
|
+
id: batchId,
|
|
10343
|
+
kind,
|
|
10344
|
+
scorerName: scorerName2,
|
|
10345
|
+
itemIds: records.map((record) => record.id),
|
|
10346
|
+
submissionData,
|
|
10347
|
+
externalId,
|
|
10348
|
+
status: "submitted"
|
|
10349
|
+
};
|
|
10350
|
+
state.batches.push(batch);
|
|
10351
|
+
await writeBatchRecords(store, key, [batch]);
|
|
10352
|
+
}
|
|
10353
|
+
}
|
|
10354
|
+
async function collectBatch(definition, state, batch) {
|
|
10355
|
+
const processor = processorForStage(definition, batch.kind, batch.scorerName);
|
|
10356
|
+
const context = { runId: state.runId, batchId: batch.id };
|
|
10357
|
+
const results = await processor.collect(batch.submissionData, context);
|
|
10358
|
+
if (!Array.isArray(results)) {
|
|
10359
|
+
throw new Error(`collect for batch ${batch.id} must return an array`);
|
|
10360
|
+
}
|
|
10361
|
+
const expectedIds = new Set(batch.itemIds);
|
|
10362
|
+
const seen = /* @__PURE__ */ new Set();
|
|
10363
|
+
const records = [];
|
|
10364
|
+
for (const result of results) {
|
|
10365
|
+
const id = resultItemId(result);
|
|
10366
|
+
if (!expectedIds.has(id)) {
|
|
10367
|
+
throw new Error(`Batch ${batch.id} returned unknown item ${id}`);
|
|
10368
|
+
}
|
|
10369
|
+
if (seen.has(id)) {
|
|
10370
|
+
throw new Error(`Batch ${batch.id} returned item ${id} more than once`);
|
|
10371
|
+
}
|
|
10372
|
+
seen.add(id);
|
|
10373
|
+
const record = state.cases.find((candidate) => candidate.id === id);
|
|
10374
|
+
records.push(record);
|
|
10375
|
+
if (batch.kind === "task") {
|
|
10376
|
+
record.output = assertJsonValue(
|
|
10377
|
+
result.output,
|
|
10378
|
+
`task output for item ${id}`
|
|
10379
|
+
);
|
|
10380
|
+
if ("metadata" in result && result.metadata !== void 0) {
|
|
10381
|
+
record.metadata = assertJsonValue(
|
|
10382
|
+
{
|
|
10383
|
+
...record.metadata,
|
|
10384
|
+
...result.metadata
|
|
10385
|
+
},
|
|
10386
|
+
`metadata for ${id}`
|
|
10387
|
+
);
|
|
10388
|
+
}
|
|
10389
|
+
if ("tags" in result && result.tags !== void 0)
|
|
10390
|
+
record.tags = result.tags;
|
|
10391
|
+
record.taskComplete = true;
|
|
10392
|
+
} else {
|
|
10393
|
+
record.scores[batch.scorerName] = assertJsonValue(
|
|
10394
|
+
result.score,
|
|
10395
|
+
`score output for item ${id}`
|
|
10396
|
+
);
|
|
10397
|
+
}
|
|
10398
|
+
}
|
|
10399
|
+
const missing = batch.itemIds.filter((id) => !seen.has(id));
|
|
10400
|
+
if (missing.length > 0) {
|
|
10401
|
+
throw new Error(
|
|
10402
|
+
`Batch ${batch.id} did not return results for: ${missing.join(", ")}`
|
|
10403
|
+
);
|
|
10404
|
+
}
|
|
10405
|
+
return records;
|
|
10406
|
+
}
|
|
10407
|
+
function processorForStage(definition, kind, scorerName2) {
|
|
10408
|
+
if (kind === "task") {
|
|
10409
|
+
if (!isBatchTask(definition.evaluator.task)) {
|
|
10410
|
+
throw new Error("Definition no longer contains the batch task");
|
|
10411
|
+
}
|
|
10412
|
+
return definition.evaluator.task.processor;
|
|
10413
|
+
}
|
|
10414
|
+
const scorer = _optionalChain([resolveScorers, 'call', _184 => _184(_nullishCoalesce(definition.evaluator.scores, () => ( []))), 'access', _185 => _185.find, 'call', _186 => _186(
|
|
10415
|
+
({ name }) => name === scorerName2
|
|
10416
|
+
), 'optionalAccess', _187 => _187.scorer]);
|
|
10417
|
+
if (!isBatchScorer(scorer)) {
|
|
10418
|
+
throw new Error(`Definition no longer contains scorer ${scorerName2}`);
|
|
10419
|
+
}
|
|
10420
|
+
return scorer.processor;
|
|
10421
|
+
}
|
|
10422
|
+
async function materializeCases(definition, data, experiment) {
|
|
10423
|
+
const evaluator = definition.evaluator;
|
|
10424
|
+
const iterable = await _internalResolveEvaluatorData(
|
|
10425
|
+
{
|
|
10426
|
+
data,
|
|
10427
|
+
projectName: definition.projectName,
|
|
10428
|
+
projectId: evaluator.projectId,
|
|
10429
|
+
state: evaluator.state
|
|
10430
|
+
},
|
|
10431
|
+
experiment
|
|
10432
|
+
);
|
|
10433
|
+
const records = [];
|
|
10434
|
+
const seen = /* @__PURE__ */ new Set();
|
|
10435
|
+
for await (const datum of iterable) {
|
|
10436
|
+
const caseId = await _asyncNullishCoalesce(await _asyncNullishCoalesce(datum.id, async () => ( datum.upsert_id)), async () => ( (evaluator.caseId ? await evaluator.caseId(datum) : void 0)));
|
|
10437
|
+
if (!caseId) {
|
|
10438
|
+
throw new Error(
|
|
10439
|
+
"Every durable eval case requires id, upsert_id, or caseId"
|
|
10440
|
+
);
|
|
10441
|
+
}
|
|
10442
|
+
if (seen.has(caseId))
|
|
10443
|
+
throw new Error(`Duplicate durable eval case id: ${caseId}`);
|
|
10444
|
+
seen.add(caseId);
|
|
10445
|
+
const trialCount = _nullishCoalesce(_nullishCoalesce(datum.trialCount, () => ( evaluator.trialCount)), () => ( 1));
|
|
10446
|
+
if (!Number.isInteger(trialCount) || trialCount < 1) {
|
|
10447
|
+
throw new Error(`Invalid trialCount for durable eval case ${caseId}`);
|
|
10448
|
+
}
|
|
10449
|
+
for (let trialIndex = 0; trialIndex < trialCount; trialIndex++) {
|
|
10450
|
+
records.push({
|
|
10451
|
+
id: `${caseId}:trial:${trialIndex}`,
|
|
10452
|
+
caseId,
|
|
10453
|
+
trialIndex,
|
|
10454
|
+
datum: assertJsonValue(datum, `case ${caseId}`),
|
|
10455
|
+
metadata: assertJsonValue(
|
|
10456
|
+
"metadata" in datum ? datum.metadata : {},
|
|
10457
|
+
`metadata for ${caseId}`
|
|
10458
|
+
),
|
|
10459
|
+
tags: datum.tags,
|
|
10460
|
+
taskComplete: false,
|
|
10461
|
+
taskLogged: false,
|
|
10462
|
+
scores: /* @__PURE__ */ Object.create(null),
|
|
10463
|
+
loggedScores: /* @__PURE__ */ Object.create(null),
|
|
10464
|
+
classifications: /* @__PURE__ */ Object.create(null),
|
|
10465
|
+
loggedClassifications: /* @__PURE__ */ Object.create(null)
|
|
10466
|
+
});
|
|
10467
|
+
}
|
|
10468
|
+
}
|
|
10469
|
+
return records;
|
|
10470
|
+
}
|
|
10471
|
+
function taskBatchItem(record, parameters) {
|
|
10472
|
+
const datum = record.datum;
|
|
10473
|
+
return {
|
|
10474
|
+
id: record.id,
|
|
10475
|
+
input: datum.input,
|
|
10476
|
+
expected: "expected" in datum ? datum.expected : void 0,
|
|
10477
|
+
metadata: record.metadata,
|
|
10478
|
+
tags: record.tags,
|
|
10479
|
+
parameters,
|
|
10480
|
+
trialIndex: record.trialIndex
|
|
10481
|
+
};
|
|
10482
|
+
}
|
|
10483
|
+
function scorerBatchItem(record) {
|
|
10484
|
+
const datum = record.datum;
|
|
10485
|
+
return {
|
|
10486
|
+
id: record.id,
|
|
10487
|
+
input: datum.input,
|
|
10488
|
+
output: record.output,
|
|
10489
|
+
expected: "expected" in datum ? datum.expected : void 0,
|
|
10490
|
+
metadata: record.metadata,
|
|
10491
|
+
tags: record.tags,
|
|
10492
|
+
trialIndex: record.trialIndex
|
|
10493
|
+
};
|
|
10494
|
+
}
|
|
10495
|
+
async function finishExperiment(definition, state, experiment) {
|
|
10496
|
+
const scorerNames = resolveScorers(_nullishCoalesce(definition.evaluator.scores, () => ( []))).map(
|
|
10497
|
+
({ name }) => name
|
|
10498
|
+
);
|
|
10499
|
+
const results = state.cases.map((record) => {
|
|
10500
|
+
const datum = record.datum;
|
|
10501
|
+
const scores = Object.fromEntries(
|
|
10502
|
+
scorerNames.flatMap(
|
|
10503
|
+
(name) => Object.entries(
|
|
10504
|
+
_nullishCoalesce(_internalPrepareEvaluatorScore(
|
|
10505
|
+
record.scores[name],
|
|
10506
|
+
name
|
|
10507
|
+
).scores, () => ( {}))
|
|
10508
|
+
)
|
|
10509
|
+
)
|
|
10510
|
+
);
|
|
10511
|
+
const classifications = Object.fromEntries(
|
|
10512
|
+
Object.entries(record.classifications).flatMap(
|
|
10513
|
+
([name, value]) => Object.entries(
|
|
10514
|
+
_nullishCoalesce(_internalPrepareEvaluatorClassification(value, name).classifications, () => ( {}))
|
|
10515
|
+
)
|
|
10516
|
+
)
|
|
10517
|
+
);
|
|
10518
|
+
return {
|
|
10519
|
+
...datum,
|
|
10520
|
+
output: record.output,
|
|
10521
|
+
metadata: record.metadata,
|
|
10522
|
+
tags: record.tags,
|
|
10523
|
+
scores,
|
|
10524
|
+
error: void 0,
|
|
10525
|
+
...Object.keys(classifications).length > 0 ? { classifications } : {}
|
|
10526
|
+
};
|
|
10527
|
+
});
|
|
10528
|
+
if (!experiment) {
|
|
10529
|
+
return buildLocalSummary(
|
|
10530
|
+
{
|
|
10531
|
+
...definition.evaluator,
|
|
10532
|
+
projectName: definition.projectName,
|
|
10533
|
+
evalName: state.experimentName
|
|
10534
|
+
},
|
|
10535
|
+
results
|
|
10536
|
+
);
|
|
10537
|
+
}
|
|
10538
|
+
await experiment.flush();
|
|
10539
|
+
let comparisonExperimentId = definition.evaluator.baseExperimentId;
|
|
10540
|
+
if (!comparisonExperimentId) {
|
|
10541
|
+
try {
|
|
10542
|
+
comparisonExperimentId = await experiment._getBaseExperimentId();
|
|
10543
|
+
} catch (e11) {
|
|
10544
|
+
comparisonExperimentId = void 0;
|
|
10545
|
+
}
|
|
10546
|
+
}
|
|
10547
|
+
return await experiment.summarize({
|
|
10548
|
+
summarizeScores: definition.evaluator.summarizeScores,
|
|
10549
|
+
...comparisonExperimentId ? { comparisonExperimentId } : {}
|
|
10550
|
+
});
|
|
10551
|
+
}
|
|
10552
|
+
function resolveScorers(scorers) {
|
|
10553
|
+
return scorers.map((scorer, index) => ({
|
|
10554
|
+
name: isBatchScorer(scorer) ? scorer.name : scorer.name || `scorer_${index}`,
|
|
10555
|
+
scorer
|
|
10556
|
+
}));
|
|
10557
|
+
}
|
|
10558
|
+
function runKey(projectName, evalName, runId) {
|
|
10559
|
+
return `durable-eval/v1/runs/${contentVersion(encoder.encode(`${projectName}\0${evalName}\0${runId}`))}`;
|
|
10560
|
+
}
|
|
10561
|
+
function encodedKeyPart(value) {
|
|
10562
|
+
return _chunkOBBWQW6Kjs.uint8ArrayToBase64.call(void 0, encoder.encode(value)).replaceAll("+", "-").replaceAll("/", "_").replace(/=+$/, "");
|
|
10563
|
+
}
|
|
10564
|
+
function caseRecordKey(key, caseId, kind, ...names) {
|
|
10565
|
+
const suffix = names.map(encodedKeyPart).join("/");
|
|
10566
|
+
return `${key}/cases/${encodedKeyPart(caseId)}/${kind}${suffix ? `/${suffix}` : ""}`;
|
|
10567
|
+
}
|
|
10568
|
+
function batchRecordKey(key, batchId) {
|
|
10569
|
+
return `${key}/batches/${encodedKeyPart(batchId)}`;
|
|
10570
|
+
}
|
|
10571
|
+
function claimRecordKey(key, kind, ...parts) {
|
|
10572
|
+
const identity = stableStringify([kind, parts]);
|
|
10573
|
+
return `${key}/claims/${contentVersion(encoder.encode(identity))}`;
|
|
10574
|
+
}
|
|
10575
|
+
async function claimAction(store, key, kind, ...parts) {
|
|
10576
|
+
return (await store.getOrSet(
|
|
10577
|
+
claimRecordKey(key, kind, ...parts),
|
|
10578
|
+
encoder.encode("claimed")
|
|
10579
|
+
)).created;
|
|
10580
|
+
}
|
|
10581
|
+
function plannedBatches(definition, runId, caseIds) {
|
|
10582
|
+
const stages = [];
|
|
10583
|
+
if (isBatchTask(definition.evaluator.task)) stages.push({ kind: "task" });
|
|
10584
|
+
for (const { name, scorer } of resolveScorers(
|
|
10585
|
+
_nullishCoalesce(definition.evaluator.scores, () => ( []))
|
|
10586
|
+
)) {
|
|
10587
|
+
if (isBatchScorer(scorer)) {
|
|
10588
|
+
stages.push({ kind: "score", scorerName: name });
|
|
10589
|
+
}
|
|
10590
|
+
}
|
|
10591
|
+
const plans = [];
|
|
10592
|
+
for (const { kind, scorerName: scorerName2 } of stages) {
|
|
10593
|
+
const batchSize = _nullishCoalesce(processorForStage(definition, kind, scorerName2).batchSize, () => ( DEFAULT_BATCH_SIZE));
|
|
10594
|
+
if (!Number.isInteger(batchSize) || batchSize < 1) {
|
|
10595
|
+
throw new Error(
|
|
10596
|
+
`Invalid batchSize for ${_nullishCoalesce(scorerName2, () => ( "task"))}: ${batchSize}`
|
|
10597
|
+
);
|
|
10598
|
+
}
|
|
10599
|
+
for (let offset = 0; offset < caseIds.length; offset += batchSize) {
|
|
10600
|
+
const itemIds = caseIds.slice(offset, offset + batchSize);
|
|
10601
|
+
plans.push({
|
|
10602
|
+
id: deterministicId(
|
|
10603
|
+
stableStringify([runId, kind, scorerName2, itemIds])
|
|
10604
|
+
),
|
|
10605
|
+
kind,
|
|
10606
|
+
scorerName: scorerName2,
|
|
10607
|
+
itemIds
|
|
10608
|
+
});
|
|
10609
|
+
}
|
|
10610
|
+
}
|
|
10611
|
+
return plans;
|
|
10612
|
+
}
|
|
10613
|
+
async function readCaseRecord(definition, store, key, id) {
|
|
10614
|
+
const scorers = resolveScorers(_nullishCoalesce(definition.evaluator.scores, () => ( [])));
|
|
10615
|
+
const classifiers = (_nullishCoalesce(definition.evaluator.classifiers, () => ( []))).map(
|
|
10616
|
+
classifierName
|
|
10617
|
+
);
|
|
10618
|
+
const [
|
|
10619
|
+
base,
|
|
10620
|
+
task,
|
|
10621
|
+
taskLog,
|
|
10622
|
+
scoreValues,
|
|
10623
|
+
scoreLogValues,
|
|
10624
|
+
classificationValues,
|
|
10625
|
+
classificationLogValues
|
|
10626
|
+
] = await Promise.all([
|
|
10627
|
+
readJson(store, caseRecordKey(key, id, "base")),
|
|
10628
|
+
readJson(store, caseRecordKey(key, id, "task")),
|
|
10629
|
+
readJson(store, caseRecordKey(key, id, "task-log")),
|
|
10630
|
+
Promise.all(
|
|
10631
|
+
scorers.map(async ({ name }) => ({
|
|
10632
|
+
name,
|
|
10633
|
+
value: await readJson(
|
|
10634
|
+
store,
|
|
10635
|
+
caseRecordKey(key, id, "score", name)
|
|
10636
|
+
)
|
|
10637
|
+
}))
|
|
10638
|
+
),
|
|
10639
|
+
Promise.all(
|
|
10640
|
+
scorers.map(async ({ name }) => ({
|
|
10641
|
+
name,
|
|
10642
|
+
value: await readJson(
|
|
10643
|
+
store,
|
|
10644
|
+
caseRecordKey(key, id, "score-log", name)
|
|
10645
|
+
)
|
|
10646
|
+
}))
|
|
10647
|
+
),
|
|
10648
|
+
Promise.all(
|
|
10649
|
+
classifiers.map(async (name) => ({
|
|
10650
|
+
name,
|
|
10651
|
+
value: await readJson(
|
|
10652
|
+
store,
|
|
10653
|
+
caseRecordKey(key, id, "classification", name)
|
|
10654
|
+
)
|
|
10655
|
+
}))
|
|
10656
|
+
),
|
|
10657
|
+
Promise.all(
|
|
10658
|
+
classifiers.map(async (name) => ({
|
|
10659
|
+
name,
|
|
10660
|
+
value: await readJson(
|
|
10661
|
+
store,
|
|
10662
|
+
caseRecordKey(key, id, "classification-log", name)
|
|
10663
|
+
)
|
|
10664
|
+
}))
|
|
10665
|
+
)
|
|
10666
|
+
]);
|
|
10667
|
+
if (!base) throw new Error(`Durable eval case ${id} is missing`);
|
|
10668
|
+
const scores = /* @__PURE__ */ Object.create(null);
|
|
10669
|
+
for (const { name, value } of scoreValues) {
|
|
10670
|
+
if (value !== void 0) scores[name] = value;
|
|
10671
|
+
}
|
|
10672
|
+
const loggedScores = /* @__PURE__ */ Object.create(null);
|
|
10673
|
+
for (const { name, value } of scoreLogValues) {
|
|
10674
|
+
if (value) loggedScores[name] = true;
|
|
10675
|
+
}
|
|
10676
|
+
const classifications = /* @__PURE__ */ Object.create(null);
|
|
10677
|
+
for (const { name, value } of classificationValues) {
|
|
10678
|
+
if (value !== void 0) classifications[name] = value;
|
|
10679
|
+
}
|
|
10680
|
+
const loggedClassifications = /* @__PURE__ */ Object.create(null);
|
|
10681
|
+
for (const { name, value } of classificationLogValues) {
|
|
10682
|
+
if (value) loggedClassifications[name] = true;
|
|
10683
|
+
}
|
|
10684
|
+
return {
|
|
10685
|
+
...base,
|
|
10686
|
+
metadata: _nullishCoalesce(_optionalChain([task, 'optionalAccess', _188 => _188.metadata]), () => ( base.metadata)),
|
|
10687
|
+
tags: task ? task.tags : base.tags,
|
|
10688
|
+
taskComplete: task !== void 0,
|
|
10689
|
+
taskLogged: taskLog !== void 0,
|
|
10690
|
+
output: _optionalChain([task, 'optionalAccess', _189 => _189.output]),
|
|
10691
|
+
rootSpan: _optionalChain([taskLog, 'optionalAccess', _190 => _190.rootSpan]),
|
|
10692
|
+
scores,
|
|
10693
|
+
loggedScores,
|
|
10694
|
+
classifications,
|
|
10695
|
+
loggedClassifications
|
|
10696
|
+
};
|
|
10697
|
+
}
|
|
10698
|
+
async function readRunState(definition, store, key) {
|
|
10699
|
+
const record = await readJson(store, key);
|
|
10700
|
+
if (!record) return void 0;
|
|
10701
|
+
const plans = plannedBatches(definition, record.runId, record.caseIds);
|
|
10702
|
+
const [cases, batchRecords] = await Promise.all([
|
|
10703
|
+
Promise.all(
|
|
10704
|
+
record.caseIds.map((id) => readCaseRecord(definition, store, key, id))
|
|
10705
|
+
),
|
|
10706
|
+
Promise.all(
|
|
10707
|
+
plans.map(async ({ id }) => {
|
|
10708
|
+
return readJson(store, batchRecordKey(key, id));
|
|
10709
|
+
})
|
|
10710
|
+
)
|
|
10711
|
+
]);
|
|
10712
|
+
const batches = batchRecords.filter(
|
|
10713
|
+
(value) => value !== void 0
|
|
10714
|
+
);
|
|
10715
|
+
const { caseIds: _caseIds, ...state } = record;
|
|
10716
|
+
return { ...state, cases, batches };
|
|
10717
|
+
}
|
|
10718
|
+
async function writeRunRecord(store, key, state) {
|
|
10719
|
+
const { cases, batches: _batches, ...record } = state;
|
|
10720
|
+
await writeJson(store, key, {
|
|
10721
|
+
...record,
|
|
10722
|
+
caseIds: cases.map(({ id }) => id)
|
|
10723
|
+
});
|
|
10724
|
+
}
|
|
10725
|
+
async function writeCaseBaseRecords(store, key, records) {
|
|
10726
|
+
await Promise.all(
|
|
10727
|
+
records.map(
|
|
10728
|
+
({ id, caseId, trialIndex, datum, metadata, tags }) => writeJson(store, caseRecordKey(key, id, "base"), {
|
|
10729
|
+
id,
|
|
10730
|
+
caseId,
|
|
10731
|
+
trialIndex,
|
|
10732
|
+
datum,
|
|
10733
|
+
metadata,
|
|
10734
|
+
tags
|
|
10735
|
+
})
|
|
10736
|
+
)
|
|
10737
|
+
);
|
|
10738
|
+
}
|
|
10739
|
+
async function writeCaseRecords(store, key, records) {
|
|
10740
|
+
const writes = [];
|
|
10741
|
+
for (const record of records) {
|
|
10742
|
+
if (record.taskComplete) {
|
|
10743
|
+
writes.push(
|
|
10744
|
+
writeJson(store, caseRecordKey(key, record.id, "task"), {
|
|
10745
|
+
output: record.output,
|
|
10746
|
+
metadata: record.metadata,
|
|
10747
|
+
tags: record.tags,
|
|
10748
|
+
taskComplete: true
|
|
10749
|
+
})
|
|
10750
|
+
);
|
|
10751
|
+
}
|
|
10752
|
+
if (record.taskLogged) {
|
|
10753
|
+
writes.push(
|
|
10754
|
+
writeJson(store, caseRecordKey(key, record.id, "task-log"), {
|
|
10755
|
+
rootSpan: record.rootSpan,
|
|
10756
|
+
taskLogged: true
|
|
10757
|
+
})
|
|
10758
|
+
);
|
|
10759
|
+
}
|
|
10760
|
+
for (const [name, value] of Object.entries(record.scores)) {
|
|
10761
|
+
writes.push(
|
|
10762
|
+
writeJson(store, caseRecordKey(key, record.id, "score", name), value)
|
|
10763
|
+
);
|
|
10764
|
+
}
|
|
10765
|
+
for (const name of Object.keys(record.loggedScores)) {
|
|
10766
|
+
writes.push(
|
|
10767
|
+
writeJson(
|
|
10768
|
+
store,
|
|
10769
|
+
caseRecordKey(key, record.id, "score-log", name),
|
|
10770
|
+
true
|
|
10771
|
+
)
|
|
10772
|
+
);
|
|
10773
|
+
}
|
|
10774
|
+
for (const [name, value] of Object.entries(record.classifications)) {
|
|
10775
|
+
writes.push(
|
|
10776
|
+
writeJson(
|
|
10777
|
+
store,
|
|
10778
|
+
caseRecordKey(key, record.id, "classification", name),
|
|
10779
|
+
value
|
|
10780
|
+
)
|
|
10781
|
+
);
|
|
10782
|
+
}
|
|
10783
|
+
for (const name of Object.keys(record.loggedClassifications)) {
|
|
10784
|
+
writes.push(
|
|
10785
|
+
writeJson(
|
|
10786
|
+
store,
|
|
10787
|
+
caseRecordKey(key, record.id, "classification-log", name),
|
|
10788
|
+
true
|
|
10789
|
+
)
|
|
10790
|
+
);
|
|
10791
|
+
}
|
|
10792
|
+
}
|
|
10793
|
+
await Promise.all(writes);
|
|
10794
|
+
}
|
|
10795
|
+
async function writeBatchRecords(store, key, records) {
|
|
10796
|
+
await Promise.all(
|
|
10797
|
+
records.map(
|
|
10798
|
+
(record) => writeJson(store, batchRecordKey(key, record.id), record)
|
|
10799
|
+
)
|
|
10800
|
+
);
|
|
10801
|
+
}
|
|
10802
|
+
function deterministicId(value) {
|
|
10803
|
+
const hex = contentVersion(encoder.encode(value)).padEnd(32, "0").slice(0, 32);
|
|
10804
|
+
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-5${hex.slice(13, 16)}-a${hex.slice(17, 20)}-${hex.slice(20, 32)}`;
|
|
10805
|
+
}
|
|
10806
|
+
function contentVersion(value) {
|
|
10807
|
+
if (_chunkBBE7SNRVjs.isomorph_default.hash) return _chunkBBE7SNRVjs.isomorph_default.hash(decoder.decode(value));
|
|
10808
|
+
let hash = 2166136261;
|
|
10809
|
+
for (const byte of value) {
|
|
10810
|
+
hash ^= byte;
|
|
10811
|
+
hash = Math.imul(hash, 16777619);
|
|
10812
|
+
}
|
|
10813
|
+
return (hash >>> 0).toString(16).padStart(8, "0");
|
|
10814
|
+
}
|
|
10815
|
+
async function readJson(store, key) {
|
|
10816
|
+
const value = await store.read(key);
|
|
10817
|
+
return value ? JSON.parse(decoder.decode(value)) : void 0;
|
|
10818
|
+
}
|
|
10819
|
+
async function writeJson(store, key, value) {
|
|
10820
|
+
await store.write(key, encoder.encode(stableStringify(value)));
|
|
10821
|
+
}
|
|
10822
|
+
function stableStringify(value) {
|
|
10823
|
+
return JSON.stringify(value, (_key, nested) => {
|
|
10824
|
+
if (nested && typeof nested === "object" && !Array.isArray(nested)) {
|
|
10825
|
+
return Object.fromEntries(
|
|
10826
|
+
Object.entries(nested).sort(
|
|
10827
|
+
([left], [right]) => left.localeCompare(right)
|
|
10828
|
+
)
|
|
10829
|
+
);
|
|
10830
|
+
}
|
|
10831
|
+
return nested;
|
|
10832
|
+
});
|
|
10833
|
+
}
|
|
10834
|
+
function assertJsonValue(value, label) {
|
|
10835
|
+
try {
|
|
10836
|
+
const serialized = JSON.stringify(value);
|
|
10837
|
+
if (serialized === void 0)
|
|
10838
|
+
throw new Error("value serializes to undefined");
|
|
10839
|
+
return JSON.parse(serialized);
|
|
10840
|
+
} catch (error) {
|
|
10841
|
+
throw new Error(`${label} must be JSON serializable`, { cause: error });
|
|
10842
|
+
}
|
|
10843
|
+
}
|
|
10844
|
+
function resultItemId(value) {
|
|
10845
|
+
if (typeof value !== "object" || value === null || !("id" in value) || typeof value.id !== "string") {
|
|
10846
|
+
throw new Error("Batch results must contain a string id");
|
|
10847
|
+
}
|
|
10848
|
+
return value.id;
|
|
10849
|
+
}
|
|
10850
|
+
function isBatchTask(value) {
|
|
10851
|
+
return typeof value === "object" && value !== null && "kind" in value && value.kind === BATCH_TASK_KIND;
|
|
10852
|
+
}
|
|
10853
|
+
function isBatchScorer(value) {
|
|
10854
|
+
return typeof value === "object" && value !== null && "kind" in value && value.kind === BATCH_SCORER_KIND;
|
|
10855
|
+
}
|
|
10856
|
+
function asError(error) {
|
|
10857
|
+
return error instanceof Error ? error : new Error(String(error));
|
|
10858
|
+
}
|
|
10859
|
+
|
|
9576
10860
|
// src/agent-assertions.ts
|
|
9577
10861
|
function agentAssertionScorer(callback, options = {}) {
|
|
9578
10862
|
return async (args) => {
|
|
@@ -9585,7 +10869,7 @@ function agentAssertionScorer(callback, options = {}) {
|
|
|
9585
10869
|
});
|
|
9586
10870
|
const resources = {};
|
|
9587
10871
|
if (assertions.some((assertion) => assertion.requiresTrace)) {
|
|
9588
|
-
resources.spans = await _optionalChain([args, 'access',
|
|
10872
|
+
resources.spans = await _optionalChain([args, 'access', _191 => _191.trace, 'optionalAccess', _192 => _192.getSpans, 'call', _193 => _193({ spanType: ["tool"] })]);
|
|
9589
10873
|
}
|
|
9590
10874
|
const results = await Promise.all(
|
|
9591
10875
|
assertions.map(async (assertion) => {
|
|
@@ -9743,7 +11027,7 @@ async function validateSchema(schema, value) {
|
|
|
9743
11027
|
}
|
|
9744
11028
|
}
|
|
9745
11029
|
function toolCalls(spans) {
|
|
9746
|
-
return spans.filter((span) => _optionalChain([span, 'access',
|
|
11030
|
+
return spans.filter((span) => _optionalChain([span, 'access', _194 => _194.span_attributes, 'optionalAccess', _195 => _195.type]) === "tool");
|
|
9747
11031
|
}
|
|
9748
11032
|
function matchingToolCalls(spans, toolName, options) {
|
|
9749
11033
|
return toolCalls(spans).filter((span) => {
|
|
@@ -9761,17 +11045,17 @@ function matchingToolCalls(spans, toolName, options) {
|
|
|
9761
11045
|
});
|
|
9762
11046
|
}
|
|
9763
11047
|
function getToolName(span) {
|
|
9764
|
-
const spanName = [_optionalChain([span, 'access',
|
|
9765
|
-
if (_optionalChain([spanName, 'optionalAccess',
|
|
11048
|
+
const spanName = [_optionalChain([span, 'access', _196 => _196.span_attributes, 'optionalAccess', _197 => _197.name]), span.name].map(normalizeToolName).find((value) => value !== void 0);
|
|
11049
|
+
if (_optionalChain([spanName, 'optionalAccess', _198 => _198.includes, 'call', _199 => _199("/")])) {
|
|
9766
11050
|
return spanName;
|
|
9767
11051
|
}
|
|
9768
11052
|
const metadataName = [
|
|
9769
|
-
_optionalChain([span, 'access',
|
|
9770
|
-
_optionalChain([span, 'access',
|
|
11053
|
+
_optionalChain([span, 'access', _200 => _200.metadata, 'optionalAccess', _201 => _201.tool_name]),
|
|
11054
|
+
_optionalChain([span, 'access', _202 => _202.metadata, 'optionalAccess', _203 => _203["gen_ai.tool.name"]])
|
|
9771
11055
|
].map(normalizeToolName).find((value) => value !== void 0);
|
|
9772
11056
|
const mcpServer = [
|
|
9773
|
-
_optionalChain([span, 'access',
|
|
9774
|
-
_optionalChain([span, 'access',
|
|
11057
|
+
_optionalChain([span, 'access', _204 => _204.metadata, 'optionalAccess', _205 => _205["mcp.server"]]),
|
|
11058
|
+
_optionalChain([span, 'access', _206 => _206.metadata, 'optionalAccess', _207 => _207["openai_codex.mcp.server"]])
|
|
9775
11059
|
].find((value) => typeof value === "string" && value !== "");
|
|
9776
11060
|
if (metadataName && mcpServer) {
|
|
9777
11061
|
return `${mcpServer}/${metadataName}`;
|
|
@@ -9841,7 +11125,7 @@ function formatValue(value) {
|
|
|
9841
11125
|
return serialized;
|
|
9842
11126
|
}
|
|
9843
11127
|
return formatValueWithUndefined(value, /* @__PURE__ */ new Set());
|
|
9844
|
-
} catch (
|
|
11128
|
+
} catch (e12) {
|
|
9845
11129
|
return String(value);
|
|
9846
11130
|
}
|
|
9847
11131
|
}
|
|
@@ -9954,7 +11238,7 @@ var ProjectBuilder = class {
|
|
|
9954
11238
|
}
|
|
9955
11239
|
};
|
|
9956
11240
|
var projects = new ProjectBuilder();
|
|
9957
|
-
var Project2 = (
|
|
11241
|
+
var Project2 = (_class10 = class {
|
|
9958
11242
|
|
|
9959
11243
|
|
|
9960
11244
|
|
|
@@ -9962,10 +11246,10 @@ var Project2 = (_class7 = class {
|
|
|
9962
11246
|
|
|
9963
11247
|
|
|
9964
11248
|
|
|
9965
|
-
|
|
9966
|
-
|
|
9967
|
-
|
|
9968
|
-
constructor(args) {;
|
|
11249
|
+
__init19() {this._publishableCodeFunctions = []}
|
|
11250
|
+
__init20() {this._publishablePrompts = []}
|
|
11251
|
+
__init21() {this._publishableParameters = []}
|
|
11252
|
+
constructor(args) {;_class10.prototype.__init19.call(this);_class10.prototype.__init20.call(this);_class10.prototype.__init21.call(this);
|
|
9969
11253
|
_initializeSpanContext();
|
|
9970
11254
|
this.name = "name" in args ? args.name : void 0;
|
|
9971
11255
|
this.id = "id" in args ? args.id : void 0;
|
|
@@ -10000,7 +11284,7 @@ var Project2 = (_class7 = class {
|
|
|
10000
11284
|
console.warn("publish() is a no-op when running `braintrust push`.");
|
|
10001
11285
|
return;
|
|
10002
11286
|
}
|
|
10003
|
-
await
|
|
11287
|
+
await _chunkOBBWQW6Kjs.login.call(void 0, );
|
|
10004
11288
|
const projectMap = new ProjectNameIdMap();
|
|
10005
11289
|
const functionDefinitions = [];
|
|
10006
11290
|
if (this._publishableCodeFunctions.length > 0) {
|
|
@@ -10014,17 +11298,17 @@ var Project2 = (_class7 = class {
|
|
|
10014
11298
|
functionDefinitions.push(functionDefinition);
|
|
10015
11299
|
}
|
|
10016
11300
|
}
|
|
10017
|
-
await
|
|
11301
|
+
await _chunkOBBWQW6Kjs._internalGetGlobalState.call(void 0, ).apiConn().post_json("insert-functions", {
|
|
10018
11302
|
functions: functionDefinitions
|
|
10019
11303
|
});
|
|
10020
11304
|
}
|
|
10021
|
-
},
|
|
10022
|
-
var ToolBuilder = (
|
|
10023
|
-
constructor(project) {;
|
|
11305
|
+
}, _class10);
|
|
11306
|
+
var ToolBuilder = (_class11 = class {
|
|
11307
|
+
constructor(project) {;_class11.prototype.__init22.call(this);
|
|
10024
11308
|
this.project = project;
|
|
10025
11309
|
}
|
|
10026
11310
|
|
|
10027
|
-
|
|
11311
|
+
__init22() {this.taskCounter = 0}
|
|
10028
11312
|
// This type definition is just a catch all so that the implementation can be
|
|
10029
11313
|
// less specific than the two more specific declarations above.
|
|
10030
11314
|
create(opts) {
|
|
@@ -10033,12 +11317,12 @@ var ToolBuilder = (_class8 = class {
|
|
|
10033
11317
|
const { handler, name, slug, parameters, returns, ...rest } = opts;
|
|
10034
11318
|
let resolvedName = _nullishCoalesce(name, () => ( handler.name));
|
|
10035
11319
|
if (resolvedName.trim().length === 0) {
|
|
10036
|
-
resolvedName = `Tool ${
|
|
11320
|
+
resolvedName = `Tool ${_chunkBBE7SNRVjs.isomorph_default.basename(currentFilename)} ${this.taskCounter}`;
|
|
10037
11321
|
}
|
|
10038
11322
|
const tool = new CodeFunction(this.project, {
|
|
10039
11323
|
handler,
|
|
10040
11324
|
name: resolvedName,
|
|
10041
|
-
slug: _nullishCoalesce(slug, () => (
|
|
11325
|
+
slug: _nullishCoalesce(slug, () => ( _chunkOBBWQW6Kjs.slugify.call(void 0, resolvedName, { lower: true, strict: true }))),
|
|
10042
11326
|
type: "tool",
|
|
10043
11327
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/consistent-type-assertions
|
|
10044
11328
|
parameters,
|
|
@@ -10049,13 +11333,13 @@ var ToolBuilder = (_class8 = class {
|
|
|
10049
11333
|
this.project.addCodeFunction(tool);
|
|
10050
11334
|
return tool;
|
|
10051
11335
|
}
|
|
10052
|
-
},
|
|
10053
|
-
var ScorerBuilder = (
|
|
10054
|
-
constructor(project) {;
|
|
11336
|
+
}, _class11);
|
|
11337
|
+
var ScorerBuilder = (_class12 = class {
|
|
11338
|
+
constructor(project) {;_class12.prototype.__init23.call(this);
|
|
10055
11339
|
this.project = project;
|
|
10056
11340
|
}
|
|
10057
11341
|
|
|
10058
|
-
|
|
11342
|
+
__init23() {this.taskCounter = 0}
|
|
10059
11343
|
create(opts) {
|
|
10060
11344
|
this.taskCounter++;
|
|
10061
11345
|
let resolvedName = opts.name;
|
|
@@ -10063,9 +11347,9 @@ var ScorerBuilder = (_class9 = class {
|
|
|
10063
11347
|
resolvedName = opts.handler.name;
|
|
10064
11348
|
}
|
|
10065
11349
|
if (!resolvedName || resolvedName.trim().length === 0) {
|
|
10066
|
-
resolvedName = `Scorer ${
|
|
11350
|
+
resolvedName = `Scorer ${_chunkBBE7SNRVjs.isomorph_default.basename(currentFilename)} ${this.taskCounter}`;
|
|
10067
11351
|
}
|
|
10068
|
-
const slug = _nullishCoalesce(opts.slug, () => (
|
|
11352
|
+
const slug = _nullishCoalesce(opts.slug, () => ( _chunkOBBWQW6Kjs.slugify.call(void 0, resolvedName, { lower: true, strict: true })));
|
|
10069
11353
|
if ("handler" in opts) {
|
|
10070
11354
|
const scorer = new CodeFunction(this.project, {
|
|
10071
11355
|
...opts,
|
|
@@ -10109,20 +11393,20 @@ var ScorerBuilder = (_class9 = class {
|
|
|
10109
11393
|
this.project.addPrompt(codePrompt);
|
|
10110
11394
|
}
|
|
10111
11395
|
}
|
|
10112
|
-
},
|
|
10113
|
-
var ClassifierBuilder = (
|
|
10114
|
-
constructor(project) {;
|
|
11396
|
+
}, _class12);
|
|
11397
|
+
var ClassifierBuilder = (_class13 = class {
|
|
11398
|
+
constructor(project) {;_class13.prototype.__init24.call(this);
|
|
10115
11399
|
this.project = project;
|
|
10116
11400
|
}
|
|
10117
11401
|
|
|
10118
|
-
|
|
11402
|
+
__init24() {this.taskCounter = 0}
|
|
10119
11403
|
create(opts) {
|
|
10120
11404
|
this.taskCounter++;
|
|
10121
11405
|
let resolvedName = _nullishCoalesce(opts.name, () => ( opts.handler.name));
|
|
10122
11406
|
if (!resolvedName || resolvedName.trim().length === 0) {
|
|
10123
|
-
resolvedName = `Classifier ${
|
|
11407
|
+
resolvedName = `Classifier ${_chunkBBE7SNRVjs.isomorph_default.basename(currentFilename)} ${this.taskCounter}`;
|
|
10124
11408
|
}
|
|
10125
|
-
const slug = _nullishCoalesce(opts.slug, () => (
|
|
11409
|
+
const slug = _nullishCoalesce(opts.slug, () => ( _chunkOBBWQW6Kjs.slugify.call(void 0, resolvedName, { lower: true, strict: true })));
|
|
10126
11410
|
const classifier = new CodeFunction(this.project, {
|
|
10127
11411
|
...opts,
|
|
10128
11412
|
name: resolvedName,
|
|
@@ -10132,7 +11416,7 @@ var ClassifierBuilder = (_class10 = class {
|
|
|
10132
11416
|
this.project.addCodeFunction(classifier);
|
|
10133
11417
|
return classifier;
|
|
10134
11418
|
}
|
|
10135
|
-
},
|
|
11419
|
+
}, _class13);
|
|
10136
11420
|
var CodeFunction = class {
|
|
10137
11421
|
constructor(project, opts) {
|
|
10138
11422
|
this.project = project;
|
|
@@ -10251,18 +11535,18 @@ var PromptBuilder = class {
|
|
|
10251
11535
|
rawTools.push(tool);
|
|
10252
11536
|
}
|
|
10253
11537
|
}
|
|
10254
|
-
const slug = _nullishCoalesce(opts.slug, () => (
|
|
11538
|
+
const slug = _nullishCoalesce(opts.slug, () => ( _chunkOBBWQW6Kjs.slugify.call(void 0, opts.name, { lower: true, strict: true })));
|
|
10255
11539
|
const promptData = promptDefinitionToPromptData(opts, rawTools);
|
|
10256
11540
|
const promptRow = {
|
|
10257
11541
|
id: opts.id,
|
|
10258
|
-
_xact_id: opts.version ?
|
|
11542
|
+
_xact_id: opts.version ? _chunkOBBWQW6Kjs.loadPrettyXact.call(void 0, opts.version) : void 0,
|
|
10259
11543
|
name: opts.name,
|
|
10260
11544
|
slug,
|
|
10261
11545
|
prompt_data: promptData,
|
|
10262
11546
|
tags: opts.tags,
|
|
10263
11547
|
...this.project.id !== void 0 ? { project_id: this.project.id } : {}
|
|
10264
11548
|
};
|
|
10265
|
-
const prompt = new (0,
|
|
11549
|
+
const prompt = new (0, _chunkOBBWQW6Kjs.Prompt)(
|
|
10266
11550
|
promptRow,
|
|
10267
11551
|
{},
|
|
10268
11552
|
// It doesn't make sense to specify defaults here.
|
|
@@ -10317,7 +11601,7 @@ var ParametersBuilder = class {
|
|
|
10317
11601
|
}
|
|
10318
11602
|
|
|
10319
11603
|
create(opts) {
|
|
10320
|
-
const slug = _nullishCoalesce(opts.slug, () => (
|
|
11604
|
+
const slug = _nullishCoalesce(opts.slug, () => ( _chunkOBBWQW6Kjs.slugify.call(void 0, opts.name, { lower: true, strict: true })));
|
|
10321
11605
|
const codeParameters = new CodeParameters(this.project, {
|
|
10322
11606
|
name: opts.name,
|
|
10323
11607
|
slug,
|
|
@@ -10356,7 +11640,7 @@ function serializeEvalParameterstoParametersSchema(parameters) {
|
|
|
10356
11640
|
required.push(name);
|
|
10357
11641
|
}
|
|
10358
11642
|
} else {
|
|
10359
|
-
const schemaObj =
|
|
11643
|
+
const schemaObj = _chunkOBBWQW6Kjs.zodToJsonSchema.call(void 0, value);
|
|
10360
11644
|
properties[name] = schemaObj;
|
|
10361
11645
|
if (!("default" in schemaObj)) {
|
|
10362
11646
|
required.push(name);
|
|
@@ -10380,16 +11664,16 @@ function getDefaultDataFromParametersSchema(schema) {
|
|
|
10380
11664
|
})
|
|
10381
11665
|
);
|
|
10382
11666
|
}
|
|
10383
|
-
var ProjectNameIdMap = (
|
|
10384
|
-
|
|
10385
|
-
|
|
11667
|
+
var ProjectNameIdMap = (_class14 = class {constructor() { _class14.prototype.__init25.call(this);_class14.prototype.__init26.call(this); }
|
|
11668
|
+
__init25() {this.nameToId = {}}
|
|
11669
|
+
__init26() {this.idToName = {}}
|
|
10386
11670
|
async getId(projectName) {
|
|
10387
11671
|
if (!(projectName in this.nameToId)) {
|
|
10388
|
-
const response = await
|
|
11672
|
+
const response = await _chunkOBBWQW6Kjs._internalGetGlobalState.call(void 0, ).appConn().post_json("api/project/register", {
|
|
10389
11673
|
project_name: projectName
|
|
10390
11674
|
});
|
|
10391
11675
|
const result = _v3.z.object({
|
|
10392
|
-
project:
|
|
11676
|
+
project: _chunkOBBWQW6Kjs.Project
|
|
10393
11677
|
}).parse(response);
|
|
10394
11678
|
const projectId = result.project.id;
|
|
10395
11679
|
this.nameToId[projectName] = projectId;
|
|
@@ -10399,10 +11683,10 @@ var ProjectNameIdMap = (_class11 = class {constructor() { _class11.prototype.__i
|
|
|
10399
11683
|
}
|
|
10400
11684
|
async getName(projectId) {
|
|
10401
11685
|
if (!(projectId in this.idToName)) {
|
|
10402
|
-
const response = await
|
|
11686
|
+
const response = await _chunkOBBWQW6Kjs._internalGetGlobalState.call(void 0, ).appConn().post_json("api/project/get", {
|
|
10403
11687
|
id: projectId
|
|
10404
11688
|
});
|
|
10405
|
-
const result = _v3.z.array(
|
|
11689
|
+
const result = _v3.z.array(_chunkOBBWQW6Kjs.Project).nonempty().parse(response);
|
|
10406
11690
|
const projectName = result[0].name;
|
|
10407
11691
|
this.idToName[projectId] = projectName;
|
|
10408
11692
|
this.nameToId[projectName] = projectId;
|
|
@@ -10415,23 +11699,23 @@ var ProjectNameIdMap = (_class11 = class {constructor() { _class11.prototype.__i
|
|
|
10415
11699
|
}
|
|
10416
11700
|
return this.getId(project.name);
|
|
10417
11701
|
}
|
|
10418
|
-
},
|
|
11702
|
+
}, _class14);
|
|
10419
11703
|
|
|
10420
11704
|
// dev/types.ts
|
|
10421
11705
|
|
|
10422
11706
|
var evalBodySchema = _v3.z.object({
|
|
10423
11707
|
name: _v3.z.string(),
|
|
10424
11708
|
parameters: _v3.z.record(_v3.z.string(), _v3.z.unknown()).nullish(),
|
|
10425
|
-
data:
|
|
11709
|
+
data: _chunkOBBWQW6Kjs.RunEval.shape.data,
|
|
10426
11710
|
scores: _v3.z.array(
|
|
10427
11711
|
_v3.z.object({
|
|
10428
|
-
function_id:
|
|
11712
|
+
function_id: _chunkOBBWQW6Kjs.FunctionId,
|
|
10429
11713
|
name: _v3.z.string()
|
|
10430
11714
|
})
|
|
10431
11715
|
).nullish(),
|
|
10432
11716
|
experiment_name: _v3.z.string().nullish(),
|
|
10433
11717
|
project_id: _v3.z.string().nullish(),
|
|
10434
|
-
parent:
|
|
11718
|
+
parent: _chunkOBBWQW6Kjs.InvokeParent.optional(),
|
|
10435
11719
|
stream: _v3.z.boolean().optional()
|
|
10436
11720
|
});
|
|
10437
11721
|
var staticParametersSchema = _v3.z.record(
|
|
@@ -10439,7 +11723,7 @@ var staticParametersSchema = _v3.z.record(
|
|
|
10439
11723
|
_v3.z.union([
|
|
10440
11724
|
_v3.z.object({
|
|
10441
11725
|
type: _v3.z.literal("prompt"),
|
|
10442
|
-
default:
|
|
11726
|
+
default: _chunkOBBWQW6Kjs.PromptData.optional(),
|
|
10443
11727
|
description: _v3.z.string().optional()
|
|
10444
11728
|
}),
|
|
10445
11729
|
_v3.z.object({
|
|
@@ -10495,7 +11779,13 @@ var evaluatorDefinitionsSchema = _v3.z.record(
|
|
|
10495
11779
|
);
|
|
10496
11780
|
|
|
10497
11781
|
// src/node/index.ts
|
|
10498
|
-
|
|
11782
|
+
_chunkOBBWQW6Kjs.configureNode.call(void 0, );
|
|
11783
|
+
|
|
11784
|
+
|
|
11785
|
+
|
|
11786
|
+
|
|
11787
|
+
|
|
11788
|
+
|
|
10499
11789
|
|
|
10500
11790
|
|
|
10501
11791
|
|
|
@@ -10672,4 +11962,4 @@ _chunkQRHGVBKUjs.configureNode.call(void 0, );
|
|
|
10672
11962
|
|
|
10673
11963
|
|
|
10674
11964
|
|
|
10675
|
-
exports.Attachment = _chunkQRHGVBKUjs.Attachment; exports.AttachmentReference = _chunkQRHGVBKUjs.AttachmentReference; exports.BAGGAGE_HEADER = _chunkQRHGVBKUjs.BAGGAGE_HEADER; exports.BRAINTRUST_CURRENT_SPAN_STORE = _chunkQRHGVBKUjs.BRAINTRUST_CURRENT_SPAN_STORE; exports.BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME = _chunkQRHGVBKUjs.BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME; exports.BRAINTRUST_PARENT_KEY = _chunkQRHGVBKUjs.BRAINTRUST_PARENT_KEY; exports.BaseAttachment = _chunkQRHGVBKUjs.BaseAttachment; exports.BaseExperiment = BaseExperiment; exports.BraintrustLangChainCallbackHandler = _chunkQRHGVBKUjs.BraintrustLangChainCallbackHandler; exports.BraintrustMiddleware = BraintrustMiddleware; exports.BraintrustObservabilityExporter = _chunkQRHGVBKUjs.BraintrustObservabilityExporter; exports.BraintrustState = _chunkQRHGVBKUjs.BraintrustState; exports.BraintrustStream = _chunkQRHGVBKUjs.BraintrustStream; exports.CachedSpanFetcher = CachedSpanFetcher; exports.CodeFunction = CodeFunction; exports.CodePrompt = CodePrompt; exports.ContextManager = _chunkQRHGVBKUjs.ContextManager; exports.DEFAULT_FETCH_BATCH_SIZE = _chunkQRHGVBKUjs.DEFAULT_FETCH_BATCH_SIZE; exports.DEFAULT_MAX_REQUEST_SIZE = _chunkQRHGVBKUjs.DEFAULT_MAX_REQUEST_SIZE; exports.Dataset = _chunkQRHGVBKUjs.Dataset; exports.DatasetPipeline = DatasetPipeline; exports.ERR_PERMALINK = _chunkQRHGVBKUjs.ERR_PERMALINK; exports.Eval = Eval; exports.EvalResultWithSummary = EvalResultWithSummary; exports.Experiment = _chunkQRHGVBKUjs.Experiment; exports.ExternalAttachment = _chunkQRHGVBKUjs.ExternalAttachment; exports.FailedHTTPResponse = _chunkQRHGVBKUjs.FailedHTTPResponse; exports.IDGenerator = _chunkQRHGVBKUjs.IDGenerator; exports.JSONAttachment = _chunkQRHGVBKUjs.JSONAttachment; exports.LEGACY_CACHED_HEADER = _chunkQRHGVBKUjs.LEGACY_CACHED_HEADER; exports.LOGS3_OVERFLOW_REFERENCE_TYPE = _chunkQRHGVBKUjs.LOGS3_OVERFLOW_REFERENCE_TYPE; exports.LazyValue = _chunkQRHGVBKUjs.LazyValue; exports.LocalTrace = LocalTrace; exports.Logger = _chunkQRHGVBKUjs.Logger; exports.LoginInvalidOrgError = _chunkQRHGVBKUjs.LoginInvalidOrgError; exports.NOOP_SPAN = _chunkQRHGVBKUjs.NOOP_SPAN; exports.NOOP_SPAN_PERMALINK = _chunkQRHGVBKUjs.NOOP_SPAN_PERMALINK; exports.NoopSpan = _chunkQRHGVBKUjs.NoopSpan; exports.OTELIDGenerator = _chunkQRHGVBKUjs.OTELIDGenerator; exports.ObjectFetcher = _chunkQRHGVBKUjs.ObjectFetcher; exports.Project = Project2; exports.ProjectNameIdMap = ProjectNameIdMap; exports.Prompt = _chunkQRHGVBKUjs.Prompt; exports.PromptBuilder = PromptBuilder; exports.ReadonlyAttachment = _chunkQRHGVBKUjs.ReadonlyAttachment; exports.ReadonlyExperiment = _chunkQRHGVBKUjs.ReadonlyExperiment; exports.Reporter = Reporter; exports.ScorerBuilder = ScorerBuilder; exports.SpanFetcher = SpanFetcher; exports.SpanImpl = _chunkQRHGVBKUjs.SpanImpl; exports.TRACEPARENT_HEADER = _chunkQRHGVBKUjs.TRACEPARENT_HEADER; exports.TRACESTATE_HEADER = _chunkQRHGVBKUjs.TRACESTATE_HEADER; exports.TestBackgroundLogger = _chunkQRHGVBKUjs.TestBackgroundLogger; exports.ToolBuilder = ToolBuilder; exports.UUIDGenerator = _chunkQRHGVBKUjs.UUIDGenerator; exports.X_CACHED_HEADER = _chunkQRHGVBKUjs.X_CACHED_HEADER; exports._exportsForTestingOnly = _chunkQRHGVBKUjs._exportsForTestingOnly; exports._internalGetGlobalState = _chunkQRHGVBKUjs._internalGetGlobalState; exports._internalIso = _chunkMF7NU6BTjs.isomorph_default; exports._internalSetInitialState = _chunkQRHGVBKUjs._internalSetInitialState; exports.addAzureBlobHeaders = _chunkQRHGVBKUjs.addAzureBlobHeaders; exports.agentAssertionScorer = agentAssertionScorer; exports.braintrustAISDKTelemetry = _chunkQRHGVBKUjs.braintrustAISDKTelemetry; exports.braintrustEveHook = braintrustEveHook; exports.braintrustEveInstrumentation = braintrustEveInstrumentation; exports.braintrustFlueInstrumentation = _chunkQRHGVBKUjs.braintrustFlueInstrumentation; exports.braintrustFlueObserver = _chunkQRHGVBKUjs.braintrustFlueObserver; exports.braintrustStreamChunkSchema = _chunkQRHGVBKUjs.braintrustStreamChunkSchema; exports.buildLocalSummary = buildLocalSummary; exports.collectAnthropicSession = _chunkQRHGVBKUjs.collectAnthropicSession; exports.configureInstrumentation = _chunkQRHGVBKUjs.configureInstrumentation; exports.constructLogs3OverflowRequest = _chunkQRHGVBKUjs.constructLogs3OverflowRequest; exports.createFinalValuePassThroughStream = _chunkQRHGVBKUjs.createFinalValuePassThroughStream; exports.currentExperiment = _chunkQRHGVBKUjs.currentExperiment; exports.currentLogger = _chunkQRHGVBKUjs.currentLogger; exports.currentSpan = _chunkQRHGVBKUjs.currentSpan; exports.deepCopyEvent = _chunkQRHGVBKUjs.deepCopyEvent; exports.default = exports_exports; exports.defaultErrorScoreHandler = defaultErrorScoreHandler; exports.deserializePlainStringAsJSON = _chunkQRHGVBKUjs.deserializePlainStringAsJSON; exports.devNullWritableStream = _chunkQRHGVBKUjs.devNullWritableStream; exports.evaluatorDefinitionSchema = evaluatorDefinitionSchema; exports.evaluatorDefinitionsSchema = evaluatorDefinitionsSchema; exports.extractTraceContextFromHeaders = _chunkQRHGVBKUjs.extractTraceContextFromHeaders; exports.flush = _chunkQRHGVBKUjs.flush; exports.getContextManager = _chunkQRHGVBKUjs.getContextManager; exports.getIdGenerator = _chunkQRHGVBKUjs.getIdGenerator; exports.getPromptVersions = _chunkQRHGVBKUjs.getPromptVersions; exports.getSpanParentObject = _chunkQRHGVBKUjs.getSpanParentObject; exports.getTemplateRenderer = _chunkQRHGVBKUjs.getTemplateRenderer; exports.graph = graph_framework_exports; exports.init = _chunkQRHGVBKUjs.init; exports.initDataset = _chunkQRHGVBKUjs.initDataset; exports.initExperiment = _chunkQRHGVBKUjs.initExperiment; exports.initFunction = initFunction; exports.initLogger = _chunkQRHGVBKUjs.initLogger; exports.initNodeTestSuite = initNodeTestSuite; exports.injectTraceContext = _chunkQRHGVBKUjs.injectTraceContext; exports.invoke = invoke; exports.isTemplateFormat = _chunkQRHGVBKUjs.isTemplateFormat; exports.loadParameters = _chunkQRHGVBKUjs.loadParameters; exports.loadPrompt = _chunkQRHGVBKUjs.loadPrompt; exports.log = _chunkQRHGVBKUjs.log; exports.logError = _chunkQRHGVBKUjs.logError; exports.login = _chunkQRHGVBKUjs.login; exports.loginToState = _chunkQRHGVBKUjs.loginToState; exports.logs3OverflowUploadSchema = _chunkQRHGVBKUjs.logs3OverflowUploadSchema; exports.newId = _chunkQRHGVBKUjs.newId; exports.parseCachedHeader = _chunkQRHGVBKUjs.parseCachedHeader; exports.parseTemplateFormat = _chunkQRHGVBKUjs.parseTemplateFormat; exports.permalink = _chunkQRHGVBKUjs.permalink; exports.pickLogs3OverflowObjectIds = _chunkQRHGVBKUjs.pickLogs3OverflowObjectIds; exports.projects = projects; exports.promptContentsSchema = promptContentsSchema; exports.promptDefinitionSchema = promptDefinitionSchema; exports.promptDefinitionToPromptData = promptDefinitionToPromptData; exports.promptDefinitionWithToolsSchema = promptDefinitionWithToolsSchema; exports.registerOtelFlush = _chunkQRHGVBKUjs.registerOtelFlush; exports.registerSandbox = registerSandbox; exports.registerTemplatePlugin = _chunkQRHGVBKUjs.registerTemplatePlugin; exports.renderMessage = _chunkQRHGVBKUjs.renderMessage; exports.renderPromptParams = _chunkQRHGVBKUjs.renderPromptParams; exports.renderTemplateContent = _chunkQRHGVBKUjs.renderTemplateContent; exports.reportFailures = reportFailures; exports.runEvaluator = runEvaluator; exports.setFetch = _chunkQRHGVBKUjs.setFetch; exports.setMaskingFunction = _chunkQRHGVBKUjs.setMaskingFunction; exports.spanComponentsToObjectId = _chunkQRHGVBKUjs.spanComponentsToObjectId; exports.startSpan = _chunkQRHGVBKUjs.startSpan; exports.summarize = _chunkQRHGVBKUjs.summarize; exports.templateRegistry = _chunkQRHGVBKUjs.templateRegistry; exports.toolFunctionDefinitionSchema = _chunkQRHGVBKUjs.ToolFunctionDefinition; exports.traceable = _chunkQRHGVBKUjs.traceable; exports.traced = _chunkQRHGVBKUjs.traced; exports.updateSpan = _chunkQRHGVBKUjs.updateSpan; exports.uploadLogs3OverflowPayload = _chunkQRHGVBKUjs.uploadLogs3OverflowPayload; exports.utf8ByteLength = _chunkQRHGVBKUjs.utf8ByteLength; exports.withCurrent = _chunkQRHGVBKUjs.withCurrent; exports.withDataset = _chunkQRHGVBKUjs.withDataset; exports.withExperiment = _chunkQRHGVBKUjs.withExperiment; exports.withLogger = _chunkQRHGVBKUjs.withLogger; exports.withParent = _chunkQRHGVBKUjs.withParent; exports.wrapAISDK = wrapAISDK; exports.wrapAISDKModel = wrapAISDKModel; exports.wrapAgentClass = wrapAgentClass; exports.wrapAnthropic = wrapAnthropic; exports.wrapBedrockRuntime = wrapBedrockRuntime; exports.wrapClaudeAgentSDK = wrapClaudeAgentSDK; exports.wrapCloudflareAIChat = wrapCloudflareAIChat; exports.wrapCloudflareAgent = wrapCloudflareAgent; exports.wrapCloudflareThink = wrapCloudflareThink; 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.wrapHuggingFaceTransformers = wrapHuggingFaceTransformers; exports.wrapLangSmithClient = wrapLangSmithClient; exports.wrapLangSmithRunTrees = wrapLangSmithRunTrees; exports.wrapLangSmithTraceable = wrapLangSmithTraceable; exports.wrapMastraAgent = _chunkQRHGVBKUjs.wrapMastraAgent; exports.wrapMistral = wrapMistral; exports.wrapOllama = wrapOllama; exports.wrapOpenAI = wrapOpenAI; exports.wrapOpenAICodexSDK = wrapOpenAICodexSDK; exports.wrapOpenAIv4 = wrapOpenAIv4; exports.wrapOpenRouter = wrapOpenRouter; exports.wrapOpenRouterAgent = wrapOpenRouterAgent; exports.wrapPiCodingAgentSDK = wrapPiCodingAgentSDK; exports.wrapStrandsAgentSDK = wrapStrandsAgentSDK; exports.wrapTraced = _chunkQRHGVBKUjs.wrapTraced; exports.wrapVitest = wrapVitest;
|
|
11965
|
+
exports.Attachment = _chunkOBBWQW6Kjs.Attachment; exports.AttachmentReference = _chunkOBBWQW6Kjs.AttachmentReference; exports.BAGGAGE_HEADER = _chunkOBBWQW6Kjs.BAGGAGE_HEADER; exports.BRAINTRUST_CURRENT_SPAN_STORE = _chunkOBBWQW6Kjs.BRAINTRUST_CURRENT_SPAN_STORE; exports.BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME = _chunkOBBWQW6Kjs.BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME; exports.BRAINTRUST_PARENT_KEY = _chunkOBBWQW6Kjs.BRAINTRUST_PARENT_KEY; exports.BaseAttachment = _chunkOBBWQW6Kjs.BaseAttachment; exports.BaseExperiment = BaseExperiment; exports.BatchScorer = BatchScorer; exports.BatchTask = BatchTask; exports.BraintrustLangChainCallbackHandler = _chunkOBBWQW6Kjs.BraintrustLangChainCallbackHandler; exports.BraintrustMiddleware = BraintrustMiddleware; exports.BraintrustObservabilityExporter = _chunkOBBWQW6Kjs.BraintrustObservabilityExporter; exports.BraintrustState = _chunkOBBWQW6Kjs.BraintrustState; exports.BraintrustStream = _chunkOBBWQW6Kjs.BraintrustStream; exports.CachedSpanFetcher = CachedSpanFetcher; exports.CodeFunction = CodeFunction; exports.CodePrompt = CodePrompt; exports.ContextManager = _chunkOBBWQW6Kjs.ContextManager; exports.DEFAULT_FETCH_BATCH_SIZE = _chunkOBBWQW6Kjs.DEFAULT_FETCH_BATCH_SIZE; exports.DEFAULT_MAX_REQUEST_SIZE = _chunkOBBWQW6Kjs.DEFAULT_MAX_REQUEST_SIZE; exports.Dataset = _chunkOBBWQW6Kjs.Dataset; exports.DatasetPipeline = DatasetPipeline; exports.DurableEvalMemoryStore = DurableEvalMemoryStore; exports.DurableEvalRedisStore = DurableEvalRedisStore; exports.ERR_PERMALINK = _chunkOBBWQW6Kjs.ERR_PERMALINK; exports.Eval = Eval; exports.EvalResultWithSummary = EvalResultWithSummary; exports.Experiment = _chunkOBBWQW6Kjs.Experiment; exports.ExternalAttachment = _chunkOBBWQW6Kjs.ExternalAttachment; exports.FailedHTTPResponse = _chunkOBBWQW6Kjs.FailedHTTPResponse; exports.IDGenerator = _chunkOBBWQW6Kjs.IDGenerator; exports.JSONAttachment = _chunkOBBWQW6Kjs.JSONAttachment; exports.LEGACY_CACHED_HEADER = _chunkOBBWQW6Kjs.LEGACY_CACHED_HEADER; exports.LOGS3_OVERFLOW_REFERENCE_TYPE = _chunkOBBWQW6Kjs.LOGS3_OVERFLOW_REFERENCE_TYPE; exports.LazyValue = _chunkOBBWQW6Kjs.LazyValue; exports.LocalTrace = LocalTrace; exports.Logger = _chunkOBBWQW6Kjs.Logger; exports.LoginInvalidOrgError = _chunkOBBWQW6Kjs.LoginInvalidOrgError; exports.NOOP_SPAN = _chunkOBBWQW6Kjs.NOOP_SPAN; exports.NOOP_SPAN_PERMALINK = _chunkOBBWQW6Kjs.NOOP_SPAN_PERMALINK; exports.NoopSpan = _chunkOBBWQW6Kjs.NoopSpan; exports.OTELIDGenerator = _chunkOBBWQW6Kjs.OTELIDGenerator; exports.ObjectFetcher = _chunkOBBWQW6Kjs.ObjectFetcher; exports.Project = Project2; exports.ProjectNameIdMap = ProjectNameIdMap; exports.Prompt = _chunkOBBWQW6Kjs.Prompt; exports.PromptBuilder = PromptBuilder; exports.ReadonlyAttachment = _chunkOBBWQW6Kjs.ReadonlyAttachment; exports.ReadonlyExperiment = _chunkOBBWQW6Kjs.ReadonlyExperiment; exports.Reporter = Reporter; exports.ScorerBuilder = ScorerBuilder; exports.SpanFetcher = SpanFetcher; exports.SpanImpl = _chunkOBBWQW6Kjs.SpanImpl; exports.TRACEPARENT_HEADER = _chunkOBBWQW6Kjs.TRACEPARENT_HEADER; exports.TRACESTATE_HEADER = _chunkOBBWQW6Kjs.TRACESTATE_HEADER; exports.TestBackgroundLogger = _chunkOBBWQW6Kjs.TestBackgroundLogger; exports.ToolBuilder = ToolBuilder; exports.UUIDGenerator = _chunkOBBWQW6Kjs.UUIDGenerator; exports.X_CACHED_HEADER = _chunkOBBWQW6Kjs.X_CACHED_HEADER; exports._exportsForTestingOnly = _chunkOBBWQW6Kjs._exportsForTestingOnly; exports._internalGetGlobalState = _chunkOBBWQW6Kjs._internalGetGlobalState; exports._internalIso = _chunkBBE7SNRVjs.isomorph_default; exports._internalSetInitialState = _chunkOBBWQW6Kjs._internalSetInitialState; exports.addAzureBlobHeaders = _chunkOBBWQW6Kjs.addAzureBlobHeaders; exports.agentAssertionScorer = agentAssertionScorer; exports.braintrustAISDKTelemetry = _chunkOBBWQW6Kjs.braintrustAISDKTelemetry; exports.braintrustEveHook = braintrustEveHook; exports.braintrustEveInstrumentation = braintrustEveInstrumentation; exports.braintrustFlueInstrumentation = _chunkOBBWQW6Kjs.braintrustFlueInstrumentation; exports.braintrustFlueObserver = _chunkOBBWQW6Kjs.braintrustFlueObserver; exports.braintrustStreamChunkSchema = _chunkOBBWQW6Kjs.braintrustStreamChunkSchema; exports.buildLocalSummary = buildLocalSummary; exports.collectAnthropicSession = _chunkOBBWQW6Kjs.collectAnthropicSession; exports.configureInstrumentation = _chunkOBBWQW6Kjs.configureInstrumentation; exports.constructLogs3OverflowRequest = _chunkOBBWQW6Kjs.constructLogs3OverflowRequest; exports.createFinalValuePassThroughStream = _chunkOBBWQW6Kjs.createFinalValuePassThroughStream; exports.currentExperiment = _chunkOBBWQW6Kjs.currentExperiment; exports.currentLogger = _chunkOBBWQW6Kjs.currentLogger; exports.currentSpan = _chunkOBBWQW6Kjs.currentSpan; exports.deepCopyEvent = _chunkOBBWQW6Kjs.deepCopyEvent; exports.default = exports_exports; exports.defaultErrorScoreHandler = defaultErrorScoreHandler; exports.defineDurableEval = defineDurableEval; exports.deserializePlainStringAsJSON = _chunkOBBWQW6Kjs.deserializePlainStringAsJSON; exports.devNullWritableStream = _chunkOBBWQW6Kjs.devNullWritableStream; exports.evaluatorDefinitionSchema = evaluatorDefinitionSchema; exports.evaluatorDefinitionsSchema = evaluatorDefinitionsSchema; exports.extractTraceContextFromHeaders = _chunkOBBWQW6Kjs.extractTraceContextFromHeaders; exports.flush = _chunkOBBWQW6Kjs.flush; exports.getContextManager = _chunkOBBWQW6Kjs.getContextManager; exports.getIdGenerator = _chunkOBBWQW6Kjs.getIdGenerator; exports.getPromptVersions = _chunkOBBWQW6Kjs.getPromptVersions; exports.getSpanParentObject = _chunkOBBWQW6Kjs.getSpanParentObject; exports.getTemplateRenderer = _chunkOBBWQW6Kjs.getTemplateRenderer; exports.graph = graph_framework_exports; exports.init = _chunkOBBWQW6Kjs.init; exports.initDataset = _chunkOBBWQW6Kjs.initDataset; exports.initExperiment = _chunkOBBWQW6Kjs.initExperiment; exports.initFunction = initFunction; exports.initLogger = _chunkOBBWQW6Kjs.initLogger; exports.initNodeTestSuite = initNodeTestSuite; exports.injectTraceContext = _chunkOBBWQW6Kjs.injectTraceContext; exports.invoke = invoke; exports.isTemplateFormat = _chunkOBBWQW6Kjs.isTemplateFormat; exports.loadParameters = _chunkOBBWQW6Kjs.loadParameters; exports.loadPrompt = _chunkOBBWQW6Kjs.loadPrompt; exports.log = _chunkOBBWQW6Kjs.log; exports.logError = _chunkOBBWQW6Kjs.logError; exports.login = _chunkOBBWQW6Kjs.login; exports.loginToState = _chunkOBBWQW6Kjs.loginToState; exports.logs3OverflowUploadSchema = _chunkOBBWQW6Kjs.logs3OverflowUploadSchema; exports.newId = _chunkOBBWQW6Kjs.newId; exports.parseCachedHeader = _chunkOBBWQW6Kjs.parseCachedHeader; exports.parseTemplateFormat = _chunkOBBWQW6Kjs.parseTemplateFormat; exports.permalink = _chunkOBBWQW6Kjs.permalink; exports.pickLogs3OverflowObjectIds = _chunkOBBWQW6Kjs.pickLogs3OverflowObjectIds; exports.projects = projects; exports.promptContentsSchema = promptContentsSchema; exports.promptDefinitionSchema = promptDefinitionSchema; exports.promptDefinitionToPromptData = promptDefinitionToPromptData; exports.promptDefinitionWithToolsSchema = promptDefinitionWithToolsSchema; exports.registerOtelFlush = _chunkOBBWQW6Kjs.registerOtelFlush; exports.registerSandbox = registerSandbox; exports.registerTemplatePlugin = _chunkOBBWQW6Kjs.registerTemplatePlugin; exports.renderMessage = _chunkOBBWQW6Kjs.renderMessage; exports.renderPromptParams = _chunkOBBWQW6Kjs.renderPromptParams; exports.renderTemplateContent = _chunkOBBWQW6Kjs.renderTemplateContent; exports.reportFailures = reportFailures; exports.runEvaluator = runEvaluator; exports.setFetch = _chunkOBBWQW6Kjs.setFetch; exports.setMaskingFunction = _chunkOBBWQW6Kjs.setMaskingFunction; exports.spanComponentsToObjectId = _chunkOBBWQW6Kjs.spanComponentsToObjectId; exports.startSpan = _chunkOBBWQW6Kjs.startSpan; exports.summarize = _chunkOBBWQW6Kjs.summarize; exports.templateRegistry = _chunkOBBWQW6Kjs.templateRegistry; exports.toolFunctionDefinitionSchema = _chunkOBBWQW6Kjs.ToolFunctionDefinition; exports.traceable = _chunkOBBWQW6Kjs.traceable; exports.traced = _chunkOBBWQW6Kjs.traced; exports.updateSpan = _chunkOBBWQW6Kjs.updateSpan; exports.uploadLogs3OverflowPayload = _chunkOBBWQW6Kjs.uploadLogs3OverflowPayload; exports.utf8ByteLength = _chunkOBBWQW6Kjs.utf8ByteLength; exports.withCurrent = _chunkOBBWQW6Kjs.withCurrent; exports.withDataset = _chunkOBBWQW6Kjs.withDataset; exports.withExperiment = _chunkOBBWQW6Kjs.withExperiment; exports.withLogger = _chunkOBBWQW6Kjs.withLogger; exports.withParent = _chunkOBBWQW6Kjs.withParent; exports.wrapAISDK = wrapAISDK; exports.wrapAISDKModel = wrapAISDKModel; exports.wrapAgentClass = wrapAgentClass; exports.wrapAnthropic = wrapAnthropic; exports.wrapBedrockRuntime = wrapBedrockRuntime; exports.wrapClaudeAgentSDK = wrapClaudeAgentSDK; exports.wrapCloudflareAIChat = wrapCloudflareAIChat; exports.wrapCloudflareAgent = wrapCloudflareAgent; exports.wrapCloudflareThink = wrapCloudflareThink; 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.wrapHuggingFaceTransformers = wrapHuggingFaceTransformers; exports.wrapLangSmithClient = wrapLangSmithClient; exports.wrapLangSmithRunTrees = wrapLangSmithRunTrees; exports.wrapLangSmithTraceable = wrapLangSmithTraceable; exports.wrapMastraAgent = _chunkOBBWQW6Kjs.wrapMastraAgent; exports.wrapMistral = wrapMistral; exports.wrapOllama = wrapOllama; exports.wrapOpenAI = wrapOpenAI; exports.wrapOpenAICodexSDK = wrapOpenAICodexSDK; exports.wrapOpenAIv4 = wrapOpenAIv4; exports.wrapOpenRouter = wrapOpenRouter; exports.wrapOpenRouterAgent = wrapOpenRouterAgent; exports.wrapPiCodingAgentSDK = wrapPiCodingAgentSDK; exports.wrapStrandsAgentSDK = wrapStrandsAgentSDK; exports.wrapTraced = _chunkOBBWQW6Kjs.wrapTraced; exports.wrapVitest = wrapVitest; exports.wrapVoyageAI = wrapVoyageAI;
|