braintrust 3.26.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 +3727 -1526
- package/dev/dist/index.mjs +2815 -614
- package/dist/apply-auto-instrumentation.js +372 -261
- package/dist/apply-auto-instrumentation.mjs +171 -60
- package/dist/auto-instrumentations/bundler/esbuild.cjs +458 -61
- package/dist/auto-instrumentations/bundler/esbuild.mjs +5 -4
- package/dist/auto-instrumentations/bundler/next.cjs +460 -63
- package/dist/auto-instrumentations/bundler/next.mjs +6 -5
- package/dist/auto-instrumentations/bundler/rollup.cjs +458 -61
- package/dist/auto-instrumentations/bundler/rollup.mjs +5 -4
- package/dist/auto-instrumentations/bundler/vite.cjs +487 -62
- package/dist/auto-instrumentations/bundler/vite.mjs +34 -5
- package/dist/auto-instrumentations/bundler/webpack-loader.cjs +444 -61
- package/dist/auto-instrumentations/bundler/webpack.cjs +458 -61
- package/dist/auto-instrumentations/bundler/webpack.mjs +6 -5
- package/dist/auto-instrumentations/{chunk-6E22MYSW.mjs → chunk-26PKVUKB.mjs} +109 -5
- package/dist/auto-instrumentations/{chunk-AKKPLXTP.mjs → chunk-2AMDGD65.mjs} +160 -57
- package/dist/auto-instrumentations/{chunk-V5LEODRX.mjs → chunk-HD35AM3M.mjs} +1 -1
- package/dist/auto-instrumentations/{chunk-XYN63IG5.mjs → chunk-I55G56ZL.mjs} +21 -58
- package/dist/auto-instrumentations/{chunk-NRE4QUQR.mjs → chunk-JPUFNW7X.mjs} +140 -0
- package/dist/auto-instrumentations/{chunk-XZHHE4Y3.mjs → chunk-NP7V4XB2.mjs} +157 -3
- package/dist/auto-instrumentations/hook.mjs +396 -32
- package/dist/auto-instrumentations/index.cjs +298 -2
- package/dist/auto-instrumentations/index.d.mts +5 -1
- package/dist/auto-instrumentations/index.d.ts +5 -1
- package/dist/auto-instrumentations/index.mjs +6 -2
- package/dist/auto-instrumentations/loader/cjs-patch.cjs +105 -57
- package/dist/auto-instrumentations/loader/cjs-patch.mjs +2 -2
- package/dist/auto-instrumentations/loader/esm-hook.mjs +1 -1
- package/dist/browser.d.mts +683 -56
- package/dist/browser.d.ts +683 -56
- package/dist/browser.js +4242 -655
- package/dist/browser.mjs +4242 -655
- package/dist/{chunk-VYNNEKSA.js → chunk-BBE7SNRV.js} +248 -10
- package/dist/{chunk-VRZZQPAA.js → chunk-OBBWQW6K.js} +3351 -1392
- package/dist/{chunk-XIZOM2HO.mjs → chunk-UPFNQCGB.mjs} +2419 -460
- package/dist/{chunk-PN7EWK66.mjs → chunk-ZHUHZWFY.mjs} +241 -3
- package/dist/cli.js +2867 -668
- package/dist/edge-light.d.mts +1 -1
- package/dist/edge-light.d.ts +1 -1
- package/dist/edge-light.js +4242 -655
- package/dist/edge-light.mjs +4242 -655
- package/dist/index.d.mts +1267 -640
- package/dist/index.d.ts +1267 -640
- package/dist/index.js +2107 -630
- package/dist/index.mjs +1649 -172
- package/dist/instrumentation/index.d.mts +198 -6
- package/dist/instrumentation/index.d.ts +198 -6
- package/dist/instrumentation/index.js +2661 -581
- package/dist/instrumentation/index.mjs +2661 -581
- package/dist/vitest-evals-reporter.js +45 -43
- package/dist/vitest-evals-reporter.mjs +5 -3
- package/dist/workerd.d.mts +1 -1
- package/dist/workerd.d.ts +1 -1
- package/dist/workerd.js +4242 -655
- package/dist/workerd.mjs +4242 -655
- 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
|
|
|
@@ -140,11 +140,11 @@
|
|
|
140
140
|
|
|
141
141
|
|
|
142
142
|
|
|
143
|
-
var _chunkVRZZQPAAjs = require('./chunk-VRZZQPAA.js');
|
|
144
143
|
|
|
145
144
|
|
|
146
145
|
|
|
147
146
|
|
|
147
|
+
var _chunkOBBWQW6Kjs = require('./chunk-OBBWQW6K.js');
|
|
148
148
|
|
|
149
149
|
|
|
150
150
|
|
|
@@ -170,151 +170,164 @@ var _chunkVRZZQPAAjs = require('./chunk-VRZZQPAA.js');
|
|
|
170
170
|
|
|
171
171
|
|
|
172
172
|
|
|
173
|
-
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
var _chunkBBE7SNRVjs = require('./chunk-BBE7SNRV.js');
|
|
174
181
|
|
|
175
182
|
// src/exports.ts
|
|
176
183
|
var exports_exports = {};
|
|
177
|
-
|
|
178
|
-
Attachment: () =>
|
|
179
|
-
AttachmentReference: () =>
|
|
180
|
-
BAGGAGE_HEADER: () =>
|
|
181
|
-
BRAINTRUST_CURRENT_SPAN_STORE: () =>
|
|
182
|
-
BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME: () =>
|
|
183
|
-
BRAINTRUST_PARENT_KEY: () =>
|
|
184
|
-
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,
|
|
185
192
|
BaseExperiment: () => BaseExperiment,
|
|
186
|
-
|
|
193
|
+
BatchScorer: () => BatchScorer,
|
|
194
|
+
BatchTask: () => BatchTask,
|
|
195
|
+
BraintrustLangChainCallbackHandler: () => _chunkOBBWQW6Kjs.BraintrustLangChainCallbackHandler,
|
|
187
196
|
BraintrustMiddleware: () => BraintrustMiddleware,
|
|
188
|
-
BraintrustObservabilityExporter: () =>
|
|
189
|
-
BraintrustState: () =>
|
|
190
|
-
BraintrustStream: () =>
|
|
197
|
+
BraintrustObservabilityExporter: () => _chunkOBBWQW6Kjs.BraintrustObservabilityExporter,
|
|
198
|
+
BraintrustState: () => _chunkOBBWQW6Kjs.BraintrustState,
|
|
199
|
+
BraintrustStream: () => _chunkOBBWQW6Kjs.BraintrustStream,
|
|
191
200
|
CachedSpanFetcher: () => CachedSpanFetcher,
|
|
192
201
|
CodeFunction: () => CodeFunction,
|
|
193
202
|
CodePrompt: () => CodePrompt,
|
|
194
|
-
ContextManager: () =>
|
|
195
|
-
DEFAULT_FETCH_BATCH_SIZE: () =>
|
|
196
|
-
DEFAULT_MAX_REQUEST_SIZE: () =>
|
|
197
|
-
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,
|
|
198
207
|
DatasetPipeline: () => DatasetPipeline,
|
|
199
|
-
|
|
208
|
+
DurableEvalMemoryStore: () => DurableEvalMemoryStore,
|
|
209
|
+
DurableEvalRedisStore: () => DurableEvalRedisStore,
|
|
210
|
+
ERR_PERMALINK: () => _chunkOBBWQW6Kjs.ERR_PERMALINK,
|
|
200
211
|
Eval: () => Eval,
|
|
201
212
|
EvalResultWithSummary: () => EvalResultWithSummary,
|
|
202
|
-
Experiment: () =>
|
|
203
|
-
ExternalAttachment: () =>
|
|
204
|
-
FailedHTTPResponse: () =>
|
|
205
|
-
IDGenerator: () =>
|
|
206
|
-
JSONAttachment: () =>
|
|
207
|
-
LEGACY_CACHED_HEADER: () =>
|
|
208
|
-
LOGS3_OVERFLOW_REFERENCE_TYPE: () =>
|
|
209
|
-
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,
|
|
210
221
|
LocalTrace: () => LocalTrace,
|
|
211
|
-
Logger: () =>
|
|
212
|
-
LoginInvalidOrgError: () =>
|
|
213
|
-
NOOP_SPAN: () =>
|
|
214
|
-
NOOP_SPAN_PERMALINK: () =>
|
|
215
|
-
NoopSpan: () =>
|
|
216
|
-
OTELIDGenerator: () =>
|
|
217
|
-
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,
|
|
218
229
|
Project: () => Project2,
|
|
219
230
|
ProjectNameIdMap: () => ProjectNameIdMap,
|
|
220
|
-
Prompt: () =>
|
|
231
|
+
Prompt: () => _chunkOBBWQW6Kjs.Prompt,
|
|
221
232
|
PromptBuilder: () => PromptBuilder,
|
|
222
|
-
ReadonlyAttachment: () =>
|
|
223
|
-
ReadonlyExperiment: () =>
|
|
233
|
+
ReadonlyAttachment: () => _chunkOBBWQW6Kjs.ReadonlyAttachment,
|
|
234
|
+
ReadonlyExperiment: () => _chunkOBBWQW6Kjs.ReadonlyExperiment,
|
|
224
235
|
Reporter: () => Reporter,
|
|
225
236
|
ScorerBuilder: () => ScorerBuilder,
|
|
226
237
|
SpanFetcher: () => SpanFetcher,
|
|
227
|
-
SpanImpl: () =>
|
|
228
|
-
TRACEPARENT_HEADER: () =>
|
|
229
|
-
TRACESTATE_HEADER: () =>
|
|
230
|
-
TestBackgroundLogger: () =>
|
|
238
|
+
SpanImpl: () => _chunkOBBWQW6Kjs.SpanImpl,
|
|
239
|
+
TRACEPARENT_HEADER: () => _chunkOBBWQW6Kjs.TRACEPARENT_HEADER,
|
|
240
|
+
TRACESTATE_HEADER: () => _chunkOBBWQW6Kjs.TRACESTATE_HEADER,
|
|
241
|
+
TestBackgroundLogger: () => _chunkOBBWQW6Kjs.TestBackgroundLogger,
|
|
231
242
|
ToolBuilder: () => ToolBuilder,
|
|
232
|
-
UUIDGenerator: () =>
|
|
233
|
-
X_CACHED_HEADER: () =>
|
|
234
|
-
_exportsForTestingOnly: () =>
|
|
235
|
-
_internalGetGlobalState: () =>
|
|
236
|
-
_internalIso: () =>
|
|
237
|
-
_internalSetInitialState: () =>
|
|
238
|
-
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,
|
|
239
250
|
agentAssertionScorer: () => agentAssertionScorer,
|
|
240
|
-
braintrustAISDKTelemetry: () =>
|
|
251
|
+
braintrustAISDKTelemetry: () => _chunkOBBWQW6Kjs.braintrustAISDKTelemetry,
|
|
241
252
|
braintrustEveHook: () => braintrustEveHook,
|
|
242
253
|
braintrustEveInstrumentation: () => braintrustEveInstrumentation,
|
|
243
|
-
braintrustFlueInstrumentation: () =>
|
|
244
|
-
braintrustFlueObserver: () =>
|
|
245
|
-
braintrustStreamChunkSchema: () =>
|
|
254
|
+
braintrustFlueInstrumentation: () => _chunkOBBWQW6Kjs.braintrustFlueInstrumentation,
|
|
255
|
+
braintrustFlueObserver: () => _chunkOBBWQW6Kjs.braintrustFlueObserver,
|
|
256
|
+
braintrustStreamChunkSchema: () => _chunkOBBWQW6Kjs.braintrustStreamChunkSchema,
|
|
246
257
|
buildLocalSummary: () => buildLocalSummary,
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
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,
|
|
254
266
|
defaultErrorScoreHandler: () => defaultErrorScoreHandler,
|
|
255
|
-
|
|
256
|
-
|
|
267
|
+
defineDurableEval: () => defineDurableEval,
|
|
268
|
+
deserializePlainStringAsJSON: () => _chunkOBBWQW6Kjs.deserializePlainStringAsJSON,
|
|
269
|
+
devNullWritableStream: () => _chunkOBBWQW6Kjs.devNullWritableStream,
|
|
257
270
|
evaluatorDefinitionSchema: () => evaluatorDefinitionSchema,
|
|
258
271
|
evaluatorDefinitionsSchema: () => evaluatorDefinitionsSchema,
|
|
259
|
-
extractTraceContextFromHeaders: () =>
|
|
260
|
-
flush: () =>
|
|
261
|
-
getContextManager: () =>
|
|
262
|
-
getIdGenerator: () =>
|
|
263
|
-
getPromptVersions: () =>
|
|
264
|
-
getSpanParentObject: () =>
|
|
265
|
-
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,
|
|
266
279
|
graph: () => graph_framework_exports,
|
|
267
|
-
init: () =>
|
|
268
|
-
initDataset: () =>
|
|
269
|
-
initExperiment: () =>
|
|
280
|
+
init: () => _chunkOBBWQW6Kjs.init,
|
|
281
|
+
initDataset: () => _chunkOBBWQW6Kjs.initDataset,
|
|
282
|
+
initExperiment: () => _chunkOBBWQW6Kjs.initExperiment,
|
|
270
283
|
initFunction: () => initFunction,
|
|
271
|
-
initLogger: () =>
|
|
284
|
+
initLogger: () => _chunkOBBWQW6Kjs.initLogger,
|
|
272
285
|
initNodeTestSuite: () => initNodeTestSuite,
|
|
273
|
-
injectTraceContext: () =>
|
|
286
|
+
injectTraceContext: () => _chunkOBBWQW6Kjs.injectTraceContext,
|
|
274
287
|
invoke: () => invoke,
|
|
275
|
-
isTemplateFormat: () =>
|
|
276
|
-
loadParameters: () =>
|
|
277
|
-
loadPrompt: () =>
|
|
278
|
-
log: () =>
|
|
279
|
-
logError: () =>
|
|
280
|
-
login: () =>
|
|
281
|
-
loginToState: () =>
|
|
282
|
-
logs3OverflowUploadSchema: () =>
|
|
283
|
-
newId: () =>
|
|
284
|
-
parseCachedHeader: () =>
|
|
285
|
-
parseTemplateFormat: () =>
|
|
286
|
-
permalink: () =>
|
|
287
|
-
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,
|
|
288
301
|
projects: () => projects,
|
|
289
302
|
promptContentsSchema: () => promptContentsSchema,
|
|
290
303
|
promptDefinitionSchema: () => promptDefinitionSchema,
|
|
291
304
|
promptDefinitionToPromptData: () => promptDefinitionToPromptData,
|
|
292
305
|
promptDefinitionWithToolsSchema: () => promptDefinitionWithToolsSchema,
|
|
293
|
-
registerOtelFlush: () =>
|
|
306
|
+
registerOtelFlush: () => _chunkOBBWQW6Kjs.registerOtelFlush,
|
|
294
307
|
registerSandbox: () => registerSandbox,
|
|
295
|
-
registerTemplatePlugin: () =>
|
|
296
|
-
renderMessage: () =>
|
|
297
|
-
renderPromptParams: () =>
|
|
298
|
-
renderTemplateContent: () =>
|
|
308
|
+
registerTemplatePlugin: () => _chunkOBBWQW6Kjs.registerTemplatePlugin,
|
|
309
|
+
renderMessage: () => _chunkOBBWQW6Kjs.renderMessage,
|
|
310
|
+
renderPromptParams: () => _chunkOBBWQW6Kjs.renderPromptParams,
|
|
311
|
+
renderTemplateContent: () => _chunkOBBWQW6Kjs.renderTemplateContent,
|
|
299
312
|
reportFailures: () => reportFailures,
|
|
300
313
|
runEvaluator: () => runEvaluator,
|
|
301
|
-
setFetch: () =>
|
|
302
|
-
setMaskingFunction: () =>
|
|
303
|
-
spanComponentsToObjectId: () =>
|
|
304
|
-
startSpan: () =>
|
|
305
|
-
summarize: () =>
|
|
306
|
-
templateRegistry: () =>
|
|
307
|
-
toolFunctionDefinitionSchema: () =>
|
|
308
|
-
traceable: () =>
|
|
309
|
-
traced: () =>
|
|
310
|
-
updateSpan: () =>
|
|
311
|
-
uploadLogs3OverflowPayload: () =>
|
|
312
|
-
utf8ByteLength: () =>
|
|
313
|
-
withCurrent: () =>
|
|
314
|
-
withDataset: () =>
|
|
315
|
-
withExperiment: () =>
|
|
316
|
-
withLogger: () =>
|
|
317
|
-
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,
|
|
318
331
|
wrapAISDK: () => wrapAISDK,
|
|
319
332
|
wrapAISDKModel: () => wrapAISDKModel,
|
|
320
333
|
wrapAgentClass: () => wrapAgentClass,
|
|
@@ -323,6 +336,7 @@ _chunkVYNNEKSAjs.__export.call(void 0, exports_exports, {
|
|
|
323
336
|
wrapClaudeAgentSDK: () => wrapClaudeAgentSDK,
|
|
324
337
|
wrapCloudflareAIChat: () => wrapCloudflareAIChat,
|
|
325
338
|
wrapCloudflareAgent: () => wrapCloudflareAgent,
|
|
339
|
+
wrapCloudflareThink: () => wrapCloudflareThink,
|
|
326
340
|
wrapCohere: () => wrapCohere,
|
|
327
341
|
wrapCopilotClient: () => wrapCopilotClient,
|
|
328
342
|
wrapCursorSDK: () => wrapCursorSDK,
|
|
@@ -335,8 +349,9 @@ _chunkVYNNEKSAjs.__export.call(void 0, exports_exports, {
|
|
|
335
349
|
wrapLangSmithClient: () => wrapLangSmithClient,
|
|
336
350
|
wrapLangSmithRunTrees: () => wrapLangSmithRunTrees,
|
|
337
351
|
wrapLangSmithTraceable: () => wrapLangSmithTraceable,
|
|
338
|
-
wrapMastraAgent: () =>
|
|
352
|
+
wrapMastraAgent: () => _chunkOBBWQW6Kjs.wrapMastraAgent,
|
|
339
353
|
wrapMistral: () => wrapMistral,
|
|
354
|
+
wrapOllama: () => wrapOllama,
|
|
340
355
|
wrapOpenAI: () => wrapOpenAI,
|
|
341
356
|
wrapOpenAICodexSDK: () => wrapOpenAICodexSDK,
|
|
342
357
|
wrapOpenAIv4: () => wrapOpenAIv4,
|
|
@@ -344,15 +359,16 @@ _chunkVYNNEKSAjs.__export.call(void 0, exports_exports, {
|
|
|
344
359
|
wrapOpenRouterAgent: () => wrapOpenRouterAgent,
|
|
345
360
|
wrapPiCodingAgentSDK: () => wrapPiCodingAgentSDK,
|
|
346
361
|
wrapStrandsAgentSDK: () => wrapStrandsAgentSDK,
|
|
347
|
-
wrapTraced: () =>
|
|
348
|
-
wrapVitest: () => wrapVitest
|
|
362
|
+
wrapTraced: () => _chunkOBBWQW6Kjs.wrapTraced,
|
|
363
|
+
wrapVitest: () => wrapVitest,
|
|
364
|
+
wrapVoyageAI: () => wrapVoyageAI
|
|
349
365
|
});
|
|
350
366
|
|
|
351
367
|
// src/sandbox.ts
|
|
352
368
|
var _v3 = require('zod/v3');
|
|
353
369
|
var SANDBOX_GROUP_NAME_METADATA_KEY = "_bt_sandbox_group_name";
|
|
354
370
|
async function registerSandbox(options) {
|
|
355
|
-
const state = _nullishCoalesce(options.state, () => (
|
|
371
|
+
const state = _nullishCoalesce(options.state, () => ( _chunkOBBWQW6Kjs._internalGetGlobalState.call(void 0, )));
|
|
356
372
|
await state.login({
|
|
357
373
|
apiKey: options.apiKey,
|
|
358
374
|
appUrl: options.appUrl,
|
|
@@ -393,7 +409,7 @@ async function registerSandbox(options) {
|
|
|
393
409
|
evaluatorDefinitions
|
|
394
410
|
)) {
|
|
395
411
|
const functionName = evalName;
|
|
396
|
-
const functionSlug =
|
|
412
|
+
const functionSlug = _chunkOBBWQW6Kjs.slugify.call(void 0, evalName, { lower: true, strict: true });
|
|
397
413
|
const functionDef = {
|
|
398
414
|
project_id: projectId,
|
|
399
415
|
org_name: state.orgName,
|
|
@@ -464,7 +480,7 @@ async function invoke(args) {
|
|
|
464
480
|
projectId,
|
|
465
481
|
...functionIdArgs
|
|
466
482
|
} = args;
|
|
467
|
-
const state = _nullishCoalesce(stateArg, () => (
|
|
483
|
+
const state = _nullishCoalesce(stateArg, () => ( _chunkOBBWQW6Kjs._internalGetGlobalState.call(void 0, )));
|
|
468
484
|
await state.login({
|
|
469
485
|
orgName,
|
|
470
486
|
apiKey,
|
|
@@ -472,8 +488,8 @@ async function invoke(args) {
|
|
|
472
488
|
forceLogin,
|
|
473
489
|
fetch
|
|
474
490
|
});
|
|
475
|
-
const parent = parentArg ? typeof parentArg === "string" ? parentArg : await parentArg.export() : await
|
|
476
|
-
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({
|
|
477
493
|
function_id: functionIdArgs.function_id,
|
|
478
494
|
project_name: functionIdArgs.projectName,
|
|
479
495
|
slug: functionIdArgs.slug,
|
|
@@ -516,7 +532,7 @@ async function invoke(args) {
|
|
|
516
532
|
if (!resp.body) {
|
|
517
533
|
throw new Error("Received empty stream body");
|
|
518
534
|
}
|
|
519
|
-
return new (0,
|
|
535
|
+
return new (0, _chunkOBBWQW6Kjs.BraintrustStream)(resp.body);
|
|
520
536
|
} else {
|
|
521
537
|
const data = await resp.json();
|
|
522
538
|
return schema ? schema.parse(data) : data;
|
|
@@ -528,7 +544,7 @@ function initFunction({
|
|
|
528
544
|
version,
|
|
529
545
|
state
|
|
530
546
|
}) {
|
|
531
|
-
const s = _nullishCoalesce(state, () => (
|
|
547
|
+
const s = _nullishCoalesce(state, () => ( _chunkOBBWQW6Kjs._internalGetGlobalState.call(void 0, )));
|
|
532
548
|
_optionalChain([s, 'optionalAccess', _2 => _2.spanCache, 'optionalAccess', _3 => _3.disable, 'call', _4 => _4()]);
|
|
533
549
|
const f = async (input) => {
|
|
534
550
|
return await invoke({
|
|
@@ -606,22 +622,22 @@ function responsesProxy(openai) {
|
|
|
606
622
|
if (name === "create" && typeof target.create === "function") {
|
|
607
623
|
return wrapResponsesAsync(
|
|
608
624
|
target.create.bind(target),
|
|
609
|
-
|
|
625
|
+
_chunkBBE7SNRVjs.openAIChannels.responsesCreate
|
|
610
626
|
);
|
|
611
627
|
} else if (name === "stream" && typeof target.stream === "function") {
|
|
612
628
|
return wrapResponsesSyncStream(
|
|
613
629
|
target.stream.bind(target),
|
|
614
|
-
|
|
630
|
+
_chunkBBE7SNRVjs.openAIChannels.responsesStream
|
|
615
631
|
);
|
|
616
632
|
} else if (name === "parse" && typeof target.parse === "function") {
|
|
617
633
|
return wrapResponsesAsync(
|
|
618
634
|
target.parse.bind(target),
|
|
619
|
-
|
|
635
|
+
_chunkBBE7SNRVjs.openAIChannels.responsesParse
|
|
620
636
|
);
|
|
621
637
|
} else if (name === "compact" && typeof target.compact === "function") {
|
|
622
638
|
return wrapResponsesAsync(
|
|
623
639
|
target.compact.bind(target),
|
|
624
|
-
|
|
640
|
+
_chunkBBE7SNRVjs.openAIChannels.responsesCompact
|
|
625
641
|
);
|
|
626
642
|
}
|
|
627
643
|
return Reflect.get(target, name, receiver);
|
|
@@ -765,7 +781,7 @@ function wrapBetaChatCompletionParse(completion) {
|
|
|
765
781
|
const { span_info, params } = splitSpanInfo(
|
|
766
782
|
allParams
|
|
767
783
|
);
|
|
768
|
-
return
|
|
784
|
+
return _chunkBBE7SNRVjs.openAIChannels.betaChatCompletionsParse.tracePromise(
|
|
769
785
|
async () => await completion(params),
|
|
770
786
|
{ arguments: [params], span_info }
|
|
771
787
|
);
|
|
@@ -776,7 +792,7 @@ function wrapBetaChatCompletionStream(completion) {
|
|
|
776
792
|
const { span_info, params } = splitSpanInfo(
|
|
777
793
|
allParams
|
|
778
794
|
);
|
|
779
|
-
return
|
|
795
|
+
return _chunkBBE7SNRVjs.openAIChannels.betaChatCompletionsStream.traceSync(
|
|
780
796
|
() => completion(params),
|
|
781
797
|
{ arguments: [params], span_info }
|
|
782
798
|
);
|
|
@@ -792,7 +808,7 @@ function wrapChatCompletion(completion) {
|
|
|
792
808
|
if (!executionPromise) {
|
|
793
809
|
executionPromise = (async () => {
|
|
794
810
|
const traceContext = createChannelContext(
|
|
795
|
-
|
|
811
|
+
_chunkBBE7SNRVjs.openAIChannels.chatCompletionsCreate,
|
|
796
812
|
params,
|
|
797
813
|
span_info
|
|
798
814
|
);
|
|
@@ -802,7 +818,7 @@ function wrapChatCompletion(completion) {
|
|
|
802
818
|
options
|
|
803
819
|
);
|
|
804
820
|
const { data: data2, response: response2 } = await tracePromiseWithResponse(
|
|
805
|
-
|
|
821
|
+
_chunkBBE7SNRVjs.openAIChannels.chatCompletionsCreate,
|
|
806
822
|
traceContext,
|
|
807
823
|
completionPromise
|
|
808
824
|
);
|
|
@@ -813,7 +829,7 @@ function wrapChatCompletion(completion) {
|
|
|
813
829
|
options
|
|
814
830
|
);
|
|
815
831
|
const { data, response } = await tracePromiseWithResponse(
|
|
816
|
-
|
|
832
|
+
_chunkBBE7SNRVjs.openAIChannels.chatCompletionsCreate,
|
|
817
833
|
traceContext,
|
|
818
834
|
completionResponse
|
|
819
835
|
);
|
|
@@ -856,8 +872,8 @@ function wrapApiCreateWithChannel(create, channel) {
|
|
|
856
872
|
return createLazyAPIPromise(ensureExecuted);
|
|
857
873
|
};
|
|
858
874
|
}
|
|
859
|
-
var wrapEmbeddings = (create) => wrapApiCreateWithChannel(create,
|
|
860
|
-
var wrapModerations = (create) => wrapApiCreateWithChannel(create,
|
|
875
|
+
var wrapEmbeddings = (create) => wrapApiCreateWithChannel(create, _chunkBBE7SNRVjs.openAIChannels.embeddingsCreate);
|
|
876
|
+
var wrapModerations = (create) => wrapApiCreateWithChannel(create, _chunkBBE7SNRVjs.openAIChannels.moderationsCreate);
|
|
861
877
|
|
|
862
878
|
// src/wrappers/ai-sdk/ai-sdk.ts
|
|
863
879
|
function isModuleNamespace(obj) {
|
|
@@ -960,7 +976,7 @@ var wrapAgentClass = (AgentClass, options = {}) => {
|
|
|
960
976
|
return wrapHarnessAgentGenerate(
|
|
961
977
|
original,
|
|
962
978
|
harnessAgent,
|
|
963
|
-
|
|
979
|
+
_chunkBBE7SNRVjs.harnessAgentChannels.generate,
|
|
964
980
|
"HarnessAgent.generate",
|
|
965
981
|
options
|
|
966
982
|
);
|
|
@@ -968,7 +984,7 @@ var wrapAgentClass = (AgentClass, options = {}) => {
|
|
|
968
984
|
return wrapHarnessAgentStream(
|
|
969
985
|
original,
|
|
970
986
|
harnessAgent,
|
|
971
|
-
|
|
987
|
+
_chunkBBE7SNRVjs.harnessAgentChannels.stream,
|
|
972
988
|
"HarnessAgent.stream",
|
|
973
989
|
options
|
|
974
990
|
);
|
|
@@ -976,7 +992,7 @@ var wrapAgentClass = (AgentClass, options = {}) => {
|
|
|
976
992
|
return wrapHarnessAgentGenerate(
|
|
977
993
|
original,
|
|
978
994
|
harnessAgent,
|
|
979
|
-
|
|
995
|
+
_chunkBBE7SNRVjs.harnessAgentChannels.continueGenerate,
|
|
980
996
|
"HarnessAgent.continueGenerate",
|
|
981
997
|
options
|
|
982
998
|
);
|
|
@@ -984,7 +1000,7 @@ var wrapAgentClass = (AgentClass, options = {}) => {
|
|
|
984
1000
|
return wrapHarnessAgentStream(
|
|
985
1001
|
original,
|
|
986
1002
|
harnessAgent,
|
|
987
|
-
|
|
1003
|
+
_chunkBBE7SNRVjs.harnessAgentChannels.continueStream,
|
|
988
1004
|
"HarnessAgent.continueStream",
|
|
989
1005
|
options
|
|
990
1006
|
);
|
|
@@ -1007,7 +1023,7 @@ var wrapAgentClass = (AgentClass, options = {}) => {
|
|
|
1007
1023
|
};
|
|
1008
1024
|
var wrapHarnessAgentCreateSession = (createSession, instance) => {
|
|
1009
1025
|
const wrapper = function(params) {
|
|
1010
|
-
return
|
|
1026
|
+
return _chunkBBE7SNRVjs.harnessAgentChannels.createSession.tracePromise(
|
|
1011
1027
|
() => params === void 0 ? createSession.call(instance) : createSession.call(instance, params),
|
|
1012
1028
|
createAISDKChannelContext(_nullishCoalesce(params, () => ( {})), { self: instance })
|
|
1013
1029
|
);
|
|
@@ -1053,15 +1069,15 @@ var wrapAgentGenerate = (generate, instance, options = {}) => {
|
|
|
1053
1069
|
};
|
|
1054
1070
|
function generateChannelForAgent(agentName) {
|
|
1055
1071
|
if (agentName === "ToolLoopAgent") {
|
|
1056
|
-
return
|
|
1072
|
+
return _chunkBBE7SNRVjs.aiSDKChannels.toolLoopAgentGenerate;
|
|
1057
1073
|
}
|
|
1058
|
-
return
|
|
1074
|
+
return _chunkBBE7SNRVjs.aiSDKChannels.agentGenerate;
|
|
1059
1075
|
}
|
|
1060
1076
|
var wrapAgentStream = (stream, instance, options = {}) => {
|
|
1061
1077
|
const defaultName = `${instance.constructor.name}.stream`;
|
|
1062
1078
|
return (params) => {
|
|
1063
1079
|
const workflowAgent = instance.constructor.name === "WorkflowAgent";
|
|
1064
|
-
if (workflowAgent &&
|
|
1080
|
+
if (workflowAgent && _chunkOBBWQW6Kjs.currentWorkflowAgentWrapperSpan.call(void 0, )) {
|
|
1065
1081
|
const { span_info: _spanInfo, ...cleanParams } = params;
|
|
1066
1082
|
return stream.call(instance, { ...instance.settings, ...cleanParams });
|
|
1067
1083
|
}
|
|
@@ -1080,12 +1096,12 @@ var wrapAgentStream = (stream, instance, options = {}) => {
|
|
|
1080
1096
|
};
|
|
1081
1097
|
function streamChannelForAgent(agentName) {
|
|
1082
1098
|
if (agentName === "ToolLoopAgent") {
|
|
1083
|
-
return
|
|
1099
|
+
return _chunkBBE7SNRVjs.aiSDKChannels.toolLoopAgentStream;
|
|
1084
1100
|
}
|
|
1085
1101
|
if (agentName === "WorkflowAgent") {
|
|
1086
|
-
return
|
|
1102
|
+
return _chunkBBE7SNRVjs.aiSDKChannels.workflowAgentStream;
|
|
1087
1103
|
}
|
|
1088
|
-
return
|
|
1104
|
+
return _chunkBBE7SNRVjs.aiSDKChannels.agentStream;
|
|
1089
1105
|
}
|
|
1090
1106
|
var makeGenerateTextWrapper = (channel, name, generateText, contextOptions = {}, options = {}) => {
|
|
1091
1107
|
const wrapper = async function(allParams) {
|
|
@@ -1109,7 +1125,7 @@ var makeGenerateTextWrapper = (channel, name, generateText, contextOptions = {},
|
|
|
1109
1125
|
};
|
|
1110
1126
|
var wrapGenerateText = (generateText, options = {}, aiSDK) => {
|
|
1111
1127
|
return makeGenerateTextWrapper(
|
|
1112
|
-
|
|
1128
|
+
_chunkBBE7SNRVjs.aiSDKChannels.generateText,
|
|
1113
1129
|
"generateText",
|
|
1114
1130
|
generateText,
|
|
1115
1131
|
{ aiSDK },
|
|
@@ -1118,7 +1134,7 @@ var wrapGenerateText = (generateText, options = {}, aiSDK) => {
|
|
|
1118
1134
|
};
|
|
1119
1135
|
var wrapGenerateObject = (generateObject, options = {}, aiSDK) => {
|
|
1120
1136
|
return makeGenerateTextWrapper(
|
|
1121
|
-
|
|
1137
|
+
_chunkBBE7SNRVjs.aiSDKChannels.generateObject,
|
|
1122
1138
|
"generateObject",
|
|
1123
1139
|
generateObject,
|
|
1124
1140
|
{ aiSDK },
|
|
@@ -1147,7 +1163,7 @@ var makeEmbedWrapper = (channel, name, embed, contextOptions = {}, options = {})
|
|
|
1147
1163
|
};
|
|
1148
1164
|
var wrapEmbed = (embed, options = {}, aiSDK) => {
|
|
1149
1165
|
return makeEmbedWrapper(
|
|
1150
|
-
|
|
1166
|
+
_chunkBBE7SNRVjs.aiSDKChannels.embed,
|
|
1151
1167
|
"embed",
|
|
1152
1168
|
embed,
|
|
1153
1169
|
{ aiSDK },
|
|
@@ -1156,7 +1172,7 @@ var wrapEmbed = (embed, options = {}, aiSDK) => {
|
|
|
1156
1172
|
};
|
|
1157
1173
|
var wrapEmbedMany = (embedMany, options = {}, aiSDK) => {
|
|
1158
1174
|
return makeEmbedWrapper(
|
|
1159
|
-
|
|
1175
|
+
_chunkBBE7SNRVjs.aiSDKChannels.embedMany,
|
|
1160
1176
|
"embedMany",
|
|
1161
1177
|
embedMany,
|
|
1162
1178
|
{ aiSDK },
|
|
@@ -1167,7 +1183,7 @@ var makeRerankWrapper = (rerank, contextOptions = {}, options = {}) => {
|
|
|
1167
1183
|
const wrapper = async function(allParams) {
|
|
1168
1184
|
const { span_info, ...params } = allParams;
|
|
1169
1185
|
const tracedParams = { ...params };
|
|
1170
|
-
return
|
|
1186
|
+
return _chunkBBE7SNRVjs.aiSDKChannels.rerank.tracePromise(
|
|
1171
1187
|
() => rerank(tracedParams),
|
|
1172
1188
|
createAISDKChannelContext(tracedParams, {
|
|
1173
1189
|
aiSDK: contextOptions.aiSDK,
|
|
@@ -1206,7 +1222,7 @@ var makeStreamWrapper = (channel, name, streamText, contextOptions = {}, options
|
|
|
1206
1222
|
};
|
|
1207
1223
|
var wrapStreamText = (streamText, options = {}, aiSDK) => {
|
|
1208
1224
|
return makeStreamWrapper(
|
|
1209
|
-
|
|
1225
|
+
_chunkBBE7SNRVjs.aiSDKChannels.streamText,
|
|
1210
1226
|
"streamText",
|
|
1211
1227
|
streamText,
|
|
1212
1228
|
{ aiSDK },
|
|
@@ -1215,7 +1231,7 @@ var wrapStreamText = (streamText, options = {}, aiSDK) => {
|
|
|
1215
1231
|
};
|
|
1216
1232
|
var wrapStreamObject = (streamObject, options = {}, aiSDK) => {
|
|
1217
1233
|
return makeStreamWrapper(
|
|
1218
|
-
|
|
1234
|
+
_chunkBBE7SNRVjs.aiSDKChannels.streamObject,
|
|
1219
1235
|
"streamObject",
|
|
1220
1236
|
streamObject,
|
|
1221
1237
|
{ aiSDK },
|
|
@@ -1287,19 +1303,19 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1287
1303
|
// For the first cut, do not support custom span_info arguments. We can
|
|
1288
1304
|
// propagate those via async local storage
|
|
1289
1305
|
async doGenerate(options) {
|
|
1290
|
-
const span =
|
|
1291
|
-
|
|
1306
|
+
const span = _chunkOBBWQW6Kjs.startSpan.call(void 0,
|
|
1307
|
+
_chunkBBE7SNRVjs.withSpanInstrumentationName.call(void 0,
|
|
1292
1308
|
{
|
|
1293
1309
|
name: "Chat Completion",
|
|
1294
1310
|
spanAttributes: {
|
|
1295
1311
|
type: "llm"
|
|
1296
1312
|
}
|
|
1297
1313
|
},
|
|
1298
|
-
|
|
1314
|
+
_chunkBBE7SNRVjs.INSTRUMENTATION_NAMES.AI_SDK
|
|
1299
1315
|
)
|
|
1300
1316
|
);
|
|
1301
1317
|
const { prompt, mode, ...rest } = options;
|
|
1302
|
-
const startTime =
|
|
1318
|
+
const startTime = _chunkOBBWQW6Kjs.getCurrentUnixTimestamp.call(void 0, );
|
|
1303
1319
|
try {
|
|
1304
1320
|
const ret = await this.model.doGenerate(options);
|
|
1305
1321
|
span.log({
|
|
@@ -1311,12 +1327,12 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1311
1327
|
},
|
|
1312
1328
|
output: postProcessOutput(ret.text, ret.toolCalls, ret.finishReason),
|
|
1313
1329
|
metrics: {
|
|
1314
|
-
time_to_first_token:
|
|
1315
|
-
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,
|
|
1316
1332
|
prompt_tokens: _optionalChain([ret, 'access', _26 => _26.usage, 'optionalAccess', _27 => _27.promptTokens]),
|
|
1317
1333
|
completion_tokens: _optionalChain([ret, 'access', _28 => _28.usage, 'optionalAccess', _29 => _29.completionTokens]),
|
|
1318
|
-
cached:
|
|
1319
|
-
_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]])))
|
|
1320
1336
|
)
|
|
1321
1337
|
}
|
|
1322
1338
|
});
|
|
@@ -1327,16 +1343,16 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1327
1343
|
}
|
|
1328
1344
|
async doStream(options) {
|
|
1329
1345
|
const { prompt, mode, ...rest } = options;
|
|
1330
|
-
const startTime =
|
|
1331
|
-
const span =
|
|
1332
|
-
|
|
1346
|
+
const startTime = _chunkOBBWQW6Kjs.getCurrentUnixTimestamp.call(void 0, );
|
|
1347
|
+
const span = _chunkOBBWQW6Kjs.startSpan.call(void 0,
|
|
1348
|
+
_chunkBBE7SNRVjs.withSpanInstrumentationName.call(void 0,
|
|
1333
1349
|
{
|
|
1334
1350
|
name: "Chat Completion",
|
|
1335
1351
|
spanAttributes: {
|
|
1336
1352
|
type: "llm"
|
|
1337
1353
|
}
|
|
1338
1354
|
},
|
|
1339
|
-
|
|
1355
|
+
_chunkBBE7SNRVjs.INSTRUMENTATION_NAMES.AI_SDK
|
|
1340
1356
|
)
|
|
1341
1357
|
);
|
|
1342
1358
|
span.log({
|
|
@@ -1367,7 +1383,7 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1367
1383
|
new TransformStream({
|
|
1368
1384
|
transform(chunk, controller) {
|
|
1369
1385
|
if (time_to_first_token === void 0) {
|
|
1370
|
-
time_to_first_token =
|
|
1386
|
+
time_to_first_token = _chunkOBBWQW6Kjs.getCurrentUnixTimestamp.call(void 0, ) - startTime;
|
|
1371
1387
|
span.log({ metrics: { time_to_first_token } });
|
|
1372
1388
|
}
|
|
1373
1389
|
switch (chunk.type) {
|
|
@@ -1412,11 +1428,11 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1412
1428
|
),
|
|
1413
1429
|
metrics: {
|
|
1414
1430
|
time_to_first_token,
|
|
1415
|
-
tokens: !
|
|
1431
|
+
tokens: !_chunkOBBWQW6Kjs.isEmpty.call(void 0, usage) ? usage.promptTokens + usage.completionTokens : void 0,
|
|
1416
1432
|
prompt_tokens: _optionalChain([usage, 'optionalAccess', _36 => _36.promptTokens]),
|
|
1417
1433
|
completion_tokens: _optionalChain([usage, 'optionalAccess', _37 => _37.completionTokens]),
|
|
1418
|
-
cached:
|
|
1419
|
-
_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]])))
|
|
1420
1436
|
)
|
|
1421
1437
|
}
|
|
1422
1438
|
});
|
|
@@ -1601,12 +1617,12 @@ function normalizeUsageMetrics(usage, provider, providerMetadata) {
|
|
|
1601
1617
|
anthropicMetadata.usage,
|
|
1602
1618
|
"cache_creation_input_tokens"
|
|
1603
1619
|
) || 0;
|
|
1604
|
-
const cacheTokens =
|
|
1620
|
+
const cacheTokens = _chunkOBBWQW6Kjs.extractAnthropicCacheTokens.call(void 0,
|
|
1605
1621
|
cacheReadTokens,
|
|
1606
1622
|
cacheCreationTokens
|
|
1607
1623
|
);
|
|
1608
1624
|
Object.assign(metrics, cacheTokens);
|
|
1609
|
-
|
|
1625
|
+
return _chunkOBBWQW6Kjs.toNumericMetrics.call(void 0, _chunkOBBWQW6Kjs.finalizeAnthropicTokens.call(void 0, metrics));
|
|
1610
1626
|
}
|
|
1611
1627
|
}
|
|
1612
1628
|
return metrics;
|
|
@@ -1678,7 +1694,7 @@ function BraintrustMiddleware(config = {}) {
|
|
|
1678
1694
|
model: modelFromWrapGenerate
|
|
1679
1695
|
}) => {
|
|
1680
1696
|
const rawInput = extractInput(params);
|
|
1681
|
-
const processedInput =
|
|
1697
|
+
const processedInput = _chunkOBBWQW6Kjs.processInputAttachments.call(void 0, rawInput);
|
|
1682
1698
|
const spanArgs = {
|
|
1683
1699
|
name: _optionalChain([config, 'access', _60 => _60.spanInfo, 'optionalAccess', _61 => _61.name]) || "ai-sdk.doGenerate",
|
|
1684
1700
|
spanAttributes: {
|
|
@@ -1693,8 +1709,8 @@ function BraintrustMiddleware(config = {}) {
|
|
|
1693
1709
|
}
|
|
1694
1710
|
}
|
|
1695
1711
|
};
|
|
1696
|
-
const span =
|
|
1697
|
-
|
|
1712
|
+
const span = _chunkOBBWQW6Kjs.startSpan.call(void 0,
|
|
1713
|
+
_chunkBBE7SNRVjs.withSpanInstrumentationName.call(void 0, spanArgs, _chunkBBE7SNRVjs.INSTRUMENTATION_NAMES.AI_SDK)
|
|
1698
1714
|
);
|
|
1699
1715
|
try {
|
|
1700
1716
|
const result = await doGenerate();
|
|
@@ -1742,7 +1758,7 @@ function BraintrustMiddleware(config = {}) {
|
|
|
1742
1758
|
},
|
|
1743
1759
|
wrapStream: async ({ doStream, params }) => {
|
|
1744
1760
|
const rawInput = extractInput(params);
|
|
1745
|
-
const processedInput =
|
|
1761
|
+
const processedInput = _chunkOBBWQW6Kjs.processInputAttachments.call(void 0, rawInput);
|
|
1746
1762
|
const spanArgs = {
|
|
1747
1763
|
name: _optionalChain([config, 'access', _69 => _69.spanInfo, 'optionalAccess', _70 => _70.name]) || "ai-sdk.doStream",
|
|
1748
1764
|
spanAttributes: {
|
|
@@ -1757,8 +1773,8 @@ function BraintrustMiddleware(config = {}) {
|
|
|
1757
1773
|
}
|
|
1758
1774
|
}
|
|
1759
1775
|
};
|
|
1760
|
-
const span =
|
|
1761
|
-
|
|
1776
|
+
const span = _chunkOBBWQW6Kjs.startSpan.call(void 0,
|
|
1777
|
+
_chunkBBE7SNRVjs.withSpanInstrumentationName.call(void 0, spanArgs, _chunkBBE7SNRVjs.INSTRUMENTATION_NAMES.AI_SDK)
|
|
1762
1778
|
);
|
|
1763
1779
|
try {
|
|
1764
1780
|
const { stream, ...rest } = await doStream();
|
|
@@ -1883,7 +1899,7 @@ function braintrustEveInstrumentation(options) {
|
|
|
1883
1899
|
try {
|
|
1884
1900
|
captureEveModelInput(state, input);
|
|
1885
1901
|
} catch (error) {
|
|
1886
|
-
|
|
1902
|
+
_chunkOBBWQW6Kjs.debugLogger.warn("Error in Eve LLM input capture:", error);
|
|
1887
1903
|
}
|
|
1888
1904
|
}
|
|
1889
1905
|
},
|
|
@@ -1893,7 +1909,7 @@ function braintrustEveInstrumentation(options) {
|
|
|
1893
1909
|
};
|
|
1894
1910
|
}
|
|
1895
1911
|
function isEveHandleMessageStreamEvent(event) {
|
|
1896
|
-
return
|
|
1912
|
+
return _chunkOBBWQW6Kjs.isObject.call(void 0, event) && typeof event["type"] === "string";
|
|
1897
1913
|
}
|
|
1898
1914
|
var ResumedEveSpan = class {
|
|
1899
1915
|
constructor(reference) {
|
|
@@ -1914,7 +1930,7 @@ var ResumedEveSpan = class {
|
|
|
1914
1930
|
...this.endTime === void 0 ? {} : { end: this.endTime },
|
|
1915
1931
|
...event.metrics
|
|
1916
1932
|
};
|
|
1917
|
-
|
|
1933
|
+
_chunkOBBWQW6Kjs.updateSpan.call(void 0, {
|
|
1918
1934
|
exported: this.reference.exported,
|
|
1919
1935
|
...this.reference.startEvent,
|
|
1920
1936
|
...event,
|
|
@@ -1923,7 +1939,7 @@ var ResumedEveSpan = class {
|
|
|
1923
1939
|
}
|
|
1924
1940
|
end(args) {
|
|
1925
1941
|
if (this.endTime === void 0) {
|
|
1926
|
-
this.endTime = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _78 => _78.endTime]), () => (
|
|
1942
|
+
this.endTime = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _78 => _78.endTime]), () => ( _chunkOBBWQW6Kjs.getCurrentUnixTimestamp.call(void 0, )));
|
|
1927
1943
|
this.log({ metrics: { end: this.endTime } });
|
|
1928
1944
|
}
|
|
1929
1945
|
return this.endTime;
|
|
@@ -1935,13 +1951,13 @@ var EveBridge = (_class = class {
|
|
|
1935
1951
|
}
|
|
1936
1952
|
|
|
1937
1953
|
__init() {this.eventQueuesBySession = /* @__PURE__ */ new Map()}
|
|
1938
|
-
__init2() {this.completedToolKeys = new (0,
|
|
1954
|
+
__init2() {this.completedToolKeys = new (0, _chunkOBBWQW6Kjs.LRUCache)({
|
|
1939
1955
|
max: MAX_EVE_CACHE_ENTRIES
|
|
1940
1956
|
})}
|
|
1941
|
-
__init3() {this.toolsByCallKey = new (0,
|
|
1957
|
+
__init3() {this.toolsByCallKey = new (0, _chunkOBBWQW6Kjs.LRUCache)({
|
|
1942
1958
|
max: MAX_EVE_CACHE_ENTRIES
|
|
1943
1959
|
})}
|
|
1944
|
-
__init4() {this.turnsByKey = new (0,
|
|
1960
|
+
__init4() {this.turnsByKey = new (0, _chunkOBBWQW6Kjs.LRUCache)({
|
|
1945
1961
|
max: MAX_EVE_CACHE_ENTRIES
|
|
1946
1962
|
})}
|
|
1947
1963
|
async startEveSpan(args) {
|
|
@@ -1952,7 +1968,7 @@ var EveBridge = (_class = class {
|
|
|
1952
1968
|
if (reference) {
|
|
1953
1969
|
return new ResumedEveSpan(reference);
|
|
1954
1970
|
}
|
|
1955
|
-
const startTime = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _81 => _81.startTime]), () => (
|
|
1971
|
+
const startTime = _nullishCoalesce(_optionalChain([args, 'optionalAccess', _81 => _81.startTime]), () => ( _chunkOBBWQW6Kjs.getCurrentUnixTimestamp.call(void 0, )));
|
|
1956
1972
|
const parentSpanIds = _optionalChain([args, 'optionalAccess', _82 => _82.parentSpanIds]);
|
|
1957
1973
|
const startEvent = {
|
|
1958
1974
|
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -1964,12 +1980,12 @@ var EveBridge = (_class = class {
|
|
|
1964
1980
|
},
|
|
1965
1981
|
span_parents: parentSpanIds ? "spanId" in parentSpanIds ? [parentSpanIds.spanId] : parentSpanIds.parentSpanIds : []
|
|
1966
1982
|
};
|
|
1967
|
-
const span =
|
|
1968
|
-
|
|
1969
|
-
() =>
|
|
1970
|
-
|
|
1983
|
+
const span = _chunkOBBWQW6Kjs.withCurrent.call(void 0,
|
|
1984
|
+
_chunkOBBWQW6Kjs.NOOP_SPAN,
|
|
1985
|
+
() => _chunkOBBWQW6Kjs._internalStartSpanWithInitialMerge.call(void 0,
|
|
1986
|
+
_chunkBBE7SNRVjs.withSpanInstrumentationName.call(void 0,
|
|
1971
1987
|
{ ...args, startTime },
|
|
1972
|
-
|
|
1988
|
+
_chunkBBE7SNRVjs.INSTRUMENTATION_NAMES.EVE
|
|
1973
1989
|
)
|
|
1974
1990
|
)
|
|
1975
1991
|
);
|
|
@@ -1997,7 +2013,7 @@ var EveBridge = (_class = class {
|
|
|
1997
2013
|
};
|
|
1998
2014
|
});
|
|
1999
2015
|
} catch (error) {
|
|
2000
|
-
|
|
2016
|
+
_chunkOBBWQW6Kjs.debugLogger.warn("Error exporting Eve span for resumption:", error);
|
|
2001
2017
|
}
|
|
2002
2018
|
return span;
|
|
2003
2019
|
}
|
|
@@ -2084,7 +2100,7 @@ var EveBridge = (_class = class {
|
|
|
2084
2100
|
}
|
|
2085
2101
|
}
|
|
2086
2102
|
} catch (error) {
|
|
2087
|
-
|
|
2103
|
+
_chunkOBBWQW6Kjs.debugLogger.warn("Error in Eve hook instrumentation:", error);
|
|
2088
2104
|
}
|
|
2089
2105
|
};
|
|
2090
2106
|
const sessionId = event.type === "session.failed" ? event.data.sessionId || sessionIdFromContext(ctx) : sessionIdFromContext(ctx);
|
|
@@ -2312,7 +2328,7 @@ var EveBridge = (_class = class {
|
|
|
2312
2328
|
return;
|
|
2313
2329
|
}
|
|
2314
2330
|
const existingMessage = eveOutputMessage(step.output);
|
|
2315
|
-
const existingToolCalls =
|
|
2331
|
+
const existingToolCalls = _chunkOBBWQW6Kjs.isObject.call(void 0, existingMessage) ? existingMessage.tool_calls : void 0;
|
|
2316
2332
|
step.output = mergeEveReasoning(
|
|
2317
2333
|
[
|
|
2318
2334
|
{
|
|
@@ -2376,11 +2392,11 @@ var EveBridge = (_class = class {
|
|
|
2376
2392
|
return;
|
|
2377
2393
|
}
|
|
2378
2394
|
const toolCallsById = /* @__PURE__ */ new Map();
|
|
2379
|
-
if (Array.isArray(step.output) &&
|
|
2395
|
+
if (Array.isArray(step.output) && _chunkOBBWQW6Kjs.isObject.call(void 0, step.output[0])) {
|
|
2380
2396
|
const message = step.output[0]["message"];
|
|
2381
|
-
if (
|
|
2397
|
+
if (_chunkOBBWQW6Kjs.isObject.call(void 0, message) && Array.isArray(message["tool_calls"])) {
|
|
2382
2398
|
for (const toolCall of message["tool_calls"]) {
|
|
2383
|
-
if (
|
|
2399
|
+
if (_chunkOBBWQW6Kjs.isObject.call(void 0, toolCall) && typeof toolCall["id"] === "string") {
|
|
2384
2400
|
toolCallsById.set(toolCall["id"], toolCall);
|
|
2385
2401
|
}
|
|
2386
2402
|
}
|
|
@@ -2589,7 +2605,7 @@ var EveBridge = (_class = class {
|
|
|
2589
2605
|
};
|
|
2590
2606
|
step.metrics = { ...step.metrics, ...metrics };
|
|
2591
2607
|
const sessionId = sessionIdFromContext(ctx);
|
|
2592
|
-
if (Array.isArray(step.output) &&
|
|
2608
|
+
if (Array.isArray(step.output) && _chunkOBBWQW6Kjs.isObject.call(void 0, step.output[0])) {
|
|
2593
2609
|
const finishReason = step.output[0].finish_reason;
|
|
2594
2610
|
if (typeof finishReason !== "string") {
|
|
2595
2611
|
step.output[0].finish_reason = normalizedFinishReason(
|
|
@@ -2927,10 +2943,10 @@ var EveBridge = (_class = class {
|
|
|
2927
2943
|
return state;
|
|
2928
2944
|
}
|
|
2929
2945
|
async startTurnSpan(sessionId, event, ctx, metadata) {
|
|
2930
|
-
const session =
|
|
2931
|
-
const parent =
|
|
2932
|
-
const parentTurn =
|
|
2933
|
-
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" ? {
|
|
2934
2950
|
callId: parent["callId"],
|
|
2935
2951
|
sessionId: parent["sessionId"],
|
|
2936
2952
|
turnId: parentTurn["id"]
|
|
@@ -3037,10 +3053,10 @@ var EveBridge = (_class = class {
|
|
|
3037
3053
|
}
|
|
3038
3054
|
async flushInstrumentation() {
|
|
3039
3055
|
try {
|
|
3040
|
-
await
|
|
3056
|
+
await _chunkOBBWQW6Kjs.flush.call(void 0, );
|
|
3041
3057
|
return true;
|
|
3042
3058
|
} catch (error) {
|
|
3043
|
-
|
|
3059
|
+
_chunkOBBWQW6Kjs.debugLogger.warn("Error in Eve flush instrumentation:", error);
|
|
3044
3060
|
return false;
|
|
3045
3061
|
}
|
|
3046
3062
|
}
|
|
@@ -3055,12 +3071,12 @@ function emptyEveTraceState() {
|
|
|
3055
3071
|
};
|
|
3056
3072
|
}
|
|
3057
3073
|
function normalizeEveTraceState(state) {
|
|
3058
|
-
if (!
|
|
3074
|
+
if (!_chunkOBBWQW6Kjs.isObject.call(void 0, state)) {
|
|
3059
3075
|
return emptyEveTraceState();
|
|
3060
3076
|
}
|
|
3061
|
-
const metadata =
|
|
3077
|
+
const metadata = _chunkOBBWQW6Kjs.isObject.call(void 0, state["metadata"]) ? state["metadata"] : {};
|
|
3062
3078
|
const spanReferences = Array.isArray(state["spanReferences"]) ? state["spanReferences"].flatMap((entry) => {
|
|
3063
|
-
if (!
|
|
3079
|
+
if (!_chunkOBBWQW6Kjs.isObject.call(void 0, entry)) {
|
|
3064
3080
|
return [];
|
|
3065
3081
|
}
|
|
3066
3082
|
const exported = entry["exported"];
|
|
@@ -3069,11 +3085,11 @@ function normalizeEveTraceState(state) {
|
|
|
3069
3085
|
const rowId = entry["rowId"];
|
|
3070
3086
|
const spanId = entry["spanId"];
|
|
3071
3087
|
const startEvent = entry["startEvent"];
|
|
3072
|
-
const startEventCreated =
|
|
3073
|
-
const startEventMetrics =
|
|
3074
|
-
const startEventSpanAttributes =
|
|
3075
|
-
const startEventSpanParents =
|
|
3076
|
-
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(
|
|
3077
3093
|
(parent) => typeof parent === "string"
|
|
3078
3094
|
) ? {
|
|
3079
3095
|
created: startEventCreated,
|
|
@@ -3093,7 +3109,7 @@ function normalizeEveTraceState(state) {
|
|
|
3093
3109
|
] : [];
|
|
3094
3110
|
}).slice(-MAX_STORED_SPAN_REFERENCES) : [];
|
|
3095
3111
|
const llmInputs = Array.isArray(state["llmInputs"]) ? state["llmInputs"].flatMap((entry) => {
|
|
3096
|
-
if (!
|
|
3112
|
+
if (!_chunkOBBWQW6Kjs.isObject.call(void 0, entry)) {
|
|
3097
3113
|
return [];
|
|
3098
3114
|
}
|
|
3099
3115
|
const key = entry["key"];
|
|
@@ -3101,7 +3117,7 @@ function normalizeEveTraceState(state) {
|
|
|
3101
3117
|
return typeof key === "string" && isCapturedModelInput(input) ? [{ input, key }] : [];
|
|
3102
3118
|
}).slice(-MAX_STORED_LLM_INPUTS) : [];
|
|
3103
3119
|
const reasoningBlocks = Array.isArray(state["reasoningBlocks"]) ? state["reasoningBlocks"].flatMap((entry) => {
|
|
3104
|
-
if (!
|
|
3120
|
+
if (!_chunkOBBWQW6Kjs.isObject.call(void 0, entry)) {
|
|
3105
3121
|
return [];
|
|
3106
3122
|
}
|
|
3107
3123
|
const content = entry["content"];
|
|
@@ -3116,7 +3132,7 @@ function normalizeEveTraceState(state) {
|
|
|
3116
3132
|
] : [];
|
|
3117
3133
|
}).slice(-MAX_STORED_REASONING_BLOCKS) : [];
|
|
3118
3134
|
const stepStarts = Array.isArray(state["stepStarts"]) ? state["stepStarts"].flatMap((entry) => {
|
|
3119
|
-
if (!
|
|
3135
|
+
if (!_chunkOBBWQW6Kjs.isObject.call(void 0, entry)) {
|
|
3120
3136
|
return [];
|
|
3121
3137
|
}
|
|
3122
3138
|
const ordinal = entry["ordinal"];
|
|
@@ -3193,14 +3209,14 @@ function clearStoredEveReasoning(state, sessionId, turnId, stepIndex) {
|
|
|
3193
3209
|
});
|
|
3194
3210
|
}
|
|
3195
3211
|
function eveOutputMessage(output) {
|
|
3196
|
-
return Array.isArray(output) &&
|
|
3212
|
+
return Array.isArray(output) && _chunkOBBWQW6Kjs.isObject.call(void 0, output[0]) ? output[0]["message"] : void 0;
|
|
3197
3213
|
}
|
|
3198
3214
|
function mergeEveReasoning(output, reasoning) {
|
|
3199
3215
|
if (reasoning.length === 0) {
|
|
3200
3216
|
return output;
|
|
3201
3217
|
}
|
|
3202
|
-
const choice = Array.isArray(output) &&
|
|
3203
|
-
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"] : {};
|
|
3204
3220
|
return [
|
|
3205
3221
|
{
|
|
3206
3222
|
...choice,
|
|
@@ -3254,7 +3270,7 @@ function consumeCapturedEveModelInput(state, sessionId, turnId, stepIndex) {
|
|
|
3254
3270
|
});
|
|
3255
3271
|
return input;
|
|
3256
3272
|
} catch (error) {
|
|
3257
|
-
|
|
3273
|
+
_chunkOBBWQW6Kjs.debugLogger.warn("Error in Eve LLM input consumption:", error);
|
|
3258
3274
|
return void 0;
|
|
3259
3275
|
}
|
|
3260
3276
|
}
|
|
@@ -3392,14 +3408,14 @@ function capturedEveModelContentPart(part) {
|
|
|
3392
3408
|
}
|
|
3393
3409
|
function isCapturedModelInput(input) {
|
|
3394
3410
|
return Array.isArray(input) && input.every(
|
|
3395
|
-
(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))
|
|
3396
3412
|
);
|
|
3397
3413
|
}
|
|
3398
3414
|
function llmInputKey(sessionId, turnId, stepIndex) {
|
|
3399
3415
|
return `${sessionId}\0${turnId}\0${stepIndex}`;
|
|
3400
3416
|
}
|
|
3401
3417
|
function modelMetadataFromRuntime(runtime) {
|
|
3402
|
-
if (!
|
|
3418
|
+
if (!_chunkOBBWQW6Kjs.isObject.call(void 0, runtime)) {
|
|
3403
3419
|
return {};
|
|
3404
3420
|
}
|
|
3405
3421
|
const modelId = runtime["modelId"];
|
|
@@ -3422,11 +3438,11 @@ function modelMetadataFromModelId(modelId) {
|
|
|
3422
3438
|
};
|
|
3423
3439
|
}
|
|
3424
3440
|
function sessionIdFromContext(ctx) {
|
|
3425
|
-
if (!
|
|
3441
|
+
if (!_chunkOBBWQW6Kjs.isObject.call(void 0, ctx)) {
|
|
3426
3442
|
return void 0;
|
|
3427
3443
|
}
|
|
3428
3444
|
const session = ctx["session"];
|
|
3429
|
-
if (!
|
|
3445
|
+
if (!_chunkOBBWQW6Kjs.isObject.call(void 0, session)) {
|
|
3430
3446
|
return void 0;
|
|
3431
3447
|
}
|
|
3432
3448
|
const id = session["id"];
|
|
@@ -3437,19 +3453,19 @@ function toolMetadataFromTurn(turn) {
|
|
|
3437
3453
|
return metadata;
|
|
3438
3454
|
}
|
|
3439
3455
|
function isToolCallAction(action) {
|
|
3440
|
-
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"]);
|
|
3441
3457
|
}
|
|
3442
3458
|
function isLocalSubagentCallAction(action) {
|
|
3443
|
-
return
|
|
3459
|
+
return _chunkOBBWQW6Kjs.isObject.call(void 0, action) && action["kind"] === "subagent-call" && typeof action["callId"] === "string" && _chunkOBBWQW6Kjs.isObject.call(void 0, action["input"]);
|
|
3444
3460
|
}
|
|
3445
3461
|
function isTraceableActionRequest(action) {
|
|
3446
3462
|
return isToolCallAction(action) || isLocalSubagentCallAction(action);
|
|
3447
3463
|
}
|
|
3448
3464
|
function isToolResult(result) {
|
|
3449
|
-
return
|
|
3465
|
+
return _chunkOBBWQW6Kjs.isObject.call(void 0, result) && result["kind"] === "tool-result" && typeof result["callId"] === "string" && typeof result["toolName"] === "string";
|
|
3450
3466
|
}
|
|
3451
3467
|
function isSubagentResult(result) {
|
|
3452
|
-
return
|
|
3468
|
+
return _chunkOBBWQW6Kjs.isObject.call(void 0, result) && result["kind"] === "subagent-result" && typeof result["callId"] === "string" && typeof result["subagentName"] === "string";
|
|
3453
3469
|
}
|
|
3454
3470
|
function normalizedFinishReason(finishReason) {
|
|
3455
3471
|
switch (finishReason) {
|
|
@@ -3541,6 +3557,66 @@ function betaProxy(beta, anthropic) {
|
|
|
3541
3557
|
if (prop === "messages") {
|
|
3542
3558
|
return betaMessagesProxy(target.messages, anthropic);
|
|
3543
3559
|
}
|
|
3560
|
+
if (prop === "sessions") {
|
|
3561
|
+
return target.sessions ? betaSessionsProxy(target.sessions) : target.sessions;
|
|
3562
|
+
}
|
|
3563
|
+
return Reflect.get(target, prop, receiver);
|
|
3564
|
+
}
|
|
3565
|
+
});
|
|
3566
|
+
}
|
|
3567
|
+
function betaSessionsProxy(sessions) {
|
|
3568
|
+
return new Proxy(sessions, {
|
|
3569
|
+
get(target, prop, receiver) {
|
|
3570
|
+
if (prop === "events") {
|
|
3571
|
+
return betaSessionEventsProxy(target.events);
|
|
3572
|
+
}
|
|
3573
|
+
if (prop === "threads") {
|
|
3574
|
+
return target.threads ? betaSessionThreadsProxy(target.threads) : target.threads;
|
|
3575
|
+
}
|
|
3576
|
+
return Reflect.get(target, prop, receiver);
|
|
3577
|
+
}
|
|
3578
|
+
});
|
|
3579
|
+
}
|
|
3580
|
+
function betaSessionEventsProxy(events) {
|
|
3581
|
+
return new Proxy(events, {
|
|
3582
|
+
get(target, prop, receiver) {
|
|
3583
|
+
if (prop === "stream") {
|
|
3584
|
+
return new TypedApplyProxy(target.stream, {
|
|
3585
|
+
apply(stream, thisArg, argArray) {
|
|
3586
|
+
return _chunkBBE7SNRVjs.anthropicChannels.betaSessionsEventsStream.tracePromise(
|
|
3587
|
+
() => Reflect.apply(stream, thisArg, argArray),
|
|
3588
|
+
{ arguments: argArray }
|
|
3589
|
+
);
|
|
3590
|
+
}
|
|
3591
|
+
});
|
|
3592
|
+
}
|
|
3593
|
+
return Reflect.get(target, prop, receiver);
|
|
3594
|
+
}
|
|
3595
|
+
});
|
|
3596
|
+
}
|
|
3597
|
+
function betaSessionThreadsProxy(threads) {
|
|
3598
|
+
return new Proxy(threads, {
|
|
3599
|
+
get(target, prop, receiver) {
|
|
3600
|
+
if (prop === "events") {
|
|
3601
|
+
return betaSessionThreadEventsProxy(target.events);
|
|
3602
|
+
}
|
|
3603
|
+
return Reflect.get(target, prop, receiver);
|
|
3604
|
+
}
|
|
3605
|
+
});
|
|
3606
|
+
}
|
|
3607
|
+
function betaSessionThreadEventsProxy(events) {
|
|
3608
|
+
return new Proxy(events, {
|
|
3609
|
+
get(target, prop, receiver) {
|
|
3610
|
+
if (prop === "stream") {
|
|
3611
|
+
return new TypedApplyProxy(target.stream, {
|
|
3612
|
+
apply(stream, thisArg, argArray) {
|
|
3613
|
+
return _chunkBBE7SNRVjs.anthropicChannels.betaSessionsThreadsEventsStream.tracePromise(
|
|
3614
|
+
() => Reflect.apply(stream, thisArg, argArray),
|
|
3615
|
+
{ arguments: argArray }
|
|
3616
|
+
);
|
|
3617
|
+
}
|
|
3618
|
+
});
|
|
3619
|
+
}
|
|
3544
3620
|
return Reflect.get(target, prop, receiver);
|
|
3545
3621
|
}
|
|
3546
3622
|
});
|
|
@@ -3549,7 +3625,7 @@ function messagesProxy(messages) {
|
|
|
3549
3625
|
return new Proxy(messages, {
|
|
3550
3626
|
get(target, prop, receiver) {
|
|
3551
3627
|
if (prop === "create") {
|
|
3552
|
-
return createProxy(target.create,
|
|
3628
|
+
return createProxy(target.create, _chunkBBE7SNRVjs.anthropicChannels.messagesCreate);
|
|
3553
3629
|
}
|
|
3554
3630
|
return Reflect.get(target, prop, receiver);
|
|
3555
3631
|
}
|
|
@@ -3559,7 +3635,7 @@ function betaMessagesProxy(messages, anthropic) {
|
|
|
3559
3635
|
return new Proxy(messages, {
|
|
3560
3636
|
get(target, prop, receiver) {
|
|
3561
3637
|
if (prop === "create") {
|
|
3562
|
-
return createProxy(target.create,
|
|
3638
|
+
return createProxy(target.create, _chunkBBE7SNRVjs.anthropicChannels.betaMessagesCreate);
|
|
3563
3639
|
}
|
|
3564
3640
|
if (prop === "toolRunner") {
|
|
3565
3641
|
if (typeof target.toolRunner !== "function") {
|
|
@@ -3568,7 +3644,7 @@ function betaMessagesProxy(messages, anthropic) {
|
|
|
3568
3644
|
return toolRunnerProxy(
|
|
3569
3645
|
target.toolRunner,
|
|
3570
3646
|
anthropic,
|
|
3571
|
-
|
|
3647
|
+
_chunkBBE7SNRVjs.anthropicChannels.betaMessagesToolRunner
|
|
3572
3648
|
);
|
|
3573
3649
|
}
|
|
3574
3650
|
return Reflect.get(target, prop, receiver);
|
|
@@ -3625,11 +3701,11 @@ function wrapClaudeAgentQuery(queryFn, defaultThis) {
|
|
|
3625
3701
|
...params,
|
|
3626
3702
|
options: {
|
|
3627
3703
|
..._nullishCoalesce(params.options, () => ( {})),
|
|
3628
|
-
[
|
|
3704
|
+
[_chunkOBBWQW6Kjs.CLAUDE_AGENT_SDK_SKIP_LOCAL_TOOL_HOOKS_OPTION]: true
|
|
3629
3705
|
}
|
|
3630
3706
|
};
|
|
3631
3707
|
const invocationTarget = thisArg === proxy || thisArg === void 0 ? _nullishCoalesce(defaultThis, () => ( thisArg)) : thisArg;
|
|
3632
|
-
return
|
|
3708
|
+
return _chunkBBE7SNRVjs.claudeAgentSDKChannels.query.traceSync(
|
|
3633
3709
|
() => Reflect.apply(target, invocationTarget, [wrappedParams]),
|
|
3634
3710
|
// The channel carries no extra context fields, but the generated
|
|
3635
3711
|
// StartOf<> type for Record<string, never> is overly strict here.
|
|
@@ -3657,7 +3733,7 @@ function wrapClaudeAgentTool(toolFn, localToolMetadataByTool, defaultThis) {
|
|
|
3657
3733
|
}
|
|
3658
3734
|
const localToolMetadata = { toolName };
|
|
3659
3735
|
const originalHandler = wrappedArgs[handlerIndex];
|
|
3660
|
-
wrappedArgs[handlerIndex] =
|
|
3736
|
+
wrappedArgs[handlerIndex] = _chunkOBBWQW6Kjs.wrapLocalClaudeToolHandler.call(void 0,
|
|
3661
3737
|
originalHandler,
|
|
3662
3738
|
() => localToolMetadata
|
|
3663
3739
|
);
|
|
@@ -3734,6 +3810,52 @@ function claudeAgentSDKProxy(sdk) {
|
|
|
3734
3810
|
});
|
|
3735
3811
|
}
|
|
3736
3812
|
|
|
3813
|
+
// src/wrappers/cloudflare-think.ts
|
|
3814
|
+
var WRAPPED_THINK = /* @__PURE__ */ Symbol.for("braintrust.cloudflare-think.wrapped");
|
|
3815
|
+
function wrapCloudflareThink(sdk) {
|
|
3816
|
+
if (!sdk || typeof sdk !== "object") {
|
|
3817
|
+
return sdk;
|
|
3818
|
+
}
|
|
3819
|
+
const thinkModule = sdk;
|
|
3820
|
+
if (typeof thinkModule.Think !== "function") {
|
|
3821
|
+
return sdk;
|
|
3822
|
+
}
|
|
3823
|
+
patchThinkClass(thinkModule.Think);
|
|
3824
|
+
return sdk;
|
|
3825
|
+
}
|
|
3826
|
+
function patchThinkClass(Think) {
|
|
3827
|
+
const prototype = Think.prototype;
|
|
3828
|
+
if (!prototype || prototype[WRAPPED_THINK]) {
|
|
3829
|
+
return;
|
|
3830
|
+
}
|
|
3831
|
+
const descriptor = Object.getOwnPropertyDescriptor(
|
|
3832
|
+
prototype,
|
|
3833
|
+
"_runInferenceLoop"
|
|
3834
|
+
);
|
|
3835
|
+
if (!descriptor || typeof descriptor.value !== "function") {
|
|
3836
|
+
return;
|
|
3837
|
+
}
|
|
3838
|
+
const original = descriptor.value;
|
|
3839
|
+
Object.defineProperty(prototype, "_runInferenceLoop", {
|
|
3840
|
+
...descriptor,
|
|
3841
|
+
value: function wrappedCloudflareThinkRunInferenceLoop(input) {
|
|
3842
|
+
const args = [input];
|
|
3843
|
+
return _chunkBBE7SNRVjs.cloudflareThinkChannels.runInferenceLoop.tracePromise(
|
|
3844
|
+
() => Reflect.apply(original, this, args),
|
|
3845
|
+
{
|
|
3846
|
+
arguments: args,
|
|
3847
|
+
self: this
|
|
3848
|
+
}
|
|
3849
|
+
);
|
|
3850
|
+
}
|
|
3851
|
+
});
|
|
3852
|
+
Object.defineProperty(prototype, WRAPPED_THINK, {
|
|
3853
|
+
configurable: false,
|
|
3854
|
+
enumerable: false,
|
|
3855
|
+
value: true
|
|
3856
|
+
});
|
|
3857
|
+
}
|
|
3858
|
+
|
|
3737
3859
|
// src/wrappers/openai-codex.ts
|
|
3738
3860
|
var WRAPPED_CLIENT = /* @__PURE__ */ Symbol.for("braintrust.openai-codex.wrapped-client");
|
|
3739
3861
|
var WRAPPED_THREAD = /* @__PURE__ */ Symbol.for("braintrust.openai-codex.wrapped-thread");
|
|
@@ -3840,7 +3962,7 @@ function wrapCodexThread(thread) {
|
|
|
3840
3962
|
if (prop === "run" && typeof value === "function") {
|
|
3841
3963
|
return function(input, turnOptions) {
|
|
3842
3964
|
const args = [input, turnOptions];
|
|
3843
|
-
return
|
|
3965
|
+
return _chunkBBE7SNRVjs.openAICodexChannels.run.tracePromise(
|
|
3844
3966
|
() => Reflect.apply(value, target, args),
|
|
3845
3967
|
{
|
|
3846
3968
|
arguments: args,
|
|
@@ -3853,7 +3975,7 @@ function wrapCodexThread(thread) {
|
|
|
3853
3975
|
if (prop === "runStreamed" && typeof value === "function") {
|
|
3854
3976
|
return function(input, turnOptions) {
|
|
3855
3977
|
const args = [input, turnOptions];
|
|
3856
|
-
return
|
|
3978
|
+
return _chunkBBE7SNRVjs.openAICodexChannels.runStreamed.tracePromise(
|
|
3857
3979
|
() => Reflect.apply(value, target, args),
|
|
3858
3980
|
{
|
|
3859
3981
|
arguments: args,
|
|
@@ -3921,7 +4043,7 @@ function wrapCursorAgentClass(Agent) {
|
|
|
3921
4043
|
if (prop === "create" && typeof value === "function") {
|
|
3922
4044
|
const wrapped = async function(options) {
|
|
3923
4045
|
const args = [options];
|
|
3924
|
-
return
|
|
4046
|
+
return _chunkBBE7SNRVjs.cursorSDKChannels.create.tracePromise(
|
|
3925
4047
|
async () => wrapCursorAgent(await Reflect.apply(value, target, args)),
|
|
3926
4048
|
{ arguments: args }
|
|
3927
4049
|
);
|
|
@@ -3932,7 +4054,7 @@ function wrapCursorAgentClass(Agent) {
|
|
|
3932
4054
|
if (prop === "resume" && typeof value === "function") {
|
|
3933
4055
|
const wrapped = async function(agentId, options) {
|
|
3934
4056
|
const args = [agentId, options];
|
|
3935
|
-
return
|
|
4057
|
+
return _chunkBBE7SNRVjs.cursorSDKChannels.resume.tracePromise(
|
|
3936
4058
|
async () => wrapCursorAgent(await Reflect.apply(value, target, args)),
|
|
3937
4059
|
{ arguments: args }
|
|
3938
4060
|
);
|
|
@@ -3943,7 +4065,7 @@ function wrapCursorAgentClass(Agent) {
|
|
|
3943
4065
|
if (prop === "prompt" && typeof value === "function") {
|
|
3944
4066
|
const wrapped = async function(message, options) {
|
|
3945
4067
|
const args = [message, options];
|
|
3946
|
-
return
|
|
4068
|
+
return _chunkBBE7SNRVjs.cursorSDKChannels.prompt.tracePromise(
|
|
3947
4069
|
() => Reflect.apply(value, target, args),
|
|
3948
4070
|
{ arguments: args }
|
|
3949
4071
|
);
|
|
@@ -3976,7 +4098,7 @@ function wrapCursorAgent(agent) {
|
|
|
3976
4098
|
if (prop === "send" && typeof value === "function") {
|
|
3977
4099
|
return function(message, options) {
|
|
3978
4100
|
const args = [message, options];
|
|
3979
|
-
return
|
|
4101
|
+
return _chunkBBE7SNRVjs.cursorSDKChannels.send.tracePromise(
|
|
3980
4102
|
() => Reflect.apply(value, target, args),
|
|
3981
4103
|
{
|
|
3982
4104
|
agent: target,
|
|
@@ -4026,14 +4148,9 @@ function patchAgentSessionClass(AgentSession) {
|
|
|
4026
4148
|
...descriptor,
|
|
4027
4149
|
value: function wrappedPiCodingAgentPrompt(text, options) {
|
|
4028
4150
|
const args = [text, options];
|
|
4029
|
-
return
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
arguments: args,
|
|
4033
|
-
self: this,
|
|
4034
|
-
session: this
|
|
4035
|
-
}
|
|
4036
|
-
);
|
|
4151
|
+
return _chunkBBE7SNRVjs.piCodingAgentChannels.prompt.invoke(originalPrompt, this, args, {
|
|
4152
|
+
session: this
|
|
4153
|
+
});
|
|
4037
4154
|
}
|
|
4038
4155
|
});
|
|
4039
4156
|
Object.defineProperty(prototype, WRAPPED_PROMPT, {
|
|
@@ -4077,7 +4194,7 @@ function wrapCloudflareAgent(Agent) {
|
|
|
4077
4194
|
if (ownValue(options, "detached")) {
|
|
4078
4195
|
return Reflect.apply(originalRunAgentTool, this, args);
|
|
4079
4196
|
}
|
|
4080
|
-
return
|
|
4197
|
+
return _chunkBBE7SNRVjs.cloudflareAgentsChannels.runAgentTool.tracePromise(
|
|
4081
4198
|
() => Reflect.apply(originalRunAgentTool, this, args),
|
|
4082
4199
|
{ arguments: args, self: this }
|
|
4083
4200
|
);
|
|
@@ -4101,7 +4218,7 @@ function isObjectLike(value) {
|
|
|
4101
4218
|
return typeof value === "object" && value !== null || typeof value === "function";
|
|
4102
4219
|
}
|
|
4103
4220
|
function warnUnsupportedAgent() {
|
|
4104
|
-
|
|
4221
|
+
_chunkOBBWQW6Kjs.debugLogger.warn("Unsupported Cloudflare Agents Agent class. Not wrapping.");
|
|
4105
4222
|
}
|
|
4106
4223
|
|
|
4107
4224
|
// src/wrappers/strands-agent-sdk.ts
|
|
@@ -4207,7 +4324,7 @@ function wrapAgentInstance(agent) {
|
|
|
4207
4324
|
if (prop === "stream" && typeof value === "function") {
|
|
4208
4325
|
return function(args, options) {
|
|
4209
4326
|
const callArgs = [args, options];
|
|
4210
|
-
return
|
|
4327
|
+
return _chunkBBE7SNRVjs.strandsAgentSDKChannels.agentStream.traceSync(
|
|
4211
4328
|
() => Reflect.apply(value, target, callArgs),
|
|
4212
4329
|
{
|
|
4213
4330
|
agent: proxy,
|
|
@@ -4243,7 +4360,7 @@ function wrapMultiAgentInstance(orchestrator, kind) {
|
|
|
4243
4360
|
if (prop === "stream" && typeof value === "function") {
|
|
4244
4361
|
return function(input, options) {
|
|
4245
4362
|
const callArgs = [input, options];
|
|
4246
|
-
const channel = kind === "graph" ?
|
|
4363
|
+
const channel = kind === "graph" ? _chunkBBE7SNRVjs.strandsAgentSDKChannels.graphStream : _chunkBBE7SNRVjs.strandsAgentSDKChannels.swarmStream;
|
|
4247
4364
|
return channel.traceSync(
|
|
4248
4365
|
() => Reflect.apply(value, target, callArgs),
|
|
4249
4366
|
{
|
|
@@ -4283,11 +4400,11 @@ function wrapCloudflareAIChat(module) {
|
|
|
4283
4400
|
try {
|
|
4284
4401
|
AIChatAgent = Reflect.get(candidate, "AIChatAgent");
|
|
4285
4402
|
} catch (error) {
|
|
4286
|
-
|
|
4403
|
+
_chunkOBBWQW6Kjs.debugLogger.debug("Failed to inspect @cloudflare/ai-chat module:", error);
|
|
4287
4404
|
return module;
|
|
4288
4405
|
}
|
|
4289
4406
|
if (typeof AIChatAgent !== "function") {
|
|
4290
|
-
|
|
4407
|
+
_chunkOBBWQW6Kjs.debugLogger.warn(
|
|
4291
4408
|
"Unsupported @cloudflare/ai-chat module. AIChatAgent was not found; not wrapping."
|
|
4292
4409
|
);
|
|
4293
4410
|
return module;
|
|
@@ -4321,7 +4438,7 @@ function wrapAIChatAgentClass(AgentClass) {
|
|
|
4321
4438
|
args,
|
|
4322
4439
|
newTarget
|
|
4323
4440
|
);
|
|
4324
|
-
return
|
|
4441
|
+
return _chunkOBBWQW6Kjs.instrumentCloudflareAIChatAgent.call(void 0, instance);
|
|
4325
4442
|
}
|
|
4326
4443
|
});
|
|
4327
4444
|
wrappedClasses.set(AgentClass, wrapped);
|
|
@@ -4393,7 +4510,7 @@ function wrapGoogleGenAIInstance(instance) {
|
|
|
4393
4510
|
}
|
|
4394
4511
|
if (prop === "interactions") {
|
|
4395
4512
|
const interactions = Reflect.get(target, prop, receiver);
|
|
4396
|
-
if (!
|
|
4513
|
+
if (!_chunkOBBWQW6Kjs.isObject.call(void 0, interactions) || typeof interactions.create !== "function") {
|
|
4397
4514
|
return interactions;
|
|
4398
4515
|
}
|
|
4399
4516
|
if (interactions !== originalInteractions) {
|
|
@@ -4407,7 +4524,7 @@ function wrapGoogleGenAIInstance(instance) {
|
|
|
4407
4524
|
});
|
|
4408
4525
|
}
|
|
4409
4526
|
function patchGoogleGenAIChats(instance, wrappedModels) {
|
|
4410
|
-
if (!
|
|
4527
|
+
if (!_chunkOBBWQW6Kjs.isObject.call(void 0, instance.chats) || !("modelsModule" in instance.chats)) {
|
|
4411
4528
|
return;
|
|
4412
4529
|
}
|
|
4413
4530
|
Reflect.set(instance.chats, "modelsModule", wrappedModels);
|
|
@@ -4440,7 +4557,7 @@ function wrapInteractions(interactions) {
|
|
|
4440
4557
|
}
|
|
4441
4558
|
function wrapGenerateContent(original) {
|
|
4442
4559
|
return function(params) {
|
|
4443
|
-
return
|
|
4560
|
+
return _chunkBBE7SNRVjs.googleGenAIChannels.generateContent.tracePromise(
|
|
4444
4561
|
() => original(params),
|
|
4445
4562
|
{ arguments: [params] }
|
|
4446
4563
|
);
|
|
@@ -4448,7 +4565,7 @@ function wrapGenerateContent(original) {
|
|
|
4448
4565
|
}
|
|
4449
4566
|
function wrapGenerateContentStream(original) {
|
|
4450
4567
|
return function(params) {
|
|
4451
|
-
return
|
|
4568
|
+
return _chunkBBE7SNRVjs.googleGenAIChannels.generateContentStream.tracePromise(
|
|
4452
4569
|
() => original(params),
|
|
4453
4570
|
{ arguments: [params] }
|
|
4454
4571
|
);
|
|
@@ -4456,7 +4573,7 @@ function wrapGenerateContentStream(original) {
|
|
|
4456
4573
|
}
|
|
4457
4574
|
function wrapEmbedContent(original) {
|
|
4458
4575
|
return function(params) {
|
|
4459
|
-
return
|
|
4576
|
+
return _chunkBBE7SNRVjs.googleGenAIChannels.embedContent.tracePromise(
|
|
4460
4577
|
() => original(params),
|
|
4461
4578
|
{ arguments: [params] }
|
|
4462
4579
|
);
|
|
@@ -4468,7 +4585,7 @@ function wrapInteractionCreate(original) {
|
|
|
4468
4585
|
return options === void 0 ? original(params) : original(params, options);
|
|
4469
4586
|
}
|
|
4470
4587
|
const traceContext = options === void 0 ? { arguments: [params] } : { arguments: [params, options] };
|
|
4471
|
-
return
|
|
4588
|
+
return _chunkBBE7SNRVjs.googleGenAIChannels.interactionsCreate.tracePromise(
|
|
4472
4589
|
() => options === void 0 ? original(params) : original(params, options),
|
|
4473
4590
|
traceContext
|
|
4474
4591
|
);
|
|
@@ -4529,7 +4646,7 @@ function wrapRunnerInstance(runner) {
|
|
|
4529
4646
|
function wrapRunnerRunAsync(runner) {
|
|
4530
4647
|
const original = runner.runAsync.bind(runner);
|
|
4531
4648
|
return function(params) {
|
|
4532
|
-
return
|
|
4649
|
+
return _chunkBBE7SNRVjs.googleADKChannels.runnerRunAsync.traceSync(() => original(params), {
|
|
4533
4650
|
arguments: [params],
|
|
4534
4651
|
self: runner
|
|
4535
4652
|
});
|
|
@@ -4556,7 +4673,7 @@ function wrapAgentInstance2(agent) {
|
|
|
4556
4673
|
function wrapAgentRunAsync(agent) {
|
|
4557
4674
|
const original = agent.runAsync.bind(agent);
|
|
4558
4675
|
return function(parentContext) {
|
|
4559
|
-
return
|
|
4676
|
+
return _chunkBBE7SNRVjs.googleADKChannels.agentRunAsync.traceSync(
|
|
4560
4677
|
() => original(parentContext),
|
|
4561
4678
|
{ arguments: [parentContext], self: agent }
|
|
4562
4679
|
);
|
|
@@ -4583,7 +4700,7 @@ function wrapToolInstance(tool) {
|
|
|
4583
4700
|
function wrapToolRunAsync(tool) {
|
|
4584
4701
|
const original = tool.runAsync.bind(tool);
|
|
4585
4702
|
return function(req) {
|
|
4586
|
-
return
|
|
4703
|
+
return _chunkBBE7SNRVjs.googleADKChannels.toolRunAsync.tracePromise(() => original(req), {
|
|
4587
4704
|
arguments: [req],
|
|
4588
4705
|
self: tool
|
|
4589
4706
|
});
|
|
@@ -4730,27 +4847,27 @@ function patchGenkitRegistryConstructor(registry) {
|
|
|
4730
4847
|
}
|
|
4731
4848
|
}
|
|
4732
4849
|
function wrapGenerate(generate) {
|
|
4733
|
-
return (input) =>
|
|
4850
|
+
return (input) => _chunkBBE7SNRVjs.genkitChannels.generate.tracePromise(() => generate(input), {
|
|
4734
4851
|
arguments: [input]
|
|
4735
4852
|
});
|
|
4736
4853
|
}
|
|
4737
4854
|
function wrapGenerateStream(generateStream) {
|
|
4738
|
-
return (input) =>
|
|
4855
|
+
return (input) => _chunkBBE7SNRVjs.genkitChannels.generateStream.traceSync(() => generateStream(input), {
|
|
4739
4856
|
arguments: [input]
|
|
4740
4857
|
});
|
|
4741
4858
|
}
|
|
4742
4859
|
function wrapEmbed2(embed) {
|
|
4743
|
-
return (params) =>
|
|
4860
|
+
return (params) => _chunkBBE7SNRVjs.genkitChannels.embed.tracePromise(() => embed(params), {
|
|
4744
4861
|
arguments: [params]
|
|
4745
4862
|
});
|
|
4746
4863
|
}
|
|
4747
4864
|
function wrapEmbedMany2(embedMany) {
|
|
4748
|
-
return (params) =>
|
|
4865
|
+
return (params) => _chunkBBE7SNRVjs.genkitChannels.embedMany.tracePromise(() => embedMany(params), {
|
|
4749
4866
|
arguments: [params]
|
|
4750
4867
|
});
|
|
4751
4868
|
}
|
|
4752
4869
|
function wrapRun(run) {
|
|
4753
|
-
return (name, inputOrFn, maybeFn) =>
|
|
4870
|
+
return (name, inputOrFn, maybeFn) => _chunkBBE7SNRVjs.genkitChannels.actionRun.tracePromise(() => run(name, inputOrFn, maybeFn), {
|
|
4754
4871
|
arguments: [name, inputOrFn, maybeFn]
|
|
4755
4872
|
});
|
|
4756
4873
|
}
|
|
@@ -4789,13 +4906,13 @@ function isGenkitAction(value) {
|
|
|
4789
4906
|
return typeof value === "function" && "__action" in value;
|
|
4790
4907
|
}
|
|
4791
4908
|
function traceActionRun(action, run) {
|
|
4792
|
-
return (input, options) =>
|
|
4909
|
+
return (input, options) => _chunkBBE7SNRVjs.genkitChannels.actionRun.tracePromise(() => run(input, options), {
|
|
4793
4910
|
arguments: [input, options],
|
|
4794
4911
|
self: action
|
|
4795
4912
|
});
|
|
4796
4913
|
}
|
|
4797
4914
|
function traceActionStream(action, stream) {
|
|
4798
|
-
return (input, options) =>
|
|
4915
|
+
return (input, options) => _chunkBBE7SNRVjs.genkitChannels.actionStream.traceSync(() => stream(input, options), {
|
|
4799
4916
|
arguments: [input, options],
|
|
4800
4917
|
self: action
|
|
4801
4918
|
});
|
|
@@ -4841,10 +4958,10 @@ function isHuggingFaceConstructorKey(value) {
|
|
|
4841
4958
|
return HUGGINGFACE_CONSTRUCTOR_KEY_SET.has(value);
|
|
4842
4959
|
}
|
|
4843
4960
|
function hasFunction2(value, methodName) {
|
|
4844
|
-
return
|
|
4961
|
+
return _chunkOBBWQW6Kjs.isObject.call(void 0, value) && methodName in value && typeof value[methodName] === "function";
|
|
4845
4962
|
}
|
|
4846
4963
|
function isSupportedHuggingFaceModule(value) {
|
|
4847
|
-
if (!
|
|
4964
|
+
if (!_chunkOBBWQW6Kjs.isObject.call(void 0, value)) {
|
|
4848
4965
|
return false;
|
|
4849
4966
|
}
|
|
4850
4967
|
return HUGGINGFACE_CONSTRUCTOR_KEYS.some(
|
|
@@ -4952,14 +5069,14 @@ function wrapChatCompletion2(original, endpointUrl) {
|
|
|
4952
5069
|
const context = {
|
|
4953
5070
|
arguments: [traceParams]
|
|
4954
5071
|
};
|
|
4955
|
-
return
|
|
5072
|
+
return _chunkBBE7SNRVjs.huggingFaceChannels.chatCompletion.tracePromise(
|
|
4956
5073
|
() => original(params, options),
|
|
4957
5074
|
context
|
|
4958
5075
|
);
|
|
4959
5076
|
};
|
|
4960
5077
|
}
|
|
4961
5078
|
function wrapChatCompletionStream(original, endpointUrl) {
|
|
4962
|
-
return (params, options) =>
|
|
5079
|
+
return (params, options) => _chunkBBE7SNRVjs.huggingFaceChannels.chatCompletionStream.traceSync(
|
|
4963
5080
|
() => original(params, options),
|
|
4964
5081
|
{
|
|
4965
5082
|
arguments: [withEndpointUrl(params, endpointUrl)]
|
|
@@ -4972,14 +5089,14 @@ function wrapTextGeneration(original, endpointUrl) {
|
|
|
4972
5089
|
const context = {
|
|
4973
5090
|
arguments: [traceParams]
|
|
4974
5091
|
};
|
|
4975
|
-
return
|
|
5092
|
+
return _chunkBBE7SNRVjs.huggingFaceChannels.textGeneration.tracePromise(
|
|
4976
5093
|
() => original(params, options),
|
|
4977
5094
|
context
|
|
4978
5095
|
);
|
|
4979
5096
|
};
|
|
4980
5097
|
}
|
|
4981
5098
|
function wrapTextGenerationStream(original, endpointUrl) {
|
|
4982
|
-
return (params, options) =>
|
|
5099
|
+
return (params, options) => _chunkBBE7SNRVjs.huggingFaceChannels.textGenerationStream.traceSync(
|
|
4983
5100
|
() => original(params, options),
|
|
4984
5101
|
{
|
|
4985
5102
|
arguments: [withEndpointUrl(params, endpointUrl)]
|
|
@@ -4992,7 +5109,7 @@ function wrapFeatureExtraction(original, endpointUrl) {
|
|
|
4992
5109
|
const context = {
|
|
4993
5110
|
arguments: [traceParams]
|
|
4994
5111
|
};
|
|
4995
|
-
return
|
|
5112
|
+
return _chunkBBE7SNRVjs.huggingFaceChannels.featureExtraction.tracePromise(
|
|
4996
5113
|
() => original(params, options),
|
|
4997
5114
|
context
|
|
4998
5115
|
);
|
|
@@ -5010,7 +5127,7 @@ var PIPELINE_CONSTRUCTOR_KEYS = /* @__PURE__ */ new Set([
|
|
|
5010
5127
|
var wrappedValues = /* @__PURE__ */ new WeakMap();
|
|
5011
5128
|
function wrapHuggingFaceTransformers(transformers) {
|
|
5012
5129
|
const pipelineTask = _optionalChain([transformers, 'optionalAccess', _124 => _124.task]);
|
|
5013
|
-
if (typeof transformers === "function" &&
|
|
5130
|
+
if (typeof transformers === "function" && _chunkBBE7SNRVjs.isSupportedHuggingFaceTransformersTask.call(void 0, pipelineTask)) {
|
|
5014
5131
|
return wrapPipeline(transformers);
|
|
5015
5132
|
}
|
|
5016
5133
|
if (!isSupportedModule(transformers)) {
|
|
@@ -5062,8 +5179,8 @@ function wrapPipelineFactory(factory) {
|
|
|
5062
5179
|
const context = {
|
|
5063
5180
|
arguments: args
|
|
5064
5181
|
};
|
|
5065
|
-
return
|
|
5066
|
-
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)))) {
|
|
5067
5184
|
return wrapPipeline(pipeline);
|
|
5068
5185
|
}
|
|
5069
5186
|
return pipeline;
|
|
@@ -5081,7 +5198,7 @@ function wrapPipelineConstructor(constructor) {
|
|
|
5081
5198
|
const proxy = new Proxy(constructor, {
|
|
5082
5199
|
construct(target, args, newTarget) {
|
|
5083
5200
|
const pipeline = Reflect.construct(target, args, newTarget);
|
|
5084
|
-
if (
|
|
5201
|
+
if (_chunkBBE7SNRVjs.isSupportedHuggingFaceTransformersTask.call(void 0, pipeline.task)) {
|
|
5085
5202
|
return wrapPipeline(pipeline);
|
|
5086
5203
|
}
|
|
5087
5204
|
return pipeline;
|
|
@@ -5102,7 +5219,7 @@ function wrapPipeline(pipeline) {
|
|
|
5102
5219
|
arguments: args,
|
|
5103
5220
|
self: target
|
|
5104
5221
|
};
|
|
5105
|
-
return
|
|
5222
|
+
return _chunkBBE7SNRVjs.huggingFaceTransformersChannels.pipelineCall.tracePromise(
|
|
5106
5223
|
() => Reflect.apply(target, thisArg, args),
|
|
5107
5224
|
context
|
|
5108
5225
|
);
|
|
@@ -5153,7 +5270,7 @@ function wrapCallModel(callModelFn, defaultThis) {
|
|
|
5153
5270
|
const request = cloneCallModelRequest(argArray[0]);
|
|
5154
5271
|
const options = argArray[1];
|
|
5155
5272
|
const invocationTarget = thisArg === void 0 ? _nullishCoalesce(defaultThis, () => ( thisArg)) : thisArg;
|
|
5156
|
-
return
|
|
5273
|
+
return _chunkBBE7SNRVjs.openRouterAgentChannels.callModel.traceSync(
|
|
5157
5274
|
() => Reflect.apply(target, invocationTarget, [request, options]),
|
|
5158
5275
|
{
|
|
5159
5276
|
arguments: [request]
|
|
@@ -5249,24 +5366,24 @@ function rerankProxy(rerank) {
|
|
|
5249
5366
|
});
|
|
5250
5367
|
}
|
|
5251
5368
|
function wrapChatSend(send) {
|
|
5252
|
-
return (request, options) =>
|
|
5369
|
+
return (request, options) => _chunkBBE7SNRVjs.openRouterChannels.chatSend.tracePromise(() => send(request, options), {
|
|
5253
5370
|
arguments: [request]
|
|
5254
5371
|
});
|
|
5255
5372
|
}
|
|
5256
5373
|
function wrapEmbeddingsGenerate(generate) {
|
|
5257
|
-
return (request, options) =>
|
|
5374
|
+
return (request, options) => _chunkBBE7SNRVjs.openRouterChannels.embeddingsGenerate.tracePromise(
|
|
5258
5375
|
() => generate(request, options),
|
|
5259
5376
|
{ arguments: [request] }
|
|
5260
5377
|
);
|
|
5261
5378
|
}
|
|
5262
5379
|
function wrapResponsesSend(send) {
|
|
5263
|
-
return (request, options) =>
|
|
5380
|
+
return (request, options) => _chunkBBE7SNRVjs.openRouterChannels.betaResponsesSend.tracePromise(
|
|
5264
5381
|
() => send(request, options),
|
|
5265
5382
|
{ arguments: [request] }
|
|
5266
5383
|
);
|
|
5267
5384
|
}
|
|
5268
5385
|
function wrapRerank2(rerank) {
|
|
5269
|
-
return (request, options) =>
|
|
5386
|
+
return (request, options) => _chunkBBE7SNRVjs.openRouterChannels.rerankRerank.tracePromise(
|
|
5270
5387
|
() => rerank(request, options),
|
|
5271
5388
|
{ arguments: [request] }
|
|
5272
5389
|
);
|
|
@@ -5274,7 +5391,7 @@ function wrapRerank2(rerank) {
|
|
|
5274
5391
|
function wrapCallModel2(callModel) {
|
|
5275
5392
|
return (request, options) => {
|
|
5276
5393
|
const tracedRequest = { ...request };
|
|
5277
|
-
return
|
|
5394
|
+
return _chunkBBE7SNRVjs.openRouterChannels.callModel.traceSync(
|
|
5278
5395
|
() => callModel(tracedRequest, options),
|
|
5279
5396
|
{
|
|
5280
5397
|
arguments: [tracedRequest]
|
|
@@ -5407,7 +5524,7 @@ function classifiersProxy(classifiers) {
|
|
|
5407
5524
|
});
|
|
5408
5525
|
}
|
|
5409
5526
|
function wrapChatComplete(complete) {
|
|
5410
|
-
return (request, options) =>
|
|
5527
|
+
return (request, options) => _chunkBBE7SNRVjs.mistralChannels.chatComplete.tracePromise(
|
|
5411
5528
|
() => complete(request, options),
|
|
5412
5529
|
{
|
|
5413
5530
|
arguments: [request]
|
|
@@ -5415,52 +5532,52 @@ function wrapChatComplete(complete) {
|
|
|
5415
5532
|
);
|
|
5416
5533
|
}
|
|
5417
5534
|
function wrapChatStream(stream) {
|
|
5418
|
-
return (request, options) =>
|
|
5535
|
+
return (request, options) => _chunkBBE7SNRVjs.mistralChannels.chatStream.tracePromise(() => stream(request, options), {
|
|
5419
5536
|
arguments: [request]
|
|
5420
5537
|
});
|
|
5421
5538
|
}
|
|
5422
5539
|
function wrapEmbeddingsCreate(create) {
|
|
5423
|
-
return (request, options) =>
|
|
5540
|
+
return (request, options) => _chunkBBE7SNRVjs.mistralChannels.embeddingsCreate.tracePromise(
|
|
5424
5541
|
() => create(request, options),
|
|
5425
5542
|
{ arguments: [request] }
|
|
5426
5543
|
);
|
|
5427
5544
|
}
|
|
5428
5545
|
function wrapClassifiersModerate(moderate) {
|
|
5429
|
-
return (request, options) =>
|
|
5546
|
+
return (request, options) => _chunkBBE7SNRVjs.mistralChannels.classifiersModerate.tracePromise(
|
|
5430
5547
|
() => moderate(request, options),
|
|
5431
5548
|
{ arguments: [request] }
|
|
5432
5549
|
);
|
|
5433
5550
|
}
|
|
5434
5551
|
function wrapClassifiersModerateChat(moderateChat) {
|
|
5435
|
-
return (request, options) =>
|
|
5552
|
+
return (request, options) => _chunkBBE7SNRVjs.mistralChannels.classifiersModerateChat.tracePromise(
|
|
5436
5553
|
() => moderateChat(request, options),
|
|
5437
5554
|
{ arguments: [request] }
|
|
5438
5555
|
);
|
|
5439
5556
|
}
|
|
5440
5557
|
function wrapClassifiersClassify(classify) {
|
|
5441
|
-
return (request, options) =>
|
|
5558
|
+
return (request, options) => _chunkBBE7SNRVjs.mistralChannels.classifiersClassify.tracePromise(
|
|
5442
5559
|
() => classify(request, options),
|
|
5443
5560
|
{ arguments: [request] }
|
|
5444
5561
|
);
|
|
5445
5562
|
}
|
|
5446
5563
|
function wrapClassifiersClassifyChat(classifyChat) {
|
|
5447
|
-
return (request, options) =>
|
|
5564
|
+
return (request, options) => _chunkBBE7SNRVjs.mistralChannels.classifiersClassifyChat.tracePromise(
|
|
5448
5565
|
() => classifyChat(request, options),
|
|
5449
5566
|
{ arguments: [request] }
|
|
5450
5567
|
);
|
|
5451
5568
|
}
|
|
5452
5569
|
function wrapFimComplete(complete) {
|
|
5453
|
-
return (request, options) =>
|
|
5570
|
+
return (request, options) => _chunkBBE7SNRVjs.mistralChannels.fimComplete.tracePromise(() => complete(request, options), {
|
|
5454
5571
|
arguments: [request]
|
|
5455
5572
|
});
|
|
5456
5573
|
}
|
|
5457
5574
|
function wrapFimStream(stream) {
|
|
5458
|
-
return (request, options) =>
|
|
5575
|
+
return (request, options) => _chunkBBE7SNRVjs.mistralChannels.fimStream.tracePromise(() => stream(request, options), {
|
|
5459
5576
|
arguments: [request]
|
|
5460
5577
|
});
|
|
5461
5578
|
}
|
|
5462
5579
|
function wrapAgentsComplete(complete) {
|
|
5463
|
-
return (request, options) =>
|
|
5580
|
+
return (request, options) => _chunkBBE7SNRVjs.mistralChannels.agentsComplete.tracePromise(
|
|
5464
5581
|
() => complete(request, options),
|
|
5465
5582
|
{
|
|
5466
5583
|
arguments: [request]
|
|
@@ -5468,7 +5585,84 @@ function wrapAgentsComplete(complete) {
|
|
|
5468
5585
|
);
|
|
5469
5586
|
}
|
|
5470
5587
|
function wrapAgentsStream(stream) {
|
|
5471
|
-
return (request, options) =>
|
|
5588
|
+
return (request, options) => _chunkBBE7SNRVjs.mistralChannels.agentsStream.tracePromise(() => stream(request, options), {
|
|
5589
|
+
arguments: [request]
|
|
5590
|
+
});
|
|
5591
|
+
}
|
|
5592
|
+
|
|
5593
|
+
// src/wrappers/ollama.ts
|
|
5594
|
+
function wrapOllama(ollama) {
|
|
5595
|
+
if (isSupportedOllamaClient(ollama)) {
|
|
5596
|
+
return ollamaProxy(ollama);
|
|
5597
|
+
}
|
|
5598
|
+
_chunkOBBWQW6Kjs.debugLogger.warn("Unsupported Ollama library. Not wrapping.");
|
|
5599
|
+
return ollama;
|
|
5600
|
+
}
|
|
5601
|
+
var ollamaProxyCache = /* @__PURE__ */ new WeakMap();
|
|
5602
|
+
function isSupportedOllamaClient(value) {
|
|
5603
|
+
return _chunkOBBWQW6Kjs.isObject.call(void 0, value) && ["chat", "generate", "embed"].some(
|
|
5604
|
+
(name) => typeof value[name] === "function"
|
|
5605
|
+
);
|
|
5606
|
+
}
|
|
5607
|
+
function ollamaProxy(ollama) {
|
|
5608
|
+
const cached = ollamaProxyCache.get(ollama);
|
|
5609
|
+
if (cached) {
|
|
5610
|
+
return cached;
|
|
5611
|
+
}
|
|
5612
|
+
let chatSource;
|
|
5613
|
+
let wrappedChat;
|
|
5614
|
+
let generateSource;
|
|
5615
|
+
let wrappedGenerate;
|
|
5616
|
+
let embedSource;
|
|
5617
|
+
let wrappedEmbed;
|
|
5618
|
+
const proxy = new Proxy(ollama, {
|
|
5619
|
+
get(target, prop, receiver) {
|
|
5620
|
+
switch (prop) {
|
|
5621
|
+
case "chat": {
|
|
5622
|
+
const source = target.chat;
|
|
5623
|
+
if (source !== chatSource) {
|
|
5624
|
+
chatSource = source;
|
|
5625
|
+
wrappedChat = typeof source === "function" ? wrapChat(source.bind(target)) : source;
|
|
5626
|
+
}
|
|
5627
|
+
return wrappedChat;
|
|
5628
|
+
}
|
|
5629
|
+
case "generate": {
|
|
5630
|
+
const source = target.generate;
|
|
5631
|
+
if (source !== generateSource) {
|
|
5632
|
+
generateSource = source;
|
|
5633
|
+
wrappedGenerate = typeof source === "function" ? wrapGenerate2(source.bind(target)) : source;
|
|
5634
|
+
}
|
|
5635
|
+
return wrappedGenerate;
|
|
5636
|
+
}
|
|
5637
|
+
case "embed": {
|
|
5638
|
+
const source = target.embed;
|
|
5639
|
+
if (source !== embedSource) {
|
|
5640
|
+
embedSource = source;
|
|
5641
|
+
wrappedEmbed = typeof source === "function" ? wrapEmbed3(source.bind(target)) : source;
|
|
5642
|
+
}
|
|
5643
|
+
return wrappedEmbed;
|
|
5644
|
+
}
|
|
5645
|
+
default:
|
|
5646
|
+
return Reflect.get(target, prop, receiver);
|
|
5647
|
+
}
|
|
5648
|
+
}
|
|
5649
|
+
});
|
|
5650
|
+
ollamaProxyCache.set(ollama, proxy);
|
|
5651
|
+
ollamaProxyCache.set(proxy, proxy);
|
|
5652
|
+
return proxy;
|
|
5653
|
+
}
|
|
5654
|
+
function wrapChat(chat) {
|
|
5655
|
+
return (request) => _chunkBBE7SNRVjs.ollamaChannels.chat.tracePromise(() => chat(request), {
|
|
5656
|
+
arguments: [request]
|
|
5657
|
+
});
|
|
5658
|
+
}
|
|
5659
|
+
function wrapGenerate2(generate) {
|
|
5660
|
+
return (request) => _chunkBBE7SNRVjs.ollamaChannels.generate.tracePromise(() => generate(request), {
|
|
5661
|
+
arguments: [request]
|
|
5662
|
+
});
|
|
5663
|
+
}
|
|
5664
|
+
function wrapEmbed3(embed) {
|
|
5665
|
+
return (request) => _chunkBBE7SNRVjs.ollamaChannels.embed.tracePromise(() => embed(request), {
|
|
5472
5666
|
arguments: [request]
|
|
5473
5667
|
});
|
|
5474
5668
|
}
|
|
@@ -5503,11 +5697,11 @@ function cohereProxy(cohere) {
|
|
|
5503
5697
|
get(target, prop, receiver) {
|
|
5504
5698
|
switch (prop) {
|
|
5505
5699
|
case "chat":
|
|
5506
|
-
return typeof target.chat === "function" ?
|
|
5700
|
+
return typeof target.chat === "function" ? wrapChat2(target.chat.bind(target)) : target.chat;
|
|
5507
5701
|
case "chatStream":
|
|
5508
5702
|
return typeof target.chatStream === "function" ? wrapChatStream2(target.chatStream.bind(target)) : target.chatStream;
|
|
5509
5703
|
case "embed":
|
|
5510
|
-
return typeof target.embed === "function" ?
|
|
5704
|
+
return typeof target.embed === "function" ? wrapEmbed4(target.embed.bind(target)) : target.embed;
|
|
5511
5705
|
case "rerank":
|
|
5512
5706
|
return typeof target.rerank === "function" ? wrapRerank3(target.rerank.bind(target)) : target.rerank;
|
|
5513
5707
|
default: {
|
|
@@ -5520,27 +5714,105 @@ function cohereProxy(cohere) {
|
|
|
5520
5714
|
cohereProxyCache.set(cohere, proxy);
|
|
5521
5715
|
return proxy;
|
|
5522
5716
|
}
|
|
5523
|
-
function
|
|
5524
|
-
return (request, options) =>
|
|
5717
|
+
function wrapChat2(chat) {
|
|
5718
|
+
return (request, options) => _chunkBBE7SNRVjs.cohereChannels.chat.tracePromise(() => chat(request, options), {
|
|
5525
5719
|
arguments: [request]
|
|
5526
5720
|
});
|
|
5527
5721
|
}
|
|
5528
5722
|
function wrapChatStream2(chatStream) {
|
|
5529
|
-
return (request, options) =>
|
|
5723
|
+
return (request, options) => _chunkBBE7SNRVjs.cohereChannels.chatStream.tracePromise(() => chatStream(request, options), {
|
|
5530
5724
|
arguments: [request]
|
|
5531
5725
|
});
|
|
5532
5726
|
}
|
|
5533
|
-
function
|
|
5534
|
-
return (request, options) =>
|
|
5727
|
+
function wrapEmbed4(embed) {
|
|
5728
|
+
return (request, options) => _chunkBBE7SNRVjs.cohereChannels.embed.tracePromise(() => embed(request, options), {
|
|
5535
5729
|
arguments: [request]
|
|
5536
5730
|
});
|
|
5537
5731
|
}
|
|
5538
5732
|
function wrapRerank3(rerank) {
|
|
5539
|
-
return (request, options) =>
|
|
5733
|
+
return (request, options) => _chunkBBE7SNRVjs.cohereChannels.rerank.tracePromise(() => rerank(request, options), {
|
|
5540
5734
|
arguments: [request]
|
|
5541
5735
|
});
|
|
5542
5736
|
}
|
|
5543
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
|
+
|
|
5544
5816
|
// src/wrappers/groq.ts
|
|
5545
5817
|
function wrapGroq(groq) {
|
|
5546
5818
|
if (isSupportedGroqClient(groq)) {
|
|
@@ -5552,14 +5824,14 @@ function wrapGroq(groq) {
|
|
|
5552
5824
|
function isRecord4(value) {
|
|
5553
5825
|
return typeof value === "object" && value !== null;
|
|
5554
5826
|
}
|
|
5555
|
-
function
|
|
5827
|
+
function hasFunction6(value, methodName) {
|
|
5556
5828
|
return isRecord4(value) && methodName in value && typeof value[methodName] === "function";
|
|
5557
5829
|
}
|
|
5558
5830
|
function hasChat2(value) {
|
|
5559
|
-
return isRecord4(value) && isRecord4(value.completions) &&
|
|
5831
|
+
return isRecord4(value) && isRecord4(value.completions) && hasFunction6(value.completions, "create");
|
|
5560
5832
|
}
|
|
5561
5833
|
function hasEmbeddings2(value) {
|
|
5562
|
-
return
|
|
5834
|
+
return hasFunction6(value, "create");
|
|
5563
5835
|
}
|
|
5564
5836
|
function isSupportedGroqClient(value) {
|
|
5565
5837
|
return isRecord4(value) && (value.chat !== void 0 && hasChat2(value.chat) || value.embeddings !== void 0 && hasEmbeddings2(value.embeddings));
|
|
@@ -5618,13 +5890,13 @@ function groqProxy(groq) {
|
|
|
5618
5890
|
return topLevelProxy;
|
|
5619
5891
|
}
|
|
5620
5892
|
function wrapChatCompletionsCreate(create) {
|
|
5621
|
-
return (request, options) =>
|
|
5893
|
+
return (request, options) => _chunkBBE7SNRVjs.groqChannels.chatCompletionsCreate.tracePromise(
|
|
5622
5894
|
() => create(request, options),
|
|
5623
5895
|
{ arguments: [request] }
|
|
5624
5896
|
);
|
|
5625
5897
|
}
|
|
5626
5898
|
function wrapEmbeddingsCreate2(create) {
|
|
5627
|
-
return (request, options) =>
|
|
5899
|
+
return (request, options) => _chunkBBE7SNRVjs.groqChannels.embeddingsCreate.tracePromise(() => create(request, options), {
|
|
5628
5900
|
arguments: [request]
|
|
5629
5901
|
});
|
|
5630
5902
|
}
|
|
@@ -5698,16 +5970,16 @@ function bedrockRuntimeProxy(client) {
|
|
|
5698
5970
|
}
|
|
5699
5971
|
function wrapSend(send) {
|
|
5700
5972
|
return (command, optionsOrCb, cb) => {
|
|
5701
|
-
if (
|
|
5973
|
+
if (_chunkOBBWQW6Kjs.getBedrockRuntimeOperation.call(void 0, command) === void 0 || typeof optionsOrCb === "function" || typeof cb === "function") {
|
|
5702
5974
|
return send(command, optionsOrCb, cb);
|
|
5703
5975
|
}
|
|
5704
|
-
return
|
|
5705
|
-
() =>
|
|
5976
|
+
return _chunkBBE7SNRVjs.bedrockRuntimeChannels.clientSend.tracePromise(
|
|
5977
|
+
() => _chunkOBBWQW6Kjs.runWithAutoInstrumentationSuppressed.call(void 0,
|
|
5706
5978
|
() => send(command, optionsOrCb)
|
|
5707
5979
|
),
|
|
5708
5980
|
{
|
|
5709
5981
|
arguments: [command, optionsOrCb],
|
|
5710
|
-
span_info:
|
|
5982
|
+
span_info: _chunkOBBWQW6Kjs.buildBedrockRuntimeSpanInfo.call(void 0, command)
|
|
5711
5983
|
}
|
|
5712
5984
|
);
|
|
5713
5985
|
};
|
|
@@ -5756,13 +6028,13 @@ function copilotClientProxy(client) {
|
|
|
5756
6028
|
return proxy;
|
|
5757
6029
|
}
|
|
5758
6030
|
function wrappedCreateSession(client) {
|
|
5759
|
-
return (config) =>
|
|
6031
|
+
return (config) => _chunkBBE7SNRVjs.gitHubCopilotChannels.createSession.tracePromise(
|
|
5760
6032
|
() => client.createSession(config),
|
|
5761
6033
|
{ arguments: [config] }
|
|
5762
6034
|
);
|
|
5763
6035
|
}
|
|
5764
6036
|
function wrappedResumeSession(client) {
|
|
5765
|
-
return (sessionId, config) =>
|
|
6037
|
+
return (sessionId, config) => _chunkBBE7SNRVjs.gitHubCopilotChannels.resumeSession.tracePromise(
|
|
5766
6038
|
() => client.resumeSession(sessionId, config),
|
|
5767
6039
|
{ arguments: [sessionId, config] }
|
|
5768
6040
|
);
|
|
@@ -5940,13 +6212,13 @@ function wrapRunTreeInstance(runTree) {
|
|
|
5940
6212
|
wrapped = (...args) => wrapRunTreeInstance(Reflect.apply(value, target, args));
|
|
5941
6213
|
} else if (prop === "postRun") {
|
|
5942
6214
|
const method = value;
|
|
5943
|
-
wrapped = (...args) =>
|
|
6215
|
+
wrapped = (...args) => _chunkBBE7SNRVjs.langSmithChannels.createRun.tracePromise(
|
|
5944
6216
|
() => Reflect.apply(method, target, args),
|
|
5945
6217
|
{ arguments: [target] }
|
|
5946
6218
|
);
|
|
5947
6219
|
} else if (prop === "patchRun") {
|
|
5948
6220
|
const method = value;
|
|
5949
|
-
wrapped = (...args) =>
|
|
6221
|
+
wrapped = (...args) => _chunkBBE7SNRVjs.langSmithChannels.updateRun.tracePromise(
|
|
5950
6222
|
() => Reflect.apply(method, target, args),
|
|
5951
6223
|
{
|
|
5952
6224
|
arguments: [
|
|
@@ -5995,19 +6267,19 @@ function wrapClientInstance(client) {
|
|
|
5995
6267
|
let wrapped;
|
|
5996
6268
|
if (prop === "createRun") {
|
|
5997
6269
|
const method = value;
|
|
5998
|
-
wrapped = (...args) =>
|
|
6270
|
+
wrapped = (...args) => _chunkBBE7SNRVjs.langSmithChannels.createRun.tracePromise(
|
|
5999
6271
|
() => Reflect.apply(method, target, args),
|
|
6000
6272
|
{ arguments: args }
|
|
6001
6273
|
);
|
|
6002
6274
|
} else if (prop === "updateRun") {
|
|
6003
6275
|
const method = value;
|
|
6004
|
-
wrapped = (...args) =>
|
|
6276
|
+
wrapped = (...args) => _chunkBBE7SNRVjs.langSmithChannels.updateRun.tracePromise(
|
|
6005
6277
|
() => Reflect.apply(method, target, args),
|
|
6006
6278
|
{ arguments: args }
|
|
6007
6279
|
);
|
|
6008
6280
|
} else if (prop === "batchIngestRuns") {
|
|
6009
6281
|
const method = value;
|
|
6010
|
-
wrapped = (...args) =>
|
|
6282
|
+
wrapped = (...args) => _chunkBBE7SNRVjs.langSmithChannels.batchIngestRuns.tracePromise(
|
|
6011
6283
|
() => Reflect.apply(method, target, args),
|
|
6012
6284
|
{ arguments: args }
|
|
6013
6285
|
);
|
|
@@ -6023,13 +6295,13 @@ function publishRunUpdate(runTree) {
|
|
|
6023
6295
|
return;
|
|
6024
6296
|
}
|
|
6025
6297
|
try {
|
|
6026
|
-
void
|
|
6298
|
+
void _chunkBBE7SNRVjs.langSmithChannels.updateRun.tracePromise(() => Promise.resolve(void 0), {
|
|
6027
6299
|
arguments: [runTree.id, runTree]
|
|
6028
6300
|
}).catch((error) => {
|
|
6029
|
-
|
|
6301
|
+
_chunkOBBWQW6Kjs.debugLogger.error("LangSmith traceable instrumentation failed:", error);
|
|
6030
6302
|
});
|
|
6031
6303
|
} catch (error) {
|
|
6032
|
-
|
|
6304
|
+
_chunkOBBWQW6Kjs.debugLogger.error("LangSmith traceable instrumentation failed:", error);
|
|
6033
6305
|
}
|
|
6034
6306
|
}
|
|
6035
6307
|
|
|
@@ -6041,7 +6313,7 @@ var VitestContextManager = class {
|
|
|
6041
6313
|
*/
|
|
6042
6314
|
|
|
6043
6315
|
constructor() {
|
|
6044
|
-
this.contextStorage =
|
|
6316
|
+
this.contextStorage = _chunkBBE7SNRVjs.isomorph_default.newAsyncLocalStorage();
|
|
6045
6317
|
}
|
|
6046
6318
|
getCurrentContext() {
|
|
6047
6319
|
return this.contextStorage.getStore();
|
|
@@ -6082,7 +6354,7 @@ var FlushCoordinator = (_class2 = class {constructor() { _class2.prototype.__ini
|
|
|
6082
6354
|
if (this.activeFlushes.has(experimentId)) {
|
|
6083
6355
|
return this.activeFlushes.get(experimentId);
|
|
6084
6356
|
}
|
|
6085
|
-
const flushPromise =
|
|
6357
|
+
const flushPromise = _chunkOBBWQW6Kjs.summarizeAndFlush.call(void 0, context.experiment, {
|
|
6086
6358
|
displaySummary: config.displaySummary
|
|
6087
6359
|
});
|
|
6088
6360
|
this.activeFlushes.set(experimentId, flushPromise);
|
|
@@ -6101,7 +6373,7 @@ async function flushExperimentWithSync(context, config) {
|
|
|
6101
6373
|
// src/wrappers/shared/scorers.ts
|
|
6102
6374
|
async function runScorers(args) {
|
|
6103
6375
|
const { scorers, output, expected, input, metadata, span } = args;
|
|
6104
|
-
const
|
|
6376
|
+
const scorerArgs2 = {
|
|
6105
6377
|
output,
|
|
6106
6378
|
expected,
|
|
6107
6379
|
input,
|
|
@@ -6110,7 +6382,7 @@ async function runScorers(args) {
|
|
|
6110
6382
|
await Promise.all(
|
|
6111
6383
|
scorers.map(async (scorer) => {
|
|
6112
6384
|
try {
|
|
6113
|
-
const result = await scorer(
|
|
6385
|
+
const result = await scorer(scorerArgs2);
|
|
6114
6386
|
const scores = normalizeScores(result);
|
|
6115
6387
|
if (scores.length > 0) {
|
|
6116
6388
|
const accScores = {};
|
|
@@ -6180,7 +6452,7 @@ async function runTracedEval(args) {
|
|
|
6180
6452
|
}
|
|
6181
6453
|
if (testError) {
|
|
6182
6454
|
span.log({ scores: { pass: 0 } });
|
|
6183
|
-
|
|
6455
|
+
_chunkOBBWQW6Kjs.logError.call(void 0, span, testError);
|
|
6184
6456
|
throw testError;
|
|
6185
6457
|
}
|
|
6186
6458
|
span.log({
|
|
@@ -6354,10 +6626,10 @@ function wrapDescribe(originalDescribe, config, afterAll) {
|
|
|
6354
6626
|
const getOrCreateContext = () => {
|
|
6355
6627
|
if (!context) {
|
|
6356
6628
|
const experimentName = `${suiteName}-${(/* @__PURE__ */ new Date()).toISOString()}`;
|
|
6357
|
-
const experiment = config.projectId ?
|
|
6629
|
+
const experiment = config.projectId ? _chunkOBBWQW6Kjs.initExperiment.call(void 0, {
|
|
6358
6630
|
projectId: config.projectId,
|
|
6359
6631
|
experiment: experimentName
|
|
6360
|
-
}) :
|
|
6632
|
+
}) : _chunkOBBWQW6Kjs.initExperiment.call(void 0, config.projectName || suiteName, {
|
|
6361
6633
|
experiment: experimentName
|
|
6362
6634
|
});
|
|
6363
6635
|
context = contextManager.createChildContext(void 0, experiment);
|
|
@@ -6465,7 +6737,7 @@ function wrapExpect(originalExpect) {
|
|
|
6465
6737
|
return originalExpect(value);
|
|
6466
6738
|
}
|
|
6467
6739
|
const assertion = originalExpect(value, message);
|
|
6468
|
-
const span =
|
|
6740
|
+
const span = _chunkOBBWQW6Kjs.currentSpan.call(void 0, );
|
|
6469
6741
|
if (!span) {
|
|
6470
6742
|
return assertion;
|
|
6471
6743
|
}
|
|
@@ -6477,16 +6749,16 @@ function wrapExpect(originalExpect) {
|
|
|
6477
6749
|
|
|
6478
6750
|
// src/wrappers/shared/logging.ts
|
|
6479
6751
|
function logOutputs(outputs) {
|
|
6480
|
-
|
|
6752
|
+
_chunkOBBWQW6Kjs.currentSpan.call(void 0, ).log({ output: outputs });
|
|
6481
6753
|
}
|
|
6482
6754
|
function logFeedback(feedback) {
|
|
6483
|
-
|
|
6755
|
+
_chunkOBBWQW6Kjs.currentSpan.call(void 0, ).log({
|
|
6484
6756
|
scores: { [feedback.name]: feedback.score },
|
|
6485
6757
|
metadata: feedback.metadata
|
|
6486
6758
|
});
|
|
6487
6759
|
}
|
|
6488
6760
|
function getCurrentSpan() {
|
|
6489
|
-
return
|
|
6761
|
+
return _chunkOBBWQW6Kjs.currentSpan.call(void 0, );
|
|
6490
6762
|
}
|
|
6491
6763
|
|
|
6492
6764
|
// src/wrappers/vitest/index.ts
|
|
@@ -6534,7 +6806,7 @@ function wrapVitest(vitestMethods, config = {}) {
|
|
|
6534
6806
|
);
|
|
6535
6807
|
return;
|
|
6536
6808
|
}
|
|
6537
|
-
await
|
|
6809
|
+
await _chunkOBBWQW6Kjs.summarizeAndFlush.call(void 0, ctx.experiment, {
|
|
6538
6810
|
displaySummary: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _139 => _139.displaySummary]), () => ( config.displaySummary))
|
|
6539
6811
|
});
|
|
6540
6812
|
}
|
|
@@ -6549,7 +6821,7 @@ function initNodeTestSuite(config) {
|
|
|
6549
6821
|
return experiment;
|
|
6550
6822
|
}
|
|
6551
6823
|
const experimentName = config.experimentName || `${config.projectName}-${(/* @__PURE__ */ new Date()).toISOString()}`;
|
|
6552
|
-
experiment =
|
|
6824
|
+
experiment = _chunkOBBWQW6Kjs.initExperiment.call(void 0, config.projectName, {
|
|
6553
6825
|
experiment: experimentName
|
|
6554
6826
|
});
|
|
6555
6827
|
return experiment;
|
|
@@ -6598,7 +6870,7 @@ function initNodeTestSuite(config) {
|
|
|
6598
6870
|
if (!experiment) {
|
|
6599
6871
|
return;
|
|
6600
6872
|
}
|
|
6601
|
-
await
|
|
6873
|
+
await _chunkOBBWQW6Kjs.summarizeAndFlush.call(void 0, experiment, {
|
|
6602
6874
|
displaySummary: config.displaySummary
|
|
6603
6875
|
});
|
|
6604
6876
|
experiment = void 0;
|
|
@@ -6615,7 +6887,7 @@ function initNodeTestSuite(config) {
|
|
|
6615
6887
|
|
|
6616
6888
|
// src/graph-framework.ts
|
|
6617
6889
|
var graph_framework_exports = {};
|
|
6618
|
-
|
|
6890
|
+
_chunkBBE7SNRVjs.__export.call(void 0, graph_framework_exports, {
|
|
6619
6891
|
AggregatorNode: () => AggregatorNode,
|
|
6620
6892
|
GateNode: () => GateNode,
|
|
6621
6893
|
GraphBuilder: () => GraphBuilder,
|
|
@@ -6689,7 +6961,7 @@ var GraphBuilder = (_class3 = class {
|
|
|
6689
6961
|
};
|
|
6690
6962
|
}
|
|
6691
6963
|
resolveNode(node) {
|
|
6692
|
-
if (node instanceof
|
|
6964
|
+
if (node instanceof _chunkOBBWQW6Kjs.Prompt) {
|
|
6693
6965
|
const cached = this.nodeLikeNodes.get(node);
|
|
6694
6966
|
if (cached) {
|
|
6695
6967
|
return [cached, []];
|
|
@@ -6739,7 +7011,7 @@ var GraphBuilder = (_class3 = class {
|
|
|
6739
7011
|
// }
|
|
6740
7012
|
// Helper to generate node IDs
|
|
6741
7013
|
generateId(name) {
|
|
6742
|
-
const uuid =
|
|
7014
|
+
const uuid = _chunkOBBWQW6Kjs.newId.call(void 0, );
|
|
6743
7015
|
if (name) {
|
|
6744
7016
|
return `${name}-${uuid.slice(0, 8)}`;
|
|
6745
7017
|
} else {
|
|
@@ -7939,7 +8211,7 @@ function waterfall(tasks, callback) {
|
|
|
7939
8211
|
var waterfall$1 = awaitify(waterfall);
|
|
7940
8212
|
|
|
7941
8213
|
// src/trace.ts
|
|
7942
|
-
var SpanFetcher = class _SpanFetcher extends
|
|
8214
|
+
var SpanFetcher = class _SpanFetcher extends _chunkOBBWQW6Kjs.ObjectFetcher {
|
|
7943
8215
|
constructor(objectType, _objectId, rootSpanId, _state, spanTypeFilter, includeScorers = false, brainstoreRealtime = true) {
|
|
7944
8216
|
const filterExpr = _SpanFetcher.buildFilter(
|
|
7945
8217
|
rootSpanId,
|
|
@@ -8256,20 +8528,20 @@ var promptContentsSchema = _v3.z.union([
|
|
|
8256
8528
|
prompt: _v3.z.string()
|
|
8257
8529
|
}),
|
|
8258
8530
|
_v3.z.object({
|
|
8259
|
-
messages: _v3.z.array(
|
|
8531
|
+
messages: _v3.z.array(_chunkOBBWQW6Kjs.ChatCompletionMessageParam)
|
|
8260
8532
|
})
|
|
8261
8533
|
]);
|
|
8262
8534
|
var promptDefinitionSchema = promptContentsSchema.and(
|
|
8263
8535
|
_v3.z.object({
|
|
8264
8536
|
model: _v3.z.string(),
|
|
8265
|
-
params:
|
|
8537
|
+
params: _chunkOBBWQW6Kjs.ModelParams.optional(),
|
|
8266
8538
|
templateFormat: _v3.z.enum(["mustache", "nunjucks", "none"]).optional(),
|
|
8267
8539
|
environments: _v3.z.array(_v3.z.string()).optional()
|
|
8268
8540
|
})
|
|
8269
8541
|
);
|
|
8270
8542
|
var promptDefinitionWithToolsSchema = promptDefinitionSchema.and(
|
|
8271
8543
|
_v3.z.object({
|
|
8272
|
-
tools: _v3.z.array(
|
|
8544
|
+
tools: _v3.z.array(_chunkOBBWQW6Kjs.ToolFunctionDefinition).optional()
|
|
8273
8545
|
})
|
|
8274
8546
|
);
|
|
8275
8547
|
function promptDefinitionToPromptData(promptDefinition, rawTools) {
|
|
@@ -8317,7 +8589,7 @@ async function validateParameters(parameters, parameterSchema) {
|
|
|
8317
8589
|
if (resolvedSchema === void 0 || resolvedSchema === null) {
|
|
8318
8590
|
return parameters;
|
|
8319
8591
|
}
|
|
8320
|
-
if (
|
|
8592
|
+
if (_chunkOBBWQW6Kjs.RemoteEvalParameters.isParameters(resolvedSchema)) {
|
|
8321
8593
|
const mergedParameters = parameters && Object.keys(parameters).length > 0 ? {
|
|
8322
8594
|
...resolvedSchema.data,
|
|
8323
8595
|
...parameters
|
|
@@ -8339,14 +8611,14 @@ function validateParametersWithZod(parameters, parameterSchema) {
|
|
|
8339
8611
|
const value = parameters[name];
|
|
8340
8612
|
try {
|
|
8341
8613
|
if ("type" in schema && schema.type === "prompt") {
|
|
8342
|
-
const promptData = value ?
|
|
8614
|
+
const promptData = value ? _chunkOBBWQW6Kjs.PromptData.parse(value) : schema.default ? promptDefinitionToPromptData(
|
|
8343
8615
|
schema.default,
|
|
8344
8616
|
schema.default.tools
|
|
8345
8617
|
) : void 0;
|
|
8346
8618
|
if (!promptData) {
|
|
8347
8619
|
throw new Error(`Parameter '${name}' is required`);
|
|
8348
8620
|
}
|
|
8349
|
-
return [name,
|
|
8621
|
+
return [name, _chunkOBBWQW6Kjs.Prompt.fromPromptData(name, promptData)];
|
|
8350
8622
|
} else if ("type" in schema && schema.type === "model") {
|
|
8351
8623
|
const model = _nullishCoalesce(value, () => ( schema.default));
|
|
8352
8624
|
if (model === void 0) {
|
|
@@ -8397,7 +8669,7 @@ function rehydrateRemoteParameters(parameters, schema) {
|
|
|
8397
8669
|
if (Reflect.get(propertySchema, "x-bt-type") === "prompt") {
|
|
8398
8670
|
return [
|
|
8399
8671
|
name,
|
|
8400
|
-
|
|
8672
|
+
_chunkOBBWQW6Kjs.Prompt.fromPromptData(name, _chunkOBBWQW6Kjs.PromptData.parse(value))
|
|
8401
8673
|
];
|
|
8402
8674
|
}
|
|
8403
8675
|
return [name, value];
|
|
@@ -8447,7 +8719,7 @@ function makeEvalName(projectName, experimentName) {
|
|
|
8447
8719
|
return out;
|
|
8448
8720
|
}
|
|
8449
8721
|
function initExperiment2(state, options = {}) {
|
|
8450
|
-
return
|
|
8722
|
+
return _chunkOBBWQW6Kjs.init.call(void 0, {
|
|
8451
8723
|
state,
|
|
8452
8724
|
...options,
|
|
8453
8725
|
setCurrent: false
|
|
@@ -8458,7 +8730,7 @@ async function getExperimentParametersRef(parameters) {
|
|
|
8458
8730
|
return void 0;
|
|
8459
8731
|
}
|
|
8460
8732
|
const resolvedParameters = parameters instanceof Promise ? await parameters : parameters;
|
|
8461
|
-
if (!
|
|
8733
|
+
if (!_chunkOBBWQW6Kjs.RemoteEvalParameters.isParameters(resolvedParameters)) {
|
|
8462
8734
|
return void 0;
|
|
8463
8735
|
}
|
|
8464
8736
|
if (resolvedParameters.id === void 0) {
|
|
@@ -8469,6 +8741,26 @@ async function getExperimentParametersRef(parameters) {
|
|
|
8469
8741
|
version: resolvedParameters.version
|
|
8470
8742
|
};
|
|
8471
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
|
+
}
|
|
8472
8764
|
function callEvaluatorData(data) {
|
|
8473
8765
|
const dataResult = typeof data === "function" ? data() : data;
|
|
8474
8766
|
let baseExperiment = void 0;
|
|
@@ -8486,6 +8778,48 @@ function isAsyncIterable2(value) {
|
|
|
8486
8778
|
function isIterable(value) {
|
|
8487
8779
|
return typeof value === "object" && value !== null && Symbol.iterator in value && typeof value[Symbol.iterator] === "function";
|
|
8488
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
|
+
}
|
|
8489
8823
|
globalThis._evals = {
|
|
8490
8824
|
functions: [],
|
|
8491
8825
|
prompts: [],
|
|
@@ -8494,10 +8828,10 @@ globalThis._evals = {
|
|
|
8494
8828
|
reporters: {}
|
|
8495
8829
|
};
|
|
8496
8830
|
function _initializeSpanContext() {
|
|
8497
|
-
globalThis._spanContext = { currentSpan:
|
|
8831
|
+
globalThis._spanContext = { currentSpan: _chunkOBBWQW6Kjs.currentSpan, withCurrent: _chunkOBBWQW6Kjs.withCurrent, startSpan: _chunkOBBWQW6Kjs.startSpan, NOOP_SPAN: _chunkOBBWQW6Kjs.NOOP_SPAN };
|
|
8498
8832
|
}
|
|
8499
8833
|
async function Eval(name, evaluator, reporterOrOpts) {
|
|
8500
|
-
const options =
|
|
8834
|
+
const options = _chunkOBBWQW6Kjs.isEmpty.call(void 0, reporterOrOpts) ? {} : typeof reporterOrOpts === "string" ? { reporter: reporterOrOpts } : "name" in reporterOrOpts ? { reporter: reporterOrOpts } : reporterOrOpts;
|
|
8501
8835
|
let evalName = makeEvalName(name, evaluator.experimentName);
|
|
8502
8836
|
if (globalThis._evals.evaluators[evalName]) {
|
|
8503
8837
|
evalName = `${evalName}_${Object.keys(_evals).length}`;
|
|
@@ -8532,25 +8866,13 @@ async function Eval(name, evaluator, reporterOrOpts) {
|
|
|
8532
8866
|
}
|
|
8533
8867
|
const resolvedReporter = options.reporter || defaultReporter;
|
|
8534
8868
|
try {
|
|
8535
|
-
const { data
|
|
8536
|
-
|
|
8869
|
+
const { data } = callEvaluatorData(evaluator.data);
|
|
8870
|
+
const experiment = await _internalInitEvaluatorExperiment(
|
|
8871
|
+
name,
|
|
8872
|
+
evaluator,
|
|
8873
|
+
data,
|
|
8874
|
+
{ disabled: Boolean(options.parent || options.noSendLogs) }
|
|
8537
8875
|
);
|
|
8538
|
-
const parameters = await getExperimentParametersRef(evaluator.parameters);
|
|
8539
|
-
const experiment = options.parent || options.noSendLogs ? null : initExperiment2(evaluator.state, {
|
|
8540
|
-
...evaluator.projectId ? { projectId: evaluator.projectId } : { project: name },
|
|
8541
|
-
experiment: evaluator.experimentName,
|
|
8542
|
-
description: evaluator.description,
|
|
8543
|
-
metadata: evaluator.metadata,
|
|
8544
|
-
tags: evaluator.tags,
|
|
8545
|
-
isPublic: evaluator.isPublic,
|
|
8546
|
-
update: evaluator.update,
|
|
8547
|
-
baseExperiment: _nullishCoalesce(evaluator.baseExperimentName, () => ( defaultBaseExperiment)),
|
|
8548
|
-
baseExperimentId: evaluator.baseExperimentId,
|
|
8549
|
-
gitMetadataSettings: evaluator.gitMetadataSettings,
|
|
8550
|
-
repoInfo: evaluator.repoInfo,
|
|
8551
|
-
dataset: _chunkVRZZQPAAjs.Dataset.isDataset(data) ? data : void 0,
|
|
8552
|
-
parameters
|
|
8553
|
-
});
|
|
8554
8876
|
if (experiment && typeof process !== "undefined" && globalThis.BRAINTRUST_CONTEXT_MANAGER !== void 0) {
|
|
8555
8877
|
await experiment._waitForId();
|
|
8556
8878
|
}
|
|
@@ -8568,7 +8890,7 @@ async function Eval(name, evaluator, reporterOrOpts) {
|
|
|
8568
8890
|
const enableCache = _nullishCoalesce(options.enableCache, () => ( true));
|
|
8569
8891
|
let ret;
|
|
8570
8892
|
if (options.parent) {
|
|
8571
|
-
ret = await
|
|
8893
|
+
ret = await _chunkOBBWQW6Kjs.withParent.call(void 0,
|
|
8572
8894
|
options.parent,
|
|
8573
8895
|
() => runEvaluator(
|
|
8574
8896
|
null,
|
|
@@ -8604,7 +8926,7 @@ async function Eval(name, evaluator, reporterOrOpts) {
|
|
|
8604
8926
|
if (experiment) {
|
|
8605
8927
|
await experiment.flush().catch(console.error);
|
|
8606
8928
|
} else if (options.parent) {
|
|
8607
|
-
await
|
|
8929
|
+
await _chunkOBBWQW6Kjs.flush.call(void 0, { state: evaluator.state }).catch(console.error);
|
|
8608
8930
|
}
|
|
8609
8931
|
}
|
|
8610
8932
|
} finally {
|
|
@@ -8648,19 +8970,74 @@ function scorerName(scorer, scorer_idx) {
|
|
|
8648
8970
|
function classifierName(classifier, classifier_idx) {
|
|
8649
8971
|
return classifier.name || `classifier_${classifier_idx}`;
|
|
8650
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
|
+
}
|
|
8651
8997
|
function buildSpanMetadata(results) {
|
|
8652
|
-
return results.length === 1 ? results[0].metadata :
|
|
8653
|
-
(
|
|
8654
|
-
{}
|
|
8998
|
+
return results.length === 1 ? results[0].metadata : Object.fromEntries(
|
|
8999
|
+
results.map((result) => [result.name, result.metadata])
|
|
8655
9000
|
);
|
|
8656
9001
|
}
|
|
8657
9002
|
function buildSpanScores(results) {
|
|
8658
|
-
const scoresRecord =
|
|
8659
|
-
(
|
|
8660
|
-
{}
|
|
9003
|
+
const scoresRecord = Object.fromEntries(
|
|
9004
|
+
results.map((result) => [result.name, result.score])
|
|
8661
9005
|
);
|
|
8662
9006
|
return { resultMetadata: buildSpanMetadata(results), scoresRecord };
|
|
8663
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
|
+
}
|
|
8664
9041
|
async function runInScorerSpan(rootSpan, spanName, spanType, propagatedEvent, eventInput, fn) {
|
|
8665
9042
|
try {
|
|
8666
9043
|
const value = await rootSpan.traced(fn, {
|
|
@@ -8686,7 +9063,7 @@ function collectScoringResults(runResults, names, onResult) {
|
|
|
8686
9063
|
return failing;
|
|
8687
9064
|
}
|
|
8688
9065
|
function validateClassificationResult(value, scorerName2) {
|
|
8689
|
-
if (!(typeof value === "object" && value !== null && !
|
|
9066
|
+
if (!(typeof value === "object" && value !== null && !_chunkOBBWQW6Kjs.isEmpty.call(void 0, value))) {
|
|
8690
9067
|
throw new Error(
|
|
8691
9068
|
`When returning structured classifier results, each classification must be a non-empty object. Got: ${JSON.stringify(value)}`
|
|
8692
9069
|
);
|
|
@@ -8705,6 +9082,27 @@ function toClassificationItem(c) {
|
|
|
8705
9082
|
...c.metadata !== void 0 ? { metadata: c.metadata } : {}
|
|
8706
9083
|
};
|
|
8707
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
|
+
}
|
|
8708
9106
|
function logScoringFailures(kind, failures, metadata, rootSpan, state) {
|
|
8709
9107
|
if (!failures.length) return [];
|
|
8710
9108
|
const errorMap = Object.fromEntries(
|
|
@@ -8715,7 +9113,7 @@ function logScoringFailures(kind, failures, metadata, rootSpan, state) {
|
|
|
8715
9113
|
);
|
|
8716
9114
|
metadata[`${kind}_errors`] = errorMap;
|
|
8717
9115
|
rootSpan.log({ metadata: { [`${kind}_errors`]: errorMap } });
|
|
8718
|
-
|
|
9116
|
+
_chunkOBBWQW6Kjs.debugLogger.forState(state).warn(
|
|
8719
9117
|
`Found exceptions for the following ${kind}s: ${Object.keys(errorMap).join(", ")}`,
|
|
8720
9118
|
failures.map((f) => f.error)
|
|
8721
9119
|
);
|
|
@@ -8749,57 +9147,17 @@ var defaultErrorScoreHandler = ({
|
|
|
8749
9147
|
};
|
|
8750
9148
|
async function runEvaluatorInternal(experiment, evaluator, progressReporter, filters, stream, parameters, collectResults, enableCache) {
|
|
8751
9149
|
if (enableCache) {
|
|
8752
|
-
_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()]);
|
|
8753
9151
|
}
|
|
8754
9152
|
try {
|
|
8755
|
-
if (typeof evaluator.data === "string") {
|
|
8756
|
-
throw new Error("Unimplemented: string data paths");
|
|
8757
|
-
}
|
|
8758
|
-
let dataResult = typeof evaluator.data === "function" ? evaluator.data() : evaluator.data;
|
|
8759
9153
|
parameters = await validateParameters(
|
|
8760
9154
|
_nullishCoalesce(parameters, () => ( {})),
|
|
8761
9155
|
evaluator.parameters
|
|
8762
9156
|
);
|
|
8763
|
-
|
|
8764
|
-
|
|
8765
|
-
|
|
8766
|
-
|
|
8767
|
-
if (!experiment) {
|
|
8768
|
-
throw new Error(
|
|
8769
|
-
"Cannot use BaseExperiment() without connecting to Braintrust (you most likely set --no-send-logs)"
|
|
8770
|
-
);
|
|
8771
|
-
}
|
|
8772
|
-
let name = dataResult.name;
|
|
8773
|
-
if (_chunkVRZZQPAAjs.isEmpty.call(void 0, name)) {
|
|
8774
|
-
const baseExperiment = await experiment.fetchBaseExperiment();
|
|
8775
|
-
if (!baseExperiment) {
|
|
8776
|
-
throw new Error("BaseExperiment() failed to fetch base experiment");
|
|
8777
|
-
}
|
|
8778
|
-
name = baseExperiment.name;
|
|
8779
|
-
}
|
|
8780
|
-
dataResult = initExperiment2(evaluator.state, {
|
|
8781
|
-
...evaluator.projectId ? { projectId: evaluator.projectId } : { project: evaluator.projectName },
|
|
8782
|
-
experiment: name,
|
|
8783
|
-
open: true
|
|
8784
|
-
}).asDataset();
|
|
8785
|
-
}
|
|
8786
|
-
const resolvedDataResult = dataResult instanceof Promise ? await dataResult : dataResult;
|
|
8787
|
-
const dataIterable = (() => {
|
|
8788
|
-
if (isAsyncIterable2(resolvedDataResult)) {
|
|
8789
|
-
return resolvedDataResult;
|
|
8790
|
-
}
|
|
8791
|
-
if (Array.isArray(resolvedDataResult) || isIterable(resolvedDataResult)) {
|
|
8792
|
-
const iterable = resolvedDataResult;
|
|
8793
|
-
return (async function* () {
|
|
8794
|
-
for (const datum of iterable) {
|
|
8795
|
-
yield datum;
|
|
8796
|
-
}
|
|
8797
|
-
})();
|
|
8798
|
-
}
|
|
8799
|
-
throw new Error(
|
|
8800
|
-
"Evaluator data must be an array, iterable, or async iterable"
|
|
8801
|
-
);
|
|
8802
|
-
})();
|
|
9157
|
+
const dataIterable = await _internalResolveEvaluatorData(
|
|
9158
|
+
evaluator,
|
|
9159
|
+
experiment
|
|
9160
|
+
);
|
|
8803
9161
|
progressReporter.start(evaluator.evalName, 0);
|
|
8804
9162
|
const experimentIdPromise = experiment ? (async () => {
|
|
8805
9163
|
try {
|
|
@@ -8820,7 +9178,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
8820
9178
|
if (cancelled) {
|
|
8821
9179
|
return;
|
|
8822
9180
|
}
|
|
8823
|
-
const eventDataset = experiment ? experiment.dataset :
|
|
9181
|
+
const eventDataset = experiment ? experiment.dataset : _chunkOBBWQW6Kjs.Dataset.isDataset(evaluator.data) ? evaluator.data : void 0;
|
|
8824
9182
|
const inlineDatasetOrigin = eventDataset && datum.id && datum._xact_id ? {
|
|
8825
9183
|
object_type: "dataset",
|
|
8826
9184
|
object_id: await eventDataset.id,
|
|
@@ -8828,7 +9186,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
8828
9186
|
created: datum.created,
|
|
8829
9187
|
_xact_id: datum._xact_id
|
|
8830
9188
|
} : void 0;
|
|
8831
|
-
const parsedDatumOrigin =
|
|
9189
|
+
const parsedDatumOrigin = _chunkOBBWQW6Kjs.ObjectReference.safeParse(datum.origin);
|
|
8832
9190
|
const origin = _nullishCoalesce(inlineDatasetOrigin, () => ( (_optionalChain([parsedDatumOrigin, 'optionalAccess', _156 => _156.success]) ? parsedDatumOrigin.data : void 0)));
|
|
8833
9191
|
const baseEvent = {
|
|
8834
9192
|
name: "eval",
|
|
@@ -8844,23 +9202,23 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
8844
9202
|
}
|
|
8845
9203
|
};
|
|
8846
9204
|
const callback = async (rootSpan) => {
|
|
8847
|
-
const state = _nullishCoalesce(evaluator.state, () => (
|
|
9205
|
+
const state = _nullishCoalesce(evaluator.state, () => ( _chunkOBBWQW6Kjs._internalGetGlobalState.call(void 0, )));
|
|
8848
9206
|
const ensureSpansFlushed = async () => {
|
|
8849
9207
|
if (experiment) {
|
|
8850
|
-
await
|
|
9208
|
+
await _chunkOBBWQW6Kjs.flush.call(void 0, { state: experiment.loggingState });
|
|
8851
9209
|
} else if (state) {
|
|
8852
|
-
await
|
|
9210
|
+
await _chunkOBBWQW6Kjs.flush.call(void 0, { state });
|
|
8853
9211
|
} else {
|
|
8854
|
-
await
|
|
9212
|
+
await _chunkOBBWQW6Kjs.flush.call(void 0, );
|
|
8855
9213
|
}
|
|
8856
9214
|
if (state) {
|
|
8857
9215
|
await state.flushOtel();
|
|
8858
9216
|
}
|
|
8859
9217
|
};
|
|
8860
9218
|
const parentStr = state.currentParent.getStore();
|
|
8861
|
-
const parentComponents = typeof parentStr === "string" ?
|
|
9219
|
+
const parentComponents = typeof parentStr === "string" ? _chunkOBBWQW6Kjs.SpanComponentsV4.fromStr(parentStr) : null;
|
|
8862
9220
|
const trace = state ? new LocalTrace({
|
|
8863
|
-
objectType: parentComponents ?
|
|
9221
|
+
objectType: parentComponents ? _chunkOBBWQW6Kjs.spanObjectTypeV3ToTypedString.call(void 0,
|
|
8864
9222
|
parentComponents.data.object_type
|
|
8865
9223
|
) : "experiment",
|
|
8866
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 () => ( "")) : ""))),
|
|
@@ -8868,57 +9226,45 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
8868
9226
|
ensureSpansFlushed,
|
|
8869
9227
|
state
|
|
8870
9228
|
}) : void 0;
|
|
8871
|
-
let metadata = {
|
|
8872
|
-
..."metadata" in datum ? datum.metadata : {}
|
|
8873
|
-
};
|
|
9229
|
+
let metadata = {};
|
|
8874
9230
|
const expected = "expected" in datum ? datum.expected : void 0;
|
|
8875
9231
|
let output = void 0;
|
|
8876
9232
|
let error = void 0;
|
|
8877
|
-
let tags = [
|
|
8878
|
-
const scores =
|
|
8879
|
-
const classifications =
|
|
9233
|
+
let tags = [];
|
|
9234
|
+
const scores = /* @__PURE__ */ Object.create(null);
|
|
9235
|
+
const classifications = /* @__PURE__ */ Object.create(null);
|
|
8880
9236
|
const scorerNames = (_nullishCoalesce(evaluator.scores, () => ( []))).map(scorerName);
|
|
8881
9237
|
const classifierNames = (_nullishCoalesce(evaluator.classifiers, () => ( []))).map(
|
|
8882
9238
|
classifierName
|
|
8883
9239
|
);
|
|
8884
9240
|
let unhandledScores = scorerNames;
|
|
8885
9241
|
try {
|
|
8886
|
-
const
|
|
8887
|
-
|
|
8888
|
-
|
|
8889
|
-
|
|
8890
|
-
|
|
8891
|
-
|
|
8892
|
-
|
|
8893
|
-
|
|
8894
|
-
|
|
8895
|
-
|
|
8896
|
-
|
|
8897
|
-
|
|
8898
|
-
|
|
8899
|
-
|
|
8900
|
-
|
|
8901
|
-
object_type: "task"
|
|
8902
|
-
})]);
|
|
8903
|
-
},
|
|
8904
|
-
trialIndex,
|
|
8905
|
-
tags
|
|
8906
|
-
};
|
|
8907
|
-
const outputResult = evaluator.task(datum.input, hooksForTask);
|
|
8908
|
-
if (outputResult instanceof Promise) {
|
|
8909
|
-
output = await outputResult;
|
|
8910
|
-
} else {
|
|
8911
|
-
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
|
+
})]);
|
|
8912
9257
|
}
|
|
8913
|
-
|
|
8914
|
-
span.log({ output });
|
|
8915
|
-
},
|
|
9258
|
+
),
|
|
8916
9259
|
{
|
|
8917
9260
|
name: "task",
|
|
8918
9261
|
spanAttributes: { type: "task" /* TASK */ },
|
|
8919
9262
|
event: { input: datum.input }
|
|
8920
9263
|
}
|
|
8921
9264
|
);
|
|
9265
|
+
output = taskResult.output;
|
|
9266
|
+
metadata = taskResult.metadata;
|
|
9267
|
+
tags = taskResult.tags;
|
|
8922
9268
|
if (tags.length) {
|
|
8923
9269
|
rootSpan.log({ output, metadata, expected, tags });
|
|
8924
9270
|
} else {
|
|
@@ -8928,20 +9274,18 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
8928
9274
|
await rootSpan.flush();
|
|
8929
9275
|
}
|
|
8930
9276
|
const scoringArgs = {
|
|
9277
|
+
id: datum.id,
|
|
8931
9278
|
input: datum.input,
|
|
8932
9279
|
expected: "expected" in datum ? datum.expected : void 0,
|
|
8933
9280
|
metadata,
|
|
8934
9281
|
output,
|
|
9282
|
+
tags,
|
|
8935
9283
|
trace
|
|
8936
9284
|
};
|
|
8937
9285
|
const { trace: _trace, ...scoringArgsForLogging } = scoringArgs;
|
|
8938
|
-
const propagatedEvent =
|
|
9286
|
+
const propagatedEvent = _chunkOBBWQW6Kjs.makeScorerPropagatedEvent.call(void 0,
|
|
8939
9287
|
await rootSpan.export()
|
|
8940
9288
|
);
|
|
8941
|
-
const getOtherFields = (s) => {
|
|
8942
|
-
const { metadata: _metadata, name: _name, ...rest } = s;
|
|
8943
|
-
return rest;
|
|
8944
|
-
};
|
|
8945
9289
|
const [scoreResults, classificationResults] = await Promise.all([
|
|
8946
9290
|
Promise.all(
|
|
8947
9291
|
(_nullishCoalesce(evaluator.scores, () => ( []))).map(
|
|
@@ -8955,35 +9299,17 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
8955
9299
|
const scoreValue = await Promise.resolve(
|
|
8956
9300
|
score(scoringArgs)
|
|
8957
9301
|
);
|
|
8958
|
-
|
|
8959
|
-
|
|
8960
|
-
|
|
8961
|
-
if (!(typeof s === "object" && !_chunkVRZZQPAAjs.isEmpty.call(void 0, s))) {
|
|
8962
|
-
throw new Error(
|
|
8963
|
-
`When returning an array of scores, each score must be a non-empty object. Got: ${JSON.stringify(s)}`
|
|
8964
|
-
);
|
|
8965
|
-
}
|
|
8966
|
-
}
|
|
8967
|
-
}
|
|
8968
|
-
const results = Array.isArray(scoreValue) ? scoreValue : typeof scoreValue === "object" && !_chunkVRZZQPAAjs.isEmpty.call(void 0, scoreValue) ? [scoreValue] : [
|
|
8969
|
-
{
|
|
8970
|
-
name: scorerNames[score_idx],
|
|
8971
|
-
score: scoreValue
|
|
8972
|
-
}
|
|
8973
|
-
];
|
|
8974
|
-
const { resultMetadata, scoresRecord } = buildSpanScores(results);
|
|
8975
|
-
const resultOutput = results.length === 1 ? getOtherFields(results[0]) : results.reduce(
|
|
8976
|
-
(prev, s) => _chunkVRZZQPAAjs.mergeDicts.call(void 0, prev, {
|
|
8977
|
-
[s.name]: getOtherFields(s)
|
|
8978
|
-
}),
|
|
8979
|
-
{}
|
|
9302
|
+
const prepared = _internalPrepareEvaluatorScore(
|
|
9303
|
+
scoreValue,
|
|
9304
|
+
scorerNames[score_idx]
|
|
8980
9305
|
);
|
|
9306
|
+
if (prepared.results === null) return null;
|
|
8981
9307
|
span.log({
|
|
8982
|
-
output:
|
|
8983
|
-
metadata:
|
|
8984
|
-
scores:
|
|
9308
|
+
output: prepared.output,
|
|
9309
|
+
metadata: prepared.metadata,
|
|
9310
|
+
scores: prepared.scores
|
|
8985
9311
|
});
|
|
8986
|
-
return results;
|
|
9312
|
+
return prepared.results;
|
|
8987
9313
|
}
|
|
8988
9314
|
)
|
|
8989
9315
|
)
|
|
@@ -9000,24 +9326,16 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
9000
9326
|
const classifierValue = await Promise.resolve(
|
|
9001
9327
|
classifier(scoringArgs)
|
|
9002
9328
|
);
|
|
9003
|
-
|
|
9004
|
-
|
|
9005
|
-
|
|
9006
|
-
result,
|
|
9007
|
-
classifierNames[idx]
|
|
9008
|
-
)
|
|
9009
|
-
);
|
|
9010
|
-
const resultOutput = rawResults.length === 1 ? toClassificationItem(rawResults[0]) : rawResults.reduce(
|
|
9011
|
-
(prev, r) => _chunkVRZZQPAAjs.mergeDicts.call(void 0, prev, {
|
|
9012
|
-
[r.name]: toClassificationItem(r)
|
|
9013
|
-
}),
|
|
9014
|
-
{}
|
|
9329
|
+
const prepared = _internalPrepareEvaluatorClassification(
|
|
9330
|
+
classifierValue,
|
|
9331
|
+
classifierNames[idx]
|
|
9015
9332
|
);
|
|
9333
|
+
if (prepared.results === null) return null;
|
|
9016
9334
|
span.log({
|
|
9017
|
-
output:
|
|
9018
|
-
metadata:
|
|
9335
|
+
output: prepared.output,
|
|
9336
|
+
metadata: prepared.metadata
|
|
9019
9337
|
});
|
|
9020
|
-
return
|
|
9338
|
+
return prepared.results;
|
|
9021
9339
|
}
|
|
9022
9340
|
)
|
|
9023
9341
|
)
|
|
@@ -9060,7 +9378,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
9060
9378
|
evaluator.state
|
|
9061
9379
|
);
|
|
9062
9380
|
} catch (e) {
|
|
9063
|
-
|
|
9381
|
+
_chunkOBBWQW6Kjs.logError.call(void 0, rootSpan, e);
|
|
9064
9382
|
error = e;
|
|
9065
9383
|
} finally {
|
|
9066
9384
|
progressReporter.increment(evaluator.evalName);
|
|
@@ -9094,7 +9412,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
9094
9412
|
}
|
|
9095
9413
|
};
|
|
9096
9414
|
if (!experiment) {
|
|
9097
|
-
return await
|
|
9415
|
+
return await _chunkOBBWQW6Kjs.traced.call(void 0, callback, {
|
|
9098
9416
|
...baseEvent,
|
|
9099
9417
|
state: evaluator.state
|
|
9100
9418
|
});
|
|
@@ -9148,7 +9466,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
9148
9466
|
const cancel = async () => {
|
|
9149
9467
|
await new Promise((_, reject2) => {
|
|
9150
9468
|
if (cancelled) {
|
|
9151
|
-
reject2(new (0,
|
|
9469
|
+
reject2(new (0, _chunkOBBWQW6Kjs.InternalAbortError)("Evaluator already cancelled"));
|
|
9152
9470
|
return;
|
|
9153
9471
|
}
|
|
9154
9472
|
const rejectOnce = (error) => {
|
|
@@ -9161,12 +9479,12 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
9161
9479
|
};
|
|
9162
9480
|
if (evaluator.timeout) {
|
|
9163
9481
|
timeoutId = setTimeout(() => {
|
|
9164
|
-
rejectOnce(new (0,
|
|
9482
|
+
rejectOnce(new (0, _chunkOBBWQW6Kjs.InternalAbortError)("Evaluator timed out"));
|
|
9165
9483
|
}, evaluator.timeout);
|
|
9166
9484
|
}
|
|
9167
9485
|
if (evaluator.signal) {
|
|
9168
9486
|
abortHandler = () => {
|
|
9169
|
-
rejectOnce(new (0,
|
|
9487
|
+
rejectOnce(new (0, _chunkOBBWQW6Kjs.InternalAbortError)("Evaluator aborted"));
|
|
9170
9488
|
};
|
|
9171
9489
|
evaluator.signal.addEventListener("abort", abortHandler);
|
|
9172
9490
|
}
|
|
@@ -9189,9 +9507,9 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
9189
9507
|
}
|
|
9190
9508
|
} catch (e) {
|
|
9191
9509
|
q.kill();
|
|
9192
|
-
if (e instanceof
|
|
9193
|
-
if (
|
|
9194
|
-
|
|
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);
|
|
9195
9513
|
}
|
|
9196
9514
|
}
|
|
9197
9515
|
throw e;
|
|
@@ -9216,7 +9534,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
9216
9534
|
);
|
|
9217
9535
|
} finally {
|
|
9218
9536
|
if (enableCache) {
|
|
9219
|
-
const spanCache = _optionalChain([(_nullishCoalesce(evaluator.state, () => (
|
|
9537
|
+
const spanCache = _optionalChain([(_nullishCoalesce(evaluator.state, () => ( _chunkOBBWQW6Kjs._internalGetGlobalState.call(void 0, )))), 'optionalAccess', _166 => _166.spanCache]);
|
|
9220
9538
|
_optionalChain([spanCache, 'optionalAccess', _167 => _167.dispose, 'call', _168 => _168()]);
|
|
9221
9539
|
_optionalChain([spanCache, 'optionalAccess', _169 => _169.stop, 'call', _170 => _170()]);
|
|
9222
9540
|
}
|
|
@@ -9246,7 +9564,7 @@ function accumulateScores(accumulator, scores) {
|
|
|
9246
9564
|
}
|
|
9247
9565
|
}
|
|
9248
9566
|
function ensureScoreAccumulator(results) {
|
|
9249
|
-
const accumulator =
|
|
9567
|
+
const accumulator = /* @__PURE__ */ Object.create(null);
|
|
9250
9568
|
for (const result of results) {
|
|
9251
9569
|
accumulateScores(accumulator, result.scores);
|
|
9252
9570
|
}
|
|
@@ -9311,25 +9629,25 @@ var defaultReporter = {
|
|
|
9311
9629
|
reportFailures(evaluator, failingResults, { verbose, jsonl });
|
|
9312
9630
|
}
|
|
9313
9631
|
if (jsonl) {
|
|
9314
|
-
|
|
9632
|
+
_chunkBBE7SNRVjs.isomorph_default.writeln(JSON.stringify(summary));
|
|
9315
9633
|
} else {
|
|
9316
|
-
|
|
9317
|
-
|
|
9634
|
+
_chunkBBE7SNRVjs.isomorph_default.writeln("Experiment summary");
|
|
9635
|
+
_chunkBBE7SNRVjs.isomorph_default.writeln("==================");
|
|
9318
9636
|
if (summary.comparisonExperimentName) {
|
|
9319
|
-
|
|
9637
|
+
_chunkBBE7SNRVjs.isomorph_default.writeln(
|
|
9320
9638
|
`${summary.comparisonExperimentName} (baseline) <- ${summary.experimentName} (comparison)`
|
|
9321
9639
|
);
|
|
9322
|
-
|
|
9640
|
+
_chunkBBE7SNRVjs.isomorph_default.writeln("");
|
|
9323
9641
|
}
|
|
9324
9642
|
const hasScores = Object.keys(summary.scores).length > 0;
|
|
9325
9643
|
const hasMetrics = Object.keys(_nullishCoalesce(summary.metrics, () => ( {}))).length > 0;
|
|
9326
9644
|
const hasComparison = !!summary.comparisonExperimentName;
|
|
9327
9645
|
if (hasScores || hasMetrics) {
|
|
9328
9646
|
if (hasComparison) {
|
|
9329
|
-
|
|
9647
|
+
_chunkBBE7SNRVjs.isomorph_default.writeln(
|
|
9330
9648
|
"Name Value Change Improvements Regressions"
|
|
9331
9649
|
);
|
|
9332
|
-
|
|
9650
|
+
_chunkBBE7SNRVjs.isomorph_default.writeln(
|
|
9333
9651
|
"----------------------------------------------------------------"
|
|
9334
9652
|
);
|
|
9335
9653
|
}
|
|
@@ -9338,18 +9656,18 @@ var defaultReporter = {
|
|
|
9338
9656
|
const scoreValue = `${scorePercent}%`;
|
|
9339
9657
|
if (hasComparison) {
|
|
9340
9658
|
let diffString = "-";
|
|
9341
|
-
if (!
|
|
9659
|
+
if (!_chunkOBBWQW6Kjs.isEmpty.call(void 0, score.diff)) {
|
|
9342
9660
|
const diffPercent = (score.diff * 100).toFixed(2);
|
|
9343
9661
|
const diffSign = score.diff > 0 ? "+" : "";
|
|
9344
9662
|
diffString = `${diffSign}${diffPercent}%`;
|
|
9345
9663
|
}
|
|
9346
9664
|
const improvements = score.improvements > 0 ? score.improvements.toString() : "-";
|
|
9347
9665
|
const regressions = score.regressions > 0 ? score.regressions.toString() : "-";
|
|
9348
|
-
|
|
9666
|
+
_chunkBBE7SNRVjs.isomorph_default.writeln(
|
|
9349
9667
|
`${score.name.padEnd(18)} ${scoreValue.padStart(10)} ${diffString.padStart(10)} ${improvements.padStart(12)} ${regressions.padStart(11)}`
|
|
9350
9668
|
);
|
|
9351
9669
|
} else {
|
|
9352
|
-
|
|
9670
|
+
_chunkBBE7SNRVjs.isomorph_default.writeln(`${score.name.padEnd(20)} ${scoreValue.padStart(15)}`);
|
|
9353
9671
|
}
|
|
9354
9672
|
}
|
|
9355
9673
|
for (const metric of Object.values(_nullishCoalesce(summary.metrics, () => ( {})))) {
|
|
@@ -9358,30 +9676,30 @@ var defaultReporter = {
|
|
|
9358
9676
|
const metricValue = metric.unit === "$" ? `${metric.unit}${formattedValue}` : `${formattedValue}${metric.unit}`;
|
|
9359
9677
|
if (hasComparison) {
|
|
9360
9678
|
let diffString = "-";
|
|
9361
|
-
if (!
|
|
9679
|
+
if (!_chunkOBBWQW6Kjs.isEmpty.call(void 0, metric.diff)) {
|
|
9362
9680
|
const diffPercent = (metric.diff * 100).toFixed(2);
|
|
9363
9681
|
const diffSign = metric.diff > 0 ? "+" : "";
|
|
9364
9682
|
diffString = `${diffSign}${diffPercent}%`;
|
|
9365
9683
|
}
|
|
9366
9684
|
const improvements = metric.improvements > 0 ? metric.improvements.toString() : "-";
|
|
9367
9685
|
const regressions = metric.regressions > 0 ? metric.regressions.toString() : "-";
|
|
9368
|
-
|
|
9686
|
+
_chunkBBE7SNRVjs.isomorph_default.writeln(
|
|
9369
9687
|
`${metric.name.padEnd(18)} ${metricValue.padStart(10)} ${diffString.padStart(10)} ${improvements.padStart(12)} ${regressions.padStart(11)}`
|
|
9370
9688
|
);
|
|
9371
9689
|
} else {
|
|
9372
|
-
|
|
9690
|
+
_chunkBBE7SNRVjs.isomorph_default.writeln(
|
|
9373
9691
|
`${metric.name.padEnd(20)} ${metricValue.padStart(15)}`
|
|
9374
9692
|
);
|
|
9375
9693
|
}
|
|
9376
9694
|
}
|
|
9377
9695
|
}
|
|
9378
9696
|
if (summary.experimentUrl) {
|
|
9379
|
-
|
|
9380
|
-
|
|
9381
|
-
|
|
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}`);
|
|
9382
9700
|
}
|
|
9383
9701
|
}
|
|
9384
|
-
|
|
9702
|
+
_chunkBBE7SNRVjs.isomorph_default.writeln("");
|
|
9385
9703
|
return failingResults.length === 0;
|
|
9386
9704
|
},
|
|
9387
9705
|
async reportRun(evalReports) {
|
|
@@ -9389,46 +9707,1196 @@ var defaultReporter = {
|
|
|
9389
9707
|
}
|
|
9390
9708
|
};
|
|
9391
9709
|
|
|
9392
|
-
// src/
|
|
9393
|
-
|
|
9394
|
-
|
|
9395
|
-
|
|
9396
|
-
|
|
9397
|
-
|
|
9398
|
-
|
|
9399
|
-
|
|
9400
|
-
|
|
9401
|
-
|
|
9402
|
-
|
|
9403
|
-
|
|
9404
|
-
|
|
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
|
+
);
|
|
9405
9766
|
}
|
|
9406
|
-
|
|
9407
|
-
|
|
9408
|
-
|
|
9409
|
-
|
|
9410
|
-
|
|
9411
|
-
|
|
9412
|
-
|
|
9413
|
-
|
|
9414
|
-
|
|
9415
|
-
)
|
|
9416
|
-
|
|
9417
|
-
|
|
9418
|
-
|
|
9419
|
-
|
|
9420
|
-
|
|
9421
|
-
|
|
9422
|
-
|
|
9423
|
-
|
|
9424
|
-
|
|
9425
|
-
|
|
9426
|
-
|
|
9427
|
-
|
|
9428
|
-
|
|
9429
|
-
|
|
9430
|
-
}
|
|
9431
|
-
|
|
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
|
+
|
|
10860
|
+
// src/agent-assertions.ts
|
|
10861
|
+
function agentAssertionScorer(callback, options = {}) {
|
|
10862
|
+
return async (args) => {
|
|
10863
|
+
const { trace: _trace, ...callbackArgs } = args;
|
|
10864
|
+
const callbackMetadata = _nullishCoalesce(callbackArgs.metadata, () => ( {}));
|
|
10865
|
+
const assertions = await callback({
|
|
10866
|
+
...callbackArgs,
|
|
10867
|
+
metadata: callbackMetadata,
|
|
10868
|
+
assert: agentAssertionHelpers
|
|
10869
|
+
});
|
|
10870
|
+
const resources = {};
|
|
10871
|
+
if (assertions.some((assertion) => assertion.requiresTrace)) {
|
|
10872
|
+
resources.spans = await _optionalChain([args, 'access', _191 => _191.trace, 'optionalAccess', _192 => _192.getSpans, 'call', _193 => _193({ spanType: ["tool"] })]);
|
|
10873
|
+
}
|
|
10874
|
+
const results = await Promise.all(
|
|
10875
|
+
assertions.map(async (assertion) => {
|
|
10876
|
+
const result = await assertion.evaluate(resources);
|
|
10877
|
+
return {
|
|
10878
|
+
name: assertion.name,
|
|
10879
|
+
passed: result.passed,
|
|
10880
|
+
failure: result.failure
|
|
10881
|
+
};
|
|
10882
|
+
})
|
|
10883
|
+
);
|
|
10884
|
+
const passed = results.filter((result) => result.passed).length;
|
|
10885
|
+
const total = results.length;
|
|
10886
|
+
const failed = results.filter((result) => !result.passed).map(
|
|
10887
|
+
(result) => `${result.name}: ${_nullishCoalesce(result.failure, () => ( "assertion did not pass"))}`
|
|
10888
|
+
);
|
|
10889
|
+
return {
|
|
10890
|
+
name: _nullishCoalesce(options.name, () => ( "assertions")),
|
|
10891
|
+
score: total === 0 ? 1 : passed / total,
|
|
10892
|
+
metadata: {
|
|
10893
|
+
assertions: results.map(({ name, passed: passed2 }) => ({ name, passed: passed2 })),
|
|
10894
|
+
failed
|
|
10895
|
+
}
|
|
10896
|
+
};
|
|
10897
|
+
};
|
|
10898
|
+
}
|
|
10899
|
+
var agentAssertionHelpers = {
|
|
9432
10900
|
equals: (actual, expected, name = "equals") => ({
|
|
9433
10901
|
name,
|
|
9434
10902
|
evaluate: () => {
|
|
@@ -9559,7 +11027,7 @@ async function validateSchema(schema, value) {
|
|
|
9559
11027
|
}
|
|
9560
11028
|
}
|
|
9561
11029
|
function toolCalls(spans) {
|
|
9562
|
-
return spans.filter((span) => _optionalChain([span, 'access',
|
|
11030
|
+
return spans.filter((span) => _optionalChain([span, 'access', _194 => _194.span_attributes, 'optionalAccess', _195 => _195.type]) === "tool");
|
|
9563
11031
|
}
|
|
9564
11032
|
function matchingToolCalls(spans, toolName, options) {
|
|
9565
11033
|
return toolCalls(spans).filter((span) => {
|
|
@@ -9577,17 +11045,17 @@ function matchingToolCalls(spans, toolName, options) {
|
|
|
9577
11045
|
});
|
|
9578
11046
|
}
|
|
9579
11047
|
function getToolName(span) {
|
|
9580
|
-
const spanName = [_optionalChain([span, 'access',
|
|
9581
|
-
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("/")])) {
|
|
9582
11050
|
return spanName;
|
|
9583
11051
|
}
|
|
9584
11052
|
const metadataName = [
|
|
9585
|
-
_optionalChain([span, 'access',
|
|
9586
|
-
_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"]])
|
|
9587
11055
|
].map(normalizeToolName).find((value) => value !== void 0);
|
|
9588
11056
|
const mcpServer = [
|
|
9589
|
-
_optionalChain([span, 'access',
|
|
9590
|
-
_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"]])
|
|
9591
11059
|
].find((value) => typeof value === "string" && value !== "");
|
|
9592
11060
|
if (metadataName && mcpServer) {
|
|
9593
11061
|
return `${mcpServer}/${metadataName}`;
|
|
@@ -9657,7 +11125,7 @@ function formatValue(value) {
|
|
|
9657
11125
|
return serialized;
|
|
9658
11126
|
}
|
|
9659
11127
|
return formatValueWithUndefined(value, /* @__PURE__ */ new Set());
|
|
9660
|
-
} catch (
|
|
11128
|
+
} catch (e12) {
|
|
9661
11129
|
return String(value);
|
|
9662
11130
|
}
|
|
9663
11131
|
}
|
|
@@ -9770,7 +11238,7 @@ var ProjectBuilder = class {
|
|
|
9770
11238
|
}
|
|
9771
11239
|
};
|
|
9772
11240
|
var projects = new ProjectBuilder();
|
|
9773
|
-
var Project2 = (
|
|
11241
|
+
var Project2 = (_class10 = class {
|
|
9774
11242
|
|
|
9775
11243
|
|
|
9776
11244
|
|
|
@@ -9778,10 +11246,10 @@ var Project2 = (_class7 = class {
|
|
|
9778
11246
|
|
|
9779
11247
|
|
|
9780
11248
|
|
|
9781
|
-
|
|
9782
|
-
|
|
9783
|
-
|
|
9784
|
-
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);
|
|
9785
11253
|
_initializeSpanContext();
|
|
9786
11254
|
this.name = "name" in args ? args.name : void 0;
|
|
9787
11255
|
this.id = "id" in args ? args.id : void 0;
|
|
@@ -9816,7 +11284,7 @@ var Project2 = (_class7 = class {
|
|
|
9816
11284
|
console.warn("publish() is a no-op when running `braintrust push`.");
|
|
9817
11285
|
return;
|
|
9818
11286
|
}
|
|
9819
|
-
await
|
|
11287
|
+
await _chunkOBBWQW6Kjs.login.call(void 0, );
|
|
9820
11288
|
const projectMap = new ProjectNameIdMap();
|
|
9821
11289
|
const functionDefinitions = [];
|
|
9822
11290
|
if (this._publishableCodeFunctions.length > 0) {
|
|
@@ -9830,17 +11298,17 @@ var Project2 = (_class7 = class {
|
|
|
9830
11298
|
functionDefinitions.push(functionDefinition);
|
|
9831
11299
|
}
|
|
9832
11300
|
}
|
|
9833
|
-
await
|
|
11301
|
+
await _chunkOBBWQW6Kjs._internalGetGlobalState.call(void 0, ).apiConn().post_json("insert-functions", {
|
|
9834
11302
|
functions: functionDefinitions
|
|
9835
11303
|
});
|
|
9836
11304
|
}
|
|
9837
|
-
},
|
|
9838
|
-
var ToolBuilder = (
|
|
9839
|
-
constructor(project) {;
|
|
11305
|
+
}, _class10);
|
|
11306
|
+
var ToolBuilder = (_class11 = class {
|
|
11307
|
+
constructor(project) {;_class11.prototype.__init22.call(this);
|
|
9840
11308
|
this.project = project;
|
|
9841
11309
|
}
|
|
9842
11310
|
|
|
9843
|
-
|
|
11311
|
+
__init22() {this.taskCounter = 0}
|
|
9844
11312
|
// This type definition is just a catch all so that the implementation can be
|
|
9845
11313
|
// less specific than the two more specific declarations above.
|
|
9846
11314
|
create(opts) {
|
|
@@ -9849,12 +11317,12 @@ var ToolBuilder = (_class8 = class {
|
|
|
9849
11317
|
const { handler, name, slug, parameters, returns, ...rest } = opts;
|
|
9850
11318
|
let resolvedName = _nullishCoalesce(name, () => ( handler.name));
|
|
9851
11319
|
if (resolvedName.trim().length === 0) {
|
|
9852
|
-
resolvedName = `Tool ${
|
|
11320
|
+
resolvedName = `Tool ${_chunkBBE7SNRVjs.isomorph_default.basename(currentFilename)} ${this.taskCounter}`;
|
|
9853
11321
|
}
|
|
9854
11322
|
const tool = new CodeFunction(this.project, {
|
|
9855
11323
|
handler,
|
|
9856
11324
|
name: resolvedName,
|
|
9857
|
-
slug: _nullishCoalesce(slug, () => (
|
|
11325
|
+
slug: _nullishCoalesce(slug, () => ( _chunkOBBWQW6Kjs.slugify.call(void 0, resolvedName, { lower: true, strict: true }))),
|
|
9858
11326
|
type: "tool",
|
|
9859
11327
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/consistent-type-assertions
|
|
9860
11328
|
parameters,
|
|
@@ -9865,13 +11333,13 @@ var ToolBuilder = (_class8 = class {
|
|
|
9865
11333
|
this.project.addCodeFunction(tool);
|
|
9866
11334
|
return tool;
|
|
9867
11335
|
}
|
|
9868
|
-
},
|
|
9869
|
-
var ScorerBuilder = (
|
|
9870
|
-
constructor(project) {;
|
|
11336
|
+
}, _class11);
|
|
11337
|
+
var ScorerBuilder = (_class12 = class {
|
|
11338
|
+
constructor(project) {;_class12.prototype.__init23.call(this);
|
|
9871
11339
|
this.project = project;
|
|
9872
11340
|
}
|
|
9873
11341
|
|
|
9874
|
-
|
|
11342
|
+
__init23() {this.taskCounter = 0}
|
|
9875
11343
|
create(opts) {
|
|
9876
11344
|
this.taskCounter++;
|
|
9877
11345
|
let resolvedName = opts.name;
|
|
@@ -9879,9 +11347,9 @@ var ScorerBuilder = (_class9 = class {
|
|
|
9879
11347
|
resolvedName = opts.handler.name;
|
|
9880
11348
|
}
|
|
9881
11349
|
if (!resolvedName || resolvedName.trim().length === 0) {
|
|
9882
|
-
resolvedName = `Scorer ${
|
|
11350
|
+
resolvedName = `Scorer ${_chunkBBE7SNRVjs.isomorph_default.basename(currentFilename)} ${this.taskCounter}`;
|
|
9883
11351
|
}
|
|
9884
|
-
const slug = _nullishCoalesce(opts.slug, () => (
|
|
11352
|
+
const slug = _nullishCoalesce(opts.slug, () => ( _chunkOBBWQW6Kjs.slugify.call(void 0, resolvedName, { lower: true, strict: true })));
|
|
9885
11353
|
if ("handler" in opts) {
|
|
9886
11354
|
const scorer = new CodeFunction(this.project, {
|
|
9887
11355
|
...opts,
|
|
@@ -9925,20 +11393,20 @@ var ScorerBuilder = (_class9 = class {
|
|
|
9925
11393
|
this.project.addPrompt(codePrompt);
|
|
9926
11394
|
}
|
|
9927
11395
|
}
|
|
9928
|
-
},
|
|
9929
|
-
var ClassifierBuilder = (
|
|
9930
|
-
constructor(project) {;
|
|
11396
|
+
}, _class12);
|
|
11397
|
+
var ClassifierBuilder = (_class13 = class {
|
|
11398
|
+
constructor(project) {;_class13.prototype.__init24.call(this);
|
|
9931
11399
|
this.project = project;
|
|
9932
11400
|
}
|
|
9933
11401
|
|
|
9934
|
-
|
|
11402
|
+
__init24() {this.taskCounter = 0}
|
|
9935
11403
|
create(opts) {
|
|
9936
11404
|
this.taskCounter++;
|
|
9937
11405
|
let resolvedName = _nullishCoalesce(opts.name, () => ( opts.handler.name));
|
|
9938
11406
|
if (!resolvedName || resolvedName.trim().length === 0) {
|
|
9939
|
-
resolvedName = `Classifier ${
|
|
11407
|
+
resolvedName = `Classifier ${_chunkBBE7SNRVjs.isomorph_default.basename(currentFilename)} ${this.taskCounter}`;
|
|
9940
11408
|
}
|
|
9941
|
-
const slug = _nullishCoalesce(opts.slug, () => (
|
|
11409
|
+
const slug = _nullishCoalesce(opts.slug, () => ( _chunkOBBWQW6Kjs.slugify.call(void 0, resolvedName, { lower: true, strict: true })));
|
|
9942
11410
|
const classifier = new CodeFunction(this.project, {
|
|
9943
11411
|
...opts,
|
|
9944
11412
|
name: resolvedName,
|
|
@@ -9948,7 +11416,7 @@ var ClassifierBuilder = (_class10 = class {
|
|
|
9948
11416
|
this.project.addCodeFunction(classifier);
|
|
9949
11417
|
return classifier;
|
|
9950
11418
|
}
|
|
9951
|
-
},
|
|
11419
|
+
}, _class13);
|
|
9952
11420
|
var CodeFunction = class {
|
|
9953
11421
|
constructor(project, opts) {
|
|
9954
11422
|
this.project = project;
|
|
@@ -10067,18 +11535,18 @@ var PromptBuilder = class {
|
|
|
10067
11535
|
rawTools.push(tool);
|
|
10068
11536
|
}
|
|
10069
11537
|
}
|
|
10070
|
-
const slug = _nullishCoalesce(opts.slug, () => (
|
|
11538
|
+
const slug = _nullishCoalesce(opts.slug, () => ( _chunkOBBWQW6Kjs.slugify.call(void 0, opts.name, { lower: true, strict: true })));
|
|
10071
11539
|
const promptData = promptDefinitionToPromptData(opts, rawTools);
|
|
10072
11540
|
const promptRow = {
|
|
10073
11541
|
id: opts.id,
|
|
10074
|
-
_xact_id: opts.version ?
|
|
11542
|
+
_xact_id: opts.version ? _chunkOBBWQW6Kjs.loadPrettyXact.call(void 0, opts.version) : void 0,
|
|
10075
11543
|
name: opts.name,
|
|
10076
11544
|
slug,
|
|
10077
11545
|
prompt_data: promptData,
|
|
10078
11546
|
tags: opts.tags,
|
|
10079
11547
|
...this.project.id !== void 0 ? { project_id: this.project.id } : {}
|
|
10080
11548
|
};
|
|
10081
|
-
const prompt = new (0,
|
|
11549
|
+
const prompt = new (0, _chunkOBBWQW6Kjs.Prompt)(
|
|
10082
11550
|
promptRow,
|
|
10083
11551
|
{},
|
|
10084
11552
|
// It doesn't make sense to specify defaults here.
|
|
@@ -10133,7 +11601,7 @@ var ParametersBuilder = class {
|
|
|
10133
11601
|
}
|
|
10134
11602
|
|
|
10135
11603
|
create(opts) {
|
|
10136
|
-
const slug = _nullishCoalesce(opts.slug, () => (
|
|
11604
|
+
const slug = _nullishCoalesce(opts.slug, () => ( _chunkOBBWQW6Kjs.slugify.call(void 0, opts.name, { lower: true, strict: true })));
|
|
10137
11605
|
const codeParameters = new CodeParameters(this.project, {
|
|
10138
11606
|
name: opts.name,
|
|
10139
11607
|
slug,
|
|
@@ -10172,7 +11640,7 @@ function serializeEvalParameterstoParametersSchema(parameters) {
|
|
|
10172
11640
|
required.push(name);
|
|
10173
11641
|
}
|
|
10174
11642
|
} else {
|
|
10175
|
-
const schemaObj =
|
|
11643
|
+
const schemaObj = _chunkOBBWQW6Kjs.zodToJsonSchema.call(void 0, value);
|
|
10176
11644
|
properties[name] = schemaObj;
|
|
10177
11645
|
if (!("default" in schemaObj)) {
|
|
10178
11646
|
required.push(name);
|
|
@@ -10196,16 +11664,16 @@ function getDefaultDataFromParametersSchema(schema) {
|
|
|
10196
11664
|
})
|
|
10197
11665
|
);
|
|
10198
11666
|
}
|
|
10199
|
-
var ProjectNameIdMap = (
|
|
10200
|
-
|
|
10201
|
-
|
|
11667
|
+
var ProjectNameIdMap = (_class14 = class {constructor() { _class14.prototype.__init25.call(this);_class14.prototype.__init26.call(this); }
|
|
11668
|
+
__init25() {this.nameToId = {}}
|
|
11669
|
+
__init26() {this.idToName = {}}
|
|
10202
11670
|
async getId(projectName) {
|
|
10203
11671
|
if (!(projectName in this.nameToId)) {
|
|
10204
|
-
const response = await
|
|
11672
|
+
const response = await _chunkOBBWQW6Kjs._internalGetGlobalState.call(void 0, ).appConn().post_json("api/project/register", {
|
|
10205
11673
|
project_name: projectName
|
|
10206
11674
|
});
|
|
10207
11675
|
const result = _v3.z.object({
|
|
10208
|
-
project:
|
|
11676
|
+
project: _chunkOBBWQW6Kjs.Project
|
|
10209
11677
|
}).parse(response);
|
|
10210
11678
|
const projectId = result.project.id;
|
|
10211
11679
|
this.nameToId[projectName] = projectId;
|
|
@@ -10215,10 +11683,10 @@ var ProjectNameIdMap = (_class11 = class {constructor() { _class11.prototype.__i
|
|
|
10215
11683
|
}
|
|
10216
11684
|
async getName(projectId) {
|
|
10217
11685
|
if (!(projectId in this.idToName)) {
|
|
10218
|
-
const response = await
|
|
11686
|
+
const response = await _chunkOBBWQW6Kjs._internalGetGlobalState.call(void 0, ).appConn().post_json("api/project/get", {
|
|
10219
11687
|
id: projectId
|
|
10220
11688
|
});
|
|
10221
|
-
const result = _v3.z.array(
|
|
11689
|
+
const result = _v3.z.array(_chunkOBBWQW6Kjs.Project).nonempty().parse(response);
|
|
10222
11690
|
const projectName = result[0].name;
|
|
10223
11691
|
this.idToName[projectId] = projectName;
|
|
10224
11692
|
this.nameToId[projectName] = projectId;
|
|
@@ -10231,23 +11699,23 @@ var ProjectNameIdMap = (_class11 = class {constructor() { _class11.prototype.__i
|
|
|
10231
11699
|
}
|
|
10232
11700
|
return this.getId(project.name);
|
|
10233
11701
|
}
|
|
10234
|
-
},
|
|
11702
|
+
}, _class14);
|
|
10235
11703
|
|
|
10236
11704
|
// dev/types.ts
|
|
10237
11705
|
|
|
10238
11706
|
var evalBodySchema = _v3.z.object({
|
|
10239
11707
|
name: _v3.z.string(),
|
|
10240
11708
|
parameters: _v3.z.record(_v3.z.string(), _v3.z.unknown()).nullish(),
|
|
10241
|
-
data:
|
|
11709
|
+
data: _chunkOBBWQW6Kjs.RunEval.shape.data,
|
|
10242
11710
|
scores: _v3.z.array(
|
|
10243
11711
|
_v3.z.object({
|
|
10244
|
-
function_id:
|
|
11712
|
+
function_id: _chunkOBBWQW6Kjs.FunctionId,
|
|
10245
11713
|
name: _v3.z.string()
|
|
10246
11714
|
})
|
|
10247
11715
|
).nullish(),
|
|
10248
11716
|
experiment_name: _v3.z.string().nullish(),
|
|
10249
11717
|
project_id: _v3.z.string().nullish(),
|
|
10250
|
-
parent:
|
|
11718
|
+
parent: _chunkOBBWQW6Kjs.InvokeParent.optional(),
|
|
10251
11719
|
stream: _v3.z.boolean().optional()
|
|
10252
11720
|
});
|
|
10253
11721
|
var staticParametersSchema = _v3.z.record(
|
|
@@ -10255,7 +11723,7 @@ var staticParametersSchema = _v3.z.record(
|
|
|
10255
11723
|
_v3.z.union([
|
|
10256
11724
|
_v3.z.object({
|
|
10257
11725
|
type: _v3.z.literal("prompt"),
|
|
10258
|
-
default:
|
|
11726
|
+
default: _chunkOBBWQW6Kjs.PromptData.optional(),
|
|
10259
11727
|
description: _v3.z.string().optional()
|
|
10260
11728
|
}),
|
|
10261
11729
|
_v3.z.object({
|
|
@@ -10311,7 +11779,16 @@ var evaluatorDefinitionsSchema = _v3.z.record(
|
|
|
10311
11779
|
);
|
|
10312
11780
|
|
|
10313
11781
|
// src/node/index.ts
|
|
10314
|
-
|
|
11782
|
+
_chunkOBBWQW6Kjs.configureNode.call(void 0, );
|
|
11783
|
+
|
|
11784
|
+
|
|
11785
|
+
|
|
11786
|
+
|
|
11787
|
+
|
|
11788
|
+
|
|
11789
|
+
|
|
11790
|
+
|
|
11791
|
+
|
|
10315
11792
|
|
|
10316
11793
|
|
|
10317
11794
|
|
|
@@ -10485,4 +11962,4 @@ _chunkVRZZQPAAjs.configureNode.call(void 0, );
|
|
|
10485
11962
|
|
|
10486
11963
|
|
|
10487
11964
|
|
|
10488
|
-
exports.Attachment = _chunkVRZZQPAAjs.Attachment; exports.AttachmentReference = _chunkVRZZQPAAjs.AttachmentReference; exports.BAGGAGE_HEADER = _chunkVRZZQPAAjs.BAGGAGE_HEADER; exports.BRAINTRUST_CURRENT_SPAN_STORE = _chunkVRZZQPAAjs.BRAINTRUST_CURRENT_SPAN_STORE; exports.BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME = _chunkVRZZQPAAjs.BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME; exports.BRAINTRUST_PARENT_KEY = _chunkVRZZQPAAjs.BRAINTRUST_PARENT_KEY; exports.BaseAttachment = _chunkVRZZQPAAjs.BaseAttachment; exports.BaseExperiment = BaseExperiment; exports.BraintrustLangChainCallbackHandler = _chunkVRZZQPAAjs.BraintrustLangChainCallbackHandler; exports.BraintrustMiddleware = BraintrustMiddleware; exports.BraintrustObservabilityExporter = _chunkVRZZQPAAjs.BraintrustObservabilityExporter; exports.BraintrustState = _chunkVRZZQPAAjs.BraintrustState; exports.BraintrustStream = _chunkVRZZQPAAjs.BraintrustStream; exports.CachedSpanFetcher = CachedSpanFetcher; exports.CodeFunction = CodeFunction; exports.CodePrompt = CodePrompt; exports.ContextManager = _chunkVRZZQPAAjs.ContextManager; exports.DEFAULT_FETCH_BATCH_SIZE = _chunkVRZZQPAAjs.DEFAULT_FETCH_BATCH_SIZE; exports.DEFAULT_MAX_REQUEST_SIZE = _chunkVRZZQPAAjs.DEFAULT_MAX_REQUEST_SIZE; exports.Dataset = _chunkVRZZQPAAjs.Dataset; exports.DatasetPipeline = DatasetPipeline; exports.ERR_PERMALINK = _chunkVRZZQPAAjs.ERR_PERMALINK; exports.Eval = Eval; exports.EvalResultWithSummary = EvalResultWithSummary; exports.Experiment = _chunkVRZZQPAAjs.Experiment; exports.ExternalAttachment = _chunkVRZZQPAAjs.ExternalAttachment; exports.FailedHTTPResponse = _chunkVRZZQPAAjs.FailedHTTPResponse; exports.IDGenerator = _chunkVRZZQPAAjs.IDGenerator; exports.JSONAttachment = _chunkVRZZQPAAjs.JSONAttachment; exports.LEGACY_CACHED_HEADER = _chunkVRZZQPAAjs.LEGACY_CACHED_HEADER; exports.LOGS3_OVERFLOW_REFERENCE_TYPE = _chunkVRZZQPAAjs.LOGS3_OVERFLOW_REFERENCE_TYPE; exports.LazyValue = _chunkVRZZQPAAjs.LazyValue; exports.LocalTrace = LocalTrace; exports.Logger = _chunkVRZZQPAAjs.Logger; exports.LoginInvalidOrgError = _chunkVRZZQPAAjs.LoginInvalidOrgError; exports.NOOP_SPAN = _chunkVRZZQPAAjs.NOOP_SPAN; exports.NOOP_SPAN_PERMALINK = _chunkVRZZQPAAjs.NOOP_SPAN_PERMALINK; exports.NoopSpan = _chunkVRZZQPAAjs.NoopSpan; exports.OTELIDGenerator = _chunkVRZZQPAAjs.OTELIDGenerator; exports.ObjectFetcher = _chunkVRZZQPAAjs.ObjectFetcher; exports.Project = Project2; exports.ProjectNameIdMap = ProjectNameIdMap; exports.Prompt = _chunkVRZZQPAAjs.Prompt; exports.PromptBuilder = PromptBuilder; exports.ReadonlyAttachment = _chunkVRZZQPAAjs.ReadonlyAttachment; exports.ReadonlyExperiment = _chunkVRZZQPAAjs.ReadonlyExperiment; exports.Reporter = Reporter; exports.ScorerBuilder = ScorerBuilder; exports.SpanFetcher = SpanFetcher; exports.SpanImpl = _chunkVRZZQPAAjs.SpanImpl; exports.TRACEPARENT_HEADER = _chunkVRZZQPAAjs.TRACEPARENT_HEADER; exports.TRACESTATE_HEADER = _chunkVRZZQPAAjs.TRACESTATE_HEADER; exports.TestBackgroundLogger = _chunkVRZZQPAAjs.TestBackgroundLogger; exports.ToolBuilder = ToolBuilder; exports.UUIDGenerator = _chunkVRZZQPAAjs.UUIDGenerator; exports.X_CACHED_HEADER = _chunkVRZZQPAAjs.X_CACHED_HEADER; exports._exportsForTestingOnly = _chunkVRZZQPAAjs._exportsForTestingOnly; exports._internalGetGlobalState = _chunkVRZZQPAAjs._internalGetGlobalState; exports._internalIso = _chunkVYNNEKSAjs.isomorph_default; exports._internalSetInitialState = _chunkVRZZQPAAjs._internalSetInitialState; exports.addAzureBlobHeaders = _chunkVRZZQPAAjs.addAzureBlobHeaders; exports.agentAssertionScorer = agentAssertionScorer; exports.braintrustAISDKTelemetry = _chunkVRZZQPAAjs.braintrustAISDKTelemetry; exports.braintrustEveHook = braintrustEveHook; exports.braintrustEveInstrumentation = braintrustEveInstrumentation; exports.braintrustFlueInstrumentation = _chunkVRZZQPAAjs.braintrustFlueInstrumentation; exports.braintrustFlueObserver = _chunkVRZZQPAAjs.braintrustFlueObserver; exports.braintrustStreamChunkSchema = _chunkVRZZQPAAjs.braintrustStreamChunkSchema; exports.buildLocalSummary = buildLocalSummary; exports.configureInstrumentation = _chunkVRZZQPAAjs.configureInstrumentation; exports.constructLogs3OverflowRequest = _chunkVRZZQPAAjs.constructLogs3OverflowRequest; exports.createFinalValuePassThroughStream = _chunkVRZZQPAAjs.createFinalValuePassThroughStream; exports.currentExperiment = _chunkVRZZQPAAjs.currentExperiment; exports.currentLogger = _chunkVRZZQPAAjs.currentLogger; exports.currentSpan = _chunkVRZZQPAAjs.currentSpan; exports.deepCopyEvent = _chunkVRZZQPAAjs.deepCopyEvent; exports.default = exports_exports; exports.defaultErrorScoreHandler = defaultErrorScoreHandler; exports.deserializePlainStringAsJSON = _chunkVRZZQPAAjs.deserializePlainStringAsJSON; exports.devNullWritableStream = _chunkVRZZQPAAjs.devNullWritableStream; exports.evaluatorDefinitionSchema = evaluatorDefinitionSchema; exports.evaluatorDefinitionsSchema = evaluatorDefinitionsSchema; exports.extractTraceContextFromHeaders = _chunkVRZZQPAAjs.extractTraceContextFromHeaders; exports.flush = _chunkVRZZQPAAjs.flush; exports.getContextManager = _chunkVRZZQPAAjs.getContextManager; exports.getIdGenerator = _chunkVRZZQPAAjs.getIdGenerator; exports.getPromptVersions = _chunkVRZZQPAAjs.getPromptVersions; exports.getSpanParentObject = _chunkVRZZQPAAjs.getSpanParentObject; exports.getTemplateRenderer = _chunkVRZZQPAAjs.getTemplateRenderer; exports.graph = graph_framework_exports; exports.init = _chunkVRZZQPAAjs.init; exports.initDataset = _chunkVRZZQPAAjs.initDataset; exports.initExperiment = _chunkVRZZQPAAjs.initExperiment; exports.initFunction = initFunction; exports.initLogger = _chunkVRZZQPAAjs.initLogger; exports.initNodeTestSuite = initNodeTestSuite; exports.injectTraceContext = _chunkVRZZQPAAjs.injectTraceContext; exports.invoke = invoke; exports.isTemplateFormat = _chunkVRZZQPAAjs.isTemplateFormat; exports.loadParameters = _chunkVRZZQPAAjs.loadParameters; exports.loadPrompt = _chunkVRZZQPAAjs.loadPrompt; exports.log = _chunkVRZZQPAAjs.log; exports.logError = _chunkVRZZQPAAjs.logError; exports.login = _chunkVRZZQPAAjs.login; exports.loginToState = _chunkVRZZQPAAjs.loginToState; exports.logs3OverflowUploadSchema = _chunkVRZZQPAAjs.logs3OverflowUploadSchema; exports.newId = _chunkVRZZQPAAjs.newId; exports.parseCachedHeader = _chunkVRZZQPAAjs.parseCachedHeader; exports.parseTemplateFormat = _chunkVRZZQPAAjs.parseTemplateFormat; exports.permalink = _chunkVRZZQPAAjs.permalink; exports.pickLogs3OverflowObjectIds = _chunkVRZZQPAAjs.pickLogs3OverflowObjectIds; exports.projects = projects; exports.promptContentsSchema = promptContentsSchema; exports.promptDefinitionSchema = promptDefinitionSchema; exports.promptDefinitionToPromptData = promptDefinitionToPromptData; exports.promptDefinitionWithToolsSchema = promptDefinitionWithToolsSchema; exports.registerOtelFlush = _chunkVRZZQPAAjs.registerOtelFlush; exports.registerSandbox = registerSandbox; exports.registerTemplatePlugin = _chunkVRZZQPAAjs.registerTemplatePlugin; exports.renderMessage = _chunkVRZZQPAAjs.renderMessage; exports.renderPromptParams = _chunkVRZZQPAAjs.renderPromptParams; exports.renderTemplateContent = _chunkVRZZQPAAjs.renderTemplateContent; exports.reportFailures = reportFailures; exports.runEvaluator = runEvaluator; exports.setFetch = _chunkVRZZQPAAjs.setFetch; exports.setMaskingFunction = _chunkVRZZQPAAjs.setMaskingFunction; exports.spanComponentsToObjectId = _chunkVRZZQPAAjs.spanComponentsToObjectId; exports.startSpan = _chunkVRZZQPAAjs.startSpan; exports.summarize = _chunkVRZZQPAAjs.summarize; exports.templateRegistry = _chunkVRZZQPAAjs.templateRegistry; exports.toolFunctionDefinitionSchema = _chunkVRZZQPAAjs.ToolFunctionDefinition; exports.traceable = _chunkVRZZQPAAjs.traceable; exports.traced = _chunkVRZZQPAAjs.traced; exports.updateSpan = _chunkVRZZQPAAjs.updateSpan; exports.uploadLogs3OverflowPayload = _chunkVRZZQPAAjs.uploadLogs3OverflowPayload; exports.utf8ByteLength = _chunkVRZZQPAAjs.utf8ByteLength; exports.withCurrent = _chunkVRZZQPAAjs.withCurrent; exports.withDataset = _chunkVRZZQPAAjs.withDataset; exports.withExperiment = _chunkVRZZQPAAjs.withExperiment; exports.withLogger = _chunkVRZZQPAAjs.withLogger; exports.withParent = _chunkVRZZQPAAjs.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.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 = _chunkVRZZQPAAjs.wrapMastraAgent; exports.wrapMistral = wrapMistral; exports.wrapOpenAI = wrapOpenAI; exports.wrapOpenAICodexSDK = wrapOpenAICodexSDK; exports.wrapOpenAIv4 = wrapOpenAIv4; exports.wrapOpenRouter = wrapOpenRouter; exports.wrapOpenRouterAgent = wrapOpenRouterAgent; exports.wrapPiCodingAgentSDK = wrapPiCodingAgentSDK; exports.wrapStrandsAgentSDK = wrapStrandsAgentSDK; exports.wrapTraced = _chunkVRZZQPAAjs.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;
|