braintrust 3.20.0 → 3.21.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/NOTICE +20 -0
- package/README.md +2 -0
- package/dev/dist/index.d.mts +309 -199
- package/dev/dist/index.d.ts +309 -199
- package/dev/dist/index.js +2826 -983
- package/dev/dist/index.mjs +2286 -443
- package/dist/apply-auto-instrumentation.js +781 -199
- package/dist/apply-auto-instrumentation.mjs +588 -6
- package/dist/auto-instrumentations/bundler/esbuild.cjs +594 -2
- package/dist/auto-instrumentations/bundler/esbuild.d.mts +2 -2
- package/dist/auto-instrumentations/bundler/esbuild.d.ts +2 -2
- package/dist/auto-instrumentations/bundler/esbuild.mjs +3 -3
- package/dist/auto-instrumentations/bundler/next.cjs +594 -2
- package/dist/auto-instrumentations/bundler/next.mjs +4 -4
- package/dist/auto-instrumentations/bundler/rollup.cjs +594 -2
- package/dist/auto-instrumentations/bundler/rollup.d.mts +2 -2
- package/dist/auto-instrumentations/bundler/rollup.d.ts +2 -2
- package/dist/auto-instrumentations/bundler/rollup.mjs +3 -3
- package/dist/auto-instrumentations/bundler/vite.cjs +594 -2
- package/dist/auto-instrumentations/bundler/vite.d.mts +2 -2
- package/dist/auto-instrumentations/bundler/vite.d.ts +2 -2
- package/dist/auto-instrumentations/bundler/vite.mjs +3 -3
- package/dist/auto-instrumentations/bundler/webpack-loader.cjs +593 -9
- package/dist/auto-instrumentations/bundler/webpack-loader.d.ts +68 -1
- package/dist/auto-instrumentations/bundler/webpack.cjs +594 -2
- package/dist/auto-instrumentations/bundler/webpack.d.mts +2 -2
- package/dist/auto-instrumentations/bundler/webpack.d.ts +2 -2
- package/dist/auto-instrumentations/bundler/webpack.mjs +4 -4
- package/dist/auto-instrumentations/{chunk-W4E36GIW.mjs → chunk-BRQX23KL.mjs} +16 -0
- package/dist/auto-instrumentations/chunk-M6DLIJ2Z.mjs +784 -0
- package/dist/auto-instrumentations/{chunk-K74TZGGM.mjs → chunk-T6J4C7LX.mjs} +1 -1
- package/dist/auto-instrumentations/{chunk-S4374IP6.mjs → chunk-TKRPRPGD.mjs} +4 -6
- package/dist/auto-instrumentations/chunk-VT6DDNKM.mjs +856 -0
- package/dist/auto-instrumentations/hook.mjs +749 -45
- package/dist/auto-instrumentations/index.cjs +16 -0
- package/dist/auto-instrumentations/index.d.mts +2 -3
- package/dist/auto-instrumentations/index.d.ts +2 -3
- package/dist/auto-instrumentations/index.mjs +1 -1
- package/dist/auto-instrumentations/loader/cjs-patch.cjs +578 -4
- package/dist/auto-instrumentations/loader/cjs-patch.d.mts +1 -1
- package/dist/auto-instrumentations/loader/cjs-patch.d.ts +1 -1
- package/dist/auto-instrumentations/loader/cjs-patch.mjs +3 -7
- package/dist/auto-instrumentations/loader/esm-hook.mjs +2 -6
- package/dist/auto-instrumentations/{plugin-D7nDswtC.d.mts → plugin-D0KHwSJv.d.mts} +1 -1
- package/dist/auto-instrumentations/{plugin-D7nDswtC.d.ts → plugin-G6fgxk1b.d.ts} +1 -1
- package/dist/auto-instrumentations/types-RNPaKi9o.d.mts +70 -0
- package/dist/auto-instrumentations/types-RNPaKi9o.d.ts +70 -0
- package/dist/browser.d.mts +1357 -847
- package/dist/browser.d.ts +1357 -847
- package/dist/browser.js +2726 -469
- package/dist/browser.mjs +2726 -469
- package/dist/{chunk-LPC4W2WX.js → chunk-BFGIH2ZJ.js} +4 -0
- package/dist/{chunk-POCCIJAL.js → chunk-FY7DAKA5.js} +3141 -1269
- package/dist/{chunk-Y7W7WP6H.mjs → chunk-KMGUTPB7.mjs} +4 -0
- package/dist/{chunk-F73OMF66.mjs → chunk-O2P765XK.mjs} +2391 -519
- package/dist/cli.js +2260 -408
- package/dist/edge-light.d.mts +1 -1
- package/dist/edge-light.d.ts +1 -1
- package/dist/edge-light.js +2726 -469
- package/dist/edge-light.mjs +2726 -469
- package/dist/index.d.mts +1837 -1327
- package/dist/index.d.ts +1837 -1327
- package/dist/index.js +752 -353
- package/dist/index.mjs +445 -46
- package/dist/instrumentation/index.d.mts +107 -19
- package/dist/instrumentation/index.d.ts +107 -19
- package/dist/instrumentation/index.js +2337 -509
- package/dist/instrumentation/index.mjs +2337 -509
- package/dist/vitest-evals-reporter.js +16 -16
- package/dist/vitest-evals-reporter.mjs +2 -2
- package/dist/workerd.d.mts +1 -1
- package/dist/workerd.d.ts +1 -1
- package/dist/workerd.js +2726 -469
- package/dist/workerd.mjs +2726 -469
- package/licenses/import-in-the-middle/LICENSE +201 -0
- package/licenses/import-in-the-middle/LICENSE-3rdparty.csv +4 -0
- package/licenses/import-in-the-middle/NOTICE +34 -0
- package/licenses/orchestrion-js/LICENSE +202 -0
- package/licenses/orchestrion-js/LICENSE-3rdparty.csv +8 -0
- package/licenses/orchestrion-js/NOTICE +3 -0
- package/licenses/require-in-the-middle/LICENSE +23 -0
- package/package.json +13 -4
- package/util/dist/index.d.mts +1 -0
- package/util/dist/index.d.ts +1 -0
- package/util/dist/index.js +4 -4
- package/util/dist/index.mjs +2 -2
- package/dist/auto-instrumentations/chunk-J57YF7WS.mjs +0 -208
- package/dist/auto-instrumentations/chunk-QFMACSOL.mjs +0 -280
package/dist/index.js
CHANGED
|
@@ -129,7 +129,6 @@
|
|
|
129
129
|
|
|
130
130
|
|
|
131
131
|
|
|
132
|
-
var _chunkPOCCIJALjs = require('./chunk-POCCIJAL.js');
|
|
133
132
|
|
|
134
133
|
|
|
135
134
|
|
|
@@ -138,6 +137,7 @@ var _chunkPOCCIJALjs = require('./chunk-POCCIJAL.js');
|
|
|
138
137
|
|
|
139
138
|
|
|
140
139
|
|
|
140
|
+
var _chunkFY7DAKA5js = require('./chunk-FY7DAKA5.js');
|
|
141
141
|
|
|
142
142
|
|
|
143
143
|
|
|
@@ -152,141 +152,157 @@ var _chunkPOCCIJALjs = require('./chunk-POCCIJAL.js');
|
|
|
152
152
|
|
|
153
153
|
|
|
154
154
|
|
|
155
|
-
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
var _chunkBFGIH2ZJjs = require('./chunk-BFGIH2ZJ.js');
|
|
156
164
|
|
|
157
165
|
// src/exports.ts
|
|
158
166
|
var exports_exports = {};
|
|
159
|
-
|
|
160
|
-
Attachment: () =>
|
|
161
|
-
AttachmentReference: () =>
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
167
|
+
_chunkBFGIH2ZJjs.__export.call(void 0, exports_exports, {
|
|
168
|
+
Attachment: () => _chunkFY7DAKA5js.Attachment,
|
|
169
|
+
AttachmentReference: () => _chunkFY7DAKA5js.AttachmentReference,
|
|
170
|
+
BAGGAGE_HEADER: () => _chunkFY7DAKA5js.BAGGAGE_HEADER,
|
|
171
|
+
BRAINTRUST_CURRENT_SPAN_STORE: () => _chunkFY7DAKA5js.BRAINTRUST_CURRENT_SPAN_STORE,
|
|
172
|
+
BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME: () => _chunkFY7DAKA5js.BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME,
|
|
173
|
+
BRAINTRUST_PARENT_KEY: () => _chunkFY7DAKA5js.BRAINTRUST_PARENT_KEY,
|
|
174
|
+
BaseAttachment: () => _chunkFY7DAKA5js.BaseAttachment,
|
|
165
175
|
BaseExperiment: () => BaseExperiment,
|
|
166
|
-
BraintrustLangChainCallbackHandler: () =>
|
|
176
|
+
BraintrustLangChainCallbackHandler: () => _chunkFY7DAKA5js.BraintrustLangChainCallbackHandler,
|
|
167
177
|
BraintrustMiddleware: () => BraintrustMiddleware,
|
|
168
|
-
BraintrustObservabilityExporter: () =>
|
|
169
|
-
BraintrustState: () =>
|
|
170
|
-
BraintrustStream: () =>
|
|
178
|
+
BraintrustObservabilityExporter: () => _chunkFY7DAKA5js.BraintrustObservabilityExporter,
|
|
179
|
+
BraintrustState: () => _chunkFY7DAKA5js.BraintrustState,
|
|
180
|
+
BraintrustStream: () => _chunkFY7DAKA5js.BraintrustStream,
|
|
171
181
|
CachedSpanFetcher: () => CachedSpanFetcher,
|
|
172
182
|
CodeFunction: () => CodeFunction,
|
|
173
183
|
CodePrompt: () => CodePrompt,
|
|
174
|
-
ContextManager: () =>
|
|
175
|
-
DEFAULT_FETCH_BATCH_SIZE: () =>
|
|
176
|
-
DEFAULT_MAX_REQUEST_SIZE: () =>
|
|
177
|
-
Dataset: () =>
|
|
184
|
+
ContextManager: () => _chunkFY7DAKA5js.ContextManager,
|
|
185
|
+
DEFAULT_FETCH_BATCH_SIZE: () => _chunkFY7DAKA5js.DEFAULT_FETCH_BATCH_SIZE,
|
|
186
|
+
DEFAULT_MAX_REQUEST_SIZE: () => _chunkFY7DAKA5js.DEFAULT_MAX_REQUEST_SIZE,
|
|
187
|
+
Dataset: () => _chunkFY7DAKA5js.Dataset,
|
|
178
188
|
DatasetPipeline: () => DatasetPipeline,
|
|
179
|
-
ERR_PERMALINK: () =>
|
|
189
|
+
ERR_PERMALINK: () => _chunkFY7DAKA5js.ERR_PERMALINK,
|
|
180
190
|
Eval: () => Eval,
|
|
181
191
|
EvalResultWithSummary: () => EvalResultWithSummary,
|
|
182
|
-
Experiment: () =>
|
|
183
|
-
ExternalAttachment: () =>
|
|
184
|
-
FailedHTTPResponse: () =>
|
|
185
|
-
IDGenerator: () =>
|
|
186
|
-
JSONAttachment: () =>
|
|
187
|
-
LEGACY_CACHED_HEADER: () =>
|
|
188
|
-
LOGS3_OVERFLOW_REFERENCE_TYPE: () =>
|
|
189
|
-
LazyValue: () =>
|
|
192
|
+
Experiment: () => _chunkFY7DAKA5js.Experiment,
|
|
193
|
+
ExternalAttachment: () => _chunkFY7DAKA5js.ExternalAttachment,
|
|
194
|
+
FailedHTTPResponse: () => _chunkFY7DAKA5js.FailedHTTPResponse,
|
|
195
|
+
IDGenerator: () => _chunkFY7DAKA5js.IDGenerator,
|
|
196
|
+
JSONAttachment: () => _chunkFY7DAKA5js.JSONAttachment,
|
|
197
|
+
LEGACY_CACHED_HEADER: () => _chunkFY7DAKA5js.LEGACY_CACHED_HEADER,
|
|
198
|
+
LOGS3_OVERFLOW_REFERENCE_TYPE: () => _chunkFY7DAKA5js.LOGS3_OVERFLOW_REFERENCE_TYPE,
|
|
199
|
+
LazyValue: () => _chunkFY7DAKA5js.LazyValue,
|
|
190
200
|
LocalTrace: () => LocalTrace,
|
|
191
|
-
Logger: () =>
|
|
192
|
-
LoginInvalidOrgError: () =>
|
|
193
|
-
NOOP_SPAN: () =>
|
|
194
|
-
NOOP_SPAN_PERMALINK: () =>
|
|
195
|
-
NoopSpan: () =>
|
|
196
|
-
|
|
201
|
+
Logger: () => _chunkFY7DAKA5js.Logger,
|
|
202
|
+
LoginInvalidOrgError: () => _chunkFY7DAKA5js.LoginInvalidOrgError,
|
|
203
|
+
NOOP_SPAN: () => _chunkFY7DAKA5js.NOOP_SPAN,
|
|
204
|
+
NOOP_SPAN_PERMALINK: () => _chunkFY7DAKA5js.NOOP_SPAN_PERMALINK,
|
|
205
|
+
NoopSpan: () => _chunkFY7DAKA5js.NoopSpan,
|
|
206
|
+
OTELIDGenerator: () => _chunkFY7DAKA5js.OTELIDGenerator,
|
|
207
|
+
ObjectFetcher: () => _chunkFY7DAKA5js.ObjectFetcher,
|
|
197
208
|
Project: () => Project2,
|
|
198
209
|
ProjectNameIdMap: () => ProjectNameIdMap,
|
|
199
|
-
Prompt: () =>
|
|
210
|
+
Prompt: () => _chunkFY7DAKA5js.Prompt,
|
|
200
211
|
PromptBuilder: () => PromptBuilder,
|
|
201
|
-
ReadonlyAttachment: () =>
|
|
202
|
-
ReadonlyExperiment: () =>
|
|
212
|
+
ReadonlyAttachment: () => _chunkFY7DAKA5js.ReadonlyAttachment,
|
|
213
|
+
ReadonlyExperiment: () => _chunkFY7DAKA5js.ReadonlyExperiment,
|
|
203
214
|
Reporter: () => Reporter,
|
|
204
215
|
ScorerBuilder: () => ScorerBuilder,
|
|
205
216
|
SpanFetcher: () => SpanFetcher,
|
|
206
|
-
SpanImpl: () =>
|
|
207
|
-
|
|
217
|
+
SpanImpl: () => _chunkFY7DAKA5js.SpanImpl,
|
|
218
|
+
TRACEPARENT_HEADER: () => _chunkFY7DAKA5js.TRACEPARENT_HEADER,
|
|
219
|
+
TRACESTATE_HEADER: () => _chunkFY7DAKA5js.TRACESTATE_HEADER,
|
|
220
|
+
TestBackgroundLogger: () => _chunkFY7DAKA5js.TestBackgroundLogger,
|
|
208
221
|
ToolBuilder: () => ToolBuilder,
|
|
209
|
-
UUIDGenerator: () =>
|
|
210
|
-
X_CACHED_HEADER: () =>
|
|
211
|
-
_exportsForTestingOnly: () =>
|
|
212
|
-
_internalGetGlobalState: () =>
|
|
213
|
-
_internalIso: () =>
|
|
214
|
-
_internalSetInitialState: () =>
|
|
215
|
-
addAzureBlobHeaders: () =>
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
222
|
+
UUIDGenerator: () => _chunkFY7DAKA5js.UUIDGenerator,
|
|
223
|
+
X_CACHED_HEADER: () => _chunkFY7DAKA5js.X_CACHED_HEADER,
|
|
224
|
+
_exportsForTestingOnly: () => _chunkFY7DAKA5js._exportsForTestingOnly,
|
|
225
|
+
_internalGetGlobalState: () => _chunkFY7DAKA5js._internalGetGlobalState,
|
|
226
|
+
_internalIso: () => _chunkBFGIH2ZJjs.isomorph_default,
|
|
227
|
+
_internalSetInitialState: () => _chunkFY7DAKA5js._internalSetInitialState,
|
|
228
|
+
addAzureBlobHeaders: () => _chunkFY7DAKA5js.addAzureBlobHeaders,
|
|
229
|
+
agentAssertionScorer: () => agentAssertionScorer,
|
|
230
|
+
braintrustAISDKTelemetry: () => _chunkFY7DAKA5js.braintrustAISDKTelemetry,
|
|
231
|
+
braintrustFlueInstrumentation: () => _chunkFY7DAKA5js.braintrustFlueInstrumentation,
|
|
232
|
+
braintrustFlueObserver: () => _chunkFY7DAKA5js.braintrustFlueObserver,
|
|
233
|
+
braintrustStreamChunkSchema: () => _chunkFY7DAKA5js.braintrustStreamChunkSchema,
|
|
220
234
|
buildLocalSummary: () => buildLocalSummary,
|
|
221
|
-
configureInstrumentation: () =>
|
|
222
|
-
constructLogs3OverflowRequest: () =>
|
|
223
|
-
createFinalValuePassThroughStream: () =>
|
|
224
|
-
currentExperiment: () =>
|
|
225
|
-
currentLogger: () =>
|
|
226
|
-
currentSpan: () =>
|
|
227
|
-
deepCopyEvent: () =>
|
|
235
|
+
configureInstrumentation: () => _chunkFY7DAKA5js.configureInstrumentation,
|
|
236
|
+
constructLogs3OverflowRequest: () => _chunkFY7DAKA5js.constructLogs3OverflowRequest,
|
|
237
|
+
createFinalValuePassThroughStream: () => _chunkFY7DAKA5js.createFinalValuePassThroughStream,
|
|
238
|
+
currentExperiment: () => _chunkFY7DAKA5js.currentExperiment,
|
|
239
|
+
currentLogger: () => _chunkFY7DAKA5js.currentLogger,
|
|
240
|
+
currentSpan: () => _chunkFY7DAKA5js.currentSpan,
|
|
241
|
+
deepCopyEvent: () => _chunkFY7DAKA5js.deepCopyEvent,
|
|
228
242
|
defaultErrorScoreHandler: () => defaultErrorScoreHandler,
|
|
229
|
-
deserializePlainStringAsJSON: () =>
|
|
230
|
-
devNullWritableStream: () =>
|
|
243
|
+
deserializePlainStringAsJSON: () => _chunkFY7DAKA5js.deserializePlainStringAsJSON,
|
|
244
|
+
devNullWritableStream: () => _chunkFY7DAKA5js.devNullWritableStream,
|
|
231
245
|
evaluatorDefinitionSchema: () => evaluatorDefinitionSchema,
|
|
232
246
|
evaluatorDefinitionsSchema: () => evaluatorDefinitionsSchema,
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
247
|
+
extractTraceContextFromHeaders: () => _chunkFY7DAKA5js.extractTraceContextFromHeaders,
|
|
248
|
+
flush: () => _chunkFY7DAKA5js.flush,
|
|
249
|
+
getContextManager: () => _chunkFY7DAKA5js.getContextManager,
|
|
250
|
+
getIdGenerator: () => _chunkFY7DAKA5js.getIdGenerator,
|
|
251
|
+
getPromptVersions: () => _chunkFY7DAKA5js.getPromptVersions,
|
|
252
|
+
getSpanParentObject: () => _chunkFY7DAKA5js.getSpanParentObject,
|
|
253
|
+
getTemplateRenderer: () => _chunkFY7DAKA5js.getTemplateRenderer,
|
|
239
254
|
graph: () => graph_framework_exports,
|
|
240
|
-
init: () =>
|
|
241
|
-
initDataset: () =>
|
|
242
|
-
initExperiment: () =>
|
|
255
|
+
init: () => _chunkFY7DAKA5js.init,
|
|
256
|
+
initDataset: () => _chunkFY7DAKA5js.initDataset,
|
|
257
|
+
initExperiment: () => _chunkFY7DAKA5js.initExperiment,
|
|
243
258
|
initFunction: () => initFunction,
|
|
244
|
-
initLogger: () =>
|
|
259
|
+
initLogger: () => _chunkFY7DAKA5js.initLogger,
|
|
245
260
|
initNodeTestSuite: () => initNodeTestSuite,
|
|
261
|
+
injectTraceContext: () => _chunkFY7DAKA5js.injectTraceContext,
|
|
246
262
|
invoke: () => invoke,
|
|
247
|
-
isTemplateFormat: () =>
|
|
248
|
-
loadParameters: () =>
|
|
249
|
-
loadPrompt: () =>
|
|
250
|
-
log: () =>
|
|
251
|
-
logError: () =>
|
|
252
|
-
login: () =>
|
|
253
|
-
loginToState: () =>
|
|
254
|
-
logs3OverflowUploadSchema: () =>
|
|
255
|
-
newId: () =>
|
|
256
|
-
parseCachedHeader: () =>
|
|
257
|
-
parseTemplateFormat: () =>
|
|
258
|
-
permalink: () =>
|
|
259
|
-
pickLogs3OverflowObjectIds: () =>
|
|
263
|
+
isTemplateFormat: () => _chunkFY7DAKA5js.isTemplateFormat,
|
|
264
|
+
loadParameters: () => _chunkFY7DAKA5js.loadParameters,
|
|
265
|
+
loadPrompt: () => _chunkFY7DAKA5js.loadPrompt,
|
|
266
|
+
log: () => _chunkFY7DAKA5js.log,
|
|
267
|
+
logError: () => _chunkFY7DAKA5js.logError,
|
|
268
|
+
login: () => _chunkFY7DAKA5js.login,
|
|
269
|
+
loginToState: () => _chunkFY7DAKA5js.loginToState,
|
|
270
|
+
logs3OverflowUploadSchema: () => _chunkFY7DAKA5js.logs3OverflowUploadSchema,
|
|
271
|
+
newId: () => _chunkFY7DAKA5js.newId,
|
|
272
|
+
parseCachedHeader: () => _chunkFY7DAKA5js.parseCachedHeader,
|
|
273
|
+
parseTemplateFormat: () => _chunkFY7DAKA5js.parseTemplateFormat,
|
|
274
|
+
permalink: () => _chunkFY7DAKA5js.permalink,
|
|
275
|
+
pickLogs3OverflowObjectIds: () => _chunkFY7DAKA5js.pickLogs3OverflowObjectIds,
|
|
260
276
|
projects: () => projects,
|
|
261
277
|
promptContentsSchema: () => promptContentsSchema,
|
|
262
278
|
promptDefinitionSchema: () => promptDefinitionSchema,
|
|
263
279
|
promptDefinitionToPromptData: () => promptDefinitionToPromptData,
|
|
264
280
|
promptDefinitionWithToolsSchema: () => promptDefinitionWithToolsSchema,
|
|
265
|
-
registerOtelFlush: () =>
|
|
281
|
+
registerOtelFlush: () => _chunkFY7DAKA5js.registerOtelFlush,
|
|
266
282
|
registerSandbox: () => registerSandbox,
|
|
267
|
-
registerTemplatePlugin: () =>
|
|
268
|
-
renderMessage: () =>
|
|
269
|
-
renderPromptParams: () =>
|
|
270
|
-
renderTemplateContent: () =>
|
|
283
|
+
registerTemplatePlugin: () => _chunkFY7DAKA5js.registerTemplatePlugin,
|
|
284
|
+
renderMessage: () => _chunkFY7DAKA5js.renderMessage,
|
|
285
|
+
renderPromptParams: () => _chunkFY7DAKA5js.renderPromptParams,
|
|
286
|
+
renderTemplateContent: () => _chunkFY7DAKA5js.renderTemplateContent,
|
|
271
287
|
reportFailures: () => reportFailures,
|
|
272
288
|
runEvaluator: () => runEvaluator,
|
|
273
|
-
setFetch: () =>
|
|
274
|
-
setMaskingFunction: () =>
|
|
275
|
-
spanComponentsToObjectId: () =>
|
|
276
|
-
startSpan: () =>
|
|
277
|
-
summarize: () =>
|
|
278
|
-
templateRegistry: () =>
|
|
279
|
-
toolFunctionDefinitionSchema: () =>
|
|
280
|
-
traceable: () =>
|
|
281
|
-
traced: () =>
|
|
282
|
-
updateSpan: () =>
|
|
283
|
-
uploadLogs3OverflowPayload: () =>
|
|
284
|
-
utf8ByteLength: () =>
|
|
285
|
-
withCurrent: () =>
|
|
286
|
-
withDataset: () =>
|
|
287
|
-
withExperiment: () =>
|
|
288
|
-
withLogger: () =>
|
|
289
|
-
withParent: () =>
|
|
289
|
+
setFetch: () => _chunkFY7DAKA5js.setFetch,
|
|
290
|
+
setMaskingFunction: () => _chunkFY7DAKA5js.setMaskingFunction,
|
|
291
|
+
spanComponentsToObjectId: () => _chunkFY7DAKA5js.spanComponentsToObjectId,
|
|
292
|
+
startSpan: () => _chunkFY7DAKA5js.startSpan,
|
|
293
|
+
summarize: () => _chunkFY7DAKA5js.summarize,
|
|
294
|
+
templateRegistry: () => _chunkFY7DAKA5js.templateRegistry,
|
|
295
|
+
toolFunctionDefinitionSchema: () => _chunkFY7DAKA5js.ToolFunctionDefinition,
|
|
296
|
+
traceable: () => _chunkFY7DAKA5js.traceable,
|
|
297
|
+
traced: () => _chunkFY7DAKA5js.traced,
|
|
298
|
+
updateSpan: () => _chunkFY7DAKA5js.updateSpan,
|
|
299
|
+
uploadLogs3OverflowPayload: () => _chunkFY7DAKA5js.uploadLogs3OverflowPayload,
|
|
300
|
+
utf8ByteLength: () => _chunkFY7DAKA5js.utf8ByteLength,
|
|
301
|
+
withCurrent: () => _chunkFY7DAKA5js.withCurrent,
|
|
302
|
+
withDataset: () => _chunkFY7DAKA5js.withDataset,
|
|
303
|
+
withExperiment: () => _chunkFY7DAKA5js.withExperiment,
|
|
304
|
+
withLogger: () => _chunkFY7DAKA5js.withLogger,
|
|
305
|
+
withParent: () => _chunkFY7DAKA5js.withParent,
|
|
290
306
|
wrapAISDK: () => wrapAISDK,
|
|
291
307
|
wrapAISDKModel: () => wrapAISDKModel,
|
|
292
308
|
wrapAgentClass: () => wrapAgentClass,
|
|
@@ -301,7 +317,7 @@ _chunkLPC4W2WXjs.__export.call(void 0, exports_exports, {
|
|
|
301
317
|
wrapGoogleGenAI: () => wrapGoogleGenAI,
|
|
302
318
|
wrapGroq: () => wrapGroq,
|
|
303
319
|
wrapHuggingFace: () => wrapHuggingFace,
|
|
304
|
-
wrapMastraAgent: () =>
|
|
320
|
+
wrapMastraAgent: () => _chunkFY7DAKA5js.wrapMastraAgent,
|
|
305
321
|
wrapMistral: () => wrapMistral,
|
|
306
322
|
wrapOpenAI: () => wrapOpenAI,
|
|
307
323
|
wrapOpenAICodexSDK: () => wrapOpenAICodexSDK,
|
|
@@ -310,7 +326,7 @@ _chunkLPC4W2WXjs.__export.call(void 0, exports_exports, {
|
|
|
310
326
|
wrapOpenRouterAgent: () => wrapOpenRouterAgent,
|
|
311
327
|
wrapPiCodingAgentSDK: () => wrapPiCodingAgentSDK,
|
|
312
328
|
wrapStrandsAgentSDK: () => wrapStrandsAgentSDK,
|
|
313
|
-
wrapTraced: () =>
|
|
329
|
+
wrapTraced: () => _chunkFY7DAKA5js.wrapTraced,
|
|
314
330
|
wrapVitest: () => wrapVitest
|
|
315
331
|
});
|
|
316
332
|
|
|
@@ -318,7 +334,7 @@ _chunkLPC4W2WXjs.__export.call(void 0, exports_exports, {
|
|
|
318
334
|
var _v3 = require('zod/v3');
|
|
319
335
|
var SANDBOX_GROUP_NAME_METADATA_KEY = "_bt_sandbox_group_name";
|
|
320
336
|
async function registerSandbox(options) {
|
|
321
|
-
const state = _nullishCoalesce(options.state, () => (
|
|
337
|
+
const state = _nullishCoalesce(options.state, () => ( _chunkFY7DAKA5js._internalGetGlobalState.call(void 0, )));
|
|
322
338
|
await state.login({
|
|
323
339
|
apiKey: options.apiKey,
|
|
324
340
|
appUrl: options.appUrl,
|
|
@@ -359,7 +375,7 @@ async function registerSandbox(options) {
|
|
|
359
375
|
evaluatorDefinitions
|
|
360
376
|
)) {
|
|
361
377
|
const functionName = evalName;
|
|
362
|
-
const functionSlug =
|
|
378
|
+
const functionSlug = _chunkFY7DAKA5js.slugify.call(void 0, evalName, { lower: true, strict: true });
|
|
363
379
|
const functionDef = {
|
|
364
380
|
project_id: projectId,
|
|
365
381
|
org_name: state.orgName,
|
|
@@ -430,7 +446,7 @@ async function invoke(args) {
|
|
|
430
446
|
projectId,
|
|
431
447
|
...functionIdArgs
|
|
432
448
|
} = args;
|
|
433
|
-
const state = _nullishCoalesce(stateArg, () => (
|
|
449
|
+
const state = _nullishCoalesce(stateArg, () => ( _chunkFY7DAKA5js._internalGetGlobalState.call(void 0, )));
|
|
434
450
|
await state.login({
|
|
435
451
|
orgName,
|
|
436
452
|
apiKey,
|
|
@@ -438,8 +454,8 @@ async function invoke(args) {
|
|
|
438
454
|
forceLogin,
|
|
439
455
|
fetch
|
|
440
456
|
});
|
|
441
|
-
const parent = parentArg ? typeof parentArg === "string" ? parentArg : await parentArg.export() : await
|
|
442
|
-
const functionId =
|
|
457
|
+
const parent = parentArg ? typeof parentArg === "string" ? parentArg : await parentArg.export() : await _chunkFY7DAKA5js.getSpanParentObject.call(void 0, ).export();
|
|
458
|
+
const functionId = _chunkFY7DAKA5js.FunctionId.safeParse({
|
|
443
459
|
function_id: functionIdArgs.function_id,
|
|
444
460
|
project_name: functionIdArgs.projectName,
|
|
445
461
|
slug: functionIdArgs.slug,
|
|
@@ -482,7 +498,7 @@ async function invoke(args) {
|
|
|
482
498
|
if (!resp.body) {
|
|
483
499
|
throw new Error("Received empty stream body");
|
|
484
500
|
}
|
|
485
|
-
return new (0,
|
|
501
|
+
return new (0, _chunkFY7DAKA5js.BraintrustStream)(resp.body);
|
|
486
502
|
} else {
|
|
487
503
|
const data = await resp.json();
|
|
488
504
|
return schema ? schema.parse(data) : data;
|
|
@@ -494,7 +510,7 @@ function initFunction({
|
|
|
494
510
|
version,
|
|
495
511
|
state
|
|
496
512
|
}) {
|
|
497
|
-
const s = _nullishCoalesce(state, () => (
|
|
513
|
+
const s = _nullishCoalesce(state, () => ( _chunkFY7DAKA5js._internalGetGlobalState.call(void 0, )));
|
|
498
514
|
_optionalChain([s, 'optionalAccess', _2 => _2.spanCache, 'optionalAccess', _3 => _3.disable, 'call', _4 => _4()]);
|
|
499
515
|
const f = async (input) => {
|
|
500
516
|
return await invoke({
|
|
@@ -572,22 +588,22 @@ function responsesProxy(openai) {
|
|
|
572
588
|
if (name === "create" && typeof target.create === "function") {
|
|
573
589
|
return wrapResponsesAsync(
|
|
574
590
|
target.create.bind(target),
|
|
575
|
-
|
|
591
|
+
_chunkBFGIH2ZJjs.openAIChannels.responsesCreate
|
|
576
592
|
);
|
|
577
593
|
} else if (name === "stream" && typeof target.stream === "function") {
|
|
578
594
|
return wrapResponsesSyncStream(
|
|
579
595
|
target.stream.bind(target),
|
|
580
|
-
|
|
596
|
+
_chunkBFGIH2ZJjs.openAIChannels.responsesStream
|
|
581
597
|
);
|
|
582
598
|
} else if (name === "parse" && typeof target.parse === "function") {
|
|
583
599
|
return wrapResponsesAsync(
|
|
584
600
|
target.parse.bind(target),
|
|
585
|
-
|
|
601
|
+
_chunkBFGIH2ZJjs.openAIChannels.responsesParse
|
|
586
602
|
);
|
|
587
603
|
} else if (name === "compact" && typeof target.compact === "function") {
|
|
588
604
|
return wrapResponsesAsync(
|
|
589
605
|
target.compact.bind(target),
|
|
590
|
-
|
|
606
|
+
_chunkBFGIH2ZJjs.openAIChannels.responsesCompact
|
|
591
607
|
);
|
|
592
608
|
}
|
|
593
609
|
return Reflect.get(target, name, receiver);
|
|
@@ -731,7 +747,7 @@ function wrapBetaChatCompletionParse(completion) {
|
|
|
731
747
|
const { span_info, params } = splitSpanInfo(
|
|
732
748
|
allParams
|
|
733
749
|
);
|
|
734
|
-
return
|
|
750
|
+
return _chunkBFGIH2ZJjs.openAIChannels.betaChatCompletionsParse.tracePromise(
|
|
735
751
|
async () => await completion(params),
|
|
736
752
|
{ arguments: [params], span_info }
|
|
737
753
|
);
|
|
@@ -742,7 +758,7 @@ function wrapBetaChatCompletionStream(completion) {
|
|
|
742
758
|
const { span_info, params } = splitSpanInfo(
|
|
743
759
|
allParams
|
|
744
760
|
);
|
|
745
|
-
return
|
|
761
|
+
return _chunkBFGIH2ZJjs.openAIChannels.betaChatCompletionsStream.traceSync(
|
|
746
762
|
() => completion(params),
|
|
747
763
|
{ arguments: [params], span_info }
|
|
748
764
|
);
|
|
@@ -758,7 +774,7 @@ function wrapChatCompletion(completion) {
|
|
|
758
774
|
if (!executionPromise) {
|
|
759
775
|
executionPromise = (async () => {
|
|
760
776
|
const traceContext = createChannelContext(
|
|
761
|
-
|
|
777
|
+
_chunkBFGIH2ZJjs.openAIChannels.chatCompletionsCreate,
|
|
762
778
|
params,
|
|
763
779
|
span_info
|
|
764
780
|
);
|
|
@@ -768,7 +784,7 @@ function wrapChatCompletion(completion) {
|
|
|
768
784
|
options
|
|
769
785
|
);
|
|
770
786
|
const { data: data2, response: response2 } = await tracePromiseWithResponse(
|
|
771
|
-
|
|
787
|
+
_chunkBFGIH2ZJjs.openAIChannels.chatCompletionsCreate,
|
|
772
788
|
traceContext,
|
|
773
789
|
completionPromise
|
|
774
790
|
);
|
|
@@ -779,7 +795,7 @@ function wrapChatCompletion(completion) {
|
|
|
779
795
|
options
|
|
780
796
|
);
|
|
781
797
|
const { data, response } = await tracePromiseWithResponse(
|
|
782
|
-
|
|
798
|
+
_chunkBFGIH2ZJjs.openAIChannels.chatCompletionsCreate,
|
|
783
799
|
traceContext,
|
|
784
800
|
completionResponse
|
|
785
801
|
);
|
|
@@ -822,8 +838,8 @@ function wrapApiCreateWithChannel(create, channel) {
|
|
|
822
838
|
return createLazyAPIPromise(ensureExecuted);
|
|
823
839
|
};
|
|
824
840
|
}
|
|
825
|
-
var wrapEmbeddings = (create) => wrapApiCreateWithChannel(create,
|
|
826
|
-
var wrapModerations = (create) => wrapApiCreateWithChannel(create,
|
|
841
|
+
var wrapEmbeddings = (create) => wrapApiCreateWithChannel(create, _chunkBFGIH2ZJjs.openAIChannels.embeddingsCreate);
|
|
842
|
+
var wrapModerations = (create) => wrapApiCreateWithChannel(create, _chunkBFGIH2ZJjs.openAIChannels.moderationsCreate);
|
|
827
843
|
|
|
828
844
|
// src/wrappers/ai-sdk/ai-sdk.ts
|
|
829
845
|
function isModuleNamespace(obj) {
|
|
@@ -874,6 +890,7 @@ function wrapAISDK(aiSDK, options = {}) {
|
|
|
874
890
|
case "Agent":
|
|
875
891
|
case "Experimental_Agent":
|
|
876
892
|
case "ToolLoopAgent":
|
|
893
|
+
case "WorkflowAgent":
|
|
877
894
|
return original ? wrapAgentClass(original, options) : original;
|
|
878
895
|
}
|
|
879
896
|
return original;
|
|
@@ -892,10 +909,10 @@ var wrapAgentClass = (AgentClass, options = {}) => {
|
|
|
892
909
|
return new Proxy(instance, {
|
|
893
910
|
get(instanceTarget, prop, instanceReceiver) {
|
|
894
911
|
const original = Reflect.get(instanceTarget, prop, instanceTarget);
|
|
895
|
-
if (prop === "generate") {
|
|
912
|
+
if (prop === "generate" && typeof original === "function" && instanceTarget.constructor.name !== "WorkflowAgent") {
|
|
896
913
|
return wrapAgentGenerate(original, instanceTarget, options);
|
|
897
914
|
}
|
|
898
|
-
if (prop === "stream") {
|
|
915
|
+
if (prop === "stream" && typeof original === "function") {
|
|
899
916
|
return wrapAgentStream(original, instanceTarget, options);
|
|
900
917
|
}
|
|
901
918
|
if (typeof original === "function") {
|
|
@@ -910,7 +927,7 @@ var wrapAgentClass = (AgentClass, options = {}) => {
|
|
|
910
927
|
var wrapAgentGenerate = (generate, instance, options = {}) => {
|
|
911
928
|
const defaultName = `${instance.constructor.name}.generate`;
|
|
912
929
|
return async (params) => makeGenerateTextWrapper(
|
|
913
|
-
|
|
930
|
+
generateChannelForAgent(instance.constructor.name),
|
|
914
931
|
defaultName,
|
|
915
932
|
generate.bind(instance),
|
|
916
933
|
{
|
|
@@ -920,19 +937,42 @@ var wrapAgentGenerate = (generate, instance, options = {}) => {
|
|
|
920
937
|
options
|
|
921
938
|
)({ ...instance.settings, ...params });
|
|
922
939
|
};
|
|
940
|
+
function generateChannelForAgent(agentName) {
|
|
941
|
+
if (agentName === "ToolLoopAgent") {
|
|
942
|
+
return _chunkBFGIH2ZJjs.aiSDKChannels.toolLoopAgentGenerate;
|
|
943
|
+
}
|
|
944
|
+
return _chunkBFGIH2ZJjs.aiSDKChannels.agentGenerate;
|
|
945
|
+
}
|
|
923
946
|
var wrapAgentStream = (stream, instance, options = {}) => {
|
|
924
947
|
const defaultName = `${instance.constructor.name}.stream`;
|
|
925
|
-
return (params) =>
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
948
|
+
return (params) => {
|
|
949
|
+
const workflowAgent = instance.constructor.name === "WorkflowAgent";
|
|
950
|
+
if (workflowAgent && _chunkFY7DAKA5js.currentWorkflowAgentWrapperSpan.call(void 0, )) {
|
|
951
|
+
const { span_info: _spanInfo, ...cleanParams } = params;
|
|
952
|
+
return stream.call(instance, { ...instance.settings, ...cleanParams });
|
|
953
|
+
}
|
|
954
|
+
const trace = () => makeStreamWrapper(
|
|
955
|
+
streamChannelForAgent(instance.constructor.name),
|
|
956
|
+
defaultName,
|
|
957
|
+
stream.bind(instance),
|
|
958
|
+
{
|
|
959
|
+
self: instance,
|
|
960
|
+
spanType: "function" /* FUNCTION */
|
|
961
|
+
},
|
|
962
|
+
options
|
|
963
|
+
)({ ...instance.settings, ...params });
|
|
964
|
+
return trace();
|
|
965
|
+
};
|
|
935
966
|
};
|
|
967
|
+
function streamChannelForAgent(agentName) {
|
|
968
|
+
if (agentName === "ToolLoopAgent") {
|
|
969
|
+
return _chunkBFGIH2ZJjs.aiSDKChannels.toolLoopAgentStream;
|
|
970
|
+
}
|
|
971
|
+
if (agentName === "WorkflowAgent") {
|
|
972
|
+
return _chunkBFGIH2ZJjs.aiSDKChannels.workflowAgentStream;
|
|
973
|
+
}
|
|
974
|
+
return _chunkBFGIH2ZJjs.aiSDKChannels.agentStream;
|
|
975
|
+
}
|
|
936
976
|
var makeGenerateTextWrapper = (channel, name, generateText, contextOptions = {}, options = {}) => {
|
|
937
977
|
const wrapper = async function(allParams) {
|
|
938
978
|
const { span_info, ...params } = allParams;
|
|
@@ -955,7 +995,7 @@ var makeGenerateTextWrapper = (channel, name, generateText, contextOptions = {},
|
|
|
955
995
|
};
|
|
956
996
|
var wrapGenerateText = (generateText, options = {}, aiSDK) => {
|
|
957
997
|
return makeGenerateTextWrapper(
|
|
958
|
-
|
|
998
|
+
_chunkBFGIH2ZJjs.aiSDKChannels.generateText,
|
|
959
999
|
"generateText",
|
|
960
1000
|
generateText,
|
|
961
1001
|
{ aiSDK },
|
|
@@ -964,7 +1004,7 @@ var wrapGenerateText = (generateText, options = {}, aiSDK) => {
|
|
|
964
1004
|
};
|
|
965
1005
|
var wrapGenerateObject = (generateObject, options = {}, aiSDK) => {
|
|
966
1006
|
return makeGenerateTextWrapper(
|
|
967
|
-
|
|
1007
|
+
_chunkBFGIH2ZJjs.aiSDKChannels.generateObject,
|
|
968
1008
|
"generateObject",
|
|
969
1009
|
generateObject,
|
|
970
1010
|
{ aiSDK },
|
|
@@ -993,7 +1033,7 @@ var makeEmbedWrapper = (channel, name, embed, contextOptions = {}, options = {})
|
|
|
993
1033
|
};
|
|
994
1034
|
var wrapEmbed = (embed, options = {}, aiSDK) => {
|
|
995
1035
|
return makeEmbedWrapper(
|
|
996
|
-
|
|
1036
|
+
_chunkBFGIH2ZJjs.aiSDKChannels.embed,
|
|
997
1037
|
"embed",
|
|
998
1038
|
embed,
|
|
999
1039
|
{ aiSDK },
|
|
@@ -1002,7 +1042,7 @@ var wrapEmbed = (embed, options = {}, aiSDK) => {
|
|
|
1002
1042
|
};
|
|
1003
1043
|
var wrapEmbedMany = (embedMany, options = {}, aiSDK) => {
|
|
1004
1044
|
return makeEmbedWrapper(
|
|
1005
|
-
|
|
1045
|
+
_chunkBFGIH2ZJjs.aiSDKChannels.embedMany,
|
|
1006
1046
|
"embedMany",
|
|
1007
1047
|
embedMany,
|
|
1008
1048
|
{ aiSDK },
|
|
@@ -1013,7 +1053,7 @@ var makeRerankWrapper = (rerank, contextOptions = {}, options = {}) => {
|
|
|
1013
1053
|
const wrapper = async function(allParams) {
|
|
1014
1054
|
const { span_info, ...params } = allParams;
|
|
1015
1055
|
const tracedParams = { ...params };
|
|
1016
|
-
return
|
|
1056
|
+
return _chunkBFGIH2ZJjs.aiSDKChannels.rerank.tracePromise(
|
|
1017
1057
|
() => rerank(tracedParams),
|
|
1018
1058
|
createAISDKChannelContext(tracedParams, {
|
|
1019
1059
|
aiSDK: contextOptions.aiSDK,
|
|
@@ -1052,7 +1092,7 @@ var makeStreamWrapper = (channel, name, streamText, contextOptions = {}, options
|
|
|
1052
1092
|
};
|
|
1053
1093
|
var wrapStreamText = (streamText, options = {}, aiSDK) => {
|
|
1054
1094
|
return makeStreamWrapper(
|
|
1055
|
-
|
|
1095
|
+
_chunkBFGIH2ZJjs.aiSDKChannels.streamText,
|
|
1056
1096
|
"streamText",
|
|
1057
1097
|
streamText,
|
|
1058
1098
|
{ aiSDK },
|
|
@@ -1061,7 +1101,7 @@ var wrapStreamText = (streamText, options = {}, aiSDK) => {
|
|
|
1061
1101
|
};
|
|
1062
1102
|
var wrapStreamObject = (streamObject, options = {}, aiSDK) => {
|
|
1063
1103
|
return makeStreamWrapper(
|
|
1064
|
-
|
|
1104
|
+
_chunkBFGIH2ZJjs.aiSDKChannels.streamObject,
|
|
1065
1105
|
"streamObject",
|
|
1066
1106
|
streamObject,
|
|
1067
1107
|
{ aiSDK },
|
|
@@ -1132,14 +1172,14 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1132
1172
|
// For the first cut, do not support custom span_info arguments. We can
|
|
1133
1173
|
// propagate those via async local storage
|
|
1134
1174
|
async doGenerate(options) {
|
|
1135
|
-
const span =
|
|
1175
|
+
const span = _chunkFY7DAKA5js.startSpan.call(void 0, {
|
|
1136
1176
|
name: "Chat Completion",
|
|
1137
1177
|
spanAttributes: {
|
|
1138
1178
|
type: "llm"
|
|
1139
1179
|
}
|
|
1140
1180
|
});
|
|
1141
1181
|
const { prompt, mode, ...rest } = options;
|
|
1142
|
-
const startTime =
|
|
1182
|
+
const startTime = _chunkFY7DAKA5js.getCurrentUnixTimestamp.call(void 0, );
|
|
1143
1183
|
try {
|
|
1144
1184
|
const ret = await this.model.doGenerate(options);
|
|
1145
1185
|
span.log({
|
|
@@ -1151,12 +1191,12 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1151
1191
|
},
|
|
1152
1192
|
output: postProcessOutput(ret.text, ret.toolCalls, ret.finishReason),
|
|
1153
1193
|
metrics: {
|
|
1154
|
-
time_to_first_token:
|
|
1155
|
-
tokens: !
|
|
1194
|
+
time_to_first_token: _chunkFY7DAKA5js.getCurrentUnixTimestamp.call(void 0, ) - startTime,
|
|
1195
|
+
tokens: !_chunkFY7DAKA5js.isEmpty.call(void 0, ret.usage) ? ret.usage.promptTokens + ret.usage.completionTokens : void 0,
|
|
1156
1196
|
prompt_tokens: _optionalChain([ret, 'access', _20 => _20.usage, 'optionalAccess', _21 => _21.promptTokens]),
|
|
1157
1197
|
completion_tokens: _optionalChain([ret, 'access', _22 => _22.usage, 'optionalAccess', _23 => _23.completionTokens]),
|
|
1158
|
-
cached:
|
|
1159
|
-
_nullishCoalesce(_optionalChain([ret, 'access', _24 => _24.rawResponse, 'optionalAccess', _25 => _25.headers, 'optionalAccess', _26 => _26[
|
|
1198
|
+
cached: _chunkFY7DAKA5js.parseCachedHeader.call(void 0,
|
|
1199
|
+
_nullishCoalesce(_optionalChain([ret, 'access', _24 => _24.rawResponse, 'optionalAccess', _25 => _25.headers, 'optionalAccess', _26 => _26[_chunkFY7DAKA5js.X_CACHED_HEADER]]), () => ( _optionalChain([ret, 'access', _27 => _27.rawResponse, 'optionalAccess', _28 => _28.headers, 'optionalAccess', _29 => _29[_chunkFY7DAKA5js.LEGACY_CACHED_HEADER]])))
|
|
1160
1200
|
)
|
|
1161
1201
|
}
|
|
1162
1202
|
});
|
|
@@ -1167,8 +1207,8 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1167
1207
|
}
|
|
1168
1208
|
async doStream(options) {
|
|
1169
1209
|
const { prompt, mode, ...rest } = options;
|
|
1170
|
-
const startTime =
|
|
1171
|
-
const span =
|
|
1210
|
+
const startTime = _chunkFY7DAKA5js.getCurrentUnixTimestamp.call(void 0, );
|
|
1211
|
+
const span = _chunkFY7DAKA5js.startSpan.call(void 0, {
|
|
1172
1212
|
name: "Chat Completion",
|
|
1173
1213
|
spanAttributes: {
|
|
1174
1214
|
type: "llm"
|
|
@@ -1194,7 +1234,7 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1194
1234
|
let time_to_first_token = void 0;
|
|
1195
1235
|
let usage = void 0;
|
|
1196
1236
|
let fullText = void 0;
|
|
1197
|
-
const
|
|
1237
|
+
const toolCalls2 = {};
|
|
1198
1238
|
let finishReason = void 0;
|
|
1199
1239
|
return {
|
|
1200
1240
|
...ret,
|
|
@@ -1202,7 +1242,7 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1202
1242
|
new TransformStream({
|
|
1203
1243
|
transform(chunk, controller) {
|
|
1204
1244
|
if (time_to_first_token === void 0) {
|
|
1205
|
-
time_to_first_token =
|
|
1245
|
+
time_to_first_token = _chunkFY7DAKA5js.getCurrentUnixTimestamp.call(void 0, ) - startTime;
|
|
1206
1246
|
span.log({ metrics: { time_to_first_token } });
|
|
1207
1247
|
}
|
|
1208
1248
|
switch (chunk.type) {
|
|
@@ -1213,7 +1253,7 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1213
1253
|
fullText += chunk.textDelta;
|
|
1214
1254
|
break;
|
|
1215
1255
|
case "tool-call":
|
|
1216
|
-
|
|
1256
|
+
toolCalls2[chunk.toolCallId] = {
|
|
1217
1257
|
toolCallType: chunk.toolCallType,
|
|
1218
1258
|
toolCallId: chunk.toolCallId,
|
|
1219
1259
|
toolName: chunk.toolName,
|
|
@@ -1221,15 +1261,15 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1221
1261
|
};
|
|
1222
1262
|
break;
|
|
1223
1263
|
case "tool-call-delta":
|
|
1224
|
-
if (
|
|
1225
|
-
|
|
1264
|
+
if (toolCalls2[chunk.toolCallId] === void 0) {
|
|
1265
|
+
toolCalls2[chunk.toolCallId] = {
|
|
1226
1266
|
toolCallType: chunk.toolCallType,
|
|
1227
1267
|
toolCallId: chunk.toolCallId,
|
|
1228
1268
|
toolName: chunk.toolName,
|
|
1229
1269
|
args: ""
|
|
1230
1270
|
};
|
|
1231
1271
|
}
|
|
1232
|
-
|
|
1272
|
+
toolCalls2[chunk.toolCallId].args += chunk.argsTextDelta;
|
|
1233
1273
|
break;
|
|
1234
1274
|
case "finish":
|
|
1235
1275
|
usage = chunk.usage;
|
|
@@ -1242,16 +1282,16 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1242
1282
|
span.log({
|
|
1243
1283
|
output: postProcessOutput(
|
|
1244
1284
|
fullText,
|
|
1245
|
-
Object.keys(
|
|
1285
|
+
Object.keys(toolCalls2).length > 0 ? Object.values(toolCalls2) : void 0,
|
|
1246
1286
|
finishReason
|
|
1247
1287
|
),
|
|
1248
1288
|
metrics: {
|
|
1249
1289
|
time_to_first_token,
|
|
1250
|
-
tokens: !
|
|
1290
|
+
tokens: !_chunkFY7DAKA5js.isEmpty.call(void 0, usage) ? usage.promptTokens + usage.completionTokens : void 0,
|
|
1251
1291
|
prompt_tokens: _optionalChain([usage, 'optionalAccess', _30 => _30.promptTokens]),
|
|
1252
1292
|
completion_tokens: _optionalChain([usage, 'optionalAccess', _31 => _31.completionTokens]),
|
|
1253
|
-
cached:
|
|
1254
|
-
_nullishCoalesce(_optionalChain([ret, 'access', _32 => _32.rawResponse, 'optionalAccess', _33 => _33.headers, 'optionalAccess', _34 => _34[
|
|
1293
|
+
cached: _chunkFY7DAKA5js.parseCachedHeader.call(void 0,
|
|
1294
|
+
_nullishCoalesce(_optionalChain([ret, 'access', _32 => _32.rawResponse, 'optionalAccess', _33 => _33.headers, 'optionalAccess', _34 => _34[_chunkFY7DAKA5js.X_CACHED_HEADER]]), () => ( _optionalChain([ret, 'access', _35 => _35.rawResponse, 'optionalAccess', _36 => _36.headers, 'optionalAccess', _37 => _37[_chunkFY7DAKA5js.LEGACY_CACHED_HEADER]])))
|
|
1255
1295
|
)
|
|
1256
1296
|
}
|
|
1257
1297
|
});
|
|
@@ -1343,15 +1383,15 @@ function postProcessPrompt(prompt) {
|
|
|
1343
1383
|
}
|
|
1344
1384
|
});
|
|
1345
1385
|
}
|
|
1346
|
-
function postProcessOutput(text,
|
|
1386
|
+
function postProcessOutput(text, toolCalls2, finishReason) {
|
|
1347
1387
|
return [
|
|
1348
1388
|
{
|
|
1349
1389
|
index: 0,
|
|
1350
1390
|
message: {
|
|
1351
1391
|
role: "assistant",
|
|
1352
1392
|
content: _nullishCoalesce(text, () => ( "")),
|
|
1353
|
-
...
|
|
1354
|
-
tool_calls:
|
|
1393
|
+
...toolCalls2 && toolCalls2.length > 0 ? {
|
|
1394
|
+
tool_calls: toolCalls2.map((toolCall) => ({
|
|
1355
1395
|
id: toolCall.toolCallId,
|
|
1356
1396
|
function: {
|
|
1357
1397
|
name: toolCall.toolName,
|
|
@@ -1436,12 +1476,12 @@ function normalizeUsageMetrics(usage, provider, providerMetadata) {
|
|
|
1436
1476
|
anthropicMetadata.usage,
|
|
1437
1477
|
"cache_creation_input_tokens"
|
|
1438
1478
|
) || 0;
|
|
1439
|
-
const cacheTokens =
|
|
1479
|
+
const cacheTokens = _chunkFY7DAKA5js.extractAnthropicCacheTokens.call(void 0,
|
|
1440
1480
|
cacheReadTokens,
|
|
1441
1481
|
cacheCreationTokens
|
|
1442
1482
|
);
|
|
1443
1483
|
Object.assign(metrics, cacheTokens);
|
|
1444
|
-
Object.assign(metrics,
|
|
1484
|
+
Object.assign(metrics, _chunkFY7DAKA5js.finalizeAnthropicTokens.call(void 0, metrics));
|
|
1445
1485
|
}
|
|
1446
1486
|
}
|
|
1447
1487
|
return metrics;
|
|
@@ -1450,29 +1490,29 @@ function normalizeFinishReason(reason) {
|
|
|
1450
1490
|
if (typeof reason !== "string") return void 0;
|
|
1451
1491
|
return reason.replace(/-/g, "_");
|
|
1452
1492
|
}
|
|
1453
|
-
function buildAssistantOutputWithToolCalls(result,
|
|
1493
|
+
function buildAssistantOutputWithToolCalls(result, toolCalls2) {
|
|
1454
1494
|
return [
|
|
1455
1495
|
{
|
|
1456
1496
|
index: 0,
|
|
1457
1497
|
logprobs: null,
|
|
1458
|
-
finish_reason: _nullishCoalesce(normalizeFinishReason(_optionalChain([result, 'optionalAccess', _49 => _49.finishReason])), () => ( (
|
|
1498
|
+
finish_reason: _nullishCoalesce(normalizeFinishReason(_optionalChain([result, 'optionalAccess', _49 => _49.finishReason])), () => ( (toolCalls2.length ? "tool_calls" : void 0))),
|
|
1459
1499
|
message: {
|
|
1460
1500
|
role: "assistant",
|
|
1461
|
-
tool_calls:
|
|
1501
|
+
tool_calls: toolCalls2.length > 0 ? toolCalls2 : void 0
|
|
1462
1502
|
}
|
|
1463
1503
|
}
|
|
1464
1504
|
];
|
|
1465
1505
|
}
|
|
1466
1506
|
function extractToolCallsFromSteps(steps) {
|
|
1467
|
-
const
|
|
1468
|
-
if (!Array.isArray(steps)) return
|
|
1507
|
+
const toolCalls2 = [];
|
|
1508
|
+
if (!Array.isArray(steps)) return toolCalls2;
|
|
1469
1509
|
let idx = 0;
|
|
1470
1510
|
for (const step of steps) {
|
|
1471
1511
|
const blocks = _optionalChain([step, 'optionalAccess', _50 => _50.content]);
|
|
1472
1512
|
if (!Array.isArray(blocks)) continue;
|
|
1473
1513
|
for (const block of blocks) {
|
|
1474
1514
|
if (block && typeof block === "object" && block.type === "tool-call") {
|
|
1475
|
-
|
|
1515
|
+
toolCalls2.push({
|
|
1476
1516
|
id: block.toolCallId,
|
|
1477
1517
|
type: "function",
|
|
1478
1518
|
index: idx++,
|
|
@@ -1484,7 +1524,7 @@ function extractToolCallsFromSteps(steps) {
|
|
|
1484
1524
|
}
|
|
1485
1525
|
}
|
|
1486
1526
|
}
|
|
1487
|
-
return
|
|
1527
|
+
return toolCalls2;
|
|
1488
1528
|
}
|
|
1489
1529
|
function extractToolCallsFromBlocks(blocks) {
|
|
1490
1530
|
if (!Array.isArray(blocks)) return [];
|
|
@@ -1513,7 +1553,7 @@ function BraintrustMiddleware(config = {}) {
|
|
|
1513
1553
|
model: modelFromWrapGenerate
|
|
1514
1554
|
}) => {
|
|
1515
1555
|
const rawInput = extractInput(params);
|
|
1516
|
-
const processedInput =
|
|
1556
|
+
const processedInput = _chunkFY7DAKA5js.processInputAttachments.call(void 0, rawInput);
|
|
1517
1557
|
const spanArgs = {
|
|
1518
1558
|
name: _optionalChain([config, 'access', _54 => _54.spanInfo, 'optionalAccess', _55 => _55.name]) || "ai-sdk.doGenerate",
|
|
1519
1559
|
spanAttributes: {
|
|
@@ -1528,7 +1568,7 @@ function BraintrustMiddleware(config = {}) {
|
|
|
1528
1568
|
}
|
|
1529
1569
|
}
|
|
1530
1570
|
};
|
|
1531
|
-
const span =
|
|
1571
|
+
const span = _chunkFY7DAKA5js.startSpan.call(void 0, spanArgs);
|
|
1532
1572
|
try {
|
|
1533
1573
|
const result = await doGenerate();
|
|
1534
1574
|
const metadata = {};
|
|
@@ -1550,12 +1590,12 @@ function BraintrustMiddleware(config = {}) {
|
|
|
1550
1590
|
metadata.model = modelId;
|
|
1551
1591
|
}
|
|
1552
1592
|
}
|
|
1553
|
-
let
|
|
1554
|
-
if (!
|
|
1555
|
-
|
|
1593
|
+
let toolCalls2 = extractToolCallsFromSteps(_optionalChain([result, 'optionalAccess', _60 => _60.steps]));
|
|
1594
|
+
if (!toolCalls2 || toolCalls2.length === 0) {
|
|
1595
|
+
toolCalls2 = extractToolCallsFromBlocks(_optionalChain([result, 'optionalAccess', _61 => _61.content]));
|
|
1556
1596
|
}
|
|
1557
1597
|
span.log({
|
|
1558
|
-
output:
|
|
1598
|
+
output: toolCalls2.length > 0 ? buildAssistantOutputWithToolCalls(result, toolCalls2) : _optionalChain([result, 'optionalAccess', _62 => _62.content]),
|
|
1559
1599
|
metadata,
|
|
1560
1600
|
metrics: normalizeUsageMetrics(
|
|
1561
1601
|
result.usage,
|
|
@@ -1575,7 +1615,7 @@ function BraintrustMiddleware(config = {}) {
|
|
|
1575
1615
|
},
|
|
1576
1616
|
wrapStream: async ({ doStream, params }) => {
|
|
1577
1617
|
const rawInput = extractInput(params);
|
|
1578
|
-
const processedInput =
|
|
1618
|
+
const processedInput = _chunkFY7DAKA5js.processInputAttachments.call(void 0, rawInput);
|
|
1579
1619
|
const spanArgs = {
|
|
1580
1620
|
name: _optionalChain([config, 'access', _63 => _63.spanInfo, 'optionalAccess', _64 => _64.name]) || "ai-sdk.doStream",
|
|
1581
1621
|
spanAttributes: {
|
|
@@ -1590,7 +1630,7 @@ function BraintrustMiddleware(config = {}) {
|
|
|
1590
1630
|
}
|
|
1591
1631
|
}
|
|
1592
1632
|
};
|
|
1593
|
-
const span =
|
|
1633
|
+
const span = _chunkFY7DAKA5js.startSpan.call(void 0, spanArgs);
|
|
1594
1634
|
try {
|
|
1595
1635
|
const { stream, ...rest } = await doStream();
|
|
1596
1636
|
const textChunks = [];
|
|
@@ -1644,13 +1684,13 @@ function BraintrustMiddleware(config = {}) {
|
|
|
1644
1684
|
metadata.model = model;
|
|
1645
1685
|
}
|
|
1646
1686
|
if (toolBlocks.length > 0) {
|
|
1647
|
-
const
|
|
1687
|
+
const toolCalls2 = extractToolCallsFromSteps([
|
|
1648
1688
|
{ content: toolBlocks }
|
|
1649
1689
|
]);
|
|
1650
|
-
if (
|
|
1690
|
+
if (toolCalls2.length > 0) {
|
|
1651
1691
|
output = buildAssistantOutputWithToolCalls(
|
|
1652
1692
|
resultForDetection,
|
|
1653
|
-
|
|
1693
|
+
toolCalls2
|
|
1654
1694
|
);
|
|
1655
1695
|
}
|
|
1656
1696
|
}
|
|
@@ -1729,7 +1769,7 @@ function messagesProxy(messages) {
|
|
|
1729
1769
|
return new Proxy(messages, {
|
|
1730
1770
|
get(target, prop, receiver) {
|
|
1731
1771
|
if (prop === "create") {
|
|
1732
|
-
return createProxy(target.create,
|
|
1772
|
+
return createProxy(target.create, _chunkBFGIH2ZJjs.anthropicChannels.messagesCreate);
|
|
1733
1773
|
}
|
|
1734
1774
|
return Reflect.get(target, prop, receiver);
|
|
1735
1775
|
}
|
|
@@ -1739,7 +1779,7 @@ function betaMessagesProxy(messages, anthropic) {
|
|
|
1739
1779
|
return new Proxy(messages, {
|
|
1740
1780
|
get(target, prop, receiver) {
|
|
1741
1781
|
if (prop === "create") {
|
|
1742
|
-
return createProxy(target.create,
|
|
1782
|
+
return createProxy(target.create, _chunkBFGIH2ZJjs.anthropicChannels.betaMessagesCreate);
|
|
1743
1783
|
}
|
|
1744
1784
|
if (prop === "toolRunner") {
|
|
1745
1785
|
if (typeof target.toolRunner !== "function") {
|
|
@@ -1748,7 +1788,7 @@ function betaMessagesProxy(messages, anthropic) {
|
|
|
1748
1788
|
return toolRunnerProxy(
|
|
1749
1789
|
target.toolRunner,
|
|
1750
1790
|
anthropic,
|
|
1751
|
-
|
|
1791
|
+
_chunkBFGIH2ZJjs.anthropicChannels.betaMessagesToolRunner
|
|
1752
1792
|
);
|
|
1753
1793
|
}
|
|
1754
1794
|
return Reflect.get(target, prop, receiver);
|
|
@@ -1805,11 +1845,11 @@ function wrapClaudeAgentQuery(queryFn, defaultThis) {
|
|
|
1805
1845
|
...params,
|
|
1806
1846
|
options: {
|
|
1807
1847
|
..._nullishCoalesce(params.options, () => ( {})),
|
|
1808
|
-
[
|
|
1848
|
+
[_chunkFY7DAKA5js.CLAUDE_AGENT_SDK_SKIP_LOCAL_TOOL_HOOKS_OPTION]: true
|
|
1809
1849
|
}
|
|
1810
1850
|
};
|
|
1811
1851
|
const invocationTarget = thisArg === proxy || thisArg === void 0 ? _nullishCoalesce(defaultThis, () => ( thisArg)) : thisArg;
|
|
1812
|
-
return
|
|
1852
|
+
return _chunkBFGIH2ZJjs.claudeAgentSDKChannels.query.traceSync(
|
|
1813
1853
|
() => Reflect.apply(target, invocationTarget, [wrappedParams]),
|
|
1814
1854
|
// The channel carries no extra context fields, but the generated
|
|
1815
1855
|
// StartOf<> type for Record<string, never> is overly strict here.
|
|
@@ -1837,7 +1877,7 @@ function wrapClaudeAgentTool(toolFn, localToolMetadataByTool, defaultThis) {
|
|
|
1837
1877
|
}
|
|
1838
1878
|
const localToolMetadata = { toolName };
|
|
1839
1879
|
const originalHandler = wrappedArgs[handlerIndex];
|
|
1840
|
-
wrappedArgs[handlerIndex] =
|
|
1880
|
+
wrappedArgs[handlerIndex] = _chunkFY7DAKA5js.wrapLocalClaudeToolHandler.call(void 0,
|
|
1841
1881
|
originalHandler,
|
|
1842
1882
|
() => localToolMetadata
|
|
1843
1883
|
);
|
|
@@ -2020,7 +2060,7 @@ function wrapCodexThread(thread) {
|
|
|
2020
2060
|
if (prop === "run" && typeof value === "function") {
|
|
2021
2061
|
return function(input, turnOptions) {
|
|
2022
2062
|
const args = [input, turnOptions];
|
|
2023
|
-
return
|
|
2063
|
+
return _chunkBFGIH2ZJjs.openAICodexChannels.run.tracePromise(
|
|
2024
2064
|
() => Reflect.apply(value, target, args),
|
|
2025
2065
|
{
|
|
2026
2066
|
arguments: args,
|
|
@@ -2033,7 +2073,7 @@ function wrapCodexThread(thread) {
|
|
|
2033
2073
|
if (prop === "runStreamed" && typeof value === "function") {
|
|
2034
2074
|
return function(input, turnOptions) {
|
|
2035
2075
|
const args = [input, turnOptions];
|
|
2036
|
-
return
|
|
2076
|
+
return _chunkBFGIH2ZJjs.openAICodexChannels.runStreamed.tracePromise(
|
|
2037
2077
|
() => Reflect.apply(value, target, args),
|
|
2038
2078
|
{
|
|
2039
2079
|
arguments: args,
|
|
@@ -2101,7 +2141,7 @@ function wrapCursorAgentClass(Agent) {
|
|
|
2101
2141
|
if (prop === "create" && typeof value === "function") {
|
|
2102
2142
|
const wrapped = async function(options) {
|
|
2103
2143
|
const args = [options];
|
|
2104
|
-
return
|
|
2144
|
+
return _chunkBFGIH2ZJjs.cursorSDKChannels.create.tracePromise(
|
|
2105
2145
|
async () => wrapCursorAgent(await Reflect.apply(value, target, args)),
|
|
2106
2146
|
{ arguments: args }
|
|
2107
2147
|
);
|
|
@@ -2112,7 +2152,7 @@ function wrapCursorAgentClass(Agent) {
|
|
|
2112
2152
|
if (prop === "resume" && typeof value === "function") {
|
|
2113
2153
|
const wrapped = async function(agentId, options) {
|
|
2114
2154
|
const args = [agentId, options];
|
|
2115
|
-
return
|
|
2155
|
+
return _chunkBFGIH2ZJjs.cursorSDKChannels.resume.tracePromise(
|
|
2116
2156
|
async () => wrapCursorAgent(await Reflect.apply(value, target, args)),
|
|
2117
2157
|
{ arguments: args }
|
|
2118
2158
|
);
|
|
@@ -2123,7 +2163,7 @@ function wrapCursorAgentClass(Agent) {
|
|
|
2123
2163
|
if (prop === "prompt" && typeof value === "function") {
|
|
2124
2164
|
const wrapped = async function(message, options) {
|
|
2125
2165
|
const args = [message, options];
|
|
2126
|
-
return
|
|
2166
|
+
return _chunkBFGIH2ZJjs.cursorSDKChannels.prompt.tracePromise(
|
|
2127
2167
|
() => Reflect.apply(value, target, args),
|
|
2128
2168
|
{ arguments: args }
|
|
2129
2169
|
);
|
|
@@ -2156,7 +2196,7 @@ function wrapCursorAgent(agent) {
|
|
|
2156
2196
|
if (prop === "send" && typeof value === "function") {
|
|
2157
2197
|
return function(message, options) {
|
|
2158
2198
|
const args = [message, options];
|
|
2159
|
-
return
|
|
2199
|
+
return _chunkBFGIH2ZJjs.cursorSDKChannels.send.tracePromise(
|
|
2160
2200
|
() => Reflect.apply(value, target, args),
|
|
2161
2201
|
{
|
|
2162
2202
|
agent: target,
|
|
@@ -2206,7 +2246,7 @@ function patchAgentSessionClass(AgentSession) {
|
|
|
2206
2246
|
...descriptor,
|
|
2207
2247
|
value: function wrappedPiCodingAgentPrompt(text, options) {
|
|
2208
2248
|
const args = [text, options];
|
|
2209
|
-
return
|
|
2249
|
+
return _chunkBFGIH2ZJjs.piCodingAgentChannels.prompt.tracePromise(
|
|
2210
2250
|
() => Reflect.apply(originalPrompt, this, args),
|
|
2211
2251
|
{
|
|
2212
2252
|
arguments: args,
|
|
@@ -2326,7 +2366,7 @@ function wrapAgentInstance(agent) {
|
|
|
2326
2366
|
if (prop === "stream" && typeof value === "function") {
|
|
2327
2367
|
return function(args, options) {
|
|
2328
2368
|
const callArgs = [args, options];
|
|
2329
|
-
return
|
|
2369
|
+
return _chunkBFGIH2ZJjs.strandsAgentSDKChannels.agentStream.traceSync(
|
|
2330
2370
|
() => Reflect.apply(value, target, callArgs),
|
|
2331
2371
|
{
|
|
2332
2372
|
agent: proxy,
|
|
@@ -2362,7 +2402,7 @@ function wrapMultiAgentInstance(orchestrator, kind) {
|
|
|
2362
2402
|
if (prop === "stream" && typeof value === "function") {
|
|
2363
2403
|
return function(input, options) {
|
|
2364
2404
|
const callArgs = [input, options];
|
|
2365
|
-
const channel = kind === "graph" ?
|
|
2405
|
+
const channel = kind === "graph" ? _chunkBFGIH2ZJjs.strandsAgentSDKChannels.graphStream : _chunkBFGIH2ZJjs.strandsAgentSDKChannels.swarmStream;
|
|
2366
2406
|
return channel.traceSync(
|
|
2367
2407
|
() => Reflect.apply(value, target, callArgs),
|
|
2368
2408
|
{
|
|
@@ -2437,7 +2477,7 @@ function wrapGoogleGenAIInstance(instance) {
|
|
|
2437
2477
|
}
|
|
2438
2478
|
if (prop === "interactions") {
|
|
2439
2479
|
const interactions = Reflect.get(target, prop, receiver);
|
|
2440
|
-
if (!
|
|
2480
|
+
if (!_chunkFY7DAKA5js.isObject.call(void 0, interactions) || typeof interactions.create !== "function") {
|
|
2441
2481
|
return interactions;
|
|
2442
2482
|
}
|
|
2443
2483
|
if (interactions !== originalInteractions) {
|
|
@@ -2451,7 +2491,7 @@ function wrapGoogleGenAIInstance(instance) {
|
|
|
2451
2491
|
});
|
|
2452
2492
|
}
|
|
2453
2493
|
function patchGoogleGenAIChats(instance, wrappedModels) {
|
|
2454
|
-
if (!
|
|
2494
|
+
if (!_chunkFY7DAKA5js.isObject.call(void 0, instance.chats) || !("modelsModule" in instance.chats)) {
|
|
2455
2495
|
return;
|
|
2456
2496
|
}
|
|
2457
2497
|
Reflect.set(instance.chats, "modelsModule", wrappedModels);
|
|
@@ -2484,7 +2524,7 @@ function wrapInteractions(interactions) {
|
|
|
2484
2524
|
}
|
|
2485
2525
|
function wrapGenerateContent(original) {
|
|
2486
2526
|
return function(params) {
|
|
2487
|
-
return
|
|
2527
|
+
return _chunkBFGIH2ZJjs.googleGenAIChannels.generateContent.tracePromise(
|
|
2488
2528
|
() => original(params),
|
|
2489
2529
|
{ arguments: [params] }
|
|
2490
2530
|
);
|
|
@@ -2492,7 +2532,7 @@ function wrapGenerateContent(original) {
|
|
|
2492
2532
|
}
|
|
2493
2533
|
function wrapGenerateContentStream(original) {
|
|
2494
2534
|
return function(params) {
|
|
2495
|
-
return
|
|
2535
|
+
return _chunkBFGIH2ZJjs.googleGenAIChannels.generateContentStream.tracePromise(
|
|
2496
2536
|
() => original(params),
|
|
2497
2537
|
{ arguments: [params] }
|
|
2498
2538
|
);
|
|
@@ -2500,7 +2540,7 @@ function wrapGenerateContentStream(original) {
|
|
|
2500
2540
|
}
|
|
2501
2541
|
function wrapEmbedContent(original) {
|
|
2502
2542
|
return function(params) {
|
|
2503
|
-
return
|
|
2543
|
+
return _chunkBFGIH2ZJjs.googleGenAIChannels.embedContent.tracePromise(
|
|
2504
2544
|
() => original(params),
|
|
2505
2545
|
{ arguments: [params] }
|
|
2506
2546
|
);
|
|
@@ -2512,7 +2552,7 @@ function wrapInteractionCreate(original) {
|
|
|
2512
2552
|
return options === void 0 ? original(params) : original(params, options);
|
|
2513
2553
|
}
|
|
2514
2554
|
const traceContext = options === void 0 ? { arguments: [params] } : { arguments: [params, options] };
|
|
2515
|
-
return
|
|
2555
|
+
return _chunkBFGIH2ZJjs.googleGenAIChannels.interactionsCreate.tracePromise(
|
|
2516
2556
|
() => options === void 0 ? original(params) : original(params, options),
|
|
2517
2557
|
traceContext
|
|
2518
2558
|
);
|
|
@@ -2573,7 +2613,7 @@ function wrapRunnerInstance(runner) {
|
|
|
2573
2613
|
function wrapRunnerRunAsync(runner) {
|
|
2574
2614
|
const original = runner.runAsync.bind(runner);
|
|
2575
2615
|
return function(params) {
|
|
2576
|
-
return
|
|
2616
|
+
return _chunkBFGIH2ZJjs.googleADKChannels.runnerRunAsync.traceSync(() => original(params), {
|
|
2577
2617
|
arguments: [params],
|
|
2578
2618
|
self: runner
|
|
2579
2619
|
});
|
|
@@ -2600,7 +2640,7 @@ function wrapAgentInstance2(agent) {
|
|
|
2600
2640
|
function wrapAgentRunAsync(agent) {
|
|
2601
2641
|
const original = agent.runAsync.bind(agent);
|
|
2602
2642
|
return function(parentContext) {
|
|
2603
|
-
return
|
|
2643
|
+
return _chunkBFGIH2ZJjs.googleADKChannels.agentRunAsync.traceSync(
|
|
2604
2644
|
() => original(parentContext),
|
|
2605
2645
|
{ arguments: [parentContext], self: agent }
|
|
2606
2646
|
);
|
|
@@ -2627,7 +2667,7 @@ function wrapToolInstance(tool) {
|
|
|
2627
2667
|
function wrapToolRunAsync(tool) {
|
|
2628
2668
|
const original = tool.runAsync.bind(tool);
|
|
2629
2669
|
return function(req) {
|
|
2630
|
-
return
|
|
2670
|
+
return _chunkBFGIH2ZJjs.googleADKChannels.toolRunAsync.tracePromise(() => original(req), {
|
|
2631
2671
|
arguments: [req],
|
|
2632
2672
|
self: tool
|
|
2633
2673
|
});
|
|
@@ -2774,27 +2814,27 @@ function patchGenkitRegistryConstructor(registry) {
|
|
|
2774
2814
|
}
|
|
2775
2815
|
}
|
|
2776
2816
|
function wrapGenerate(generate) {
|
|
2777
|
-
return (input) =>
|
|
2817
|
+
return (input) => _chunkBFGIH2ZJjs.genkitChannels.generate.tracePromise(() => generate(input), {
|
|
2778
2818
|
arguments: [input]
|
|
2779
2819
|
});
|
|
2780
2820
|
}
|
|
2781
2821
|
function wrapGenerateStream(generateStream) {
|
|
2782
|
-
return (input) =>
|
|
2822
|
+
return (input) => _chunkBFGIH2ZJjs.genkitChannels.generateStream.traceSync(() => generateStream(input), {
|
|
2783
2823
|
arguments: [input]
|
|
2784
2824
|
});
|
|
2785
2825
|
}
|
|
2786
2826
|
function wrapEmbed2(embed) {
|
|
2787
|
-
return (params) =>
|
|
2827
|
+
return (params) => _chunkBFGIH2ZJjs.genkitChannels.embed.tracePromise(() => embed(params), {
|
|
2788
2828
|
arguments: [params]
|
|
2789
2829
|
});
|
|
2790
2830
|
}
|
|
2791
2831
|
function wrapEmbedMany2(embedMany) {
|
|
2792
|
-
return (params) =>
|
|
2832
|
+
return (params) => _chunkBFGIH2ZJjs.genkitChannels.embedMany.tracePromise(() => embedMany(params), {
|
|
2793
2833
|
arguments: [params]
|
|
2794
2834
|
});
|
|
2795
2835
|
}
|
|
2796
2836
|
function wrapRun(run) {
|
|
2797
|
-
return (name, inputOrFn, maybeFn) =>
|
|
2837
|
+
return (name, inputOrFn, maybeFn) => _chunkBFGIH2ZJjs.genkitChannels.actionRun.tracePromise(() => run(name, inputOrFn, maybeFn), {
|
|
2798
2838
|
arguments: [name, inputOrFn, maybeFn]
|
|
2799
2839
|
});
|
|
2800
2840
|
}
|
|
@@ -2833,13 +2873,13 @@ function isGenkitAction(value) {
|
|
|
2833
2873
|
return typeof value === "function" && "__action" in value;
|
|
2834
2874
|
}
|
|
2835
2875
|
function traceActionRun(action, run) {
|
|
2836
|
-
return (input, options) =>
|
|
2876
|
+
return (input, options) => _chunkBFGIH2ZJjs.genkitChannels.actionRun.tracePromise(() => run(input, options), {
|
|
2837
2877
|
arguments: [input, options],
|
|
2838
2878
|
self: action
|
|
2839
2879
|
});
|
|
2840
2880
|
}
|
|
2841
2881
|
function traceActionStream(action, stream) {
|
|
2842
|
-
return (input, options) =>
|
|
2882
|
+
return (input, options) => _chunkBFGIH2ZJjs.genkitChannels.actionStream.traceSync(() => stream(input, options), {
|
|
2843
2883
|
arguments: [input, options],
|
|
2844
2884
|
self: action
|
|
2845
2885
|
});
|
|
@@ -2885,10 +2925,10 @@ function isHuggingFaceConstructorKey(value) {
|
|
|
2885
2925
|
return HUGGINGFACE_CONSTRUCTOR_KEY_SET.has(value);
|
|
2886
2926
|
}
|
|
2887
2927
|
function hasFunction2(value, methodName) {
|
|
2888
|
-
return
|
|
2928
|
+
return _chunkFY7DAKA5js.isObject.call(void 0, value) && methodName in value && typeof value[methodName] === "function";
|
|
2889
2929
|
}
|
|
2890
2930
|
function isSupportedHuggingFaceModule(value) {
|
|
2891
|
-
if (!
|
|
2931
|
+
if (!_chunkFY7DAKA5js.isObject.call(void 0, value)) {
|
|
2892
2932
|
return false;
|
|
2893
2933
|
}
|
|
2894
2934
|
return HUGGINGFACE_CONSTRUCTOR_KEYS.some(
|
|
@@ -2996,14 +3036,14 @@ function wrapChatCompletion2(original, endpointUrl) {
|
|
|
2996
3036
|
const context = {
|
|
2997
3037
|
arguments: [traceParams]
|
|
2998
3038
|
};
|
|
2999
|
-
return
|
|
3039
|
+
return _chunkBFGIH2ZJjs.huggingFaceChannels.chatCompletion.tracePromise(
|
|
3000
3040
|
() => original(params, options),
|
|
3001
3041
|
context
|
|
3002
3042
|
);
|
|
3003
3043
|
};
|
|
3004
3044
|
}
|
|
3005
3045
|
function wrapChatCompletionStream(original, endpointUrl) {
|
|
3006
|
-
return (params, options) =>
|
|
3046
|
+
return (params, options) => _chunkBFGIH2ZJjs.huggingFaceChannels.chatCompletionStream.traceSync(
|
|
3007
3047
|
() => original(params, options),
|
|
3008
3048
|
{
|
|
3009
3049
|
arguments: [withEndpointUrl(params, endpointUrl)]
|
|
@@ -3016,14 +3056,14 @@ function wrapTextGeneration(original, endpointUrl) {
|
|
|
3016
3056
|
const context = {
|
|
3017
3057
|
arguments: [traceParams]
|
|
3018
3058
|
};
|
|
3019
|
-
return
|
|
3059
|
+
return _chunkBFGIH2ZJjs.huggingFaceChannels.textGeneration.tracePromise(
|
|
3020
3060
|
() => original(params, options),
|
|
3021
3061
|
context
|
|
3022
3062
|
);
|
|
3023
3063
|
};
|
|
3024
3064
|
}
|
|
3025
3065
|
function wrapTextGenerationStream(original, endpointUrl) {
|
|
3026
|
-
return (params, options) =>
|
|
3066
|
+
return (params, options) => _chunkBFGIH2ZJjs.huggingFaceChannels.textGenerationStream.traceSync(
|
|
3027
3067
|
() => original(params, options),
|
|
3028
3068
|
{
|
|
3029
3069
|
arguments: [withEndpointUrl(params, endpointUrl)]
|
|
@@ -3036,7 +3076,7 @@ function wrapFeatureExtraction(original, endpointUrl) {
|
|
|
3036
3076
|
const context = {
|
|
3037
3077
|
arguments: [traceParams]
|
|
3038
3078
|
};
|
|
3039
|
-
return
|
|
3079
|
+
return _chunkBFGIH2ZJjs.huggingFaceChannels.featureExtraction.tracePromise(
|
|
3040
3080
|
() => original(params, options),
|
|
3041
3081
|
context
|
|
3042
3082
|
);
|
|
@@ -3083,7 +3123,7 @@ function wrapCallModel(callModelFn, defaultThis) {
|
|
|
3083
3123
|
const request = cloneCallModelRequest(argArray[0]);
|
|
3084
3124
|
const options = argArray[1];
|
|
3085
3125
|
const invocationTarget = thisArg === void 0 ? _nullishCoalesce(defaultThis, () => ( thisArg)) : thisArg;
|
|
3086
|
-
return
|
|
3126
|
+
return _chunkBFGIH2ZJjs.openRouterAgentChannels.callModel.traceSync(
|
|
3087
3127
|
() => Reflect.apply(target, invocationTarget, [request, options]),
|
|
3088
3128
|
{
|
|
3089
3129
|
arguments: [request]
|
|
@@ -3179,24 +3219,24 @@ function rerankProxy(rerank) {
|
|
|
3179
3219
|
});
|
|
3180
3220
|
}
|
|
3181
3221
|
function wrapChatSend(send) {
|
|
3182
|
-
return (request, options) =>
|
|
3222
|
+
return (request, options) => _chunkBFGIH2ZJjs.openRouterChannels.chatSend.tracePromise(() => send(request, options), {
|
|
3183
3223
|
arguments: [request]
|
|
3184
3224
|
});
|
|
3185
3225
|
}
|
|
3186
3226
|
function wrapEmbeddingsGenerate(generate) {
|
|
3187
|
-
return (request, options) =>
|
|
3227
|
+
return (request, options) => _chunkBFGIH2ZJjs.openRouterChannels.embeddingsGenerate.tracePromise(
|
|
3188
3228
|
() => generate(request, options),
|
|
3189
3229
|
{ arguments: [request] }
|
|
3190
3230
|
);
|
|
3191
3231
|
}
|
|
3192
3232
|
function wrapResponsesSend(send) {
|
|
3193
|
-
return (request, options) =>
|
|
3233
|
+
return (request, options) => _chunkBFGIH2ZJjs.openRouterChannels.betaResponsesSend.tracePromise(
|
|
3194
3234
|
() => send(request, options),
|
|
3195
3235
|
{ arguments: [request] }
|
|
3196
3236
|
);
|
|
3197
3237
|
}
|
|
3198
3238
|
function wrapRerank2(rerank) {
|
|
3199
|
-
return (request, options) =>
|
|
3239
|
+
return (request, options) => _chunkBFGIH2ZJjs.openRouterChannels.rerankRerank.tracePromise(
|
|
3200
3240
|
() => rerank(request, options),
|
|
3201
3241
|
{ arguments: [request] }
|
|
3202
3242
|
);
|
|
@@ -3204,7 +3244,7 @@ function wrapRerank2(rerank) {
|
|
|
3204
3244
|
function wrapCallModel2(callModel) {
|
|
3205
3245
|
return (request, options) => {
|
|
3206
3246
|
const tracedRequest = { ...request };
|
|
3207
|
-
return
|
|
3247
|
+
return _chunkBFGIH2ZJjs.openRouterChannels.callModel.traceSync(
|
|
3208
3248
|
() => callModel(tracedRequest, options),
|
|
3209
3249
|
{
|
|
3210
3250
|
arguments: [tracedRequest]
|
|
@@ -3337,7 +3377,7 @@ function classifiersProxy(classifiers) {
|
|
|
3337
3377
|
});
|
|
3338
3378
|
}
|
|
3339
3379
|
function wrapChatComplete(complete) {
|
|
3340
|
-
return (request, options) =>
|
|
3380
|
+
return (request, options) => _chunkBFGIH2ZJjs.mistralChannels.chatComplete.tracePromise(
|
|
3341
3381
|
() => complete(request, options),
|
|
3342
3382
|
{
|
|
3343
3383
|
arguments: [request]
|
|
@@ -3345,52 +3385,52 @@ function wrapChatComplete(complete) {
|
|
|
3345
3385
|
);
|
|
3346
3386
|
}
|
|
3347
3387
|
function wrapChatStream(stream) {
|
|
3348
|
-
return (request, options) =>
|
|
3388
|
+
return (request, options) => _chunkBFGIH2ZJjs.mistralChannels.chatStream.tracePromise(() => stream(request, options), {
|
|
3349
3389
|
arguments: [request]
|
|
3350
3390
|
});
|
|
3351
3391
|
}
|
|
3352
3392
|
function wrapEmbeddingsCreate(create) {
|
|
3353
|
-
return (request, options) =>
|
|
3393
|
+
return (request, options) => _chunkBFGIH2ZJjs.mistralChannels.embeddingsCreate.tracePromise(
|
|
3354
3394
|
() => create(request, options),
|
|
3355
3395
|
{ arguments: [request] }
|
|
3356
3396
|
);
|
|
3357
3397
|
}
|
|
3358
3398
|
function wrapClassifiersModerate(moderate) {
|
|
3359
|
-
return (request, options) =>
|
|
3399
|
+
return (request, options) => _chunkBFGIH2ZJjs.mistralChannels.classifiersModerate.tracePromise(
|
|
3360
3400
|
() => moderate(request, options),
|
|
3361
3401
|
{ arguments: [request] }
|
|
3362
3402
|
);
|
|
3363
3403
|
}
|
|
3364
3404
|
function wrapClassifiersModerateChat(moderateChat) {
|
|
3365
|
-
return (request, options) =>
|
|
3405
|
+
return (request, options) => _chunkBFGIH2ZJjs.mistralChannels.classifiersModerateChat.tracePromise(
|
|
3366
3406
|
() => moderateChat(request, options),
|
|
3367
3407
|
{ arguments: [request] }
|
|
3368
3408
|
);
|
|
3369
3409
|
}
|
|
3370
3410
|
function wrapClassifiersClassify(classify) {
|
|
3371
|
-
return (request, options) =>
|
|
3411
|
+
return (request, options) => _chunkBFGIH2ZJjs.mistralChannels.classifiersClassify.tracePromise(
|
|
3372
3412
|
() => classify(request, options),
|
|
3373
3413
|
{ arguments: [request] }
|
|
3374
3414
|
);
|
|
3375
3415
|
}
|
|
3376
3416
|
function wrapClassifiersClassifyChat(classifyChat) {
|
|
3377
|
-
return (request, options) =>
|
|
3417
|
+
return (request, options) => _chunkBFGIH2ZJjs.mistralChannels.classifiersClassifyChat.tracePromise(
|
|
3378
3418
|
() => classifyChat(request, options),
|
|
3379
3419
|
{ arguments: [request] }
|
|
3380
3420
|
);
|
|
3381
3421
|
}
|
|
3382
3422
|
function wrapFimComplete(complete) {
|
|
3383
|
-
return (request, options) =>
|
|
3423
|
+
return (request, options) => _chunkBFGIH2ZJjs.mistralChannels.fimComplete.tracePromise(() => complete(request, options), {
|
|
3384
3424
|
arguments: [request]
|
|
3385
3425
|
});
|
|
3386
3426
|
}
|
|
3387
3427
|
function wrapFimStream(stream) {
|
|
3388
|
-
return (request, options) =>
|
|
3428
|
+
return (request, options) => _chunkBFGIH2ZJjs.mistralChannels.fimStream.tracePromise(() => stream(request, options), {
|
|
3389
3429
|
arguments: [request]
|
|
3390
3430
|
});
|
|
3391
3431
|
}
|
|
3392
3432
|
function wrapAgentsComplete(complete) {
|
|
3393
|
-
return (request, options) =>
|
|
3433
|
+
return (request, options) => _chunkBFGIH2ZJjs.mistralChannels.agentsComplete.tracePromise(
|
|
3394
3434
|
() => complete(request, options),
|
|
3395
3435
|
{
|
|
3396
3436
|
arguments: [request]
|
|
@@ -3398,7 +3438,7 @@ function wrapAgentsComplete(complete) {
|
|
|
3398
3438
|
);
|
|
3399
3439
|
}
|
|
3400
3440
|
function wrapAgentsStream(stream) {
|
|
3401
|
-
return (request, options) =>
|
|
3441
|
+
return (request, options) => _chunkBFGIH2ZJjs.mistralChannels.agentsStream.tracePromise(() => stream(request, options), {
|
|
3402
3442
|
arguments: [request]
|
|
3403
3443
|
});
|
|
3404
3444
|
}
|
|
@@ -3451,22 +3491,22 @@ function cohereProxy(cohere) {
|
|
|
3451
3491
|
return proxy;
|
|
3452
3492
|
}
|
|
3453
3493
|
function wrapChat(chat) {
|
|
3454
|
-
return (request, options) =>
|
|
3494
|
+
return (request, options) => _chunkBFGIH2ZJjs.cohereChannels.chat.tracePromise(() => chat(request, options), {
|
|
3455
3495
|
arguments: [request]
|
|
3456
3496
|
});
|
|
3457
3497
|
}
|
|
3458
3498
|
function wrapChatStream2(chatStream) {
|
|
3459
|
-
return (request, options) =>
|
|
3499
|
+
return (request, options) => _chunkBFGIH2ZJjs.cohereChannels.chatStream.tracePromise(() => chatStream(request, options), {
|
|
3460
3500
|
arguments: [request]
|
|
3461
3501
|
});
|
|
3462
3502
|
}
|
|
3463
3503
|
function wrapEmbed3(embed) {
|
|
3464
|
-
return (request, options) =>
|
|
3504
|
+
return (request, options) => _chunkBFGIH2ZJjs.cohereChannels.embed.tracePromise(() => embed(request, options), {
|
|
3465
3505
|
arguments: [request]
|
|
3466
3506
|
});
|
|
3467
3507
|
}
|
|
3468
3508
|
function wrapRerank3(rerank) {
|
|
3469
|
-
return (request, options) =>
|
|
3509
|
+
return (request, options) => _chunkBFGIH2ZJjs.cohereChannels.rerank.tracePromise(() => rerank(request, options), {
|
|
3470
3510
|
arguments: [request]
|
|
3471
3511
|
});
|
|
3472
3512
|
}
|
|
@@ -3548,13 +3588,13 @@ function groqProxy(groq) {
|
|
|
3548
3588
|
return topLevelProxy;
|
|
3549
3589
|
}
|
|
3550
3590
|
function wrapChatCompletionsCreate(create) {
|
|
3551
|
-
return (request, options) =>
|
|
3591
|
+
return (request, options) => _chunkBFGIH2ZJjs.groqChannels.chatCompletionsCreate.tracePromise(
|
|
3552
3592
|
() => create(request, options),
|
|
3553
3593
|
{ arguments: [request] }
|
|
3554
3594
|
);
|
|
3555
3595
|
}
|
|
3556
3596
|
function wrapEmbeddingsCreate2(create) {
|
|
3557
|
-
return (request, options) =>
|
|
3597
|
+
return (request, options) => _chunkBFGIH2ZJjs.groqChannels.embeddingsCreate.tracePromise(() => create(request, options), {
|
|
3558
3598
|
arguments: [request]
|
|
3559
3599
|
});
|
|
3560
3600
|
}
|
|
@@ -3628,16 +3668,16 @@ function bedrockRuntimeProxy(client) {
|
|
|
3628
3668
|
}
|
|
3629
3669
|
function wrapSend(send) {
|
|
3630
3670
|
return (command, optionsOrCb, cb) => {
|
|
3631
|
-
if (
|
|
3671
|
+
if (_chunkFY7DAKA5js.getBedrockRuntimeOperation.call(void 0, command) === void 0 || typeof optionsOrCb === "function" || typeof cb === "function") {
|
|
3632
3672
|
return send(command, optionsOrCb, cb);
|
|
3633
3673
|
}
|
|
3634
|
-
return
|
|
3635
|
-
() =>
|
|
3674
|
+
return _chunkBFGIH2ZJjs.bedrockRuntimeChannels.clientSend.tracePromise(
|
|
3675
|
+
() => _chunkFY7DAKA5js.runWithAutoInstrumentationSuppressed.call(void 0,
|
|
3636
3676
|
() => send(command, optionsOrCb)
|
|
3637
3677
|
),
|
|
3638
3678
|
{
|
|
3639
3679
|
arguments: [command, optionsOrCb],
|
|
3640
|
-
span_info:
|
|
3680
|
+
span_info: _chunkFY7DAKA5js.buildBedrockRuntimeSpanInfo.call(void 0, command)
|
|
3641
3681
|
}
|
|
3642
3682
|
);
|
|
3643
3683
|
};
|
|
@@ -3686,13 +3726,13 @@ function copilotClientProxy(client) {
|
|
|
3686
3726
|
return proxy;
|
|
3687
3727
|
}
|
|
3688
3728
|
function wrappedCreateSession(client) {
|
|
3689
|
-
return (config) =>
|
|
3729
|
+
return (config) => _chunkBFGIH2ZJjs.gitHubCopilotChannels.createSession.tracePromise(
|
|
3690
3730
|
() => client.createSession(config),
|
|
3691
3731
|
{ arguments: [config] }
|
|
3692
3732
|
);
|
|
3693
3733
|
}
|
|
3694
3734
|
function wrappedResumeSession(client) {
|
|
3695
|
-
return (sessionId, config) =>
|
|
3735
|
+
return (sessionId, config) => _chunkBFGIH2ZJjs.gitHubCopilotChannels.resumeSession.tracePromise(
|
|
3696
3736
|
() => client.resumeSession(sessionId, config),
|
|
3697
3737
|
{ arguments: [sessionId, config] }
|
|
3698
3738
|
);
|
|
@@ -3706,7 +3746,7 @@ var VitestContextManager = class {
|
|
|
3706
3746
|
*/
|
|
3707
3747
|
|
|
3708
3748
|
constructor() {
|
|
3709
|
-
this.contextStorage =
|
|
3749
|
+
this.contextStorage = _chunkBFGIH2ZJjs.isomorph_default.newAsyncLocalStorage();
|
|
3710
3750
|
}
|
|
3711
3751
|
getCurrentContext() {
|
|
3712
3752
|
return this.contextStorage.getStore();
|
|
@@ -3747,7 +3787,7 @@ var FlushCoordinator = (_class = class {constructor() { _class.prototype.__init.
|
|
|
3747
3787
|
if (this.activeFlushes.has(experimentId)) {
|
|
3748
3788
|
return this.activeFlushes.get(experimentId);
|
|
3749
3789
|
}
|
|
3750
|
-
const flushPromise =
|
|
3790
|
+
const flushPromise = _chunkFY7DAKA5js.summarizeAndFlush.call(void 0, context.experiment, {
|
|
3751
3791
|
displaySummary: config.displaySummary
|
|
3752
3792
|
});
|
|
3753
3793
|
this.activeFlushes.set(experimentId, flushPromise);
|
|
@@ -3845,7 +3885,7 @@ async function runTracedEval(args) {
|
|
|
3845
3885
|
}
|
|
3846
3886
|
if (testError) {
|
|
3847
3887
|
span.log({ scores: { pass: 0 } });
|
|
3848
|
-
|
|
3888
|
+
_chunkFY7DAKA5js.logError.call(void 0, span, testError);
|
|
3849
3889
|
throw testError;
|
|
3850
3890
|
}
|
|
3851
3891
|
span.log({
|
|
@@ -4019,10 +4059,10 @@ function wrapDescribe(originalDescribe, config, afterAll) {
|
|
|
4019
4059
|
const getOrCreateContext = () => {
|
|
4020
4060
|
if (!context) {
|
|
4021
4061
|
const experimentName = `${suiteName}-${(/* @__PURE__ */ new Date()).toISOString()}`;
|
|
4022
|
-
const experiment = config.projectId ?
|
|
4062
|
+
const experiment = config.projectId ? _chunkFY7DAKA5js.initExperiment.call(void 0, {
|
|
4023
4063
|
projectId: config.projectId,
|
|
4024
4064
|
experiment: experimentName
|
|
4025
|
-
}) :
|
|
4065
|
+
}) : _chunkFY7DAKA5js.initExperiment.call(void 0, config.projectName || suiteName, {
|
|
4026
4066
|
experiment: experimentName
|
|
4027
4067
|
});
|
|
4028
4068
|
context = contextManager.createChildContext(void 0, experiment);
|
|
@@ -4130,7 +4170,7 @@ function wrapExpect(originalExpect) {
|
|
|
4130
4170
|
return originalExpect(value);
|
|
4131
4171
|
}
|
|
4132
4172
|
const assertion = originalExpect(value, message);
|
|
4133
|
-
const span =
|
|
4173
|
+
const span = _chunkFY7DAKA5js.currentSpan.call(void 0, );
|
|
4134
4174
|
if (!span) {
|
|
4135
4175
|
return assertion;
|
|
4136
4176
|
}
|
|
@@ -4142,16 +4182,16 @@ function wrapExpect(originalExpect) {
|
|
|
4142
4182
|
|
|
4143
4183
|
// src/wrappers/shared/logging.ts
|
|
4144
4184
|
function logOutputs(outputs) {
|
|
4145
|
-
|
|
4185
|
+
_chunkFY7DAKA5js.currentSpan.call(void 0, ).log({ output: outputs });
|
|
4146
4186
|
}
|
|
4147
4187
|
function logFeedback(feedback) {
|
|
4148
|
-
|
|
4188
|
+
_chunkFY7DAKA5js.currentSpan.call(void 0, ).log({
|
|
4149
4189
|
scores: { [feedback.name]: feedback.score },
|
|
4150
4190
|
metadata: feedback.metadata
|
|
4151
4191
|
});
|
|
4152
4192
|
}
|
|
4153
4193
|
function getCurrentSpan() {
|
|
4154
|
-
return
|
|
4194
|
+
return _chunkFY7DAKA5js.currentSpan.call(void 0, );
|
|
4155
4195
|
}
|
|
4156
4196
|
|
|
4157
4197
|
// src/wrappers/vitest/index.ts
|
|
@@ -4199,7 +4239,7 @@ function wrapVitest(vitestMethods, config = {}) {
|
|
|
4199
4239
|
);
|
|
4200
4240
|
return;
|
|
4201
4241
|
}
|
|
4202
|
-
await
|
|
4242
|
+
await _chunkFY7DAKA5js.summarizeAndFlush.call(void 0, ctx.experiment, {
|
|
4203
4243
|
displaySummary: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _88 => _88.displaySummary]), () => ( config.displaySummary))
|
|
4204
4244
|
});
|
|
4205
4245
|
}
|
|
@@ -4214,7 +4254,7 @@ function initNodeTestSuite(config) {
|
|
|
4214
4254
|
return experiment;
|
|
4215
4255
|
}
|
|
4216
4256
|
const experimentName = config.experimentName || `${config.projectName}-${(/* @__PURE__ */ new Date()).toISOString()}`;
|
|
4217
|
-
experiment =
|
|
4257
|
+
experiment = _chunkFY7DAKA5js.initExperiment.call(void 0, config.projectName, {
|
|
4218
4258
|
experiment: experimentName
|
|
4219
4259
|
});
|
|
4220
4260
|
return experiment;
|
|
@@ -4263,7 +4303,7 @@ function initNodeTestSuite(config) {
|
|
|
4263
4303
|
if (!experiment) {
|
|
4264
4304
|
return;
|
|
4265
4305
|
}
|
|
4266
|
-
await
|
|
4306
|
+
await _chunkFY7DAKA5js.summarizeAndFlush.call(void 0, experiment, {
|
|
4267
4307
|
displaySummary: config.displaySummary
|
|
4268
4308
|
});
|
|
4269
4309
|
experiment = void 0;
|
|
@@ -4280,7 +4320,7 @@ function initNodeTestSuite(config) {
|
|
|
4280
4320
|
|
|
4281
4321
|
// src/graph-framework.ts
|
|
4282
4322
|
var graph_framework_exports = {};
|
|
4283
|
-
|
|
4323
|
+
_chunkBFGIH2ZJjs.__export.call(void 0, graph_framework_exports, {
|
|
4284
4324
|
AggregatorNode: () => AggregatorNode,
|
|
4285
4325
|
GateNode: () => GateNode,
|
|
4286
4326
|
GraphBuilder: () => GraphBuilder,
|
|
@@ -4354,7 +4394,7 @@ var GraphBuilder = (_class2 = class {
|
|
|
4354
4394
|
};
|
|
4355
4395
|
}
|
|
4356
4396
|
resolveNode(node) {
|
|
4357
|
-
if (node instanceof
|
|
4397
|
+
if (node instanceof _chunkFY7DAKA5js.Prompt) {
|
|
4358
4398
|
const cached = this.nodeLikeNodes.get(node);
|
|
4359
4399
|
if (cached) {
|
|
4360
4400
|
return [cached, []];
|
|
@@ -4404,7 +4444,7 @@ var GraphBuilder = (_class2 = class {
|
|
|
4404
4444
|
// }
|
|
4405
4445
|
// Helper to generate node IDs
|
|
4406
4446
|
generateId(name) {
|
|
4407
|
-
const uuid =
|
|
4447
|
+
const uuid = _chunkFY7DAKA5js.newId.call(void 0, );
|
|
4408
4448
|
if (name) {
|
|
4409
4449
|
return `${name}-${uuid.slice(0, 8)}`;
|
|
4410
4450
|
} else {
|
|
@@ -5598,16 +5638,22 @@ function waterfall(tasks, callback) {
|
|
|
5598
5638
|
var waterfall$1 = awaitify(waterfall);
|
|
5599
5639
|
|
|
5600
5640
|
// src/trace.ts
|
|
5601
|
-
var SpanFetcher = class _SpanFetcher extends
|
|
5602
|
-
constructor(objectType, _objectId, rootSpanId, _state, spanTypeFilter, includeScorers = false) {
|
|
5641
|
+
var SpanFetcher = class _SpanFetcher extends _chunkFY7DAKA5js.ObjectFetcher {
|
|
5642
|
+
constructor(objectType, _objectId, rootSpanId, _state, spanTypeFilter, includeScorers = false, brainstoreRealtime = true) {
|
|
5603
5643
|
const filterExpr = _SpanFetcher.buildFilter(
|
|
5604
5644
|
rootSpanId,
|
|
5605
5645
|
spanTypeFilter,
|
|
5606
5646
|
includeScorers
|
|
5607
5647
|
);
|
|
5608
|
-
super(
|
|
5609
|
-
|
|
5610
|
-
|
|
5648
|
+
super(
|
|
5649
|
+
objectType,
|
|
5650
|
+
void 0,
|
|
5651
|
+
void 0,
|
|
5652
|
+
{
|
|
5653
|
+
filter: filterExpr
|
|
5654
|
+
},
|
|
5655
|
+
brainstoreRealtime
|
|
5656
|
+
);
|
|
5611
5657
|
this._objectId = _objectId;
|
|
5612
5658
|
this.rootSpanId = rootSpanId;
|
|
5613
5659
|
this._state = _state;
|
|
@@ -5661,7 +5707,7 @@ var CachedSpanFetcher = (_class4 = class {
|
|
|
5661
5707
|
__init7() {this.spanCache = /* @__PURE__ */ new Map()}
|
|
5662
5708
|
__init8() {this.allFetched = false}
|
|
5663
5709
|
|
|
5664
|
-
constructor(objectTypeOrFetchFn, objectId, rootSpanId, getState) {;_class4.prototype.__init7.call(this);_class4.prototype.__init8.call(this);
|
|
5710
|
+
constructor(objectTypeOrFetchFn, objectId, rootSpanId, getState, brainstoreRealtime = true) {;_class4.prototype.__init7.call(this);_class4.prototype.__init8.call(this);
|
|
5665
5711
|
if (typeof objectTypeOrFetchFn === "function") {
|
|
5666
5712
|
this.fetchFn = (spanType) => objectTypeOrFetchFn(spanType);
|
|
5667
5713
|
} else {
|
|
@@ -5674,7 +5720,8 @@ var CachedSpanFetcher = (_class4 = class {
|
|
|
5674
5720
|
rootSpanId,
|
|
5675
5721
|
state,
|
|
5676
5722
|
spanType,
|
|
5677
|
-
includeScorers
|
|
5723
|
+
includeScorers,
|
|
5724
|
+
brainstoreRealtime
|
|
5678
5725
|
);
|
|
5679
5726
|
const rows = await fetcher.fetchedData();
|
|
5680
5727
|
return rows.map((row) => ({
|
|
@@ -5904,20 +5951,20 @@ var promptContentsSchema = _v3.z.union([
|
|
|
5904
5951
|
prompt: _v3.z.string()
|
|
5905
5952
|
}),
|
|
5906
5953
|
_v3.z.object({
|
|
5907
|
-
messages: _v3.z.array(
|
|
5954
|
+
messages: _v3.z.array(_chunkFY7DAKA5js.ChatCompletionMessageParam)
|
|
5908
5955
|
})
|
|
5909
5956
|
]);
|
|
5910
5957
|
var promptDefinitionSchema = promptContentsSchema.and(
|
|
5911
5958
|
_v3.z.object({
|
|
5912
5959
|
model: _v3.z.string(),
|
|
5913
|
-
params:
|
|
5960
|
+
params: _chunkFY7DAKA5js.ModelParams.optional(),
|
|
5914
5961
|
templateFormat: _v3.z.enum(["mustache", "nunjucks", "none"]).optional(),
|
|
5915
5962
|
environments: _v3.z.array(_v3.z.string()).optional()
|
|
5916
5963
|
})
|
|
5917
5964
|
);
|
|
5918
5965
|
var promptDefinitionWithToolsSchema = promptDefinitionSchema.and(
|
|
5919
5966
|
_v3.z.object({
|
|
5920
|
-
tools: _v3.z.array(
|
|
5967
|
+
tools: _v3.z.array(_chunkFY7DAKA5js.ToolFunctionDefinition).optional()
|
|
5921
5968
|
})
|
|
5922
5969
|
);
|
|
5923
5970
|
function promptDefinitionToPromptData(promptDefinition, rawTools) {
|
|
@@ -5965,7 +6012,7 @@ async function validateParameters(parameters, parameterSchema) {
|
|
|
5965
6012
|
if (resolvedSchema === void 0 || resolvedSchema === null) {
|
|
5966
6013
|
return parameters;
|
|
5967
6014
|
}
|
|
5968
|
-
if (
|
|
6015
|
+
if (_chunkFY7DAKA5js.RemoteEvalParameters.isParameters(resolvedSchema)) {
|
|
5969
6016
|
const mergedParameters = parameters && Object.keys(parameters).length > 0 ? {
|
|
5970
6017
|
...resolvedSchema.data,
|
|
5971
6018
|
...parameters
|
|
@@ -5987,14 +6034,14 @@ function validateParametersWithZod(parameters, parameterSchema) {
|
|
|
5987
6034
|
const value = parameters[name];
|
|
5988
6035
|
try {
|
|
5989
6036
|
if ("type" in schema && schema.type === "prompt") {
|
|
5990
|
-
const promptData = value ?
|
|
6037
|
+
const promptData = value ? _chunkFY7DAKA5js.PromptData.parse(value) : schema.default ? promptDefinitionToPromptData(
|
|
5991
6038
|
schema.default,
|
|
5992
6039
|
schema.default.tools
|
|
5993
6040
|
) : void 0;
|
|
5994
6041
|
if (!promptData) {
|
|
5995
6042
|
throw new Error(`Parameter '${name}' is required`);
|
|
5996
6043
|
}
|
|
5997
|
-
return [name,
|
|
6044
|
+
return [name, _chunkFY7DAKA5js.Prompt.fromPromptData(name, promptData)];
|
|
5998
6045
|
} else if ("type" in schema && schema.type === "model") {
|
|
5999
6046
|
const model = _nullishCoalesce(value, () => ( schema.default));
|
|
6000
6047
|
if (model === void 0) {
|
|
@@ -6045,7 +6092,7 @@ function rehydrateRemoteParameters(parameters, schema) {
|
|
|
6045
6092
|
if (Reflect.get(propertySchema, "x-bt-type") === "prompt") {
|
|
6046
6093
|
return [
|
|
6047
6094
|
name,
|
|
6048
|
-
|
|
6095
|
+
_chunkFY7DAKA5js.Prompt.fromPromptData(name, _chunkFY7DAKA5js.PromptData.parse(value))
|
|
6049
6096
|
];
|
|
6050
6097
|
}
|
|
6051
6098
|
return [name, value];
|
|
@@ -6093,7 +6140,7 @@ function makeEvalName(projectName, experimentName) {
|
|
|
6093
6140
|
return out;
|
|
6094
6141
|
}
|
|
6095
6142
|
function initExperiment2(state, options = {}) {
|
|
6096
|
-
return
|
|
6143
|
+
return _chunkFY7DAKA5js.init.call(void 0, {
|
|
6097
6144
|
state,
|
|
6098
6145
|
...options,
|
|
6099
6146
|
setCurrent: false
|
|
@@ -6104,7 +6151,7 @@ async function getExperimentParametersRef(parameters) {
|
|
|
6104
6151
|
return void 0;
|
|
6105
6152
|
}
|
|
6106
6153
|
const resolvedParameters = parameters instanceof Promise ? await parameters : parameters;
|
|
6107
|
-
if (!
|
|
6154
|
+
if (!_chunkFY7DAKA5js.RemoteEvalParameters.isParameters(resolvedParameters)) {
|
|
6108
6155
|
return void 0;
|
|
6109
6156
|
}
|
|
6110
6157
|
if (resolvedParameters.id === void 0) {
|
|
@@ -6140,10 +6187,10 @@ globalThis._evals = {
|
|
|
6140
6187
|
reporters: {}
|
|
6141
6188
|
};
|
|
6142
6189
|
function _initializeSpanContext() {
|
|
6143
|
-
globalThis._spanContext = { currentSpan:
|
|
6190
|
+
globalThis._spanContext = { currentSpan: _chunkFY7DAKA5js.currentSpan, withCurrent: _chunkFY7DAKA5js.withCurrent, startSpan: _chunkFY7DAKA5js.startSpan, NOOP_SPAN: _chunkFY7DAKA5js.NOOP_SPAN };
|
|
6144
6191
|
}
|
|
6145
6192
|
async function Eval(name, evaluator, reporterOrOpts) {
|
|
6146
|
-
const options =
|
|
6193
|
+
const options = _chunkFY7DAKA5js.isEmpty.call(void 0, reporterOrOpts) ? {} : typeof reporterOrOpts === "string" ? { reporter: reporterOrOpts } : "name" in reporterOrOpts ? { reporter: reporterOrOpts } : reporterOrOpts;
|
|
6147
6194
|
let evalName = makeEvalName(name, evaluator.experimentName);
|
|
6148
6195
|
if (globalThis._evals.evaluators[evalName]) {
|
|
6149
6196
|
evalName = `${evalName}_${Object.keys(_evals).length}`;
|
|
@@ -6194,7 +6241,7 @@ async function Eval(name, evaluator, reporterOrOpts) {
|
|
|
6194
6241
|
baseExperimentId: evaluator.baseExperimentId,
|
|
6195
6242
|
gitMetadataSettings: evaluator.gitMetadataSettings,
|
|
6196
6243
|
repoInfo: evaluator.repoInfo,
|
|
6197
|
-
dataset:
|
|
6244
|
+
dataset: _chunkFY7DAKA5js.Dataset.isDataset(data) ? data : void 0,
|
|
6198
6245
|
parameters
|
|
6199
6246
|
});
|
|
6200
6247
|
if (experiment && typeof process !== "undefined" && globalThis.BRAINTRUST_CONTEXT_MANAGER !== void 0) {
|
|
@@ -6214,7 +6261,7 @@ async function Eval(name, evaluator, reporterOrOpts) {
|
|
|
6214
6261
|
const enableCache = _nullishCoalesce(options.enableCache, () => ( true));
|
|
6215
6262
|
let ret;
|
|
6216
6263
|
if (options.parent) {
|
|
6217
|
-
ret = await
|
|
6264
|
+
ret = await _chunkFY7DAKA5js.withParent.call(void 0,
|
|
6218
6265
|
options.parent,
|
|
6219
6266
|
() => runEvaluator(
|
|
6220
6267
|
null,
|
|
@@ -6250,7 +6297,7 @@ async function Eval(name, evaluator, reporterOrOpts) {
|
|
|
6250
6297
|
if (experiment) {
|
|
6251
6298
|
await experiment.flush().catch(console.error);
|
|
6252
6299
|
} else if (options.parent) {
|
|
6253
|
-
await
|
|
6300
|
+
await _chunkFY7DAKA5js.flush.call(void 0, { state: evaluator.state }).catch(console.error);
|
|
6254
6301
|
}
|
|
6255
6302
|
}
|
|
6256
6303
|
} finally {
|
|
@@ -6296,13 +6343,13 @@ function classifierName(classifier, classifier_idx) {
|
|
|
6296
6343
|
}
|
|
6297
6344
|
function buildSpanMetadata(results) {
|
|
6298
6345
|
return results.length === 1 ? results[0].metadata : results.reduce(
|
|
6299
|
-
(prev, s) =>
|
|
6346
|
+
(prev, s) => _chunkFY7DAKA5js.mergeDicts.call(void 0, prev, { [s.name]: s.metadata }),
|
|
6300
6347
|
{}
|
|
6301
6348
|
);
|
|
6302
6349
|
}
|
|
6303
6350
|
function buildSpanScores(results) {
|
|
6304
6351
|
const scoresRecord = results.reduce(
|
|
6305
|
-
(prev, s) =>
|
|
6352
|
+
(prev, s) => _chunkFY7DAKA5js.mergeDicts.call(void 0, prev, { [s.name]: s.score }),
|
|
6306
6353
|
{}
|
|
6307
6354
|
);
|
|
6308
6355
|
return { resultMetadata: buildSpanMetadata(results), scoresRecord };
|
|
@@ -6332,7 +6379,7 @@ function collectScoringResults(runResults, names, onResult) {
|
|
|
6332
6379
|
return failing;
|
|
6333
6380
|
}
|
|
6334
6381
|
function validateClassificationResult(value, scorerName2) {
|
|
6335
|
-
if (!(typeof value === "object" && value !== null && !
|
|
6382
|
+
if (!(typeof value === "object" && value !== null && !_chunkFY7DAKA5js.isEmpty.call(void 0, value))) {
|
|
6336
6383
|
throw new Error(
|
|
6337
6384
|
`When returning structured classifier results, each classification must be a non-empty object. Got: ${JSON.stringify(value)}`
|
|
6338
6385
|
);
|
|
@@ -6361,7 +6408,7 @@ function logScoringFailures(kind, failures, metadata, rootSpan, state) {
|
|
|
6361
6408
|
);
|
|
6362
6409
|
metadata[`${kind}_errors`] = errorMap;
|
|
6363
6410
|
rootSpan.log({ metadata: { [`${kind}_errors`]: errorMap } });
|
|
6364
|
-
|
|
6411
|
+
_chunkFY7DAKA5js.debugLogger.forState(state).warn(
|
|
6365
6412
|
`Found exceptions for the following ${kind}s: ${Object.keys(errorMap).join(", ")}`,
|
|
6366
6413
|
failures.map((f) => f.error)
|
|
6367
6414
|
);
|
|
@@ -6395,7 +6442,7 @@ var defaultErrorScoreHandler = ({
|
|
|
6395
6442
|
};
|
|
6396
6443
|
async function runEvaluatorInternal(experiment, evaluator, progressReporter, filters, stream, parameters, collectResults, enableCache) {
|
|
6397
6444
|
if (enableCache) {
|
|
6398
|
-
_optionalChain([(_nullishCoalesce(evaluator.state, () => (
|
|
6445
|
+
_optionalChain([(_nullishCoalesce(evaluator.state, () => ( _chunkFY7DAKA5js._internalGetGlobalState.call(void 0, )))), 'optionalAccess', _102 => _102.spanCache, 'optionalAccess', _103 => _103.start, 'call', _104 => _104()]);
|
|
6399
6446
|
}
|
|
6400
6447
|
try {
|
|
6401
6448
|
if (typeof evaluator.data === "string") {
|
|
@@ -6416,7 +6463,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6416
6463
|
);
|
|
6417
6464
|
}
|
|
6418
6465
|
let name = dataResult.name;
|
|
6419
|
-
if (
|
|
6466
|
+
if (_chunkFY7DAKA5js.isEmpty.call(void 0, name)) {
|
|
6420
6467
|
const baseExperiment = await experiment.fetchBaseExperiment();
|
|
6421
6468
|
if (!baseExperiment) {
|
|
6422
6469
|
throw new Error("BaseExperiment() failed to fetch base experiment");
|
|
@@ -6466,7 +6513,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6466
6513
|
if (cancelled) {
|
|
6467
6514
|
return;
|
|
6468
6515
|
}
|
|
6469
|
-
const eventDataset = experiment ? experiment.dataset :
|
|
6516
|
+
const eventDataset = experiment ? experiment.dataset : _chunkFY7DAKA5js.Dataset.isDataset(evaluator.data) ? evaluator.data : void 0;
|
|
6470
6517
|
const inlineDatasetOrigin = eventDataset && datum.id && datum._xact_id ? {
|
|
6471
6518
|
object_type: "dataset",
|
|
6472
6519
|
object_id: await eventDataset.id,
|
|
@@ -6474,7 +6521,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6474
6521
|
created: datum.created,
|
|
6475
6522
|
_xact_id: datum._xact_id
|
|
6476
6523
|
} : void 0;
|
|
6477
|
-
const parsedDatumOrigin =
|
|
6524
|
+
const parsedDatumOrigin = _chunkFY7DAKA5js.ObjectReference.safeParse(datum.origin);
|
|
6478
6525
|
const origin = _nullishCoalesce(inlineDatasetOrigin, () => ( (_optionalChain([parsedDatumOrigin, 'optionalAccess', _105 => _105.success]) ? parsedDatumOrigin.data : void 0)));
|
|
6479
6526
|
const baseEvent = {
|
|
6480
6527
|
name: "eval",
|
|
@@ -6490,23 +6537,23 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6490
6537
|
}
|
|
6491
6538
|
};
|
|
6492
6539
|
const callback = async (rootSpan) => {
|
|
6493
|
-
const state = _nullishCoalesce(evaluator.state, () => (
|
|
6540
|
+
const state = _nullishCoalesce(evaluator.state, () => ( _chunkFY7DAKA5js._internalGetGlobalState.call(void 0, )));
|
|
6494
6541
|
const ensureSpansFlushed = async () => {
|
|
6495
6542
|
if (experiment) {
|
|
6496
|
-
await
|
|
6543
|
+
await _chunkFY7DAKA5js.flush.call(void 0, { state: experiment.loggingState });
|
|
6497
6544
|
} else if (state) {
|
|
6498
|
-
await
|
|
6545
|
+
await _chunkFY7DAKA5js.flush.call(void 0, { state });
|
|
6499
6546
|
} else {
|
|
6500
|
-
await
|
|
6547
|
+
await _chunkFY7DAKA5js.flush.call(void 0, );
|
|
6501
6548
|
}
|
|
6502
6549
|
if (state) {
|
|
6503
6550
|
await state.flushOtel();
|
|
6504
6551
|
}
|
|
6505
6552
|
};
|
|
6506
6553
|
const parentStr = state.currentParent.getStore();
|
|
6507
|
-
const parentComponents = parentStr ?
|
|
6554
|
+
const parentComponents = typeof parentStr === "string" ? _chunkFY7DAKA5js.SpanComponentsV4.fromStr(parentStr) : null;
|
|
6508
6555
|
const trace = state ? new LocalTrace({
|
|
6509
|
-
objectType: parentComponents ?
|
|
6556
|
+
objectType: parentComponents ? _chunkFY7DAKA5js.spanObjectTypeV3ToTypedString.call(void 0,
|
|
6510
6557
|
parentComponents.data.object_type
|
|
6511
6558
|
) : "experiment",
|
|
6512
6559
|
objectId: await _asyncNullishCoalesce(await _asyncOptionalChain([parentComponents, 'optionalAccess', async _106 => _106.data, 'access', async _107 => _107.object_id]), async () => ( (experimentIdPromise ? await _asyncNullishCoalesce(await experimentIdPromise, async () => ( "")) : ""))),
|
|
@@ -6581,7 +6628,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6581
6628
|
trace
|
|
6582
6629
|
};
|
|
6583
6630
|
const { trace: _trace, ...scoringArgsForLogging } = scoringArgs;
|
|
6584
|
-
const propagatedEvent =
|
|
6631
|
+
const propagatedEvent = _chunkFY7DAKA5js.makeScorerPropagatedEvent.call(void 0,
|
|
6585
6632
|
await rootSpan.export()
|
|
6586
6633
|
);
|
|
6587
6634
|
const getOtherFields = (s) => {
|
|
@@ -6604,14 +6651,14 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6604
6651
|
if (scoreValue === null) return null;
|
|
6605
6652
|
if (Array.isArray(scoreValue)) {
|
|
6606
6653
|
for (const s of scoreValue) {
|
|
6607
|
-
if (!(typeof s === "object" && !
|
|
6654
|
+
if (!(typeof s === "object" && !_chunkFY7DAKA5js.isEmpty.call(void 0, s))) {
|
|
6608
6655
|
throw new Error(
|
|
6609
6656
|
`When returning an array of scores, each score must be a non-empty object. Got: ${JSON.stringify(s)}`
|
|
6610
6657
|
);
|
|
6611
6658
|
}
|
|
6612
6659
|
}
|
|
6613
6660
|
}
|
|
6614
|
-
const results = Array.isArray(scoreValue) ? scoreValue : typeof scoreValue === "object" && !
|
|
6661
|
+
const results = Array.isArray(scoreValue) ? scoreValue : typeof scoreValue === "object" && !_chunkFY7DAKA5js.isEmpty.call(void 0, scoreValue) ? [scoreValue] : [
|
|
6615
6662
|
{
|
|
6616
6663
|
name: scorerNames[score_idx],
|
|
6617
6664
|
score: scoreValue
|
|
@@ -6619,7 +6666,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6619
6666
|
];
|
|
6620
6667
|
const { resultMetadata, scoresRecord } = buildSpanScores(results);
|
|
6621
6668
|
const resultOutput = results.length === 1 ? getOtherFields(results[0]) : results.reduce(
|
|
6622
|
-
(prev, s) =>
|
|
6669
|
+
(prev, s) => _chunkFY7DAKA5js.mergeDicts.call(void 0, prev, {
|
|
6623
6670
|
[s.name]: getOtherFields(s)
|
|
6624
6671
|
}),
|
|
6625
6672
|
{}
|
|
@@ -6654,7 +6701,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6654
6701
|
)
|
|
6655
6702
|
);
|
|
6656
6703
|
const resultOutput = rawResults.length === 1 ? toClassificationItem(rawResults[0]) : rawResults.reduce(
|
|
6657
|
-
(prev, r) =>
|
|
6704
|
+
(prev, r) => _chunkFY7DAKA5js.mergeDicts.call(void 0, prev, {
|
|
6658
6705
|
[r.name]: toClassificationItem(r)
|
|
6659
6706
|
}),
|
|
6660
6707
|
{}
|
|
@@ -6706,7 +6753,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6706
6753
|
evaluator.state
|
|
6707
6754
|
);
|
|
6708
6755
|
} catch (e) {
|
|
6709
|
-
|
|
6756
|
+
_chunkFY7DAKA5js.logError.call(void 0, rootSpan, e);
|
|
6710
6757
|
error = e;
|
|
6711
6758
|
} finally {
|
|
6712
6759
|
progressReporter.increment(evaluator.evalName);
|
|
@@ -6740,7 +6787,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6740
6787
|
}
|
|
6741
6788
|
};
|
|
6742
6789
|
if (!experiment) {
|
|
6743
|
-
return await
|
|
6790
|
+
return await _chunkFY7DAKA5js.traced.call(void 0, callback, {
|
|
6744
6791
|
...baseEvent,
|
|
6745
6792
|
state: evaluator.state
|
|
6746
6793
|
});
|
|
@@ -6782,7 +6829,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6782
6829
|
const cancel = async () => {
|
|
6783
6830
|
await new Promise((_, reject2) => {
|
|
6784
6831
|
if (cancelled) {
|
|
6785
|
-
reject2(new (0,
|
|
6832
|
+
reject2(new (0, _chunkFY7DAKA5js.InternalAbortError)("Evaluator already cancelled"));
|
|
6786
6833
|
return;
|
|
6787
6834
|
}
|
|
6788
6835
|
let timeoutId;
|
|
@@ -6803,12 +6850,12 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6803
6850
|
};
|
|
6804
6851
|
if (evaluator.timeout) {
|
|
6805
6852
|
timeoutId = setTimeout(() => {
|
|
6806
|
-
rejectOnce(new (0,
|
|
6853
|
+
rejectOnce(new (0, _chunkFY7DAKA5js.InternalAbortError)("Evaluator timed out"));
|
|
6807
6854
|
}, evaluator.timeout);
|
|
6808
6855
|
}
|
|
6809
6856
|
if (evaluator.signal) {
|
|
6810
6857
|
abortHandler = () => {
|
|
6811
|
-
rejectOnce(new (0,
|
|
6858
|
+
rejectOnce(new (0, _chunkFY7DAKA5js.InternalAbortError)("Evaluator aborted"));
|
|
6812
6859
|
};
|
|
6813
6860
|
evaluator.signal.addEventListener("abort", abortHandler);
|
|
6814
6861
|
}
|
|
@@ -6831,9 +6878,9 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6831
6878
|
}
|
|
6832
6879
|
} catch (e) {
|
|
6833
6880
|
q.kill();
|
|
6834
|
-
if (e instanceof
|
|
6835
|
-
if (
|
|
6836
|
-
|
|
6881
|
+
if (e instanceof _chunkFY7DAKA5js.InternalAbortError) {
|
|
6882
|
+
if (_chunkBFGIH2ZJjs.isomorph_default.getEnv("BRAINTRUST_VERBOSE")) {
|
|
6883
|
+
_chunkFY7DAKA5js.debugLogger.forState(evaluator.state).warn("Evaluator cancelled:", e.message);
|
|
6837
6884
|
}
|
|
6838
6885
|
}
|
|
6839
6886
|
throw e;
|
|
@@ -6857,7 +6904,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6857
6904
|
);
|
|
6858
6905
|
} finally {
|
|
6859
6906
|
if (enableCache) {
|
|
6860
|
-
const spanCache = _optionalChain([(_nullishCoalesce(evaluator.state, () => (
|
|
6907
|
+
const spanCache = _optionalChain([(_nullishCoalesce(evaluator.state, () => ( _chunkFY7DAKA5js._internalGetGlobalState.call(void 0, )))), 'optionalAccess', _115 => _115.spanCache]);
|
|
6861
6908
|
_optionalChain([spanCache, 'optionalAccess', _116 => _116.dispose, 'call', _117 => _117()]);
|
|
6862
6909
|
_optionalChain([spanCache, 'optionalAccess', _118 => _118.stop, 'call', _119 => _119()]);
|
|
6863
6910
|
}
|
|
@@ -6952,25 +6999,25 @@ var defaultReporter = {
|
|
|
6952
6999
|
reportFailures(evaluator, failingResults, { verbose, jsonl });
|
|
6953
7000
|
}
|
|
6954
7001
|
if (jsonl) {
|
|
6955
|
-
|
|
7002
|
+
_chunkBFGIH2ZJjs.isomorph_default.writeln(JSON.stringify(summary));
|
|
6956
7003
|
} else {
|
|
6957
|
-
|
|
6958
|
-
|
|
7004
|
+
_chunkBFGIH2ZJjs.isomorph_default.writeln("Experiment summary");
|
|
7005
|
+
_chunkBFGIH2ZJjs.isomorph_default.writeln("==================");
|
|
6959
7006
|
if (summary.comparisonExperimentName) {
|
|
6960
|
-
|
|
7007
|
+
_chunkBFGIH2ZJjs.isomorph_default.writeln(
|
|
6961
7008
|
`${summary.comparisonExperimentName} (baseline) <- ${summary.experimentName} (comparison)`
|
|
6962
7009
|
);
|
|
6963
|
-
|
|
7010
|
+
_chunkBFGIH2ZJjs.isomorph_default.writeln("");
|
|
6964
7011
|
}
|
|
6965
7012
|
const hasScores = Object.keys(summary.scores).length > 0;
|
|
6966
7013
|
const hasMetrics = Object.keys(_nullishCoalesce(summary.metrics, () => ( {}))).length > 0;
|
|
6967
7014
|
const hasComparison = !!summary.comparisonExperimentName;
|
|
6968
7015
|
if (hasScores || hasMetrics) {
|
|
6969
7016
|
if (hasComparison) {
|
|
6970
|
-
|
|
7017
|
+
_chunkBFGIH2ZJjs.isomorph_default.writeln(
|
|
6971
7018
|
"Name Value Change Improvements Regressions"
|
|
6972
7019
|
);
|
|
6973
|
-
|
|
7020
|
+
_chunkBFGIH2ZJjs.isomorph_default.writeln(
|
|
6974
7021
|
"----------------------------------------------------------------"
|
|
6975
7022
|
);
|
|
6976
7023
|
}
|
|
@@ -6979,18 +7026,18 @@ var defaultReporter = {
|
|
|
6979
7026
|
const scoreValue = `${scorePercent}%`;
|
|
6980
7027
|
if (hasComparison) {
|
|
6981
7028
|
let diffString = "-";
|
|
6982
|
-
if (!
|
|
7029
|
+
if (!_chunkFY7DAKA5js.isEmpty.call(void 0, score.diff)) {
|
|
6983
7030
|
const diffPercent = (score.diff * 100).toFixed(2);
|
|
6984
7031
|
const diffSign = score.diff > 0 ? "+" : "";
|
|
6985
7032
|
diffString = `${diffSign}${diffPercent}%`;
|
|
6986
7033
|
}
|
|
6987
7034
|
const improvements = score.improvements > 0 ? score.improvements.toString() : "-";
|
|
6988
7035
|
const regressions = score.regressions > 0 ? score.regressions.toString() : "-";
|
|
6989
|
-
|
|
7036
|
+
_chunkBFGIH2ZJjs.isomorph_default.writeln(
|
|
6990
7037
|
`${score.name.padEnd(18)} ${scoreValue.padStart(10)} ${diffString.padStart(10)} ${improvements.padStart(12)} ${regressions.padStart(11)}`
|
|
6991
7038
|
);
|
|
6992
7039
|
} else {
|
|
6993
|
-
|
|
7040
|
+
_chunkBFGIH2ZJjs.isomorph_default.writeln(`${score.name.padEnd(20)} ${scoreValue.padStart(15)}`);
|
|
6994
7041
|
}
|
|
6995
7042
|
}
|
|
6996
7043
|
for (const metric of Object.values(_nullishCoalesce(summary.metrics, () => ( {})))) {
|
|
@@ -6999,30 +7046,30 @@ var defaultReporter = {
|
|
|
6999
7046
|
const metricValue = metric.unit === "$" ? `${metric.unit}${formattedValue}` : `${formattedValue}${metric.unit}`;
|
|
7000
7047
|
if (hasComparison) {
|
|
7001
7048
|
let diffString = "-";
|
|
7002
|
-
if (!
|
|
7049
|
+
if (!_chunkFY7DAKA5js.isEmpty.call(void 0, metric.diff)) {
|
|
7003
7050
|
const diffPercent = (metric.diff * 100).toFixed(2);
|
|
7004
7051
|
const diffSign = metric.diff > 0 ? "+" : "";
|
|
7005
7052
|
diffString = `${diffSign}${diffPercent}%`;
|
|
7006
7053
|
}
|
|
7007
7054
|
const improvements = metric.improvements > 0 ? metric.improvements.toString() : "-";
|
|
7008
7055
|
const regressions = metric.regressions > 0 ? metric.regressions.toString() : "-";
|
|
7009
|
-
|
|
7056
|
+
_chunkBFGIH2ZJjs.isomorph_default.writeln(
|
|
7010
7057
|
`${metric.name.padEnd(18)} ${metricValue.padStart(10)} ${diffString.padStart(10)} ${improvements.padStart(12)} ${regressions.padStart(11)}`
|
|
7011
7058
|
);
|
|
7012
7059
|
} else {
|
|
7013
|
-
|
|
7060
|
+
_chunkBFGIH2ZJjs.isomorph_default.writeln(
|
|
7014
7061
|
`${metric.name.padEnd(20)} ${metricValue.padStart(15)}`
|
|
7015
7062
|
);
|
|
7016
7063
|
}
|
|
7017
7064
|
}
|
|
7018
7065
|
}
|
|
7019
7066
|
if (summary.experimentUrl) {
|
|
7020
|
-
|
|
7021
|
-
|
|
7022
|
-
|
|
7067
|
+
_chunkBFGIH2ZJjs.isomorph_default.writeln("");
|
|
7068
|
+
_chunkBFGIH2ZJjs.isomorph_default.writeln(`View results for ${summary.experimentName}`);
|
|
7069
|
+
_chunkBFGIH2ZJjs.isomorph_default.writeln(`See results at ${summary.experimentUrl}`);
|
|
7023
7070
|
}
|
|
7024
7071
|
}
|
|
7025
|
-
|
|
7072
|
+
_chunkBFGIH2ZJjs.isomorph_default.writeln("");
|
|
7026
7073
|
return failingResults.length === 0;
|
|
7027
7074
|
},
|
|
7028
7075
|
async reportRun(evalReports) {
|
|
@@ -7030,6 +7077,350 @@ var defaultReporter = {
|
|
|
7030
7077
|
}
|
|
7031
7078
|
};
|
|
7032
7079
|
|
|
7080
|
+
// src/agent-assertions.ts
|
|
7081
|
+
function agentAssertionScorer(callback, options = {}) {
|
|
7082
|
+
return async (args) => {
|
|
7083
|
+
const { trace: _trace, ...callbackArgs } = args;
|
|
7084
|
+
const callbackMetadata = _nullishCoalesce(callbackArgs.metadata, () => ( {}));
|
|
7085
|
+
const assertions = await callback({
|
|
7086
|
+
...callbackArgs,
|
|
7087
|
+
metadata: callbackMetadata,
|
|
7088
|
+
assert: agentAssertionHelpers
|
|
7089
|
+
});
|
|
7090
|
+
const resources = {};
|
|
7091
|
+
if (assertions.some((assertion) => assertion.requiresTrace)) {
|
|
7092
|
+
resources.spans = await _optionalChain([args, 'access', _120 => _120.trace, 'optionalAccess', _121 => _121.getSpans, 'call', _122 => _122({ spanType: ["tool"] })]);
|
|
7093
|
+
}
|
|
7094
|
+
const results = await Promise.all(
|
|
7095
|
+
assertions.map(async (assertion) => {
|
|
7096
|
+
const result = await assertion.evaluate(resources);
|
|
7097
|
+
return {
|
|
7098
|
+
name: assertion.name,
|
|
7099
|
+
passed: result.passed,
|
|
7100
|
+
failure: result.failure
|
|
7101
|
+
};
|
|
7102
|
+
})
|
|
7103
|
+
);
|
|
7104
|
+
const passed = results.filter((result) => result.passed).length;
|
|
7105
|
+
const total = results.length;
|
|
7106
|
+
const failed = results.filter((result) => !result.passed).map(
|
|
7107
|
+
(result) => `${result.name}: ${_nullishCoalesce(result.failure, () => ( "assertion did not pass"))}`
|
|
7108
|
+
);
|
|
7109
|
+
return {
|
|
7110
|
+
name: _nullishCoalesce(options.name, () => ( "assertions")),
|
|
7111
|
+
score: total === 0 ? 1 : passed / total,
|
|
7112
|
+
metadata: {
|
|
7113
|
+
assertions: results.map(({ name, passed: passed2 }) => ({ name, passed: passed2 })),
|
|
7114
|
+
failed
|
|
7115
|
+
}
|
|
7116
|
+
};
|
|
7117
|
+
};
|
|
7118
|
+
}
|
|
7119
|
+
var agentAssertionHelpers = {
|
|
7120
|
+
equals: (actual, expected, name = "equals") => ({
|
|
7121
|
+
name,
|
|
7122
|
+
evaluate: () => {
|
|
7123
|
+
const passed = deepEqual(actual, expected);
|
|
7124
|
+
return {
|
|
7125
|
+
passed,
|
|
7126
|
+
failure: passed ? void 0 : `expected ${formatValue(actual)} to equal ${formatValue(expected)}`
|
|
7127
|
+
};
|
|
7128
|
+
}
|
|
7129
|
+
}),
|
|
7130
|
+
notEquals: (actual, expected, name = "not equals") => ({
|
|
7131
|
+
name,
|
|
7132
|
+
evaluate: () => {
|
|
7133
|
+
const passed = !deepEqual(actual, expected);
|
|
7134
|
+
return {
|
|
7135
|
+
passed,
|
|
7136
|
+
failure: passed ? void 0 : `expected ${formatValue(actual)} not to equal ${formatValue(expected)}`
|
|
7137
|
+
};
|
|
7138
|
+
}
|
|
7139
|
+
}),
|
|
7140
|
+
contains: (value, expected, name = "contains") => ({
|
|
7141
|
+
name,
|
|
7142
|
+
evaluate: () => {
|
|
7143
|
+
const searchedValue = typeof value === "string" ? value : formatValue(value);
|
|
7144
|
+
const passed = expected instanceof RegExp ? testRegex(expected, value) : searchedValue.includes(expected);
|
|
7145
|
+
return {
|
|
7146
|
+
passed,
|
|
7147
|
+
failure: passed ? void 0 : `expected ${formatValue(value)} to contain ${formatValue(expected)}`
|
|
7148
|
+
};
|
|
7149
|
+
}
|
|
7150
|
+
}),
|
|
7151
|
+
matches: (value, schema, name = "matches schema") => ({
|
|
7152
|
+
name,
|
|
7153
|
+
evaluate: async () => {
|
|
7154
|
+
const result = await validateSchema(schema, value);
|
|
7155
|
+
return {
|
|
7156
|
+
passed: result.passed,
|
|
7157
|
+
failure: result.passed ? void 0 : `expected value to match schema: ${result.message}`
|
|
7158
|
+
};
|
|
7159
|
+
}
|
|
7160
|
+
}),
|
|
7161
|
+
calledTool: (toolName, options = {}, name = `called tool ${toolName}`) => ({
|
|
7162
|
+
name,
|
|
7163
|
+
requiresTrace: true,
|
|
7164
|
+
evaluate: ({ spans }) => {
|
|
7165
|
+
const calls = matchingToolCalls(_nullishCoalesce(spans, () => ( [])), toolName, options);
|
|
7166
|
+
const passed = options.times === void 0 ? calls.length > 0 : calls.length === options.times;
|
|
7167
|
+
return {
|
|
7168
|
+
passed,
|
|
7169
|
+
failure: passed ? void 0 : options.times === void 0 ? `expected tool "${toolName}" to be called; found ${calls.length} matching call${calls.length === 1 ? "" : "s"}` : `expected tool "${toolName}" to be called ${options.times} time${options.times === 1 ? "" : "s"}; found ${calls.length} matching call${calls.length === 1 ? "" : "s"}`
|
|
7170
|
+
};
|
|
7171
|
+
}
|
|
7172
|
+
}),
|
|
7173
|
+
notCalledTool: (toolName, name = `did not call tool ${toolName}`) => ({
|
|
7174
|
+
name,
|
|
7175
|
+
requiresTrace: true,
|
|
7176
|
+
evaluate: ({ spans }) => {
|
|
7177
|
+
const calls = toolCalls(_nullishCoalesce(spans, () => ( []))).filter(
|
|
7178
|
+
(span) => getToolName(span) === toolName
|
|
7179
|
+
);
|
|
7180
|
+
const passed = calls.length === 0;
|
|
7181
|
+
return {
|
|
7182
|
+
passed,
|
|
7183
|
+
failure: passed ? void 0 : `expected tool "${toolName}" not to be called; found ${calls.length} call${calls.length === 1 ? "" : "s"}`
|
|
7184
|
+
};
|
|
7185
|
+
}
|
|
7186
|
+
}),
|
|
7187
|
+
toolOrder: (toolNames, name = "tool order") => ({
|
|
7188
|
+
name,
|
|
7189
|
+
requiresTrace: true,
|
|
7190
|
+
evaluate: ({ spans }) => {
|
|
7191
|
+
const observed = toolCalls(_nullishCoalesce(spans, () => ( []))).map(getToolName).filter((toolName) => toolName !== void 0);
|
|
7192
|
+
let fromIndex = 0;
|
|
7193
|
+
const passed = toolNames.every((toolName) => {
|
|
7194
|
+
const index = observed.indexOf(toolName, fromIndex);
|
|
7195
|
+
if (index === -1) return false;
|
|
7196
|
+
fromIndex = index + 1;
|
|
7197
|
+
return true;
|
|
7198
|
+
});
|
|
7199
|
+
return {
|
|
7200
|
+
passed,
|
|
7201
|
+
failure: passed ? void 0 : `expected tool order ${toolNames.join(" -> ")}; observed ${observed.join(" -> ") || "no tools"}`
|
|
7202
|
+
};
|
|
7203
|
+
}
|
|
7204
|
+
}),
|
|
7205
|
+
usedNoTools: (name = "used no tools") => ({
|
|
7206
|
+
name,
|
|
7207
|
+
requiresTrace: true,
|
|
7208
|
+
evaluate: ({ spans }) => {
|
|
7209
|
+
const calls = toolCalls(_nullishCoalesce(spans, () => ( [])));
|
|
7210
|
+
const passed = calls.length === 0;
|
|
7211
|
+
return {
|
|
7212
|
+
passed,
|
|
7213
|
+
failure: passed ? void 0 : `expected no tool calls; found ${calls.length}`
|
|
7214
|
+
};
|
|
7215
|
+
}
|
|
7216
|
+
}),
|
|
7217
|
+
maxToolCalls: (max, name = `at most ${max} tool calls`) => ({
|
|
7218
|
+
name,
|
|
7219
|
+
requiresTrace: true,
|
|
7220
|
+
evaluate: ({ spans }) => {
|
|
7221
|
+
const calls = toolCalls(_nullishCoalesce(spans, () => ( [])));
|
|
7222
|
+
const passed = calls.length <= max;
|
|
7223
|
+
return {
|
|
7224
|
+
passed,
|
|
7225
|
+
failure: passed ? void 0 : `expected at most ${max} tool call${max === 1 ? "" : "s"}; found ${calls.length}`
|
|
7226
|
+
};
|
|
7227
|
+
}
|
|
7228
|
+
})
|
|
7229
|
+
};
|
|
7230
|
+
async function validateSchema(schema, value) {
|
|
7231
|
+
try {
|
|
7232
|
+
if ("safeParse" in schema) {
|
|
7233
|
+
const result2 = schema.safeParse(value);
|
|
7234
|
+
return result2.success ? { passed: true, message: "" } : { passed: false, message: formatSchemaError(result2.error) };
|
|
7235
|
+
}
|
|
7236
|
+
if ("parse" in schema) {
|
|
7237
|
+
schema.parse(value);
|
|
7238
|
+
return { passed: true, message: "" };
|
|
7239
|
+
}
|
|
7240
|
+
const result = await schema["~standard"].validate(value);
|
|
7241
|
+
if (typeof result === "object" && result !== null && "issues" in result && Array.isArray(result.issues) && result.issues.length > 0) {
|
|
7242
|
+
return { passed: false, message: formatValue(result.issues) };
|
|
7243
|
+
}
|
|
7244
|
+
return { passed: true, message: "" };
|
|
7245
|
+
} catch (e) {
|
|
7246
|
+
return { passed: false, message: formatSchemaError(e) };
|
|
7247
|
+
}
|
|
7248
|
+
}
|
|
7249
|
+
function toolCalls(spans) {
|
|
7250
|
+
return spans.filter((span) => _optionalChain([span, 'access', _123 => _123.span_attributes, 'optionalAccess', _124 => _124.type]) === "tool");
|
|
7251
|
+
}
|
|
7252
|
+
function matchingToolCalls(spans, toolName, options) {
|
|
7253
|
+
return toolCalls(spans).filter((span) => {
|
|
7254
|
+
if (getToolName(span) !== toolName) return false;
|
|
7255
|
+
if (Object.prototype.hasOwnProperty.call(options, "input") && !matchesValue(span.input, options.input)) {
|
|
7256
|
+
return false;
|
|
7257
|
+
}
|
|
7258
|
+
if (Object.prototype.hasOwnProperty.call(options, "output") && !matchesValue(span.output, options.output)) {
|
|
7259
|
+
return false;
|
|
7260
|
+
}
|
|
7261
|
+
if (options.isError !== void 0 && Boolean(span.error) !== options.isError) {
|
|
7262
|
+
return false;
|
|
7263
|
+
}
|
|
7264
|
+
return true;
|
|
7265
|
+
});
|
|
7266
|
+
}
|
|
7267
|
+
function getToolName(span) {
|
|
7268
|
+
const spanName = [_optionalChain([span, 'access', _125 => _125.span_attributes, 'optionalAccess', _126 => _126.name]), span.name].map(normalizeToolName).find((value) => value !== void 0);
|
|
7269
|
+
if (_optionalChain([spanName, 'optionalAccess', _127 => _127.includes, 'call', _128 => _128("/")])) {
|
|
7270
|
+
return spanName;
|
|
7271
|
+
}
|
|
7272
|
+
const metadataName = [
|
|
7273
|
+
_optionalChain([span, 'access', _129 => _129.metadata, 'optionalAccess', _130 => _130.tool_name]),
|
|
7274
|
+
_optionalChain([span, 'access', _131 => _131.metadata, 'optionalAccess', _132 => _132["gen_ai.tool.name"]])
|
|
7275
|
+
].map(normalizeToolName).find((value) => value !== void 0);
|
|
7276
|
+
const mcpServer = [
|
|
7277
|
+
_optionalChain([span, 'access', _133 => _133.metadata, 'optionalAccess', _134 => _134["mcp.server"]]),
|
|
7278
|
+
_optionalChain([span, 'access', _135 => _135.metadata, 'optionalAccess', _136 => _136["openai_codex.mcp.server"]])
|
|
7279
|
+
].find((value) => typeof value === "string" && value !== "");
|
|
7280
|
+
if (metadataName && mcpServer) {
|
|
7281
|
+
return `${mcpServer}/${metadataName}`;
|
|
7282
|
+
}
|
|
7283
|
+
return _nullishCoalesce(metadataName, () => ( spanName));
|
|
7284
|
+
}
|
|
7285
|
+
function normalizeToolName(value) {
|
|
7286
|
+
if (typeof value !== "string" || value === "") {
|
|
7287
|
+
return void 0;
|
|
7288
|
+
}
|
|
7289
|
+
return value.startsWith("tool:") ? value.slice("tool:".length).trim() : value;
|
|
7290
|
+
}
|
|
7291
|
+
function matchesValue(actual, matcher) {
|
|
7292
|
+
if (matcher instanceof RegExp) {
|
|
7293
|
+
return testRegex(matcher, actual);
|
|
7294
|
+
}
|
|
7295
|
+
if (typeof matcher === "function") {
|
|
7296
|
+
return matcher(actual);
|
|
7297
|
+
}
|
|
7298
|
+
if (Array.isArray(matcher)) {
|
|
7299
|
+
return Array.isArray(actual) && actual.length === matcher.length && matcher.every((value, index) => matchesValue(actual[index], value));
|
|
7300
|
+
}
|
|
7301
|
+
if (isPlainObject(matcher) && isPlainObject(actual)) {
|
|
7302
|
+
return Object.entries(matcher).every(
|
|
7303
|
+
([key, value]) => Object.prototype.hasOwnProperty.call(actual, key) && matchesValue(actual[key], value)
|
|
7304
|
+
);
|
|
7305
|
+
}
|
|
7306
|
+
return deepEqual(actual, matcher);
|
|
7307
|
+
}
|
|
7308
|
+
function testRegex(matcher, value) {
|
|
7309
|
+
matcher.lastIndex = 0;
|
|
7310
|
+
return matcher.test(typeof value === "string" ? value : formatValue(value));
|
|
7311
|
+
}
|
|
7312
|
+
function deepEqual(left, right) {
|
|
7313
|
+
if (Object.is(left, right)) return true;
|
|
7314
|
+
if (Array.isArray(left) && Array.isArray(right)) {
|
|
7315
|
+
return left.length === right.length && left.every((item, index) => deepEqual(item, right[index]));
|
|
7316
|
+
}
|
|
7317
|
+
if (isPlainObject(left) && isPlainObject(right)) {
|
|
7318
|
+
const leftKeys = Object.keys(left);
|
|
7319
|
+
const rightKeys = Object.keys(right);
|
|
7320
|
+
return leftKeys.length === rightKeys.length && leftKeys.every(
|
|
7321
|
+
(key) => Object.prototype.hasOwnProperty.call(right, key) && deepEqual(left[key], right[key])
|
|
7322
|
+
);
|
|
7323
|
+
}
|
|
7324
|
+
return false;
|
|
7325
|
+
}
|
|
7326
|
+
function isPlainObject(value) {
|
|
7327
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) && Object.getPrototypeOf(value) === Object.prototype;
|
|
7328
|
+
}
|
|
7329
|
+
function formatSchemaError(error) {
|
|
7330
|
+
if (error instanceof Error) {
|
|
7331
|
+
return error.message;
|
|
7332
|
+
}
|
|
7333
|
+
return formatValue(error);
|
|
7334
|
+
}
|
|
7335
|
+
function formatValue(value) {
|
|
7336
|
+
if (value instanceof RegExp) {
|
|
7337
|
+
return value.toString();
|
|
7338
|
+
}
|
|
7339
|
+
if (typeof value === "string") {
|
|
7340
|
+
return JSON.stringify(value);
|
|
7341
|
+
}
|
|
7342
|
+
try {
|
|
7343
|
+
const serialized = JSON.stringify(value);
|
|
7344
|
+
if (serialized !== void 0 && !hasUndefinedJsonValue(value)) {
|
|
7345
|
+
return serialized;
|
|
7346
|
+
}
|
|
7347
|
+
return formatValueWithUndefined(value, /* @__PURE__ */ new Set());
|
|
7348
|
+
} catch (e7) {
|
|
7349
|
+
return String(value);
|
|
7350
|
+
}
|
|
7351
|
+
}
|
|
7352
|
+
function hasUndefinedJsonValue(value, seen = /* @__PURE__ */ new Set()) {
|
|
7353
|
+
if (value === void 0) {
|
|
7354
|
+
return true;
|
|
7355
|
+
}
|
|
7356
|
+
if (typeof value !== "object" || value === null) {
|
|
7357
|
+
return false;
|
|
7358
|
+
}
|
|
7359
|
+
if (seen.has(value)) {
|
|
7360
|
+
return false;
|
|
7361
|
+
}
|
|
7362
|
+
seen.add(value);
|
|
7363
|
+
if (Array.isArray(value)) {
|
|
7364
|
+
return Array.from({ length: value.length }).some(
|
|
7365
|
+
(_, index) => hasUndefinedJsonValue(value[index], seen)
|
|
7366
|
+
);
|
|
7367
|
+
}
|
|
7368
|
+
return Object.keys(value).some(
|
|
7369
|
+
(key) => hasUndefinedJsonValue(value[key], seen)
|
|
7370
|
+
);
|
|
7371
|
+
}
|
|
7372
|
+
function formatValueWithUndefined(value, seen) {
|
|
7373
|
+
if (value === void 0) {
|
|
7374
|
+
return "undefined";
|
|
7375
|
+
}
|
|
7376
|
+
if (value === null) {
|
|
7377
|
+
return "null";
|
|
7378
|
+
}
|
|
7379
|
+
if (typeof value === "string") {
|
|
7380
|
+
return JSON.stringify(value);
|
|
7381
|
+
}
|
|
7382
|
+
if (typeof value === "number" || typeof value === "boolean") {
|
|
7383
|
+
return JSON.stringify(value);
|
|
7384
|
+
}
|
|
7385
|
+
if (typeof value === "bigint" || typeof value === "function") {
|
|
7386
|
+
return String(value);
|
|
7387
|
+
}
|
|
7388
|
+
if (typeof value === "symbol") {
|
|
7389
|
+
return String(value);
|
|
7390
|
+
}
|
|
7391
|
+
if (value instanceof RegExp) {
|
|
7392
|
+
return value.toString();
|
|
7393
|
+
}
|
|
7394
|
+
if (typeof value !== "object") {
|
|
7395
|
+
return String(value);
|
|
7396
|
+
}
|
|
7397
|
+
if (seen.has(value)) {
|
|
7398
|
+
return '"[Circular]"';
|
|
7399
|
+
}
|
|
7400
|
+
seen.add(value);
|
|
7401
|
+
if (typeof value.toJSON === "function") {
|
|
7402
|
+
const jsonValue = value.toJSON();
|
|
7403
|
+
seen.delete(value);
|
|
7404
|
+
return formatValueWithUndefined(jsonValue, seen);
|
|
7405
|
+
}
|
|
7406
|
+
if (Array.isArray(value)) {
|
|
7407
|
+
const formatted2 = Array.from(
|
|
7408
|
+
{ length: value.length },
|
|
7409
|
+
(_, index) => formatValueWithUndefined(value[index], seen)
|
|
7410
|
+
);
|
|
7411
|
+
seen.delete(value);
|
|
7412
|
+
return `[${formatted2.join(",")}]`;
|
|
7413
|
+
}
|
|
7414
|
+
const formatted = Object.keys(value).map(
|
|
7415
|
+
(key) => `${JSON.stringify(key)}:${formatValueWithUndefined(
|
|
7416
|
+
value[key],
|
|
7417
|
+
seen
|
|
7418
|
+
)}`
|
|
7419
|
+
);
|
|
7420
|
+
seen.delete(value);
|
|
7421
|
+
return `{${formatted.join(",")}}`;
|
|
7422
|
+
}
|
|
7423
|
+
|
|
7033
7424
|
// src/dataset-pipeline.ts
|
|
7034
7425
|
function DatasetPipeline(definition) {
|
|
7035
7426
|
if (!globalThis.__braintrust_dataset_pipelines) {
|
|
@@ -7113,7 +7504,7 @@ var Project2 = (_class6 = class {
|
|
|
7113
7504
|
console.warn("publish() is a no-op when running `braintrust push`.");
|
|
7114
7505
|
return;
|
|
7115
7506
|
}
|
|
7116
|
-
await
|
|
7507
|
+
await _chunkFY7DAKA5js.login.call(void 0, );
|
|
7117
7508
|
const projectMap = new ProjectNameIdMap();
|
|
7118
7509
|
const functionDefinitions = [];
|
|
7119
7510
|
if (this._publishableCodeFunctions.length > 0) {
|
|
@@ -7127,7 +7518,7 @@ var Project2 = (_class6 = class {
|
|
|
7127
7518
|
functionDefinitions.push(functionDefinition);
|
|
7128
7519
|
}
|
|
7129
7520
|
}
|
|
7130
|
-
await
|
|
7521
|
+
await _chunkFY7DAKA5js._internalGetGlobalState.call(void 0, ).apiConn().post_json("insert-functions", {
|
|
7131
7522
|
functions: functionDefinitions
|
|
7132
7523
|
});
|
|
7133
7524
|
}
|
|
@@ -7145,12 +7536,12 @@ var ToolBuilder = (_class7 = class {
|
|
|
7145
7536
|
const { handler, name, slug, parameters, returns, ...rest } = opts;
|
|
7146
7537
|
let resolvedName = _nullishCoalesce(name, () => ( handler.name));
|
|
7147
7538
|
if (resolvedName.trim().length === 0) {
|
|
7148
|
-
resolvedName = `Tool ${
|
|
7539
|
+
resolvedName = `Tool ${_chunkBFGIH2ZJjs.isomorph_default.basename(currentFilename)} ${this.taskCounter}`;
|
|
7149
7540
|
}
|
|
7150
7541
|
const tool = new CodeFunction(this.project, {
|
|
7151
7542
|
handler,
|
|
7152
7543
|
name: resolvedName,
|
|
7153
|
-
slug: _nullishCoalesce(slug, () => (
|
|
7544
|
+
slug: _nullishCoalesce(slug, () => ( _chunkFY7DAKA5js.slugify.call(void 0, resolvedName, { lower: true, strict: true }))),
|
|
7154
7545
|
type: "tool",
|
|
7155
7546
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/consistent-type-assertions
|
|
7156
7547
|
parameters,
|
|
@@ -7174,9 +7565,9 @@ var ScorerBuilder = (_class8 = class {
|
|
|
7174
7565
|
resolvedName = opts.handler.name;
|
|
7175
7566
|
}
|
|
7176
7567
|
if (!resolvedName || resolvedName.trim().length === 0) {
|
|
7177
|
-
resolvedName = `Scorer ${
|
|
7568
|
+
resolvedName = `Scorer ${_chunkBFGIH2ZJjs.isomorph_default.basename(currentFilename)} ${this.taskCounter}`;
|
|
7178
7569
|
}
|
|
7179
|
-
const slug = _nullishCoalesce(opts.slug, () => (
|
|
7570
|
+
const slug = _nullishCoalesce(opts.slug, () => ( _chunkFY7DAKA5js.slugify.call(void 0, resolvedName, { lower: true, strict: true })));
|
|
7180
7571
|
if ("handler" in opts) {
|
|
7181
7572
|
const scorer = new CodeFunction(this.project, {
|
|
7182
7573
|
...opts,
|
|
@@ -7230,9 +7621,9 @@ var ClassifierBuilder = (_class9 = class {
|
|
|
7230
7621
|
this.taskCounter++;
|
|
7231
7622
|
let resolvedName = _nullishCoalesce(opts.name, () => ( opts.handler.name));
|
|
7232
7623
|
if (!resolvedName || resolvedName.trim().length === 0) {
|
|
7233
|
-
resolvedName = `Classifier ${
|
|
7624
|
+
resolvedName = `Classifier ${_chunkBFGIH2ZJjs.isomorph_default.basename(currentFilename)} ${this.taskCounter}`;
|
|
7234
7625
|
}
|
|
7235
|
-
const slug = _nullishCoalesce(opts.slug, () => (
|
|
7626
|
+
const slug = _nullishCoalesce(opts.slug, () => ( _chunkFY7DAKA5js.slugify.call(void 0, resolvedName, { lower: true, strict: true })));
|
|
7236
7627
|
const classifier = new CodeFunction(this.project, {
|
|
7237
7628
|
...opts,
|
|
7238
7629
|
name: resolvedName,
|
|
@@ -7359,18 +7750,18 @@ var PromptBuilder = class {
|
|
|
7359
7750
|
rawTools.push(tool);
|
|
7360
7751
|
}
|
|
7361
7752
|
}
|
|
7362
|
-
const slug = _nullishCoalesce(opts.slug, () => (
|
|
7753
|
+
const slug = _nullishCoalesce(opts.slug, () => ( _chunkFY7DAKA5js.slugify.call(void 0, opts.name, { lower: true, strict: true })));
|
|
7363
7754
|
const promptData = promptDefinitionToPromptData(opts, rawTools);
|
|
7364
7755
|
const promptRow = {
|
|
7365
7756
|
id: opts.id,
|
|
7366
|
-
_xact_id: opts.version ?
|
|
7757
|
+
_xact_id: opts.version ? _chunkFY7DAKA5js.loadPrettyXact.call(void 0, opts.version) : void 0,
|
|
7367
7758
|
name: opts.name,
|
|
7368
7759
|
slug,
|
|
7369
7760
|
prompt_data: promptData,
|
|
7370
7761
|
tags: opts.tags,
|
|
7371
7762
|
...this.project.id !== void 0 ? { project_id: this.project.id } : {}
|
|
7372
7763
|
};
|
|
7373
|
-
const prompt = new (0,
|
|
7764
|
+
const prompt = new (0, _chunkFY7DAKA5js.Prompt)(
|
|
7374
7765
|
promptRow,
|
|
7375
7766
|
{},
|
|
7376
7767
|
// It doesn't make sense to specify defaults here.
|
|
@@ -7424,7 +7815,7 @@ var ParametersBuilder = class {
|
|
|
7424
7815
|
this.project = project;
|
|
7425
7816
|
}
|
|
7426
7817
|
create(opts) {
|
|
7427
|
-
const slug = _nullishCoalesce(opts.slug, () => (
|
|
7818
|
+
const slug = _nullishCoalesce(opts.slug, () => ( _chunkFY7DAKA5js.slugify.call(void 0, opts.name, { lower: true, strict: true })));
|
|
7428
7819
|
const codeParameters = new CodeParameters(this.project, {
|
|
7429
7820
|
name: opts.name,
|
|
7430
7821
|
slug,
|
|
@@ -7463,7 +7854,7 @@ function serializeEvalParameterstoParametersSchema(parameters) {
|
|
|
7463
7854
|
required.push(name);
|
|
7464
7855
|
}
|
|
7465
7856
|
} else {
|
|
7466
|
-
const schemaObj =
|
|
7857
|
+
const schemaObj = _chunkFY7DAKA5js.zodToJsonSchema.call(void 0, value);
|
|
7467
7858
|
properties[name] = schemaObj;
|
|
7468
7859
|
if (!("default" in schemaObj)) {
|
|
7469
7860
|
required.push(name);
|
|
@@ -7492,11 +7883,11 @@ var ProjectNameIdMap = (_class10 = class {constructor() { _class10.prototype.__i
|
|
|
7492
7883
|
__init19() {this.idToName = {}}
|
|
7493
7884
|
async getId(projectName) {
|
|
7494
7885
|
if (!(projectName in this.nameToId)) {
|
|
7495
|
-
const response = await
|
|
7886
|
+
const response = await _chunkFY7DAKA5js._internalGetGlobalState.call(void 0, ).appConn().post_json("api/project/register", {
|
|
7496
7887
|
project_name: projectName
|
|
7497
7888
|
});
|
|
7498
7889
|
const result = _v3.z.object({
|
|
7499
|
-
project:
|
|
7890
|
+
project: _chunkFY7DAKA5js.Project
|
|
7500
7891
|
}).parse(response);
|
|
7501
7892
|
const projectId = result.project.id;
|
|
7502
7893
|
this.nameToId[projectName] = projectId;
|
|
@@ -7506,10 +7897,10 @@ var ProjectNameIdMap = (_class10 = class {constructor() { _class10.prototype.__i
|
|
|
7506
7897
|
}
|
|
7507
7898
|
async getName(projectId) {
|
|
7508
7899
|
if (!(projectId in this.idToName)) {
|
|
7509
|
-
const response = await
|
|
7900
|
+
const response = await _chunkFY7DAKA5js._internalGetGlobalState.call(void 0, ).appConn().post_json("api/project/get", {
|
|
7510
7901
|
id: projectId
|
|
7511
7902
|
});
|
|
7512
|
-
const result = _v3.z.array(
|
|
7903
|
+
const result = _v3.z.array(_chunkFY7DAKA5js.Project).nonempty().parse(response);
|
|
7513
7904
|
const projectName = result[0].name;
|
|
7514
7905
|
this.idToName[projectId] = projectName;
|
|
7515
7906
|
this.nameToId[projectName] = projectId;
|
|
@@ -7529,16 +7920,16 @@ var ProjectNameIdMap = (_class10 = class {constructor() { _class10.prototype.__i
|
|
|
7529
7920
|
var evalBodySchema = _v3.z.object({
|
|
7530
7921
|
name: _v3.z.string(),
|
|
7531
7922
|
parameters: _v3.z.record(_v3.z.string(), _v3.z.unknown()).nullish(),
|
|
7532
|
-
data:
|
|
7923
|
+
data: _chunkFY7DAKA5js.RunEval.shape.data,
|
|
7533
7924
|
scores: _v3.z.array(
|
|
7534
7925
|
_v3.z.object({
|
|
7535
|
-
function_id:
|
|
7926
|
+
function_id: _chunkFY7DAKA5js.FunctionId,
|
|
7536
7927
|
name: _v3.z.string()
|
|
7537
7928
|
})
|
|
7538
7929
|
).nullish(),
|
|
7539
7930
|
experiment_name: _v3.z.string().nullish(),
|
|
7540
7931
|
project_id: _v3.z.string().nullish(),
|
|
7541
|
-
parent:
|
|
7932
|
+
parent: _chunkFY7DAKA5js.InvokeParent.optional(),
|
|
7542
7933
|
stream: _v3.z.boolean().optional()
|
|
7543
7934
|
});
|
|
7544
7935
|
var staticParametersSchema = _v3.z.record(
|
|
@@ -7546,7 +7937,7 @@ var staticParametersSchema = _v3.z.record(
|
|
|
7546
7937
|
_v3.z.union([
|
|
7547
7938
|
_v3.z.object({
|
|
7548
7939
|
type: _v3.z.literal("prompt"),
|
|
7549
|
-
default:
|
|
7940
|
+
default: _chunkFY7DAKA5js.PromptData.optional(),
|
|
7550
7941
|
description: _v3.z.string().optional()
|
|
7551
7942
|
}),
|
|
7552
7943
|
_v3.z.object({
|
|
@@ -7602,7 +7993,15 @@ var evaluatorDefinitionsSchema = _v3.z.record(
|
|
|
7602
7993
|
);
|
|
7603
7994
|
|
|
7604
7995
|
// src/node/index.ts
|
|
7605
|
-
|
|
7996
|
+
_chunkFY7DAKA5js.configureNode.call(void 0, );
|
|
7997
|
+
|
|
7998
|
+
|
|
7999
|
+
|
|
8000
|
+
|
|
8001
|
+
|
|
8002
|
+
|
|
8003
|
+
|
|
8004
|
+
|
|
7606
8005
|
|
|
7607
8006
|
|
|
7608
8007
|
|
|
@@ -7760,4 +8159,4 @@ _chunkPOCCIJALjs.configureNode.call(void 0, );
|
|
|
7760
8159
|
|
|
7761
8160
|
|
|
7762
8161
|
|
|
7763
|
-
exports.Attachment =
|
|
8162
|
+
exports.Attachment = _chunkFY7DAKA5js.Attachment; exports.AttachmentReference = _chunkFY7DAKA5js.AttachmentReference; exports.BAGGAGE_HEADER = _chunkFY7DAKA5js.BAGGAGE_HEADER; exports.BRAINTRUST_CURRENT_SPAN_STORE = _chunkFY7DAKA5js.BRAINTRUST_CURRENT_SPAN_STORE; exports.BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME = _chunkFY7DAKA5js.BRAINTRUST_LANGCHAIN_CALLBACK_HANDLER_NAME; exports.BRAINTRUST_PARENT_KEY = _chunkFY7DAKA5js.BRAINTRUST_PARENT_KEY; exports.BaseAttachment = _chunkFY7DAKA5js.BaseAttachment; exports.BaseExperiment = BaseExperiment; exports.BraintrustLangChainCallbackHandler = _chunkFY7DAKA5js.BraintrustLangChainCallbackHandler; exports.BraintrustMiddleware = BraintrustMiddleware; exports.BraintrustObservabilityExporter = _chunkFY7DAKA5js.BraintrustObservabilityExporter; exports.BraintrustState = _chunkFY7DAKA5js.BraintrustState; exports.BraintrustStream = _chunkFY7DAKA5js.BraintrustStream; exports.CachedSpanFetcher = CachedSpanFetcher; exports.CodeFunction = CodeFunction; exports.CodePrompt = CodePrompt; exports.ContextManager = _chunkFY7DAKA5js.ContextManager; exports.DEFAULT_FETCH_BATCH_SIZE = _chunkFY7DAKA5js.DEFAULT_FETCH_BATCH_SIZE; exports.DEFAULT_MAX_REQUEST_SIZE = _chunkFY7DAKA5js.DEFAULT_MAX_REQUEST_SIZE; exports.Dataset = _chunkFY7DAKA5js.Dataset; exports.DatasetPipeline = DatasetPipeline; exports.ERR_PERMALINK = _chunkFY7DAKA5js.ERR_PERMALINK; exports.Eval = Eval; exports.EvalResultWithSummary = EvalResultWithSummary; exports.Experiment = _chunkFY7DAKA5js.Experiment; exports.ExternalAttachment = _chunkFY7DAKA5js.ExternalAttachment; exports.FailedHTTPResponse = _chunkFY7DAKA5js.FailedHTTPResponse; exports.IDGenerator = _chunkFY7DAKA5js.IDGenerator; exports.JSONAttachment = _chunkFY7DAKA5js.JSONAttachment; exports.LEGACY_CACHED_HEADER = _chunkFY7DAKA5js.LEGACY_CACHED_HEADER; exports.LOGS3_OVERFLOW_REFERENCE_TYPE = _chunkFY7DAKA5js.LOGS3_OVERFLOW_REFERENCE_TYPE; exports.LazyValue = _chunkFY7DAKA5js.LazyValue; exports.LocalTrace = LocalTrace; exports.Logger = _chunkFY7DAKA5js.Logger; exports.LoginInvalidOrgError = _chunkFY7DAKA5js.LoginInvalidOrgError; exports.NOOP_SPAN = _chunkFY7DAKA5js.NOOP_SPAN; exports.NOOP_SPAN_PERMALINK = _chunkFY7DAKA5js.NOOP_SPAN_PERMALINK; exports.NoopSpan = _chunkFY7DAKA5js.NoopSpan; exports.OTELIDGenerator = _chunkFY7DAKA5js.OTELIDGenerator; exports.ObjectFetcher = _chunkFY7DAKA5js.ObjectFetcher; exports.Project = Project2; exports.ProjectNameIdMap = ProjectNameIdMap; exports.Prompt = _chunkFY7DAKA5js.Prompt; exports.PromptBuilder = PromptBuilder; exports.ReadonlyAttachment = _chunkFY7DAKA5js.ReadonlyAttachment; exports.ReadonlyExperiment = _chunkFY7DAKA5js.ReadonlyExperiment; exports.Reporter = Reporter; exports.ScorerBuilder = ScorerBuilder; exports.SpanFetcher = SpanFetcher; exports.SpanImpl = _chunkFY7DAKA5js.SpanImpl; exports.TRACEPARENT_HEADER = _chunkFY7DAKA5js.TRACEPARENT_HEADER; exports.TRACESTATE_HEADER = _chunkFY7DAKA5js.TRACESTATE_HEADER; exports.TestBackgroundLogger = _chunkFY7DAKA5js.TestBackgroundLogger; exports.ToolBuilder = ToolBuilder; exports.UUIDGenerator = _chunkFY7DAKA5js.UUIDGenerator; exports.X_CACHED_HEADER = _chunkFY7DAKA5js.X_CACHED_HEADER; exports._exportsForTestingOnly = _chunkFY7DAKA5js._exportsForTestingOnly; exports._internalGetGlobalState = _chunkFY7DAKA5js._internalGetGlobalState; exports._internalIso = _chunkBFGIH2ZJjs.isomorph_default; exports._internalSetInitialState = _chunkFY7DAKA5js._internalSetInitialState; exports.addAzureBlobHeaders = _chunkFY7DAKA5js.addAzureBlobHeaders; exports.agentAssertionScorer = agentAssertionScorer; exports.braintrustAISDKTelemetry = _chunkFY7DAKA5js.braintrustAISDKTelemetry; exports.braintrustFlueInstrumentation = _chunkFY7DAKA5js.braintrustFlueInstrumentation; exports.braintrustFlueObserver = _chunkFY7DAKA5js.braintrustFlueObserver; exports.braintrustStreamChunkSchema = _chunkFY7DAKA5js.braintrustStreamChunkSchema; exports.buildLocalSummary = buildLocalSummary; exports.configureInstrumentation = _chunkFY7DAKA5js.configureInstrumentation; exports.constructLogs3OverflowRequest = _chunkFY7DAKA5js.constructLogs3OverflowRequest; exports.createFinalValuePassThroughStream = _chunkFY7DAKA5js.createFinalValuePassThroughStream; exports.currentExperiment = _chunkFY7DAKA5js.currentExperiment; exports.currentLogger = _chunkFY7DAKA5js.currentLogger; exports.currentSpan = _chunkFY7DAKA5js.currentSpan; exports.deepCopyEvent = _chunkFY7DAKA5js.deepCopyEvent; exports.default = exports_exports; exports.defaultErrorScoreHandler = defaultErrorScoreHandler; exports.deserializePlainStringAsJSON = _chunkFY7DAKA5js.deserializePlainStringAsJSON; exports.devNullWritableStream = _chunkFY7DAKA5js.devNullWritableStream; exports.evaluatorDefinitionSchema = evaluatorDefinitionSchema; exports.evaluatorDefinitionsSchema = evaluatorDefinitionsSchema; exports.extractTraceContextFromHeaders = _chunkFY7DAKA5js.extractTraceContextFromHeaders; exports.flush = _chunkFY7DAKA5js.flush; exports.getContextManager = _chunkFY7DAKA5js.getContextManager; exports.getIdGenerator = _chunkFY7DAKA5js.getIdGenerator; exports.getPromptVersions = _chunkFY7DAKA5js.getPromptVersions; exports.getSpanParentObject = _chunkFY7DAKA5js.getSpanParentObject; exports.getTemplateRenderer = _chunkFY7DAKA5js.getTemplateRenderer; exports.graph = graph_framework_exports; exports.init = _chunkFY7DAKA5js.init; exports.initDataset = _chunkFY7DAKA5js.initDataset; exports.initExperiment = _chunkFY7DAKA5js.initExperiment; exports.initFunction = initFunction; exports.initLogger = _chunkFY7DAKA5js.initLogger; exports.initNodeTestSuite = initNodeTestSuite; exports.injectTraceContext = _chunkFY7DAKA5js.injectTraceContext; exports.invoke = invoke; exports.isTemplateFormat = _chunkFY7DAKA5js.isTemplateFormat; exports.loadParameters = _chunkFY7DAKA5js.loadParameters; exports.loadPrompt = _chunkFY7DAKA5js.loadPrompt; exports.log = _chunkFY7DAKA5js.log; exports.logError = _chunkFY7DAKA5js.logError; exports.login = _chunkFY7DAKA5js.login; exports.loginToState = _chunkFY7DAKA5js.loginToState; exports.logs3OverflowUploadSchema = _chunkFY7DAKA5js.logs3OverflowUploadSchema; exports.newId = _chunkFY7DAKA5js.newId; exports.parseCachedHeader = _chunkFY7DAKA5js.parseCachedHeader; exports.parseTemplateFormat = _chunkFY7DAKA5js.parseTemplateFormat; exports.permalink = _chunkFY7DAKA5js.permalink; exports.pickLogs3OverflowObjectIds = _chunkFY7DAKA5js.pickLogs3OverflowObjectIds; exports.projects = projects; exports.promptContentsSchema = promptContentsSchema; exports.promptDefinitionSchema = promptDefinitionSchema; exports.promptDefinitionToPromptData = promptDefinitionToPromptData; exports.promptDefinitionWithToolsSchema = promptDefinitionWithToolsSchema; exports.registerOtelFlush = _chunkFY7DAKA5js.registerOtelFlush; exports.registerSandbox = registerSandbox; exports.registerTemplatePlugin = _chunkFY7DAKA5js.registerTemplatePlugin; exports.renderMessage = _chunkFY7DAKA5js.renderMessage; exports.renderPromptParams = _chunkFY7DAKA5js.renderPromptParams; exports.renderTemplateContent = _chunkFY7DAKA5js.renderTemplateContent; exports.reportFailures = reportFailures; exports.runEvaluator = runEvaluator; exports.setFetch = _chunkFY7DAKA5js.setFetch; exports.setMaskingFunction = _chunkFY7DAKA5js.setMaskingFunction; exports.spanComponentsToObjectId = _chunkFY7DAKA5js.spanComponentsToObjectId; exports.startSpan = _chunkFY7DAKA5js.startSpan; exports.summarize = _chunkFY7DAKA5js.summarize; exports.templateRegistry = _chunkFY7DAKA5js.templateRegistry; exports.toolFunctionDefinitionSchema = _chunkFY7DAKA5js.ToolFunctionDefinition; exports.traceable = _chunkFY7DAKA5js.traceable; exports.traced = _chunkFY7DAKA5js.traced; exports.updateSpan = _chunkFY7DAKA5js.updateSpan; exports.uploadLogs3OverflowPayload = _chunkFY7DAKA5js.uploadLogs3OverflowPayload; exports.utf8ByteLength = _chunkFY7DAKA5js.utf8ByteLength; exports.withCurrent = _chunkFY7DAKA5js.withCurrent; exports.withDataset = _chunkFY7DAKA5js.withDataset; exports.withExperiment = _chunkFY7DAKA5js.withExperiment; exports.withLogger = _chunkFY7DAKA5js.withLogger; exports.withParent = _chunkFY7DAKA5js.withParent; exports.wrapAISDK = wrapAISDK; exports.wrapAISDKModel = wrapAISDKModel; exports.wrapAgentClass = wrapAgentClass; exports.wrapAnthropic = wrapAnthropic; exports.wrapBedrockRuntime = wrapBedrockRuntime; exports.wrapClaudeAgentSDK = wrapClaudeAgentSDK; exports.wrapCohere = wrapCohere; exports.wrapCopilotClient = wrapCopilotClient; exports.wrapCursorSDK = wrapCursorSDK; exports.wrapGenkit = wrapGenkit; exports.wrapGoogleADK = wrapGoogleADK; exports.wrapGoogleGenAI = wrapGoogleGenAI; exports.wrapGroq = wrapGroq; exports.wrapHuggingFace = wrapHuggingFace; exports.wrapMastraAgent = _chunkFY7DAKA5js.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 = _chunkFY7DAKA5js.wrapTraced; exports.wrapVitest = wrapVitest;
|