braintrust 3.19.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 +2833 -987
- package/dev/dist/index.mjs +2294 -448
- 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 +1369 -848
- package/dist/browser.d.ts +1369 -848
- package/dist/browser.js +2735 -473
- package/dist/browser.mjs +2735 -473
- package/dist/{chunk-LPC4W2WX.js → chunk-BFGIH2ZJ.js} +4 -0
- package/dist/{chunk-37RLJF2U.js → chunk-FY7DAKA5.js} +3149 -1273
- package/dist/{chunk-Y7W7WP6H.mjs → chunk-KMGUTPB7.mjs} +4 -0
- package/dist/{chunk-VEQ2PCMC.mjs → chunk-O2P765XK.mjs} +2399 -523
- package/dist/cli.js +2267 -412
- package/dist/edge-light.d.mts +1 -1
- package/dist/edge-light.d.ts +1 -1
- package/dist/edge-light.js +2735 -473
- package/dist/edge-light.mjs +2735 -473
- package/dist/index.d.mts +1848 -1327
- package/dist/index.d.ts +1848 -1327
- package/dist/index.js +754 -352
- package/dist/index.mjs +448 -46
- package/dist/instrumentation/index.d.mts +119 -21
- package/dist/instrumentation/index.d.ts +119 -21
- package/dist/instrumentation/index.js +2345 -512
- package/dist/instrumentation/index.mjs +2344 -512
- 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 +2735 -473
- package/dist/workerd.mjs +2735 -473
- 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
|
@@ -128,7 +128,6 @@
|
|
|
128
128
|
|
|
129
129
|
|
|
130
130
|
|
|
131
|
-
var _chunk37RLJF2Ujs = require('./chunk-37RLJF2U.js');
|
|
132
131
|
|
|
133
132
|
|
|
134
133
|
|
|
@@ -138,6 +137,7 @@ var _chunk37RLJF2Ujs = require('./chunk-37RLJF2U.js');
|
|
|
138
137
|
|
|
139
138
|
|
|
140
139
|
|
|
140
|
+
var _chunkFY7DAKA5js = require('./chunk-FY7DAKA5.js');
|
|
141
141
|
|
|
142
142
|
|
|
143
143
|
|
|
@@ -151,140 +151,158 @@ var _chunk37RLJF2Ujs = require('./chunk-37RLJF2U.js');
|
|
|
151
151
|
|
|
152
152
|
|
|
153
153
|
|
|
154
|
-
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
var _chunkBFGIH2ZJjs = require('./chunk-BFGIH2ZJ.js');
|
|
155
164
|
|
|
156
165
|
// src/exports.ts
|
|
157
166
|
var exports_exports = {};
|
|
158
|
-
|
|
159
|
-
Attachment: () =>
|
|
160
|
-
AttachmentReference: () =>
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
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,
|
|
164
175
|
BaseExperiment: () => BaseExperiment,
|
|
165
|
-
BraintrustLangChainCallbackHandler: () =>
|
|
176
|
+
BraintrustLangChainCallbackHandler: () => _chunkFY7DAKA5js.BraintrustLangChainCallbackHandler,
|
|
166
177
|
BraintrustMiddleware: () => BraintrustMiddleware,
|
|
167
|
-
BraintrustObservabilityExporter: () =>
|
|
168
|
-
BraintrustState: () =>
|
|
169
|
-
BraintrustStream: () =>
|
|
178
|
+
BraintrustObservabilityExporter: () => _chunkFY7DAKA5js.BraintrustObservabilityExporter,
|
|
179
|
+
BraintrustState: () => _chunkFY7DAKA5js.BraintrustState,
|
|
180
|
+
BraintrustStream: () => _chunkFY7DAKA5js.BraintrustStream,
|
|
170
181
|
CachedSpanFetcher: () => CachedSpanFetcher,
|
|
171
182
|
CodeFunction: () => CodeFunction,
|
|
172
183
|
CodePrompt: () => CodePrompt,
|
|
173
|
-
ContextManager: () =>
|
|
174
|
-
DEFAULT_FETCH_BATCH_SIZE: () =>
|
|
175
|
-
DEFAULT_MAX_REQUEST_SIZE: () =>
|
|
176
|
-
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,
|
|
177
188
|
DatasetPipeline: () => DatasetPipeline,
|
|
178
|
-
ERR_PERMALINK: () =>
|
|
189
|
+
ERR_PERMALINK: () => _chunkFY7DAKA5js.ERR_PERMALINK,
|
|
179
190
|
Eval: () => Eval,
|
|
180
191
|
EvalResultWithSummary: () => EvalResultWithSummary,
|
|
181
|
-
Experiment: () =>
|
|
182
|
-
ExternalAttachment: () =>
|
|
183
|
-
FailedHTTPResponse: () =>
|
|
184
|
-
IDGenerator: () =>
|
|
185
|
-
JSONAttachment: () =>
|
|
186
|
-
LEGACY_CACHED_HEADER: () =>
|
|
187
|
-
LOGS3_OVERFLOW_REFERENCE_TYPE: () =>
|
|
188
|
-
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,
|
|
189
200
|
LocalTrace: () => LocalTrace,
|
|
190
|
-
Logger: () =>
|
|
191
|
-
LoginInvalidOrgError: () =>
|
|
192
|
-
NOOP_SPAN: () =>
|
|
193
|
-
NOOP_SPAN_PERMALINK: () =>
|
|
194
|
-
NoopSpan: () =>
|
|
195
|
-
|
|
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,
|
|
196
208
|
Project: () => Project2,
|
|
197
209
|
ProjectNameIdMap: () => ProjectNameIdMap,
|
|
198
|
-
Prompt: () =>
|
|
210
|
+
Prompt: () => _chunkFY7DAKA5js.Prompt,
|
|
199
211
|
PromptBuilder: () => PromptBuilder,
|
|
200
|
-
ReadonlyAttachment: () =>
|
|
201
|
-
ReadonlyExperiment: () =>
|
|
212
|
+
ReadonlyAttachment: () => _chunkFY7DAKA5js.ReadonlyAttachment,
|
|
213
|
+
ReadonlyExperiment: () => _chunkFY7DAKA5js.ReadonlyExperiment,
|
|
202
214
|
Reporter: () => Reporter,
|
|
203
215
|
ScorerBuilder: () => ScorerBuilder,
|
|
204
216
|
SpanFetcher: () => SpanFetcher,
|
|
205
|
-
SpanImpl: () =>
|
|
206
|
-
|
|
217
|
+
SpanImpl: () => _chunkFY7DAKA5js.SpanImpl,
|
|
218
|
+
TRACEPARENT_HEADER: () => _chunkFY7DAKA5js.TRACEPARENT_HEADER,
|
|
219
|
+
TRACESTATE_HEADER: () => _chunkFY7DAKA5js.TRACESTATE_HEADER,
|
|
220
|
+
TestBackgroundLogger: () => _chunkFY7DAKA5js.TestBackgroundLogger,
|
|
207
221
|
ToolBuilder: () => ToolBuilder,
|
|
208
|
-
UUIDGenerator: () =>
|
|
209
|
-
X_CACHED_HEADER: () =>
|
|
210
|
-
_exportsForTestingOnly: () =>
|
|
211
|
-
_internalGetGlobalState: () =>
|
|
212
|
-
_internalIso: () =>
|
|
213
|
-
_internalSetInitialState: () =>
|
|
214
|
-
addAzureBlobHeaders: () =>
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
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,
|
|
218
234
|
buildLocalSummary: () => buildLocalSummary,
|
|
219
|
-
configureInstrumentation: () =>
|
|
220
|
-
constructLogs3OverflowRequest: () =>
|
|
221
|
-
createFinalValuePassThroughStream: () =>
|
|
222
|
-
currentExperiment: () =>
|
|
223
|
-
currentLogger: () =>
|
|
224
|
-
currentSpan: () =>
|
|
225
|
-
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,
|
|
226
242
|
defaultErrorScoreHandler: () => defaultErrorScoreHandler,
|
|
227
|
-
deserializePlainStringAsJSON: () =>
|
|
228
|
-
devNullWritableStream: () =>
|
|
243
|
+
deserializePlainStringAsJSON: () => _chunkFY7DAKA5js.deserializePlainStringAsJSON,
|
|
244
|
+
devNullWritableStream: () => _chunkFY7DAKA5js.devNullWritableStream,
|
|
229
245
|
evaluatorDefinitionSchema: () => evaluatorDefinitionSchema,
|
|
230
246
|
evaluatorDefinitionsSchema: () => evaluatorDefinitionsSchema,
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
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,
|
|
237
254
|
graph: () => graph_framework_exports,
|
|
238
|
-
init: () =>
|
|
239
|
-
initDataset: () =>
|
|
240
|
-
initExperiment: () =>
|
|
255
|
+
init: () => _chunkFY7DAKA5js.init,
|
|
256
|
+
initDataset: () => _chunkFY7DAKA5js.initDataset,
|
|
257
|
+
initExperiment: () => _chunkFY7DAKA5js.initExperiment,
|
|
241
258
|
initFunction: () => initFunction,
|
|
242
|
-
initLogger: () =>
|
|
259
|
+
initLogger: () => _chunkFY7DAKA5js.initLogger,
|
|
243
260
|
initNodeTestSuite: () => initNodeTestSuite,
|
|
261
|
+
injectTraceContext: () => _chunkFY7DAKA5js.injectTraceContext,
|
|
244
262
|
invoke: () => invoke,
|
|
245
|
-
isTemplateFormat: () =>
|
|
246
|
-
loadParameters: () =>
|
|
247
|
-
loadPrompt: () =>
|
|
248
|
-
log: () =>
|
|
249
|
-
logError: () =>
|
|
250
|
-
login: () =>
|
|
251
|
-
loginToState: () =>
|
|
252
|
-
logs3OverflowUploadSchema: () =>
|
|
253
|
-
newId: () =>
|
|
254
|
-
parseCachedHeader: () =>
|
|
255
|
-
parseTemplateFormat: () =>
|
|
256
|
-
permalink: () =>
|
|
257
|
-
pickLogs3OverflowObjectIds: () =>
|
|
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,
|
|
258
276
|
projects: () => projects,
|
|
259
277
|
promptContentsSchema: () => promptContentsSchema,
|
|
260
278
|
promptDefinitionSchema: () => promptDefinitionSchema,
|
|
261
279
|
promptDefinitionToPromptData: () => promptDefinitionToPromptData,
|
|
262
280
|
promptDefinitionWithToolsSchema: () => promptDefinitionWithToolsSchema,
|
|
263
|
-
registerOtelFlush: () =>
|
|
281
|
+
registerOtelFlush: () => _chunkFY7DAKA5js.registerOtelFlush,
|
|
264
282
|
registerSandbox: () => registerSandbox,
|
|
265
|
-
registerTemplatePlugin: () =>
|
|
266
|
-
renderMessage: () =>
|
|
267
|
-
renderPromptParams: () =>
|
|
268
|
-
renderTemplateContent: () =>
|
|
283
|
+
registerTemplatePlugin: () => _chunkFY7DAKA5js.registerTemplatePlugin,
|
|
284
|
+
renderMessage: () => _chunkFY7DAKA5js.renderMessage,
|
|
285
|
+
renderPromptParams: () => _chunkFY7DAKA5js.renderPromptParams,
|
|
286
|
+
renderTemplateContent: () => _chunkFY7DAKA5js.renderTemplateContent,
|
|
269
287
|
reportFailures: () => reportFailures,
|
|
270
288
|
runEvaluator: () => runEvaluator,
|
|
271
|
-
setFetch: () =>
|
|
272
|
-
setMaskingFunction: () =>
|
|
273
|
-
spanComponentsToObjectId: () =>
|
|
274
|
-
startSpan: () =>
|
|
275
|
-
summarize: () =>
|
|
276
|
-
templateRegistry: () =>
|
|
277
|
-
toolFunctionDefinitionSchema: () =>
|
|
278
|
-
traceable: () =>
|
|
279
|
-
traced: () =>
|
|
280
|
-
updateSpan: () =>
|
|
281
|
-
uploadLogs3OverflowPayload: () =>
|
|
282
|
-
utf8ByteLength: () =>
|
|
283
|
-
withCurrent: () =>
|
|
284
|
-
withDataset: () =>
|
|
285
|
-
withExperiment: () =>
|
|
286
|
-
withLogger: () =>
|
|
287
|
-
withParent: () =>
|
|
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,
|
|
288
306
|
wrapAISDK: () => wrapAISDK,
|
|
289
307
|
wrapAISDKModel: () => wrapAISDKModel,
|
|
290
308
|
wrapAgentClass: () => wrapAgentClass,
|
|
@@ -299,7 +317,7 @@ _chunkLPC4W2WXjs.__export.call(void 0, exports_exports, {
|
|
|
299
317
|
wrapGoogleGenAI: () => wrapGoogleGenAI,
|
|
300
318
|
wrapGroq: () => wrapGroq,
|
|
301
319
|
wrapHuggingFace: () => wrapHuggingFace,
|
|
302
|
-
wrapMastraAgent: () =>
|
|
320
|
+
wrapMastraAgent: () => _chunkFY7DAKA5js.wrapMastraAgent,
|
|
303
321
|
wrapMistral: () => wrapMistral,
|
|
304
322
|
wrapOpenAI: () => wrapOpenAI,
|
|
305
323
|
wrapOpenAICodexSDK: () => wrapOpenAICodexSDK,
|
|
@@ -308,7 +326,7 @@ _chunkLPC4W2WXjs.__export.call(void 0, exports_exports, {
|
|
|
308
326
|
wrapOpenRouterAgent: () => wrapOpenRouterAgent,
|
|
309
327
|
wrapPiCodingAgentSDK: () => wrapPiCodingAgentSDK,
|
|
310
328
|
wrapStrandsAgentSDK: () => wrapStrandsAgentSDK,
|
|
311
|
-
wrapTraced: () =>
|
|
329
|
+
wrapTraced: () => _chunkFY7DAKA5js.wrapTraced,
|
|
312
330
|
wrapVitest: () => wrapVitest
|
|
313
331
|
});
|
|
314
332
|
|
|
@@ -316,7 +334,7 @@ _chunkLPC4W2WXjs.__export.call(void 0, exports_exports, {
|
|
|
316
334
|
var _v3 = require('zod/v3');
|
|
317
335
|
var SANDBOX_GROUP_NAME_METADATA_KEY = "_bt_sandbox_group_name";
|
|
318
336
|
async function registerSandbox(options) {
|
|
319
|
-
const state = _nullishCoalesce(options.state, () => (
|
|
337
|
+
const state = _nullishCoalesce(options.state, () => ( _chunkFY7DAKA5js._internalGetGlobalState.call(void 0, )));
|
|
320
338
|
await state.login({
|
|
321
339
|
apiKey: options.apiKey,
|
|
322
340
|
appUrl: options.appUrl,
|
|
@@ -357,7 +375,7 @@ async function registerSandbox(options) {
|
|
|
357
375
|
evaluatorDefinitions
|
|
358
376
|
)) {
|
|
359
377
|
const functionName = evalName;
|
|
360
|
-
const functionSlug =
|
|
378
|
+
const functionSlug = _chunkFY7DAKA5js.slugify.call(void 0, evalName, { lower: true, strict: true });
|
|
361
379
|
const functionDef = {
|
|
362
380
|
project_id: projectId,
|
|
363
381
|
org_name: state.orgName,
|
|
@@ -428,7 +446,7 @@ async function invoke(args) {
|
|
|
428
446
|
projectId,
|
|
429
447
|
...functionIdArgs
|
|
430
448
|
} = args;
|
|
431
|
-
const state = _nullishCoalesce(stateArg, () => (
|
|
449
|
+
const state = _nullishCoalesce(stateArg, () => ( _chunkFY7DAKA5js._internalGetGlobalState.call(void 0, )));
|
|
432
450
|
await state.login({
|
|
433
451
|
orgName,
|
|
434
452
|
apiKey,
|
|
@@ -436,8 +454,8 @@ async function invoke(args) {
|
|
|
436
454
|
forceLogin,
|
|
437
455
|
fetch
|
|
438
456
|
});
|
|
439
|
-
const parent = parentArg ? typeof parentArg === "string" ? parentArg : await parentArg.export() : await
|
|
440
|
-
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({
|
|
441
459
|
function_id: functionIdArgs.function_id,
|
|
442
460
|
project_name: functionIdArgs.projectName,
|
|
443
461
|
slug: functionIdArgs.slug,
|
|
@@ -480,7 +498,7 @@ async function invoke(args) {
|
|
|
480
498
|
if (!resp.body) {
|
|
481
499
|
throw new Error("Received empty stream body");
|
|
482
500
|
}
|
|
483
|
-
return new (0,
|
|
501
|
+
return new (0, _chunkFY7DAKA5js.BraintrustStream)(resp.body);
|
|
484
502
|
} else {
|
|
485
503
|
const data = await resp.json();
|
|
486
504
|
return schema ? schema.parse(data) : data;
|
|
@@ -492,7 +510,7 @@ function initFunction({
|
|
|
492
510
|
version,
|
|
493
511
|
state
|
|
494
512
|
}) {
|
|
495
|
-
const s = _nullishCoalesce(state, () => (
|
|
513
|
+
const s = _nullishCoalesce(state, () => ( _chunkFY7DAKA5js._internalGetGlobalState.call(void 0, )));
|
|
496
514
|
_optionalChain([s, 'optionalAccess', _2 => _2.spanCache, 'optionalAccess', _3 => _3.disable, 'call', _4 => _4()]);
|
|
497
515
|
const f = async (input) => {
|
|
498
516
|
return await invoke({
|
|
@@ -570,22 +588,22 @@ function responsesProxy(openai) {
|
|
|
570
588
|
if (name === "create" && typeof target.create === "function") {
|
|
571
589
|
return wrapResponsesAsync(
|
|
572
590
|
target.create.bind(target),
|
|
573
|
-
|
|
591
|
+
_chunkBFGIH2ZJjs.openAIChannels.responsesCreate
|
|
574
592
|
);
|
|
575
593
|
} else if (name === "stream" && typeof target.stream === "function") {
|
|
576
594
|
return wrapResponsesSyncStream(
|
|
577
595
|
target.stream.bind(target),
|
|
578
|
-
|
|
596
|
+
_chunkBFGIH2ZJjs.openAIChannels.responsesStream
|
|
579
597
|
);
|
|
580
598
|
} else if (name === "parse" && typeof target.parse === "function") {
|
|
581
599
|
return wrapResponsesAsync(
|
|
582
600
|
target.parse.bind(target),
|
|
583
|
-
|
|
601
|
+
_chunkBFGIH2ZJjs.openAIChannels.responsesParse
|
|
584
602
|
);
|
|
585
603
|
} else if (name === "compact" && typeof target.compact === "function") {
|
|
586
604
|
return wrapResponsesAsync(
|
|
587
605
|
target.compact.bind(target),
|
|
588
|
-
|
|
606
|
+
_chunkBFGIH2ZJjs.openAIChannels.responsesCompact
|
|
589
607
|
);
|
|
590
608
|
}
|
|
591
609
|
return Reflect.get(target, name, receiver);
|
|
@@ -729,7 +747,7 @@ function wrapBetaChatCompletionParse(completion) {
|
|
|
729
747
|
const { span_info, params } = splitSpanInfo(
|
|
730
748
|
allParams
|
|
731
749
|
);
|
|
732
|
-
return
|
|
750
|
+
return _chunkBFGIH2ZJjs.openAIChannels.betaChatCompletionsParse.tracePromise(
|
|
733
751
|
async () => await completion(params),
|
|
734
752
|
{ arguments: [params], span_info }
|
|
735
753
|
);
|
|
@@ -740,7 +758,7 @@ function wrapBetaChatCompletionStream(completion) {
|
|
|
740
758
|
const { span_info, params } = splitSpanInfo(
|
|
741
759
|
allParams
|
|
742
760
|
);
|
|
743
|
-
return
|
|
761
|
+
return _chunkBFGIH2ZJjs.openAIChannels.betaChatCompletionsStream.traceSync(
|
|
744
762
|
() => completion(params),
|
|
745
763
|
{ arguments: [params], span_info }
|
|
746
764
|
);
|
|
@@ -756,7 +774,7 @@ function wrapChatCompletion(completion) {
|
|
|
756
774
|
if (!executionPromise) {
|
|
757
775
|
executionPromise = (async () => {
|
|
758
776
|
const traceContext = createChannelContext(
|
|
759
|
-
|
|
777
|
+
_chunkBFGIH2ZJjs.openAIChannels.chatCompletionsCreate,
|
|
760
778
|
params,
|
|
761
779
|
span_info
|
|
762
780
|
);
|
|
@@ -766,7 +784,7 @@ function wrapChatCompletion(completion) {
|
|
|
766
784
|
options
|
|
767
785
|
);
|
|
768
786
|
const { data: data2, response: response2 } = await tracePromiseWithResponse(
|
|
769
|
-
|
|
787
|
+
_chunkBFGIH2ZJjs.openAIChannels.chatCompletionsCreate,
|
|
770
788
|
traceContext,
|
|
771
789
|
completionPromise
|
|
772
790
|
);
|
|
@@ -777,7 +795,7 @@ function wrapChatCompletion(completion) {
|
|
|
777
795
|
options
|
|
778
796
|
);
|
|
779
797
|
const { data, response } = await tracePromiseWithResponse(
|
|
780
|
-
|
|
798
|
+
_chunkBFGIH2ZJjs.openAIChannels.chatCompletionsCreate,
|
|
781
799
|
traceContext,
|
|
782
800
|
completionResponse
|
|
783
801
|
);
|
|
@@ -820,8 +838,8 @@ function wrapApiCreateWithChannel(create, channel) {
|
|
|
820
838
|
return createLazyAPIPromise(ensureExecuted);
|
|
821
839
|
};
|
|
822
840
|
}
|
|
823
|
-
var wrapEmbeddings = (create) => wrapApiCreateWithChannel(create,
|
|
824
|
-
var wrapModerations = (create) => wrapApiCreateWithChannel(create,
|
|
841
|
+
var wrapEmbeddings = (create) => wrapApiCreateWithChannel(create, _chunkBFGIH2ZJjs.openAIChannels.embeddingsCreate);
|
|
842
|
+
var wrapModerations = (create) => wrapApiCreateWithChannel(create, _chunkBFGIH2ZJjs.openAIChannels.moderationsCreate);
|
|
825
843
|
|
|
826
844
|
// src/wrappers/ai-sdk/ai-sdk.ts
|
|
827
845
|
function isModuleNamespace(obj) {
|
|
@@ -872,6 +890,7 @@ function wrapAISDK(aiSDK, options = {}) {
|
|
|
872
890
|
case "Agent":
|
|
873
891
|
case "Experimental_Agent":
|
|
874
892
|
case "ToolLoopAgent":
|
|
893
|
+
case "WorkflowAgent":
|
|
875
894
|
return original ? wrapAgentClass(original, options) : original;
|
|
876
895
|
}
|
|
877
896
|
return original;
|
|
@@ -890,10 +909,10 @@ var wrapAgentClass = (AgentClass, options = {}) => {
|
|
|
890
909
|
return new Proxy(instance, {
|
|
891
910
|
get(instanceTarget, prop, instanceReceiver) {
|
|
892
911
|
const original = Reflect.get(instanceTarget, prop, instanceTarget);
|
|
893
|
-
if (prop === "generate") {
|
|
912
|
+
if (prop === "generate" && typeof original === "function" && instanceTarget.constructor.name !== "WorkflowAgent") {
|
|
894
913
|
return wrapAgentGenerate(original, instanceTarget, options);
|
|
895
914
|
}
|
|
896
|
-
if (prop === "stream") {
|
|
915
|
+
if (prop === "stream" && typeof original === "function") {
|
|
897
916
|
return wrapAgentStream(original, instanceTarget, options);
|
|
898
917
|
}
|
|
899
918
|
if (typeof original === "function") {
|
|
@@ -908,7 +927,7 @@ var wrapAgentClass = (AgentClass, options = {}) => {
|
|
|
908
927
|
var wrapAgentGenerate = (generate, instance, options = {}) => {
|
|
909
928
|
const defaultName = `${instance.constructor.name}.generate`;
|
|
910
929
|
return async (params) => makeGenerateTextWrapper(
|
|
911
|
-
|
|
930
|
+
generateChannelForAgent(instance.constructor.name),
|
|
912
931
|
defaultName,
|
|
913
932
|
generate.bind(instance),
|
|
914
933
|
{
|
|
@@ -918,19 +937,42 @@ var wrapAgentGenerate = (generate, instance, options = {}) => {
|
|
|
918
937
|
options
|
|
919
938
|
)({ ...instance.settings, ...params });
|
|
920
939
|
};
|
|
940
|
+
function generateChannelForAgent(agentName) {
|
|
941
|
+
if (agentName === "ToolLoopAgent") {
|
|
942
|
+
return _chunkBFGIH2ZJjs.aiSDKChannels.toolLoopAgentGenerate;
|
|
943
|
+
}
|
|
944
|
+
return _chunkBFGIH2ZJjs.aiSDKChannels.agentGenerate;
|
|
945
|
+
}
|
|
921
946
|
var wrapAgentStream = (stream, instance, options = {}) => {
|
|
922
947
|
const defaultName = `${instance.constructor.name}.stream`;
|
|
923
|
-
return (params) =>
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
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
|
+
};
|
|
933
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
|
+
}
|
|
934
976
|
var makeGenerateTextWrapper = (channel, name, generateText, contextOptions = {}, options = {}) => {
|
|
935
977
|
const wrapper = async function(allParams) {
|
|
936
978
|
const { span_info, ...params } = allParams;
|
|
@@ -953,7 +995,7 @@ var makeGenerateTextWrapper = (channel, name, generateText, contextOptions = {},
|
|
|
953
995
|
};
|
|
954
996
|
var wrapGenerateText = (generateText, options = {}, aiSDK) => {
|
|
955
997
|
return makeGenerateTextWrapper(
|
|
956
|
-
|
|
998
|
+
_chunkBFGIH2ZJjs.aiSDKChannels.generateText,
|
|
957
999
|
"generateText",
|
|
958
1000
|
generateText,
|
|
959
1001
|
{ aiSDK },
|
|
@@ -962,7 +1004,7 @@ var wrapGenerateText = (generateText, options = {}, aiSDK) => {
|
|
|
962
1004
|
};
|
|
963
1005
|
var wrapGenerateObject = (generateObject, options = {}, aiSDK) => {
|
|
964
1006
|
return makeGenerateTextWrapper(
|
|
965
|
-
|
|
1007
|
+
_chunkBFGIH2ZJjs.aiSDKChannels.generateObject,
|
|
966
1008
|
"generateObject",
|
|
967
1009
|
generateObject,
|
|
968
1010
|
{ aiSDK },
|
|
@@ -991,7 +1033,7 @@ var makeEmbedWrapper = (channel, name, embed, contextOptions = {}, options = {})
|
|
|
991
1033
|
};
|
|
992
1034
|
var wrapEmbed = (embed, options = {}, aiSDK) => {
|
|
993
1035
|
return makeEmbedWrapper(
|
|
994
|
-
|
|
1036
|
+
_chunkBFGIH2ZJjs.aiSDKChannels.embed,
|
|
995
1037
|
"embed",
|
|
996
1038
|
embed,
|
|
997
1039
|
{ aiSDK },
|
|
@@ -1000,7 +1042,7 @@ var wrapEmbed = (embed, options = {}, aiSDK) => {
|
|
|
1000
1042
|
};
|
|
1001
1043
|
var wrapEmbedMany = (embedMany, options = {}, aiSDK) => {
|
|
1002
1044
|
return makeEmbedWrapper(
|
|
1003
|
-
|
|
1045
|
+
_chunkBFGIH2ZJjs.aiSDKChannels.embedMany,
|
|
1004
1046
|
"embedMany",
|
|
1005
1047
|
embedMany,
|
|
1006
1048
|
{ aiSDK },
|
|
@@ -1011,7 +1053,7 @@ var makeRerankWrapper = (rerank, contextOptions = {}, options = {}) => {
|
|
|
1011
1053
|
const wrapper = async function(allParams) {
|
|
1012
1054
|
const { span_info, ...params } = allParams;
|
|
1013
1055
|
const tracedParams = { ...params };
|
|
1014
|
-
return
|
|
1056
|
+
return _chunkBFGIH2ZJjs.aiSDKChannels.rerank.tracePromise(
|
|
1015
1057
|
() => rerank(tracedParams),
|
|
1016
1058
|
createAISDKChannelContext(tracedParams, {
|
|
1017
1059
|
aiSDK: contextOptions.aiSDK,
|
|
@@ -1050,7 +1092,7 @@ var makeStreamWrapper = (channel, name, streamText, contextOptions = {}, options
|
|
|
1050
1092
|
};
|
|
1051
1093
|
var wrapStreamText = (streamText, options = {}, aiSDK) => {
|
|
1052
1094
|
return makeStreamWrapper(
|
|
1053
|
-
|
|
1095
|
+
_chunkBFGIH2ZJjs.aiSDKChannels.streamText,
|
|
1054
1096
|
"streamText",
|
|
1055
1097
|
streamText,
|
|
1056
1098
|
{ aiSDK },
|
|
@@ -1059,7 +1101,7 @@ var wrapStreamText = (streamText, options = {}, aiSDK) => {
|
|
|
1059
1101
|
};
|
|
1060
1102
|
var wrapStreamObject = (streamObject, options = {}, aiSDK) => {
|
|
1061
1103
|
return makeStreamWrapper(
|
|
1062
|
-
|
|
1104
|
+
_chunkBFGIH2ZJjs.aiSDKChannels.streamObject,
|
|
1063
1105
|
"streamObject",
|
|
1064
1106
|
streamObject,
|
|
1065
1107
|
{ aiSDK },
|
|
@@ -1130,14 +1172,14 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1130
1172
|
// For the first cut, do not support custom span_info arguments. We can
|
|
1131
1173
|
// propagate those via async local storage
|
|
1132
1174
|
async doGenerate(options) {
|
|
1133
|
-
const span =
|
|
1175
|
+
const span = _chunkFY7DAKA5js.startSpan.call(void 0, {
|
|
1134
1176
|
name: "Chat Completion",
|
|
1135
1177
|
spanAttributes: {
|
|
1136
1178
|
type: "llm"
|
|
1137
1179
|
}
|
|
1138
1180
|
});
|
|
1139
1181
|
const { prompt, mode, ...rest } = options;
|
|
1140
|
-
const startTime =
|
|
1182
|
+
const startTime = _chunkFY7DAKA5js.getCurrentUnixTimestamp.call(void 0, );
|
|
1141
1183
|
try {
|
|
1142
1184
|
const ret = await this.model.doGenerate(options);
|
|
1143
1185
|
span.log({
|
|
@@ -1149,12 +1191,12 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1149
1191
|
},
|
|
1150
1192
|
output: postProcessOutput(ret.text, ret.toolCalls, ret.finishReason),
|
|
1151
1193
|
metrics: {
|
|
1152
|
-
time_to_first_token:
|
|
1153
|
-
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,
|
|
1154
1196
|
prompt_tokens: _optionalChain([ret, 'access', _20 => _20.usage, 'optionalAccess', _21 => _21.promptTokens]),
|
|
1155
1197
|
completion_tokens: _optionalChain([ret, 'access', _22 => _22.usage, 'optionalAccess', _23 => _23.completionTokens]),
|
|
1156
|
-
cached:
|
|
1157
|
-
_nullishCoalesce(_optionalChain([ret, 'access', _24 => _24.rawResponse, 'optionalAccess', _25 => _25.headers, 'optionalAccess', _26 => _26[
|
|
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]])))
|
|
1158
1200
|
)
|
|
1159
1201
|
}
|
|
1160
1202
|
});
|
|
@@ -1165,8 +1207,8 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1165
1207
|
}
|
|
1166
1208
|
async doStream(options) {
|
|
1167
1209
|
const { prompt, mode, ...rest } = options;
|
|
1168
|
-
const startTime =
|
|
1169
|
-
const span =
|
|
1210
|
+
const startTime = _chunkFY7DAKA5js.getCurrentUnixTimestamp.call(void 0, );
|
|
1211
|
+
const span = _chunkFY7DAKA5js.startSpan.call(void 0, {
|
|
1170
1212
|
name: "Chat Completion",
|
|
1171
1213
|
spanAttributes: {
|
|
1172
1214
|
type: "llm"
|
|
@@ -1192,7 +1234,7 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1192
1234
|
let time_to_first_token = void 0;
|
|
1193
1235
|
let usage = void 0;
|
|
1194
1236
|
let fullText = void 0;
|
|
1195
|
-
const
|
|
1237
|
+
const toolCalls2 = {};
|
|
1196
1238
|
let finishReason = void 0;
|
|
1197
1239
|
return {
|
|
1198
1240
|
...ret,
|
|
@@ -1200,7 +1242,7 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1200
1242
|
new TransformStream({
|
|
1201
1243
|
transform(chunk, controller) {
|
|
1202
1244
|
if (time_to_first_token === void 0) {
|
|
1203
|
-
time_to_first_token =
|
|
1245
|
+
time_to_first_token = _chunkFY7DAKA5js.getCurrentUnixTimestamp.call(void 0, ) - startTime;
|
|
1204
1246
|
span.log({ metrics: { time_to_first_token } });
|
|
1205
1247
|
}
|
|
1206
1248
|
switch (chunk.type) {
|
|
@@ -1211,7 +1253,7 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1211
1253
|
fullText += chunk.textDelta;
|
|
1212
1254
|
break;
|
|
1213
1255
|
case "tool-call":
|
|
1214
|
-
|
|
1256
|
+
toolCalls2[chunk.toolCallId] = {
|
|
1215
1257
|
toolCallType: chunk.toolCallType,
|
|
1216
1258
|
toolCallId: chunk.toolCallId,
|
|
1217
1259
|
toolName: chunk.toolName,
|
|
@@ -1219,15 +1261,15 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1219
1261
|
};
|
|
1220
1262
|
break;
|
|
1221
1263
|
case "tool-call-delta":
|
|
1222
|
-
if (
|
|
1223
|
-
|
|
1264
|
+
if (toolCalls2[chunk.toolCallId] === void 0) {
|
|
1265
|
+
toolCalls2[chunk.toolCallId] = {
|
|
1224
1266
|
toolCallType: chunk.toolCallType,
|
|
1225
1267
|
toolCallId: chunk.toolCallId,
|
|
1226
1268
|
toolName: chunk.toolName,
|
|
1227
1269
|
args: ""
|
|
1228
1270
|
};
|
|
1229
1271
|
}
|
|
1230
|
-
|
|
1272
|
+
toolCalls2[chunk.toolCallId].args += chunk.argsTextDelta;
|
|
1231
1273
|
break;
|
|
1232
1274
|
case "finish":
|
|
1233
1275
|
usage = chunk.usage;
|
|
@@ -1240,16 +1282,16 @@ var BraintrustLanguageModelWrapper = class {
|
|
|
1240
1282
|
span.log({
|
|
1241
1283
|
output: postProcessOutput(
|
|
1242
1284
|
fullText,
|
|
1243
|
-
Object.keys(
|
|
1285
|
+
Object.keys(toolCalls2).length > 0 ? Object.values(toolCalls2) : void 0,
|
|
1244
1286
|
finishReason
|
|
1245
1287
|
),
|
|
1246
1288
|
metrics: {
|
|
1247
1289
|
time_to_first_token,
|
|
1248
|
-
tokens: !
|
|
1290
|
+
tokens: !_chunkFY7DAKA5js.isEmpty.call(void 0, usage) ? usage.promptTokens + usage.completionTokens : void 0,
|
|
1249
1291
|
prompt_tokens: _optionalChain([usage, 'optionalAccess', _30 => _30.promptTokens]),
|
|
1250
1292
|
completion_tokens: _optionalChain([usage, 'optionalAccess', _31 => _31.completionTokens]),
|
|
1251
|
-
cached:
|
|
1252
|
-
_nullishCoalesce(_optionalChain([ret, 'access', _32 => _32.rawResponse, 'optionalAccess', _33 => _33.headers, 'optionalAccess', _34 => _34[
|
|
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]])))
|
|
1253
1295
|
)
|
|
1254
1296
|
}
|
|
1255
1297
|
});
|
|
@@ -1341,15 +1383,15 @@ function postProcessPrompt(prompt) {
|
|
|
1341
1383
|
}
|
|
1342
1384
|
});
|
|
1343
1385
|
}
|
|
1344
|
-
function postProcessOutput(text,
|
|
1386
|
+
function postProcessOutput(text, toolCalls2, finishReason) {
|
|
1345
1387
|
return [
|
|
1346
1388
|
{
|
|
1347
1389
|
index: 0,
|
|
1348
1390
|
message: {
|
|
1349
1391
|
role: "assistant",
|
|
1350
1392
|
content: _nullishCoalesce(text, () => ( "")),
|
|
1351
|
-
...
|
|
1352
|
-
tool_calls:
|
|
1393
|
+
...toolCalls2 && toolCalls2.length > 0 ? {
|
|
1394
|
+
tool_calls: toolCalls2.map((toolCall) => ({
|
|
1353
1395
|
id: toolCall.toolCallId,
|
|
1354
1396
|
function: {
|
|
1355
1397
|
name: toolCall.toolName,
|
|
@@ -1434,12 +1476,12 @@ function normalizeUsageMetrics(usage, provider, providerMetadata) {
|
|
|
1434
1476
|
anthropicMetadata.usage,
|
|
1435
1477
|
"cache_creation_input_tokens"
|
|
1436
1478
|
) || 0;
|
|
1437
|
-
const cacheTokens =
|
|
1479
|
+
const cacheTokens = _chunkFY7DAKA5js.extractAnthropicCacheTokens.call(void 0,
|
|
1438
1480
|
cacheReadTokens,
|
|
1439
1481
|
cacheCreationTokens
|
|
1440
1482
|
);
|
|
1441
1483
|
Object.assign(metrics, cacheTokens);
|
|
1442
|
-
Object.assign(metrics,
|
|
1484
|
+
Object.assign(metrics, _chunkFY7DAKA5js.finalizeAnthropicTokens.call(void 0, metrics));
|
|
1443
1485
|
}
|
|
1444
1486
|
}
|
|
1445
1487
|
return metrics;
|
|
@@ -1448,29 +1490,29 @@ function normalizeFinishReason(reason) {
|
|
|
1448
1490
|
if (typeof reason !== "string") return void 0;
|
|
1449
1491
|
return reason.replace(/-/g, "_");
|
|
1450
1492
|
}
|
|
1451
|
-
function buildAssistantOutputWithToolCalls(result,
|
|
1493
|
+
function buildAssistantOutputWithToolCalls(result, toolCalls2) {
|
|
1452
1494
|
return [
|
|
1453
1495
|
{
|
|
1454
1496
|
index: 0,
|
|
1455
1497
|
logprobs: null,
|
|
1456
|
-
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))),
|
|
1457
1499
|
message: {
|
|
1458
1500
|
role: "assistant",
|
|
1459
|
-
tool_calls:
|
|
1501
|
+
tool_calls: toolCalls2.length > 0 ? toolCalls2 : void 0
|
|
1460
1502
|
}
|
|
1461
1503
|
}
|
|
1462
1504
|
];
|
|
1463
1505
|
}
|
|
1464
1506
|
function extractToolCallsFromSteps(steps) {
|
|
1465
|
-
const
|
|
1466
|
-
if (!Array.isArray(steps)) return
|
|
1507
|
+
const toolCalls2 = [];
|
|
1508
|
+
if (!Array.isArray(steps)) return toolCalls2;
|
|
1467
1509
|
let idx = 0;
|
|
1468
1510
|
for (const step of steps) {
|
|
1469
1511
|
const blocks = _optionalChain([step, 'optionalAccess', _50 => _50.content]);
|
|
1470
1512
|
if (!Array.isArray(blocks)) continue;
|
|
1471
1513
|
for (const block of blocks) {
|
|
1472
1514
|
if (block && typeof block === "object" && block.type === "tool-call") {
|
|
1473
|
-
|
|
1515
|
+
toolCalls2.push({
|
|
1474
1516
|
id: block.toolCallId,
|
|
1475
1517
|
type: "function",
|
|
1476
1518
|
index: idx++,
|
|
@@ -1482,7 +1524,7 @@ function extractToolCallsFromSteps(steps) {
|
|
|
1482
1524
|
}
|
|
1483
1525
|
}
|
|
1484
1526
|
}
|
|
1485
|
-
return
|
|
1527
|
+
return toolCalls2;
|
|
1486
1528
|
}
|
|
1487
1529
|
function extractToolCallsFromBlocks(blocks) {
|
|
1488
1530
|
if (!Array.isArray(blocks)) return [];
|
|
@@ -1511,7 +1553,7 @@ function BraintrustMiddleware(config = {}) {
|
|
|
1511
1553
|
model: modelFromWrapGenerate
|
|
1512
1554
|
}) => {
|
|
1513
1555
|
const rawInput = extractInput(params);
|
|
1514
|
-
const processedInput =
|
|
1556
|
+
const processedInput = _chunkFY7DAKA5js.processInputAttachments.call(void 0, rawInput);
|
|
1515
1557
|
const spanArgs = {
|
|
1516
1558
|
name: _optionalChain([config, 'access', _54 => _54.spanInfo, 'optionalAccess', _55 => _55.name]) || "ai-sdk.doGenerate",
|
|
1517
1559
|
spanAttributes: {
|
|
@@ -1526,7 +1568,7 @@ function BraintrustMiddleware(config = {}) {
|
|
|
1526
1568
|
}
|
|
1527
1569
|
}
|
|
1528
1570
|
};
|
|
1529
|
-
const span =
|
|
1571
|
+
const span = _chunkFY7DAKA5js.startSpan.call(void 0, spanArgs);
|
|
1530
1572
|
try {
|
|
1531
1573
|
const result = await doGenerate();
|
|
1532
1574
|
const metadata = {};
|
|
@@ -1548,12 +1590,12 @@ function BraintrustMiddleware(config = {}) {
|
|
|
1548
1590
|
metadata.model = modelId;
|
|
1549
1591
|
}
|
|
1550
1592
|
}
|
|
1551
|
-
let
|
|
1552
|
-
if (!
|
|
1553
|
-
|
|
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]));
|
|
1554
1596
|
}
|
|
1555
1597
|
span.log({
|
|
1556
|
-
output:
|
|
1598
|
+
output: toolCalls2.length > 0 ? buildAssistantOutputWithToolCalls(result, toolCalls2) : _optionalChain([result, 'optionalAccess', _62 => _62.content]),
|
|
1557
1599
|
metadata,
|
|
1558
1600
|
metrics: normalizeUsageMetrics(
|
|
1559
1601
|
result.usage,
|
|
@@ -1573,7 +1615,7 @@ function BraintrustMiddleware(config = {}) {
|
|
|
1573
1615
|
},
|
|
1574
1616
|
wrapStream: async ({ doStream, params }) => {
|
|
1575
1617
|
const rawInput = extractInput(params);
|
|
1576
|
-
const processedInput =
|
|
1618
|
+
const processedInput = _chunkFY7DAKA5js.processInputAttachments.call(void 0, rawInput);
|
|
1577
1619
|
const spanArgs = {
|
|
1578
1620
|
name: _optionalChain([config, 'access', _63 => _63.spanInfo, 'optionalAccess', _64 => _64.name]) || "ai-sdk.doStream",
|
|
1579
1621
|
spanAttributes: {
|
|
@@ -1588,7 +1630,7 @@ function BraintrustMiddleware(config = {}) {
|
|
|
1588
1630
|
}
|
|
1589
1631
|
}
|
|
1590
1632
|
};
|
|
1591
|
-
const span =
|
|
1633
|
+
const span = _chunkFY7DAKA5js.startSpan.call(void 0, spanArgs);
|
|
1592
1634
|
try {
|
|
1593
1635
|
const { stream, ...rest } = await doStream();
|
|
1594
1636
|
const textChunks = [];
|
|
@@ -1642,13 +1684,13 @@ function BraintrustMiddleware(config = {}) {
|
|
|
1642
1684
|
metadata.model = model;
|
|
1643
1685
|
}
|
|
1644
1686
|
if (toolBlocks.length > 0) {
|
|
1645
|
-
const
|
|
1687
|
+
const toolCalls2 = extractToolCallsFromSteps([
|
|
1646
1688
|
{ content: toolBlocks }
|
|
1647
1689
|
]);
|
|
1648
|
-
if (
|
|
1690
|
+
if (toolCalls2.length > 0) {
|
|
1649
1691
|
output = buildAssistantOutputWithToolCalls(
|
|
1650
1692
|
resultForDetection,
|
|
1651
|
-
|
|
1693
|
+
toolCalls2
|
|
1652
1694
|
);
|
|
1653
1695
|
}
|
|
1654
1696
|
}
|
|
@@ -1727,7 +1769,7 @@ function messagesProxy(messages) {
|
|
|
1727
1769
|
return new Proxy(messages, {
|
|
1728
1770
|
get(target, prop, receiver) {
|
|
1729
1771
|
if (prop === "create") {
|
|
1730
|
-
return createProxy(target.create,
|
|
1772
|
+
return createProxy(target.create, _chunkBFGIH2ZJjs.anthropicChannels.messagesCreate);
|
|
1731
1773
|
}
|
|
1732
1774
|
return Reflect.get(target, prop, receiver);
|
|
1733
1775
|
}
|
|
@@ -1737,7 +1779,7 @@ function betaMessagesProxy(messages, anthropic) {
|
|
|
1737
1779
|
return new Proxy(messages, {
|
|
1738
1780
|
get(target, prop, receiver) {
|
|
1739
1781
|
if (prop === "create") {
|
|
1740
|
-
return createProxy(target.create,
|
|
1782
|
+
return createProxy(target.create, _chunkBFGIH2ZJjs.anthropicChannels.betaMessagesCreate);
|
|
1741
1783
|
}
|
|
1742
1784
|
if (prop === "toolRunner") {
|
|
1743
1785
|
if (typeof target.toolRunner !== "function") {
|
|
@@ -1746,7 +1788,7 @@ function betaMessagesProxy(messages, anthropic) {
|
|
|
1746
1788
|
return toolRunnerProxy(
|
|
1747
1789
|
target.toolRunner,
|
|
1748
1790
|
anthropic,
|
|
1749
|
-
|
|
1791
|
+
_chunkBFGIH2ZJjs.anthropicChannels.betaMessagesToolRunner
|
|
1750
1792
|
);
|
|
1751
1793
|
}
|
|
1752
1794
|
return Reflect.get(target, prop, receiver);
|
|
@@ -1803,11 +1845,11 @@ function wrapClaudeAgentQuery(queryFn, defaultThis) {
|
|
|
1803
1845
|
...params,
|
|
1804
1846
|
options: {
|
|
1805
1847
|
..._nullishCoalesce(params.options, () => ( {})),
|
|
1806
|
-
[
|
|
1848
|
+
[_chunkFY7DAKA5js.CLAUDE_AGENT_SDK_SKIP_LOCAL_TOOL_HOOKS_OPTION]: true
|
|
1807
1849
|
}
|
|
1808
1850
|
};
|
|
1809
1851
|
const invocationTarget = thisArg === proxy || thisArg === void 0 ? _nullishCoalesce(defaultThis, () => ( thisArg)) : thisArg;
|
|
1810
|
-
return
|
|
1852
|
+
return _chunkBFGIH2ZJjs.claudeAgentSDKChannels.query.traceSync(
|
|
1811
1853
|
() => Reflect.apply(target, invocationTarget, [wrappedParams]),
|
|
1812
1854
|
// The channel carries no extra context fields, but the generated
|
|
1813
1855
|
// StartOf<> type for Record<string, never> is overly strict here.
|
|
@@ -1835,7 +1877,7 @@ function wrapClaudeAgentTool(toolFn, localToolMetadataByTool, defaultThis) {
|
|
|
1835
1877
|
}
|
|
1836
1878
|
const localToolMetadata = { toolName };
|
|
1837
1879
|
const originalHandler = wrappedArgs[handlerIndex];
|
|
1838
|
-
wrappedArgs[handlerIndex] =
|
|
1880
|
+
wrappedArgs[handlerIndex] = _chunkFY7DAKA5js.wrapLocalClaudeToolHandler.call(void 0,
|
|
1839
1881
|
originalHandler,
|
|
1840
1882
|
() => localToolMetadata
|
|
1841
1883
|
);
|
|
@@ -2018,7 +2060,7 @@ function wrapCodexThread(thread) {
|
|
|
2018
2060
|
if (prop === "run" && typeof value === "function") {
|
|
2019
2061
|
return function(input, turnOptions) {
|
|
2020
2062
|
const args = [input, turnOptions];
|
|
2021
|
-
return
|
|
2063
|
+
return _chunkBFGIH2ZJjs.openAICodexChannels.run.tracePromise(
|
|
2022
2064
|
() => Reflect.apply(value, target, args),
|
|
2023
2065
|
{
|
|
2024
2066
|
arguments: args,
|
|
@@ -2031,7 +2073,7 @@ function wrapCodexThread(thread) {
|
|
|
2031
2073
|
if (prop === "runStreamed" && typeof value === "function") {
|
|
2032
2074
|
return function(input, turnOptions) {
|
|
2033
2075
|
const args = [input, turnOptions];
|
|
2034
|
-
return
|
|
2076
|
+
return _chunkBFGIH2ZJjs.openAICodexChannels.runStreamed.tracePromise(
|
|
2035
2077
|
() => Reflect.apply(value, target, args),
|
|
2036
2078
|
{
|
|
2037
2079
|
arguments: args,
|
|
@@ -2099,7 +2141,7 @@ function wrapCursorAgentClass(Agent) {
|
|
|
2099
2141
|
if (prop === "create" && typeof value === "function") {
|
|
2100
2142
|
const wrapped = async function(options) {
|
|
2101
2143
|
const args = [options];
|
|
2102
|
-
return
|
|
2144
|
+
return _chunkBFGIH2ZJjs.cursorSDKChannels.create.tracePromise(
|
|
2103
2145
|
async () => wrapCursorAgent(await Reflect.apply(value, target, args)),
|
|
2104
2146
|
{ arguments: args }
|
|
2105
2147
|
);
|
|
@@ -2110,7 +2152,7 @@ function wrapCursorAgentClass(Agent) {
|
|
|
2110
2152
|
if (prop === "resume" && typeof value === "function") {
|
|
2111
2153
|
const wrapped = async function(agentId, options) {
|
|
2112
2154
|
const args = [agentId, options];
|
|
2113
|
-
return
|
|
2155
|
+
return _chunkBFGIH2ZJjs.cursorSDKChannels.resume.tracePromise(
|
|
2114
2156
|
async () => wrapCursorAgent(await Reflect.apply(value, target, args)),
|
|
2115
2157
|
{ arguments: args }
|
|
2116
2158
|
);
|
|
@@ -2121,7 +2163,7 @@ function wrapCursorAgentClass(Agent) {
|
|
|
2121
2163
|
if (prop === "prompt" && typeof value === "function") {
|
|
2122
2164
|
const wrapped = async function(message, options) {
|
|
2123
2165
|
const args = [message, options];
|
|
2124
|
-
return
|
|
2166
|
+
return _chunkBFGIH2ZJjs.cursorSDKChannels.prompt.tracePromise(
|
|
2125
2167
|
() => Reflect.apply(value, target, args),
|
|
2126
2168
|
{ arguments: args }
|
|
2127
2169
|
);
|
|
@@ -2154,7 +2196,7 @@ function wrapCursorAgent(agent) {
|
|
|
2154
2196
|
if (prop === "send" && typeof value === "function") {
|
|
2155
2197
|
return function(message, options) {
|
|
2156
2198
|
const args = [message, options];
|
|
2157
|
-
return
|
|
2199
|
+
return _chunkBFGIH2ZJjs.cursorSDKChannels.send.tracePromise(
|
|
2158
2200
|
() => Reflect.apply(value, target, args),
|
|
2159
2201
|
{
|
|
2160
2202
|
agent: target,
|
|
@@ -2204,7 +2246,7 @@ function patchAgentSessionClass(AgentSession) {
|
|
|
2204
2246
|
...descriptor,
|
|
2205
2247
|
value: function wrappedPiCodingAgentPrompt(text, options) {
|
|
2206
2248
|
const args = [text, options];
|
|
2207
|
-
return
|
|
2249
|
+
return _chunkBFGIH2ZJjs.piCodingAgentChannels.prompt.tracePromise(
|
|
2208
2250
|
() => Reflect.apply(originalPrompt, this, args),
|
|
2209
2251
|
{
|
|
2210
2252
|
arguments: args,
|
|
@@ -2324,7 +2366,7 @@ function wrapAgentInstance(agent) {
|
|
|
2324
2366
|
if (prop === "stream" && typeof value === "function") {
|
|
2325
2367
|
return function(args, options) {
|
|
2326
2368
|
const callArgs = [args, options];
|
|
2327
|
-
return
|
|
2369
|
+
return _chunkBFGIH2ZJjs.strandsAgentSDKChannels.agentStream.traceSync(
|
|
2328
2370
|
() => Reflect.apply(value, target, callArgs),
|
|
2329
2371
|
{
|
|
2330
2372
|
agent: proxy,
|
|
@@ -2360,7 +2402,7 @@ function wrapMultiAgentInstance(orchestrator, kind) {
|
|
|
2360
2402
|
if (prop === "stream" && typeof value === "function") {
|
|
2361
2403
|
return function(input, options) {
|
|
2362
2404
|
const callArgs = [input, options];
|
|
2363
|
-
const channel = kind === "graph" ?
|
|
2405
|
+
const channel = kind === "graph" ? _chunkBFGIH2ZJjs.strandsAgentSDKChannels.graphStream : _chunkBFGIH2ZJjs.strandsAgentSDKChannels.swarmStream;
|
|
2364
2406
|
return channel.traceSync(
|
|
2365
2407
|
() => Reflect.apply(value, target, callArgs),
|
|
2366
2408
|
{
|
|
@@ -2435,7 +2477,7 @@ function wrapGoogleGenAIInstance(instance) {
|
|
|
2435
2477
|
}
|
|
2436
2478
|
if (prop === "interactions") {
|
|
2437
2479
|
const interactions = Reflect.get(target, prop, receiver);
|
|
2438
|
-
if (!
|
|
2480
|
+
if (!_chunkFY7DAKA5js.isObject.call(void 0, interactions) || typeof interactions.create !== "function") {
|
|
2439
2481
|
return interactions;
|
|
2440
2482
|
}
|
|
2441
2483
|
if (interactions !== originalInteractions) {
|
|
@@ -2449,7 +2491,7 @@ function wrapGoogleGenAIInstance(instance) {
|
|
|
2449
2491
|
});
|
|
2450
2492
|
}
|
|
2451
2493
|
function patchGoogleGenAIChats(instance, wrappedModels) {
|
|
2452
|
-
if (!
|
|
2494
|
+
if (!_chunkFY7DAKA5js.isObject.call(void 0, instance.chats) || !("modelsModule" in instance.chats)) {
|
|
2453
2495
|
return;
|
|
2454
2496
|
}
|
|
2455
2497
|
Reflect.set(instance.chats, "modelsModule", wrappedModels);
|
|
@@ -2482,7 +2524,7 @@ function wrapInteractions(interactions) {
|
|
|
2482
2524
|
}
|
|
2483
2525
|
function wrapGenerateContent(original) {
|
|
2484
2526
|
return function(params) {
|
|
2485
|
-
return
|
|
2527
|
+
return _chunkBFGIH2ZJjs.googleGenAIChannels.generateContent.tracePromise(
|
|
2486
2528
|
() => original(params),
|
|
2487
2529
|
{ arguments: [params] }
|
|
2488
2530
|
);
|
|
@@ -2490,7 +2532,7 @@ function wrapGenerateContent(original) {
|
|
|
2490
2532
|
}
|
|
2491
2533
|
function wrapGenerateContentStream(original) {
|
|
2492
2534
|
return function(params) {
|
|
2493
|
-
return
|
|
2535
|
+
return _chunkBFGIH2ZJjs.googleGenAIChannels.generateContentStream.tracePromise(
|
|
2494
2536
|
() => original(params),
|
|
2495
2537
|
{ arguments: [params] }
|
|
2496
2538
|
);
|
|
@@ -2498,7 +2540,7 @@ function wrapGenerateContentStream(original) {
|
|
|
2498
2540
|
}
|
|
2499
2541
|
function wrapEmbedContent(original) {
|
|
2500
2542
|
return function(params) {
|
|
2501
|
-
return
|
|
2543
|
+
return _chunkBFGIH2ZJjs.googleGenAIChannels.embedContent.tracePromise(
|
|
2502
2544
|
() => original(params),
|
|
2503
2545
|
{ arguments: [params] }
|
|
2504
2546
|
);
|
|
@@ -2510,7 +2552,7 @@ function wrapInteractionCreate(original) {
|
|
|
2510
2552
|
return options === void 0 ? original(params) : original(params, options);
|
|
2511
2553
|
}
|
|
2512
2554
|
const traceContext = options === void 0 ? { arguments: [params] } : { arguments: [params, options] };
|
|
2513
|
-
return
|
|
2555
|
+
return _chunkBFGIH2ZJjs.googleGenAIChannels.interactionsCreate.tracePromise(
|
|
2514
2556
|
() => options === void 0 ? original(params) : original(params, options),
|
|
2515
2557
|
traceContext
|
|
2516
2558
|
);
|
|
@@ -2571,7 +2613,7 @@ function wrapRunnerInstance(runner) {
|
|
|
2571
2613
|
function wrapRunnerRunAsync(runner) {
|
|
2572
2614
|
const original = runner.runAsync.bind(runner);
|
|
2573
2615
|
return function(params) {
|
|
2574
|
-
return
|
|
2616
|
+
return _chunkBFGIH2ZJjs.googleADKChannels.runnerRunAsync.traceSync(() => original(params), {
|
|
2575
2617
|
arguments: [params],
|
|
2576
2618
|
self: runner
|
|
2577
2619
|
});
|
|
@@ -2598,7 +2640,7 @@ function wrapAgentInstance2(agent) {
|
|
|
2598
2640
|
function wrapAgentRunAsync(agent) {
|
|
2599
2641
|
const original = agent.runAsync.bind(agent);
|
|
2600
2642
|
return function(parentContext) {
|
|
2601
|
-
return
|
|
2643
|
+
return _chunkBFGIH2ZJjs.googleADKChannels.agentRunAsync.traceSync(
|
|
2602
2644
|
() => original(parentContext),
|
|
2603
2645
|
{ arguments: [parentContext], self: agent }
|
|
2604
2646
|
);
|
|
@@ -2625,7 +2667,7 @@ function wrapToolInstance(tool) {
|
|
|
2625
2667
|
function wrapToolRunAsync(tool) {
|
|
2626
2668
|
const original = tool.runAsync.bind(tool);
|
|
2627
2669
|
return function(req) {
|
|
2628
|
-
return
|
|
2670
|
+
return _chunkBFGIH2ZJjs.googleADKChannels.toolRunAsync.tracePromise(() => original(req), {
|
|
2629
2671
|
arguments: [req],
|
|
2630
2672
|
self: tool
|
|
2631
2673
|
});
|
|
@@ -2772,27 +2814,27 @@ function patchGenkitRegistryConstructor(registry) {
|
|
|
2772
2814
|
}
|
|
2773
2815
|
}
|
|
2774
2816
|
function wrapGenerate(generate) {
|
|
2775
|
-
return (input) =>
|
|
2817
|
+
return (input) => _chunkBFGIH2ZJjs.genkitChannels.generate.tracePromise(() => generate(input), {
|
|
2776
2818
|
arguments: [input]
|
|
2777
2819
|
});
|
|
2778
2820
|
}
|
|
2779
2821
|
function wrapGenerateStream(generateStream) {
|
|
2780
|
-
return (input) =>
|
|
2822
|
+
return (input) => _chunkBFGIH2ZJjs.genkitChannels.generateStream.traceSync(() => generateStream(input), {
|
|
2781
2823
|
arguments: [input]
|
|
2782
2824
|
});
|
|
2783
2825
|
}
|
|
2784
2826
|
function wrapEmbed2(embed) {
|
|
2785
|
-
return (params) =>
|
|
2827
|
+
return (params) => _chunkBFGIH2ZJjs.genkitChannels.embed.tracePromise(() => embed(params), {
|
|
2786
2828
|
arguments: [params]
|
|
2787
2829
|
});
|
|
2788
2830
|
}
|
|
2789
2831
|
function wrapEmbedMany2(embedMany) {
|
|
2790
|
-
return (params) =>
|
|
2832
|
+
return (params) => _chunkBFGIH2ZJjs.genkitChannels.embedMany.tracePromise(() => embedMany(params), {
|
|
2791
2833
|
arguments: [params]
|
|
2792
2834
|
});
|
|
2793
2835
|
}
|
|
2794
2836
|
function wrapRun(run) {
|
|
2795
|
-
return (name, inputOrFn, maybeFn) =>
|
|
2837
|
+
return (name, inputOrFn, maybeFn) => _chunkBFGIH2ZJjs.genkitChannels.actionRun.tracePromise(() => run(name, inputOrFn, maybeFn), {
|
|
2796
2838
|
arguments: [name, inputOrFn, maybeFn]
|
|
2797
2839
|
});
|
|
2798
2840
|
}
|
|
@@ -2831,13 +2873,13 @@ function isGenkitAction(value) {
|
|
|
2831
2873
|
return typeof value === "function" && "__action" in value;
|
|
2832
2874
|
}
|
|
2833
2875
|
function traceActionRun(action, run) {
|
|
2834
|
-
return (input, options) =>
|
|
2876
|
+
return (input, options) => _chunkBFGIH2ZJjs.genkitChannels.actionRun.tracePromise(() => run(input, options), {
|
|
2835
2877
|
arguments: [input, options],
|
|
2836
2878
|
self: action
|
|
2837
2879
|
});
|
|
2838
2880
|
}
|
|
2839
2881
|
function traceActionStream(action, stream) {
|
|
2840
|
-
return (input, options) =>
|
|
2882
|
+
return (input, options) => _chunkBFGIH2ZJjs.genkitChannels.actionStream.traceSync(() => stream(input, options), {
|
|
2841
2883
|
arguments: [input, options],
|
|
2842
2884
|
self: action
|
|
2843
2885
|
});
|
|
@@ -2883,10 +2925,10 @@ function isHuggingFaceConstructorKey(value) {
|
|
|
2883
2925
|
return HUGGINGFACE_CONSTRUCTOR_KEY_SET.has(value);
|
|
2884
2926
|
}
|
|
2885
2927
|
function hasFunction2(value, methodName) {
|
|
2886
|
-
return
|
|
2928
|
+
return _chunkFY7DAKA5js.isObject.call(void 0, value) && methodName in value && typeof value[methodName] === "function";
|
|
2887
2929
|
}
|
|
2888
2930
|
function isSupportedHuggingFaceModule(value) {
|
|
2889
|
-
if (!
|
|
2931
|
+
if (!_chunkFY7DAKA5js.isObject.call(void 0, value)) {
|
|
2890
2932
|
return false;
|
|
2891
2933
|
}
|
|
2892
2934
|
return HUGGINGFACE_CONSTRUCTOR_KEYS.some(
|
|
@@ -2994,14 +3036,14 @@ function wrapChatCompletion2(original, endpointUrl) {
|
|
|
2994
3036
|
const context = {
|
|
2995
3037
|
arguments: [traceParams]
|
|
2996
3038
|
};
|
|
2997
|
-
return
|
|
3039
|
+
return _chunkBFGIH2ZJjs.huggingFaceChannels.chatCompletion.tracePromise(
|
|
2998
3040
|
() => original(params, options),
|
|
2999
3041
|
context
|
|
3000
3042
|
);
|
|
3001
3043
|
};
|
|
3002
3044
|
}
|
|
3003
3045
|
function wrapChatCompletionStream(original, endpointUrl) {
|
|
3004
|
-
return (params, options) =>
|
|
3046
|
+
return (params, options) => _chunkBFGIH2ZJjs.huggingFaceChannels.chatCompletionStream.traceSync(
|
|
3005
3047
|
() => original(params, options),
|
|
3006
3048
|
{
|
|
3007
3049
|
arguments: [withEndpointUrl(params, endpointUrl)]
|
|
@@ -3014,14 +3056,14 @@ function wrapTextGeneration(original, endpointUrl) {
|
|
|
3014
3056
|
const context = {
|
|
3015
3057
|
arguments: [traceParams]
|
|
3016
3058
|
};
|
|
3017
|
-
return
|
|
3059
|
+
return _chunkBFGIH2ZJjs.huggingFaceChannels.textGeneration.tracePromise(
|
|
3018
3060
|
() => original(params, options),
|
|
3019
3061
|
context
|
|
3020
3062
|
);
|
|
3021
3063
|
};
|
|
3022
3064
|
}
|
|
3023
3065
|
function wrapTextGenerationStream(original, endpointUrl) {
|
|
3024
|
-
return (params, options) =>
|
|
3066
|
+
return (params, options) => _chunkBFGIH2ZJjs.huggingFaceChannels.textGenerationStream.traceSync(
|
|
3025
3067
|
() => original(params, options),
|
|
3026
3068
|
{
|
|
3027
3069
|
arguments: [withEndpointUrl(params, endpointUrl)]
|
|
@@ -3034,7 +3076,7 @@ function wrapFeatureExtraction(original, endpointUrl) {
|
|
|
3034
3076
|
const context = {
|
|
3035
3077
|
arguments: [traceParams]
|
|
3036
3078
|
};
|
|
3037
|
-
return
|
|
3079
|
+
return _chunkBFGIH2ZJjs.huggingFaceChannels.featureExtraction.tracePromise(
|
|
3038
3080
|
() => original(params, options),
|
|
3039
3081
|
context
|
|
3040
3082
|
);
|
|
@@ -3081,7 +3123,7 @@ function wrapCallModel(callModelFn, defaultThis) {
|
|
|
3081
3123
|
const request = cloneCallModelRequest(argArray[0]);
|
|
3082
3124
|
const options = argArray[1];
|
|
3083
3125
|
const invocationTarget = thisArg === void 0 ? _nullishCoalesce(defaultThis, () => ( thisArg)) : thisArg;
|
|
3084
|
-
return
|
|
3126
|
+
return _chunkBFGIH2ZJjs.openRouterAgentChannels.callModel.traceSync(
|
|
3085
3127
|
() => Reflect.apply(target, invocationTarget, [request, options]),
|
|
3086
3128
|
{
|
|
3087
3129
|
arguments: [request]
|
|
@@ -3177,24 +3219,24 @@ function rerankProxy(rerank) {
|
|
|
3177
3219
|
});
|
|
3178
3220
|
}
|
|
3179
3221
|
function wrapChatSend(send) {
|
|
3180
|
-
return (request, options) =>
|
|
3222
|
+
return (request, options) => _chunkBFGIH2ZJjs.openRouterChannels.chatSend.tracePromise(() => send(request, options), {
|
|
3181
3223
|
arguments: [request]
|
|
3182
3224
|
});
|
|
3183
3225
|
}
|
|
3184
3226
|
function wrapEmbeddingsGenerate(generate) {
|
|
3185
|
-
return (request, options) =>
|
|
3227
|
+
return (request, options) => _chunkBFGIH2ZJjs.openRouterChannels.embeddingsGenerate.tracePromise(
|
|
3186
3228
|
() => generate(request, options),
|
|
3187
3229
|
{ arguments: [request] }
|
|
3188
3230
|
);
|
|
3189
3231
|
}
|
|
3190
3232
|
function wrapResponsesSend(send) {
|
|
3191
|
-
return (request, options) =>
|
|
3233
|
+
return (request, options) => _chunkBFGIH2ZJjs.openRouterChannels.betaResponsesSend.tracePromise(
|
|
3192
3234
|
() => send(request, options),
|
|
3193
3235
|
{ arguments: [request] }
|
|
3194
3236
|
);
|
|
3195
3237
|
}
|
|
3196
3238
|
function wrapRerank2(rerank) {
|
|
3197
|
-
return (request, options) =>
|
|
3239
|
+
return (request, options) => _chunkBFGIH2ZJjs.openRouterChannels.rerankRerank.tracePromise(
|
|
3198
3240
|
() => rerank(request, options),
|
|
3199
3241
|
{ arguments: [request] }
|
|
3200
3242
|
);
|
|
@@ -3202,7 +3244,7 @@ function wrapRerank2(rerank) {
|
|
|
3202
3244
|
function wrapCallModel2(callModel) {
|
|
3203
3245
|
return (request, options) => {
|
|
3204
3246
|
const tracedRequest = { ...request };
|
|
3205
|
-
return
|
|
3247
|
+
return _chunkBFGIH2ZJjs.openRouterChannels.callModel.traceSync(
|
|
3206
3248
|
() => callModel(tracedRequest, options),
|
|
3207
3249
|
{
|
|
3208
3250
|
arguments: [tracedRequest]
|
|
@@ -3335,7 +3377,7 @@ function classifiersProxy(classifiers) {
|
|
|
3335
3377
|
});
|
|
3336
3378
|
}
|
|
3337
3379
|
function wrapChatComplete(complete) {
|
|
3338
|
-
return (request, options) =>
|
|
3380
|
+
return (request, options) => _chunkBFGIH2ZJjs.mistralChannels.chatComplete.tracePromise(
|
|
3339
3381
|
() => complete(request, options),
|
|
3340
3382
|
{
|
|
3341
3383
|
arguments: [request]
|
|
@@ -3343,52 +3385,52 @@ function wrapChatComplete(complete) {
|
|
|
3343
3385
|
);
|
|
3344
3386
|
}
|
|
3345
3387
|
function wrapChatStream(stream) {
|
|
3346
|
-
return (request, options) =>
|
|
3388
|
+
return (request, options) => _chunkBFGIH2ZJjs.mistralChannels.chatStream.tracePromise(() => stream(request, options), {
|
|
3347
3389
|
arguments: [request]
|
|
3348
3390
|
});
|
|
3349
3391
|
}
|
|
3350
3392
|
function wrapEmbeddingsCreate(create) {
|
|
3351
|
-
return (request, options) =>
|
|
3393
|
+
return (request, options) => _chunkBFGIH2ZJjs.mistralChannels.embeddingsCreate.tracePromise(
|
|
3352
3394
|
() => create(request, options),
|
|
3353
3395
|
{ arguments: [request] }
|
|
3354
3396
|
);
|
|
3355
3397
|
}
|
|
3356
3398
|
function wrapClassifiersModerate(moderate) {
|
|
3357
|
-
return (request, options) =>
|
|
3399
|
+
return (request, options) => _chunkBFGIH2ZJjs.mistralChannels.classifiersModerate.tracePromise(
|
|
3358
3400
|
() => moderate(request, options),
|
|
3359
3401
|
{ arguments: [request] }
|
|
3360
3402
|
);
|
|
3361
3403
|
}
|
|
3362
3404
|
function wrapClassifiersModerateChat(moderateChat) {
|
|
3363
|
-
return (request, options) =>
|
|
3405
|
+
return (request, options) => _chunkBFGIH2ZJjs.mistralChannels.classifiersModerateChat.tracePromise(
|
|
3364
3406
|
() => moderateChat(request, options),
|
|
3365
3407
|
{ arguments: [request] }
|
|
3366
3408
|
);
|
|
3367
3409
|
}
|
|
3368
3410
|
function wrapClassifiersClassify(classify) {
|
|
3369
|
-
return (request, options) =>
|
|
3411
|
+
return (request, options) => _chunkBFGIH2ZJjs.mistralChannels.classifiersClassify.tracePromise(
|
|
3370
3412
|
() => classify(request, options),
|
|
3371
3413
|
{ arguments: [request] }
|
|
3372
3414
|
);
|
|
3373
3415
|
}
|
|
3374
3416
|
function wrapClassifiersClassifyChat(classifyChat) {
|
|
3375
|
-
return (request, options) =>
|
|
3417
|
+
return (request, options) => _chunkBFGIH2ZJjs.mistralChannels.classifiersClassifyChat.tracePromise(
|
|
3376
3418
|
() => classifyChat(request, options),
|
|
3377
3419
|
{ arguments: [request] }
|
|
3378
3420
|
);
|
|
3379
3421
|
}
|
|
3380
3422
|
function wrapFimComplete(complete) {
|
|
3381
|
-
return (request, options) =>
|
|
3423
|
+
return (request, options) => _chunkBFGIH2ZJjs.mistralChannels.fimComplete.tracePromise(() => complete(request, options), {
|
|
3382
3424
|
arguments: [request]
|
|
3383
3425
|
});
|
|
3384
3426
|
}
|
|
3385
3427
|
function wrapFimStream(stream) {
|
|
3386
|
-
return (request, options) =>
|
|
3428
|
+
return (request, options) => _chunkBFGIH2ZJjs.mistralChannels.fimStream.tracePromise(() => stream(request, options), {
|
|
3387
3429
|
arguments: [request]
|
|
3388
3430
|
});
|
|
3389
3431
|
}
|
|
3390
3432
|
function wrapAgentsComplete(complete) {
|
|
3391
|
-
return (request, options) =>
|
|
3433
|
+
return (request, options) => _chunkBFGIH2ZJjs.mistralChannels.agentsComplete.tracePromise(
|
|
3392
3434
|
() => complete(request, options),
|
|
3393
3435
|
{
|
|
3394
3436
|
arguments: [request]
|
|
@@ -3396,7 +3438,7 @@ function wrapAgentsComplete(complete) {
|
|
|
3396
3438
|
);
|
|
3397
3439
|
}
|
|
3398
3440
|
function wrapAgentsStream(stream) {
|
|
3399
|
-
return (request, options) =>
|
|
3441
|
+
return (request, options) => _chunkBFGIH2ZJjs.mistralChannels.agentsStream.tracePromise(() => stream(request, options), {
|
|
3400
3442
|
arguments: [request]
|
|
3401
3443
|
});
|
|
3402
3444
|
}
|
|
@@ -3449,22 +3491,22 @@ function cohereProxy(cohere) {
|
|
|
3449
3491
|
return proxy;
|
|
3450
3492
|
}
|
|
3451
3493
|
function wrapChat(chat) {
|
|
3452
|
-
return (request, options) =>
|
|
3494
|
+
return (request, options) => _chunkBFGIH2ZJjs.cohereChannels.chat.tracePromise(() => chat(request, options), {
|
|
3453
3495
|
arguments: [request]
|
|
3454
3496
|
});
|
|
3455
3497
|
}
|
|
3456
3498
|
function wrapChatStream2(chatStream) {
|
|
3457
|
-
return (request, options) =>
|
|
3499
|
+
return (request, options) => _chunkBFGIH2ZJjs.cohereChannels.chatStream.tracePromise(() => chatStream(request, options), {
|
|
3458
3500
|
arguments: [request]
|
|
3459
3501
|
});
|
|
3460
3502
|
}
|
|
3461
3503
|
function wrapEmbed3(embed) {
|
|
3462
|
-
return (request, options) =>
|
|
3504
|
+
return (request, options) => _chunkBFGIH2ZJjs.cohereChannels.embed.tracePromise(() => embed(request, options), {
|
|
3463
3505
|
arguments: [request]
|
|
3464
3506
|
});
|
|
3465
3507
|
}
|
|
3466
3508
|
function wrapRerank3(rerank) {
|
|
3467
|
-
return (request, options) =>
|
|
3509
|
+
return (request, options) => _chunkBFGIH2ZJjs.cohereChannels.rerank.tracePromise(() => rerank(request, options), {
|
|
3468
3510
|
arguments: [request]
|
|
3469
3511
|
});
|
|
3470
3512
|
}
|
|
@@ -3546,13 +3588,13 @@ function groqProxy(groq) {
|
|
|
3546
3588
|
return topLevelProxy;
|
|
3547
3589
|
}
|
|
3548
3590
|
function wrapChatCompletionsCreate(create) {
|
|
3549
|
-
return (request, options) =>
|
|
3591
|
+
return (request, options) => _chunkBFGIH2ZJjs.groqChannels.chatCompletionsCreate.tracePromise(
|
|
3550
3592
|
() => create(request, options),
|
|
3551
3593
|
{ arguments: [request] }
|
|
3552
3594
|
);
|
|
3553
3595
|
}
|
|
3554
3596
|
function wrapEmbeddingsCreate2(create) {
|
|
3555
|
-
return (request, options) =>
|
|
3597
|
+
return (request, options) => _chunkBFGIH2ZJjs.groqChannels.embeddingsCreate.tracePromise(() => create(request, options), {
|
|
3556
3598
|
arguments: [request]
|
|
3557
3599
|
});
|
|
3558
3600
|
}
|
|
@@ -3626,16 +3668,16 @@ function bedrockRuntimeProxy(client) {
|
|
|
3626
3668
|
}
|
|
3627
3669
|
function wrapSend(send) {
|
|
3628
3670
|
return (command, optionsOrCb, cb) => {
|
|
3629
|
-
if (
|
|
3671
|
+
if (_chunkFY7DAKA5js.getBedrockRuntimeOperation.call(void 0, command) === void 0 || typeof optionsOrCb === "function" || typeof cb === "function") {
|
|
3630
3672
|
return send(command, optionsOrCb, cb);
|
|
3631
3673
|
}
|
|
3632
|
-
return
|
|
3633
|
-
() =>
|
|
3674
|
+
return _chunkBFGIH2ZJjs.bedrockRuntimeChannels.clientSend.tracePromise(
|
|
3675
|
+
() => _chunkFY7DAKA5js.runWithAutoInstrumentationSuppressed.call(void 0,
|
|
3634
3676
|
() => send(command, optionsOrCb)
|
|
3635
3677
|
),
|
|
3636
3678
|
{
|
|
3637
3679
|
arguments: [command, optionsOrCb],
|
|
3638
|
-
span_info:
|
|
3680
|
+
span_info: _chunkFY7DAKA5js.buildBedrockRuntimeSpanInfo.call(void 0, command)
|
|
3639
3681
|
}
|
|
3640
3682
|
);
|
|
3641
3683
|
};
|
|
@@ -3684,13 +3726,13 @@ function copilotClientProxy(client) {
|
|
|
3684
3726
|
return proxy;
|
|
3685
3727
|
}
|
|
3686
3728
|
function wrappedCreateSession(client) {
|
|
3687
|
-
return (config) =>
|
|
3729
|
+
return (config) => _chunkBFGIH2ZJjs.gitHubCopilotChannels.createSession.tracePromise(
|
|
3688
3730
|
() => client.createSession(config),
|
|
3689
3731
|
{ arguments: [config] }
|
|
3690
3732
|
);
|
|
3691
3733
|
}
|
|
3692
3734
|
function wrappedResumeSession(client) {
|
|
3693
|
-
return (sessionId, config) =>
|
|
3735
|
+
return (sessionId, config) => _chunkBFGIH2ZJjs.gitHubCopilotChannels.resumeSession.tracePromise(
|
|
3694
3736
|
() => client.resumeSession(sessionId, config),
|
|
3695
3737
|
{ arguments: [sessionId, config] }
|
|
3696
3738
|
);
|
|
@@ -3704,7 +3746,7 @@ var VitestContextManager = class {
|
|
|
3704
3746
|
*/
|
|
3705
3747
|
|
|
3706
3748
|
constructor() {
|
|
3707
|
-
this.contextStorage =
|
|
3749
|
+
this.contextStorage = _chunkBFGIH2ZJjs.isomorph_default.newAsyncLocalStorage();
|
|
3708
3750
|
}
|
|
3709
3751
|
getCurrentContext() {
|
|
3710
3752
|
return this.contextStorage.getStore();
|
|
@@ -3745,7 +3787,7 @@ var FlushCoordinator = (_class = class {constructor() { _class.prototype.__init.
|
|
|
3745
3787
|
if (this.activeFlushes.has(experimentId)) {
|
|
3746
3788
|
return this.activeFlushes.get(experimentId);
|
|
3747
3789
|
}
|
|
3748
|
-
const flushPromise =
|
|
3790
|
+
const flushPromise = _chunkFY7DAKA5js.summarizeAndFlush.call(void 0, context.experiment, {
|
|
3749
3791
|
displaySummary: config.displaySummary
|
|
3750
3792
|
});
|
|
3751
3793
|
this.activeFlushes.set(experimentId, flushPromise);
|
|
@@ -3843,7 +3885,7 @@ async function runTracedEval(args) {
|
|
|
3843
3885
|
}
|
|
3844
3886
|
if (testError) {
|
|
3845
3887
|
span.log({ scores: { pass: 0 } });
|
|
3846
|
-
|
|
3888
|
+
_chunkFY7DAKA5js.logError.call(void 0, span, testError);
|
|
3847
3889
|
throw testError;
|
|
3848
3890
|
}
|
|
3849
3891
|
span.log({
|
|
@@ -4017,10 +4059,10 @@ function wrapDescribe(originalDescribe, config, afterAll) {
|
|
|
4017
4059
|
const getOrCreateContext = () => {
|
|
4018
4060
|
if (!context) {
|
|
4019
4061
|
const experimentName = `${suiteName}-${(/* @__PURE__ */ new Date()).toISOString()}`;
|
|
4020
|
-
const experiment = config.projectId ?
|
|
4062
|
+
const experiment = config.projectId ? _chunkFY7DAKA5js.initExperiment.call(void 0, {
|
|
4021
4063
|
projectId: config.projectId,
|
|
4022
4064
|
experiment: experimentName
|
|
4023
|
-
}) :
|
|
4065
|
+
}) : _chunkFY7DAKA5js.initExperiment.call(void 0, config.projectName || suiteName, {
|
|
4024
4066
|
experiment: experimentName
|
|
4025
4067
|
});
|
|
4026
4068
|
context = contextManager.createChildContext(void 0, experiment);
|
|
@@ -4128,7 +4170,7 @@ function wrapExpect(originalExpect) {
|
|
|
4128
4170
|
return originalExpect(value);
|
|
4129
4171
|
}
|
|
4130
4172
|
const assertion = originalExpect(value, message);
|
|
4131
|
-
const span =
|
|
4173
|
+
const span = _chunkFY7DAKA5js.currentSpan.call(void 0, );
|
|
4132
4174
|
if (!span) {
|
|
4133
4175
|
return assertion;
|
|
4134
4176
|
}
|
|
@@ -4140,16 +4182,16 @@ function wrapExpect(originalExpect) {
|
|
|
4140
4182
|
|
|
4141
4183
|
// src/wrappers/shared/logging.ts
|
|
4142
4184
|
function logOutputs(outputs) {
|
|
4143
|
-
|
|
4185
|
+
_chunkFY7DAKA5js.currentSpan.call(void 0, ).log({ output: outputs });
|
|
4144
4186
|
}
|
|
4145
4187
|
function logFeedback(feedback) {
|
|
4146
|
-
|
|
4188
|
+
_chunkFY7DAKA5js.currentSpan.call(void 0, ).log({
|
|
4147
4189
|
scores: { [feedback.name]: feedback.score },
|
|
4148
4190
|
metadata: feedback.metadata
|
|
4149
4191
|
});
|
|
4150
4192
|
}
|
|
4151
4193
|
function getCurrentSpan() {
|
|
4152
|
-
return
|
|
4194
|
+
return _chunkFY7DAKA5js.currentSpan.call(void 0, );
|
|
4153
4195
|
}
|
|
4154
4196
|
|
|
4155
4197
|
// src/wrappers/vitest/index.ts
|
|
@@ -4197,7 +4239,7 @@ function wrapVitest(vitestMethods, config = {}) {
|
|
|
4197
4239
|
);
|
|
4198
4240
|
return;
|
|
4199
4241
|
}
|
|
4200
|
-
await
|
|
4242
|
+
await _chunkFY7DAKA5js.summarizeAndFlush.call(void 0, ctx.experiment, {
|
|
4201
4243
|
displaySummary: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _88 => _88.displaySummary]), () => ( config.displaySummary))
|
|
4202
4244
|
});
|
|
4203
4245
|
}
|
|
@@ -4212,7 +4254,7 @@ function initNodeTestSuite(config) {
|
|
|
4212
4254
|
return experiment;
|
|
4213
4255
|
}
|
|
4214
4256
|
const experimentName = config.experimentName || `${config.projectName}-${(/* @__PURE__ */ new Date()).toISOString()}`;
|
|
4215
|
-
experiment =
|
|
4257
|
+
experiment = _chunkFY7DAKA5js.initExperiment.call(void 0, config.projectName, {
|
|
4216
4258
|
experiment: experimentName
|
|
4217
4259
|
});
|
|
4218
4260
|
return experiment;
|
|
@@ -4261,7 +4303,7 @@ function initNodeTestSuite(config) {
|
|
|
4261
4303
|
if (!experiment) {
|
|
4262
4304
|
return;
|
|
4263
4305
|
}
|
|
4264
|
-
await
|
|
4306
|
+
await _chunkFY7DAKA5js.summarizeAndFlush.call(void 0, experiment, {
|
|
4265
4307
|
displaySummary: config.displaySummary
|
|
4266
4308
|
});
|
|
4267
4309
|
experiment = void 0;
|
|
@@ -4278,7 +4320,7 @@ function initNodeTestSuite(config) {
|
|
|
4278
4320
|
|
|
4279
4321
|
// src/graph-framework.ts
|
|
4280
4322
|
var graph_framework_exports = {};
|
|
4281
|
-
|
|
4323
|
+
_chunkBFGIH2ZJjs.__export.call(void 0, graph_framework_exports, {
|
|
4282
4324
|
AggregatorNode: () => AggregatorNode,
|
|
4283
4325
|
GateNode: () => GateNode,
|
|
4284
4326
|
GraphBuilder: () => GraphBuilder,
|
|
@@ -4352,7 +4394,7 @@ var GraphBuilder = (_class2 = class {
|
|
|
4352
4394
|
};
|
|
4353
4395
|
}
|
|
4354
4396
|
resolveNode(node) {
|
|
4355
|
-
if (node instanceof
|
|
4397
|
+
if (node instanceof _chunkFY7DAKA5js.Prompt) {
|
|
4356
4398
|
const cached = this.nodeLikeNodes.get(node);
|
|
4357
4399
|
if (cached) {
|
|
4358
4400
|
return [cached, []];
|
|
@@ -4402,7 +4444,7 @@ var GraphBuilder = (_class2 = class {
|
|
|
4402
4444
|
// }
|
|
4403
4445
|
// Helper to generate node IDs
|
|
4404
4446
|
generateId(name) {
|
|
4405
|
-
const uuid =
|
|
4447
|
+
const uuid = _chunkFY7DAKA5js.newId.call(void 0, );
|
|
4406
4448
|
if (name) {
|
|
4407
4449
|
return `${name}-${uuid.slice(0, 8)}`;
|
|
4408
4450
|
} else {
|
|
@@ -5596,16 +5638,22 @@ function waterfall(tasks, callback) {
|
|
|
5596
5638
|
var waterfall$1 = awaitify(waterfall);
|
|
5597
5639
|
|
|
5598
5640
|
// src/trace.ts
|
|
5599
|
-
var SpanFetcher = class _SpanFetcher extends
|
|
5600
|
-
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) {
|
|
5601
5643
|
const filterExpr = _SpanFetcher.buildFilter(
|
|
5602
5644
|
rootSpanId,
|
|
5603
5645
|
spanTypeFilter,
|
|
5604
5646
|
includeScorers
|
|
5605
5647
|
);
|
|
5606
|
-
super(
|
|
5607
|
-
|
|
5608
|
-
|
|
5648
|
+
super(
|
|
5649
|
+
objectType,
|
|
5650
|
+
void 0,
|
|
5651
|
+
void 0,
|
|
5652
|
+
{
|
|
5653
|
+
filter: filterExpr
|
|
5654
|
+
},
|
|
5655
|
+
brainstoreRealtime
|
|
5656
|
+
);
|
|
5609
5657
|
this._objectId = _objectId;
|
|
5610
5658
|
this.rootSpanId = rootSpanId;
|
|
5611
5659
|
this._state = _state;
|
|
@@ -5659,7 +5707,7 @@ var CachedSpanFetcher = (_class4 = class {
|
|
|
5659
5707
|
__init7() {this.spanCache = /* @__PURE__ */ new Map()}
|
|
5660
5708
|
__init8() {this.allFetched = false}
|
|
5661
5709
|
|
|
5662
|
-
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);
|
|
5663
5711
|
if (typeof objectTypeOrFetchFn === "function") {
|
|
5664
5712
|
this.fetchFn = (spanType) => objectTypeOrFetchFn(spanType);
|
|
5665
5713
|
} else {
|
|
@@ -5672,7 +5720,8 @@ var CachedSpanFetcher = (_class4 = class {
|
|
|
5672
5720
|
rootSpanId,
|
|
5673
5721
|
state,
|
|
5674
5722
|
spanType,
|
|
5675
|
-
includeScorers
|
|
5723
|
+
includeScorers,
|
|
5724
|
+
brainstoreRealtime
|
|
5676
5725
|
);
|
|
5677
5726
|
const rows = await fetcher.fetchedData();
|
|
5678
5727
|
return rows.map((row) => ({
|
|
@@ -5902,20 +5951,20 @@ var promptContentsSchema = _v3.z.union([
|
|
|
5902
5951
|
prompt: _v3.z.string()
|
|
5903
5952
|
}),
|
|
5904
5953
|
_v3.z.object({
|
|
5905
|
-
messages: _v3.z.array(
|
|
5954
|
+
messages: _v3.z.array(_chunkFY7DAKA5js.ChatCompletionMessageParam)
|
|
5906
5955
|
})
|
|
5907
5956
|
]);
|
|
5908
5957
|
var promptDefinitionSchema = promptContentsSchema.and(
|
|
5909
5958
|
_v3.z.object({
|
|
5910
5959
|
model: _v3.z.string(),
|
|
5911
|
-
params:
|
|
5960
|
+
params: _chunkFY7DAKA5js.ModelParams.optional(),
|
|
5912
5961
|
templateFormat: _v3.z.enum(["mustache", "nunjucks", "none"]).optional(),
|
|
5913
5962
|
environments: _v3.z.array(_v3.z.string()).optional()
|
|
5914
5963
|
})
|
|
5915
5964
|
);
|
|
5916
5965
|
var promptDefinitionWithToolsSchema = promptDefinitionSchema.and(
|
|
5917
5966
|
_v3.z.object({
|
|
5918
|
-
tools: _v3.z.array(
|
|
5967
|
+
tools: _v3.z.array(_chunkFY7DAKA5js.ToolFunctionDefinition).optional()
|
|
5919
5968
|
})
|
|
5920
5969
|
);
|
|
5921
5970
|
function promptDefinitionToPromptData(promptDefinition, rawTools) {
|
|
@@ -5963,7 +6012,7 @@ async function validateParameters(parameters, parameterSchema) {
|
|
|
5963
6012
|
if (resolvedSchema === void 0 || resolvedSchema === null) {
|
|
5964
6013
|
return parameters;
|
|
5965
6014
|
}
|
|
5966
|
-
if (
|
|
6015
|
+
if (_chunkFY7DAKA5js.RemoteEvalParameters.isParameters(resolvedSchema)) {
|
|
5967
6016
|
const mergedParameters = parameters && Object.keys(parameters).length > 0 ? {
|
|
5968
6017
|
...resolvedSchema.data,
|
|
5969
6018
|
...parameters
|
|
@@ -5985,14 +6034,14 @@ function validateParametersWithZod(parameters, parameterSchema) {
|
|
|
5985
6034
|
const value = parameters[name];
|
|
5986
6035
|
try {
|
|
5987
6036
|
if ("type" in schema && schema.type === "prompt") {
|
|
5988
|
-
const promptData = value ?
|
|
6037
|
+
const promptData = value ? _chunkFY7DAKA5js.PromptData.parse(value) : schema.default ? promptDefinitionToPromptData(
|
|
5989
6038
|
schema.default,
|
|
5990
6039
|
schema.default.tools
|
|
5991
6040
|
) : void 0;
|
|
5992
6041
|
if (!promptData) {
|
|
5993
6042
|
throw new Error(`Parameter '${name}' is required`);
|
|
5994
6043
|
}
|
|
5995
|
-
return [name,
|
|
6044
|
+
return [name, _chunkFY7DAKA5js.Prompt.fromPromptData(name, promptData)];
|
|
5996
6045
|
} else if ("type" in schema && schema.type === "model") {
|
|
5997
6046
|
const model = _nullishCoalesce(value, () => ( schema.default));
|
|
5998
6047
|
if (model === void 0) {
|
|
@@ -6043,7 +6092,7 @@ function rehydrateRemoteParameters(parameters, schema) {
|
|
|
6043
6092
|
if (Reflect.get(propertySchema, "x-bt-type") === "prompt") {
|
|
6044
6093
|
return [
|
|
6045
6094
|
name,
|
|
6046
|
-
|
|
6095
|
+
_chunkFY7DAKA5js.Prompt.fromPromptData(name, _chunkFY7DAKA5js.PromptData.parse(value))
|
|
6047
6096
|
];
|
|
6048
6097
|
}
|
|
6049
6098
|
return [name, value];
|
|
@@ -6091,7 +6140,7 @@ function makeEvalName(projectName, experimentName) {
|
|
|
6091
6140
|
return out;
|
|
6092
6141
|
}
|
|
6093
6142
|
function initExperiment2(state, options = {}) {
|
|
6094
|
-
return
|
|
6143
|
+
return _chunkFY7DAKA5js.init.call(void 0, {
|
|
6095
6144
|
state,
|
|
6096
6145
|
...options,
|
|
6097
6146
|
setCurrent: false
|
|
@@ -6102,7 +6151,7 @@ async function getExperimentParametersRef(parameters) {
|
|
|
6102
6151
|
return void 0;
|
|
6103
6152
|
}
|
|
6104
6153
|
const resolvedParameters = parameters instanceof Promise ? await parameters : parameters;
|
|
6105
|
-
if (!
|
|
6154
|
+
if (!_chunkFY7DAKA5js.RemoteEvalParameters.isParameters(resolvedParameters)) {
|
|
6106
6155
|
return void 0;
|
|
6107
6156
|
}
|
|
6108
6157
|
if (resolvedParameters.id === void 0) {
|
|
@@ -6138,10 +6187,10 @@ globalThis._evals = {
|
|
|
6138
6187
|
reporters: {}
|
|
6139
6188
|
};
|
|
6140
6189
|
function _initializeSpanContext() {
|
|
6141
|
-
globalThis._spanContext = { currentSpan:
|
|
6190
|
+
globalThis._spanContext = { currentSpan: _chunkFY7DAKA5js.currentSpan, withCurrent: _chunkFY7DAKA5js.withCurrent, startSpan: _chunkFY7DAKA5js.startSpan, NOOP_SPAN: _chunkFY7DAKA5js.NOOP_SPAN };
|
|
6142
6191
|
}
|
|
6143
6192
|
async function Eval(name, evaluator, reporterOrOpts) {
|
|
6144
|
-
const options =
|
|
6193
|
+
const options = _chunkFY7DAKA5js.isEmpty.call(void 0, reporterOrOpts) ? {} : typeof reporterOrOpts === "string" ? { reporter: reporterOrOpts } : "name" in reporterOrOpts ? { reporter: reporterOrOpts } : reporterOrOpts;
|
|
6145
6194
|
let evalName = makeEvalName(name, evaluator.experimentName);
|
|
6146
6195
|
if (globalThis._evals.evaluators[evalName]) {
|
|
6147
6196
|
evalName = `${evalName}_${Object.keys(_evals).length}`;
|
|
@@ -6192,7 +6241,7 @@ async function Eval(name, evaluator, reporterOrOpts) {
|
|
|
6192
6241
|
baseExperimentId: evaluator.baseExperimentId,
|
|
6193
6242
|
gitMetadataSettings: evaluator.gitMetadataSettings,
|
|
6194
6243
|
repoInfo: evaluator.repoInfo,
|
|
6195
|
-
dataset:
|
|
6244
|
+
dataset: _chunkFY7DAKA5js.Dataset.isDataset(data) ? data : void 0,
|
|
6196
6245
|
parameters
|
|
6197
6246
|
});
|
|
6198
6247
|
if (experiment && typeof process !== "undefined" && globalThis.BRAINTRUST_CONTEXT_MANAGER !== void 0) {
|
|
@@ -6212,7 +6261,7 @@ async function Eval(name, evaluator, reporterOrOpts) {
|
|
|
6212
6261
|
const enableCache = _nullishCoalesce(options.enableCache, () => ( true));
|
|
6213
6262
|
let ret;
|
|
6214
6263
|
if (options.parent) {
|
|
6215
|
-
ret = await
|
|
6264
|
+
ret = await _chunkFY7DAKA5js.withParent.call(void 0,
|
|
6216
6265
|
options.parent,
|
|
6217
6266
|
() => runEvaluator(
|
|
6218
6267
|
null,
|
|
@@ -6248,7 +6297,7 @@ async function Eval(name, evaluator, reporterOrOpts) {
|
|
|
6248
6297
|
if (experiment) {
|
|
6249
6298
|
await experiment.flush().catch(console.error);
|
|
6250
6299
|
} else if (options.parent) {
|
|
6251
|
-
await
|
|
6300
|
+
await _chunkFY7DAKA5js.flush.call(void 0, { state: evaluator.state }).catch(console.error);
|
|
6252
6301
|
}
|
|
6253
6302
|
}
|
|
6254
6303
|
} finally {
|
|
@@ -6294,13 +6343,13 @@ function classifierName(classifier, classifier_idx) {
|
|
|
6294
6343
|
}
|
|
6295
6344
|
function buildSpanMetadata(results) {
|
|
6296
6345
|
return results.length === 1 ? results[0].metadata : results.reduce(
|
|
6297
|
-
(prev, s) =>
|
|
6346
|
+
(prev, s) => _chunkFY7DAKA5js.mergeDicts.call(void 0, prev, { [s.name]: s.metadata }),
|
|
6298
6347
|
{}
|
|
6299
6348
|
);
|
|
6300
6349
|
}
|
|
6301
6350
|
function buildSpanScores(results) {
|
|
6302
6351
|
const scoresRecord = results.reduce(
|
|
6303
|
-
(prev, s) =>
|
|
6352
|
+
(prev, s) => _chunkFY7DAKA5js.mergeDicts.call(void 0, prev, { [s.name]: s.score }),
|
|
6304
6353
|
{}
|
|
6305
6354
|
);
|
|
6306
6355
|
return { resultMetadata: buildSpanMetadata(results), scoresRecord };
|
|
@@ -6330,7 +6379,7 @@ function collectScoringResults(runResults, names, onResult) {
|
|
|
6330
6379
|
return failing;
|
|
6331
6380
|
}
|
|
6332
6381
|
function validateClassificationResult(value, scorerName2) {
|
|
6333
|
-
if (!(typeof value === "object" && value !== null && !
|
|
6382
|
+
if (!(typeof value === "object" && value !== null && !_chunkFY7DAKA5js.isEmpty.call(void 0, value))) {
|
|
6334
6383
|
throw new Error(
|
|
6335
6384
|
`When returning structured classifier results, each classification must be a non-empty object. Got: ${JSON.stringify(value)}`
|
|
6336
6385
|
);
|
|
@@ -6359,7 +6408,7 @@ function logScoringFailures(kind, failures, metadata, rootSpan, state) {
|
|
|
6359
6408
|
);
|
|
6360
6409
|
metadata[`${kind}_errors`] = errorMap;
|
|
6361
6410
|
rootSpan.log({ metadata: { [`${kind}_errors`]: errorMap } });
|
|
6362
|
-
|
|
6411
|
+
_chunkFY7DAKA5js.debugLogger.forState(state).warn(
|
|
6363
6412
|
`Found exceptions for the following ${kind}s: ${Object.keys(errorMap).join(", ")}`,
|
|
6364
6413
|
failures.map((f) => f.error)
|
|
6365
6414
|
);
|
|
@@ -6393,7 +6442,7 @@ var defaultErrorScoreHandler = ({
|
|
|
6393
6442
|
};
|
|
6394
6443
|
async function runEvaluatorInternal(experiment, evaluator, progressReporter, filters, stream, parameters, collectResults, enableCache) {
|
|
6395
6444
|
if (enableCache) {
|
|
6396
|
-
_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()]);
|
|
6397
6446
|
}
|
|
6398
6447
|
try {
|
|
6399
6448
|
if (typeof evaluator.data === "string") {
|
|
@@ -6414,7 +6463,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6414
6463
|
);
|
|
6415
6464
|
}
|
|
6416
6465
|
let name = dataResult.name;
|
|
6417
|
-
if (
|
|
6466
|
+
if (_chunkFY7DAKA5js.isEmpty.call(void 0, name)) {
|
|
6418
6467
|
const baseExperiment = await experiment.fetchBaseExperiment();
|
|
6419
6468
|
if (!baseExperiment) {
|
|
6420
6469
|
throw new Error("BaseExperiment() failed to fetch base experiment");
|
|
@@ -6464,7 +6513,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6464
6513
|
if (cancelled) {
|
|
6465
6514
|
return;
|
|
6466
6515
|
}
|
|
6467
|
-
const eventDataset = experiment ? experiment.dataset :
|
|
6516
|
+
const eventDataset = experiment ? experiment.dataset : _chunkFY7DAKA5js.Dataset.isDataset(evaluator.data) ? evaluator.data : void 0;
|
|
6468
6517
|
const inlineDatasetOrigin = eventDataset && datum.id && datum._xact_id ? {
|
|
6469
6518
|
object_type: "dataset",
|
|
6470
6519
|
object_id: await eventDataset.id,
|
|
@@ -6472,7 +6521,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6472
6521
|
created: datum.created,
|
|
6473
6522
|
_xact_id: datum._xact_id
|
|
6474
6523
|
} : void 0;
|
|
6475
|
-
const parsedDatumOrigin =
|
|
6524
|
+
const parsedDatumOrigin = _chunkFY7DAKA5js.ObjectReference.safeParse(datum.origin);
|
|
6476
6525
|
const origin = _nullishCoalesce(inlineDatasetOrigin, () => ( (_optionalChain([parsedDatumOrigin, 'optionalAccess', _105 => _105.success]) ? parsedDatumOrigin.data : void 0)));
|
|
6477
6526
|
const baseEvent = {
|
|
6478
6527
|
name: "eval",
|
|
@@ -6488,23 +6537,23 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6488
6537
|
}
|
|
6489
6538
|
};
|
|
6490
6539
|
const callback = async (rootSpan) => {
|
|
6491
|
-
const state = _nullishCoalesce(evaluator.state, () => (
|
|
6540
|
+
const state = _nullishCoalesce(evaluator.state, () => ( _chunkFY7DAKA5js._internalGetGlobalState.call(void 0, )));
|
|
6492
6541
|
const ensureSpansFlushed = async () => {
|
|
6493
6542
|
if (experiment) {
|
|
6494
|
-
await
|
|
6543
|
+
await _chunkFY7DAKA5js.flush.call(void 0, { state: experiment.loggingState });
|
|
6495
6544
|
} else if (state) {
|
|
6496
|
-
await
|
|
6545
|
+
await _chunkFY7DAKA5js.flush.call(void 0, { state });
|
|
6497
6546
|
} else {
|
|
6498
|
-
await
|
|
6547
|
+
await _chunkFY7DAKA5js.flush.call(void 0, );
|
|
6499
6548
|
}
|
|
6500
6549
|
if (state) {
|
|
6501
6550
|
await state.flushOtel();
|
|
6502
6551
|
}
|
|
6503
6552
|
};
|
|
6504
6553
|
const parentStr = state.currentParent.getStore();
|
|
6505
|
-
const parentComponents = parentStr ?
|
|
6554
|
+
const parentComponents = typeof parentStr === "string" ? _chunkFY7DAKA5js.SpanComponentsV4.fromStr(parentStr) : null;
|
|
6506
6555
|
const trace = state ? new LocalTrace({
|
|
6507
|
-
objectType: parentComponents ?
|
|
6556
|
+
objectType: parentComponents ? _chunkFY7DAKA5js.spanObjectTypeV3ToTypedString.call(void 0,
|
|
6508
6557
|
parentComponents.data.object_type
|
|
6509
6558
|
) : "experiment",
|
|
6510
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 () => ( "")) : ""))),
|
|
@@ -6579,7 +6628,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6579
6628
|
trace
|
|
6580
6629
|
};
|
|
6581
6630
|
const { trace: _trace, ...scoringArgsForLogging } = scoringArgs;
|
|
6582
|
-
const propagatedEvent =
|
|
6631
|
+
const propagatedEvent = _chunkFY7DAKA5js.makeScorerPropagatedEvent.call(void 0,
|
|
6583
6632
|
await rootSpan.export()
|
|
6584
6633
|
);
|
|
6585
6634
|
const getOtherFields = (s) => {
|
|
@@ -6602,14 +6651,14 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6602
6651
|
if (scoreValue === null) return null;
|
|
6603
6652
|
if (Array.isArray(scoreValue)) {
|
|
6604
6653
|
for (const s of scoreValue) {
|
|
6605
|
-
if (!(typeof s === "object" && !
|
|
6654
|
+
if (!(typeof s === "object" && !_chunkFY7DAKA5js.isEmpty.call(void 0, s))) {
|
|
6606
6655
|
throw new Error(
|
|
6607
6656
|
`When returning an array of scores, each score must be a non-empty object. Got: ${JSON.stringify(s)}`
|
|
6608
6657
|
);
|
|
6609
6658
|
}
|
|
6610
6659
|
}
|
|
6611
6660
|
}
|
|
6612
|
-
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] : [
|
|
6613
6662
|
{
|
|
6614
6663
|
name: scorerNames[score_idx],
|
|
6615
6664
|
score: scoreValue
|
|
@@ -6617,7 +6666,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6617
6666
|
];
|
|
6618
6667
|
const { resultMetadata, scoresRecord } = buildSpanScores(results);
|
|
6619
6668
|
const resultOutput = results.length === 1 ? getOtherFields(results[0]) : results.reduce(
|
|
6620
|
-
(prev, s) =>
|
|
6669
|
+
(prev, s) => _chunkFY7DAKA5js.mergeDicts.call(void 0, prev, {
|
|
6621
6670
|
[s.name]: getOtherFields(s)
|
|
6622
6671
|
}),
|
|
6623
6672
|
{}
|
|
@@ -6652,7 +6701,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6652
6701
|
)
|
|
6653
6702
|
);
|
|
6654
6703
|
const resultOutput = rawResults.length === 1 ? toClassificationItem(rawResults[0]) : rawResults.reduce(
|
|
6655
|
-
(prev, r) =>
|
|
6704
|
+
(prev, r) => _chunkFY7DAKA5js.mergeDicts.call(void 0, prev, {
|
|
6656
6705
|
[r.name]: toClassificationItem(r)
|
|
6657
6706
|
}),
|
|
6658
6707
|
{}
|
|
@@ -6704,7 +6753,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6704
6753
|
evaluator.state
|
|
6705
6754
|
);
|
|
6706
6755
|
} catch (e) {
|
|
6707
|
-
|
|
6756
|
+
_chunkFY7DAKA5js.logError.call(void 0, rootSpan, e);
|
|
6708
6757
|
error = e;
|
|
6709
6758
|
} finally {
|
|
6710
6759
|
progressReporter.increment(evaluator.evalName);
|
|
@@ -6738,7 +6787,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6738
6787
|
}
|
|
6739
6788
|
};
|
|
6740
6789
|
if (!experiment) {
|
|
6741
|
-
return await
|
|
6790
|
+
return await _chunkFY7DAKA5js.traced.call(void 0, callback, {
|
|
6742
6791
|
...baseEvent,
|
|
6743
6792
|
state: evaluator.state
|
|
6744
6793
|
});
|
|
@@ -6780,7 +6829,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6780
6829
|
const cancel = async () => {
|
|
6781
6830
|
await new Promise((_, reject2) => {
|
|
6782
6831
|
if (cancelled) {
|
|
6783
|
-
reject2(new (0,
|
|
6832
|
+
reject2(new (0, _chunkFY7DAKA5js.InternalAbortError)("Evaluator already cancelled"));
|
|
6784
6833
|
return;
|
|
6785
6834
|
}
|
|
6786
6835
|
let timeoutId;
|
|
@@ -6801,12 +6850,12 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6801
6850
|
};
|
|
6802
6851
|
if (evaluator.timeout) {
|
|
6803
6852
|
timeoutId = setTimeout(() => {
|
|
6804
|
-
rejectOnce(new (0,
|
|
6853
|
+
rejectOnce(new (0, _chunkFY7DAKA5js.InternalAbortError)("Evaluator timed out"));
|
|
6805
6854
|
}, evaluator.timeout);
|
|
6806
6855
|
}
|
|
6807
6856
|
if (evaluator.signal) {
|
|
6808
6857
|
abortHandler = () => {
|
|
6809
|
-
rejectOnce(new (0,
|
|
6858
|
+
rejectOnce(new (0, _chunkFY7DAKA5js.InternalAbortError)("Evaluator aborted"));
|
|
6810
6859
|
};
|
|
6811
6860
|
evaluator.signal.addEventListener("abort", abortHandler);
|
|
6812
6861
|
}
|
|
@@ -6829,9 +6878,9 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6829
6878
|
}
|
|
6830
6879
|
} catch (e) {
|
|
6831
6880
|
q.kill();
|
|
6832
|
-
if (e instanceof
|
|
6833
|
-
if (
|
|
6834
|
-
|
|
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);
|
|
6835
6884
|
}
|
|
6836
6885
|
}
|
|
6837
6886
|
throw e;
|
|
@@ -6855,7 +6904,7 @@ async function runEvaluatorInternal(experiment, evaluator, progressReporter, fil
|
|
|
6855
6904
|
);
|
|
6856
6905
|
} finally {
|
|
6857
6906
|
if (enableCache) {
|
|
6858
|
-
const spanCache = _optionalChain([(_nullishCoalesce(evaluator.state, () => (
|
|
6907
|
+
const spanCache = _optionalChain([(_nullishCoalesce(evaluator.state, () => ( _chunkFY7DAKA5js._internalGetGlobalState.call(void 0, )))), 'optionalAccess', _115 => _115.spanCache]);
|
|
6859
6908
|
_optionalChain([spanCache, 'optionalAccess', _116 => _116.dispose, 'call', _117 => _117()]);
|
|
6860
6909
|
_optionalChain([spanCache, 'optionalAccess', _118 => _118.stop, 'call', _119 => _119()]);
|
|
6861
6910
|
}
|
|
@@ -6950,25 +6999,25 @@ var defaultReporter = {
|
|
|
6950
6999
|
reportFailures(evaluator, failingResults, { verbose, jsonl });
|
|
6951
7000
|
}
|
|
6952
7001
|
if (jsonl) {
|
|
6953
|
-
|
|
7002
|
+
_chunkBFGIH2ZJjs.isomorph_default.writeln(JSON.stringify(summary));
|
|
6954
7003
|
} else {
|
|
6955
|
-
|
|
6956
|
-
|
|
7004
|
+
_chunkBFGIH2ZJjs.isomorph_default.writeln("Experiment summary");
|
|
7005
|
+
_chunkBFGIH2ZJjs.isomorph_default.writeln("==================");
|
|
6957
7006
|
if (summary.comparisonExperimentName) {
|
|
6958
|
-
|
|
7007
|
+
_chunkBFGIH2ZJjs.isomorph_default.writeln(
|
|
6959
7008
|
`${summary.comparisonExperimentName} (baseline) <- ${summary.experimentName} (comparison)`
|
|
6960
7009
|
);
|
|
6961
|
-
|
|
7010
|
+
_chunkBFGIH2ZJjs.isomorph_default.writeln("");
|
|
6962
7011
|
}
|
|
6963
7012
|
const hasScores = Object.keys(summary.scores).length > 0;
|
|
6964
7013
|
const hasMetrics = Object.keys(_nullishCoalesce(summary.metrics, () => ( {}))).length > 0;
|
|
6965
7014
|
const hasComparison = !!summary.comparisonExperimentName;
|
|
6966
7015
|
if (hasScores || hasMetrics) {
|
|
6967
7016
|
if (hasComparison) {
|
|
6968
|
-
|
|
7017
|
+
_chunkBFGIH2ZJjs.isomorph_default.writeln(
|
|
6969
7018
|
"Name Value Change Improvements Regressions"
|
|
6970
7019
|
);
|
|
6971
|
-
|
|
7020
|
+
_chunkBFGIH2ZJjs.isomorph_default.writeln(
|
|
6972
7021
|
"----------------------------------------------------------------"
|
|
6973
7022
|
);
|
|
6974
7023
|
}
|
|
@@ -6977,18 +7026,18 @@ var defaultReporter = {
|
|
|
6977
7026
|
const scoreValue = `${scorePercent}%`;
|
|
6978
7027
|
if (hasComparison) {
|
|
6979
7028
|
let diffString = "-";
|
|
6980
|
-
if (!
|
|
7029
|
+
if (!_chunkFY7DAKA5js.isEmpty.call(void 0, score.diff)) {
|
|
6981
7030
|
const diffPercent = (score.diff * 100).toFixed(2);
|
|
6982
7031
|
const diffSign = score.diff > 0 ? "+" : "";
|
|
6983
7032
|
diffString = `${diffSign}${diffPercent}%`;
|
|
6984
7033
|
}
|
|
6985
7034
|
const improvements = score.improvements > 0 ? score.improvements.toString() : "-";
|
|
6986
7035
|
const regressions = score.regressions > 0 ? score.regressions.toString() : "-";
|
|
6987
|
-
|
|
7036
|
+
_chunkBFGIH2ZJjs.isomorph_default.writeln(
|
|
6988
7037
|
`${score.name.padEnd(18)} ${scoreValue.padStart(10)} ${diffString.padStart(10)} ${improvements.padStart(12)} ${regressions.padStart(11)}`
|
|
6989
7038
|
);
|
|
6990
7039
|
} else {
|
|
6991
|
-
|
|
7040
|
+
_chunkBFGIH2ZJjs.isomorph_default.writeln(`${score.name.padEnd(20)} ${scoreValue.padStart(15)}`);
|
|
6992
7041
|
}
|
|
6993
7042
|
}
|
|
6994
7043
|
for (const metric of Object.values(_nullishCoalesce(summary.metrics, () => ( {})))) {
|
|
@@ -6997,30 +7046,30 @@ var defaultReporter = {
|
|
|
6997
7046
|
const metricValue = metric.unit === "$" ? `${metric.unit}${formattedValue}` : `${formattedValue}${metric.unit}`;
|
|
6998
7047
|
if (hasComparison) {
|
|
6999
7048
|
let diffString = "-";
|
|
7000
|
-
if (!
|
|
7049
|
+
if (!_chunkFY7DAKA5js.isEmpty.call(void 0, metric.diff)) {
|
|
7001
7050
|
const diffPercent = (metric.diff * 100).toFixed(2);
|
|
7002
7051
|
const diffSign = metric.diff > 0 ? "+" : "";
|
|
7003
7052
|
diffString = `${diffSign}${diffPercent}%`;
|
|
7004
7053
|
}
|
|
7005
7054
|
const improvements = metric.improvements > 0 ? metric.improvements.toString() : "-";
|
|
7006
7055
|
const regressions = metric.regressions > 0 ? metric.regressions.toString() : "-";
|
|
7007
|
-
|
|
7056
|
+
_chunkBFGIH2ZJjs.isomorph_default.writeln(
|
|
7008
7057
|
`${metric.name.padEnd(18)} ${metricValue.padStart(10)} ${diffString.padStart(10)} ${improvements.padStart(12)} ${regressions.padStart(11)}`
|
|
7009
7058
|
);
|
|
7010
7059
|
} else {
|
|
7011
|
-
|
|
7060
|
+
_chunkBFGIH2ZJjs.isomorph_default.writeln(
|
|
7012
7061
|
`${metric.name.padEnd(20)} ${metricValue.padStart(15)}`
|
|
7013
7062
|
);
|
|
7014
7063
|
}
|
|
7015
7064
|
}
|
|
7016
7065
|
}
|
|
7017
7066
|
if (summary.experimentUrl) {
|
|
7018
|
-
|
|
7019
|
-
|
|
7020
|
-
|
|
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}`);
|
|
7021
7070
|
}
|
|
7022
7071
|
}
|
|
7023
|
-
|
|
7072
|
+
_chunkBFGIH2ZJjs.isomorph_default.writeln("");
|
|
7024
7073
|
return failingResults.length === 0;
|
|
7025
7074
|
},
|
|
7026
7075
|
async reportRun(evalReports) {
|
|
@@ -7028,6 +7077,350 @@ var defaultReporter = {
|
|
|
7028
7077
|
}
|
|
7029
7078
|
};
|
|
7030
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
|
+
|
|
7031
7424
|
// src/dataset-pipeline.ts
|
|
7032
7425
|
function DatasetPipeline(definition) {
|
|
7033
7426
|
if (!globalThis.__braintrust_dataset_pipelines) {
|
|
@@ -7111,7 +7504,7 @@ var Project2 = (_class6 = class {
|
|
|
7111
7504
|
console.warn("publish() is a no-op when running `braintrust push`.");
|
|
7112
7505
|
return;
|
|
7113
7506
|
}
|
|
7114
|
-
await
|
|
7507
|
+
await _chunkFY7DAKA5js.login.call(void 0, );
|
|
7115
7508
|
const projectMap = new ProjectNameIdMap();
|
|
7116
7509
|
const functionDefinitions = [];
|
|
7117
7510
|
if (this._publishableCodeFunctions.length > 0) {
|
|
@@ -7125,7 +7518,7 @@ var Project2 = (_class6 = class {
|
|
|
7125
7518
|
functionDefinitions.push(functionDefinition);
|
|
7126
7519
|
}
|
|
7127
7520
|
}
|
|
7128
|
-
await
|
|
7521
|
+
await _chunkFY7DAKA5js._internalGetGlobalState.call(void 0, ).apiConn().post_json("insert-functions", {
|
|
7129
7522
|
functions: functionDefinitions
|
|
7130
7523
|
});
|
|
7131
7524
|
}
|
|
@@ -7143,12 +7536,12 @@ var ToolBuilder = (_class7 = class {
|
|
|
7143
7536
|
const { handler, name, slug, parameters, returns, ...rest } = opts;
|
|
7144
7537
|
let resolvedName = _nullishCoalesce(name, () => ( handler.name));
|
|
7145
7538
|
if (resolvedName.trim().length === 0) {
|
|
7146
|
-
resolvedName = `Tool ${
|
|
7539
|
+
resolvedName = `Tool ${_chunkBFGIH2ZJjs.isomorph_default.basename(currentFilename)} ${this.taskCounter}`;
|
|
7147
7540
|
}
|
|
7148
7541
|
const tool = new CodeFunction(this.project, {
|
|
7149
7542
|
handler,
|
|
7150
7543
|
name: resolvedName,
|
|
7151
|
-
slug: _nullishCoalesce(slug, () => (
|
|
7544
|
+
slug: _nullishCoalesce(slug, () => ( _chunkFY7DAKA5js.slugify.call(void 0, resolvedName, { lower: true, strict: true }))),
|
|
7152
7545
|
type: "tool",
|
|
7153
7546
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/consistent-type-assertions
|
|
7154
7547
|
parameters,
|
|
@@ -7172,9 +7565,9 @@ var ScorerBuilder = (_class8 = class {
|
|
|
7172
7565
|
resolvedName = opts.handler.name;
|
|
7173
7566
|
}
|
|
7174
7567
|
if (!resolvedName || resolvedName.trim().length === 0) {
|
|
7175
|
-
resolvedName = `Scorer ${
|
|
7568
|
+
resolvedName = `Scorer ${_chunkBFGIH2ZJjs.isomorph_default.basename(currentFilename)} ${this.taskCounter}`;
|
|
7176
7569
|
}
|
|
7177
|
-
const slug = _nullishCoalesce(opts.slug, () => (
|
|
7570
|
+
const slug = _nullishCoalesce(opts.slug, () => ( _chunkFY7DAKA5js.slugify.call(void 0, resolvedName, { lower: true, strict: true })));
|
|
7178
7571
|
if ("handler" in opts) {
|
|
7179
7572
|
const scorer = new CodeFunction(this.project, {
|
|
7180
7573
|
...opts,
|
|
@@ -7228,9 +7621,9 @@ var ClassifierBuilder = (_class9 = class {
|
|
|
7228
7621
|
this.taskCounter++;
|
|
7229
7622
|
let resolvedName = _nullishCoalesce(opts.name, () => ( opts.handler.name));
|
|
7230
7623
|
if (!resolvedName || resolvedName.trim().length === 0) {
|
|
7231
|
-
resolvedName = `Classifier ${
|
|
7624
|
+
resolvedName = `Classifier ${_chunkBFGIH2ZJjs.isomorph_default.basename(currentFilename)} ${this.taskCounter}`;
|
|
7232
7625
|
}
|
|
7233
|
-
const slug = _nullishCoalesce(opts.slug, () => (
|
|
7626
|
+
const slug = _nullishCoalesce(opts.slug, () => ( _chunkFY7DAKA5js.slugify.call(void 0, resolvedName, { lower: true, strict: true })));
|
|
7234
7627
|
const classifier = new CodeFunction(this.project, {
|
|
7235
7628
|
...opts,
|
|
7236
7629
|
name: resolvedName,
|
|
@@ -7357,18 +7750,18 @@ var PromptBuilder = class {
|
|
|
7357
7750
|
rawTools.push(tool);
|
|
7358
7751
|
}
|
|
7359
7752
|
}
|
|
7360
|
-
const slug = _nullishCoalesce(opts.slug, () => (
|
|
7753
|
+
const slug = _nullishCoalesce(opts.slug, () => ( _chunkFY7DAKA5js.slugify.call(void 0, opts.name, { lower: true, strict: true })));
|
|
7361
7754
|
const promptData = promptDefinitionToPromptData(opts, rawTools);
|
|
7362
7755
|
const promptRow = {
|
|
7363
7756
|
id: opts.id,
|
|
7364
|
-
_xact_id: opts.version ?
|
|
7757
|
+
_xact_id: opts.version ? _chunkFY7DAKA5js.loadPrettyXact.call(void 0, opts.version) : void 0,
|
|
7365
7758
|
name: opts.name,
|
|
7366
7759
|
slug,
|
|
7367
7760
|
prompt_data: promptData,
|
|
7368
7761
|
tags: opts.tags,
|
|
7369
7762
|
...this.project.id !== void 0 ? { project_id: this.project.id } : {}
|
|
7370
7763
|
};
|
|
7371
|
-
const prompt = new (0,
|
|
7764
|
+
const prompt = new (0, _chunkFY7DAKA5js.Prompt)(
|
|
7372
7765
|
promptRow,
|
|
7373
7766
|
{},
|
|
7374
7767
|
// It doesn't make sense to specify defaults here.
|
|
@@ -7422,7 +7815,7 @@ var ParametersBuilder = class {
|
|
|
7422
7815
|
this.project = project;
|
|
7423
7816
|
}
|
|
7424
7817
|
create(opts) {
|
|
7425
|
-
const slug = _nullishCoalesce(opts.slug, () => (
|
|
7818
|
+
const slug = _nullishCoalesce(opts.slug, () => ( _chunkFY7DAKA5js.slugify.call(void 0, opts.name, { lower: true, strict: true })));
|
|
7426
7819
|
const codeParameters = new CodeParameters(this.project, {
|
|
7427
7820
|
name: opts.name,
|
|
7428
7821
|
slug,
|
|
@@ -7461,7 +7854,7 @@ function serializeEvalParameterstoParametersSchema(parameters) {
|
|
|
7461
7854
|
required.push(name);
|
|
7462
7855
|
}
|
|
7463
7856
|
} else {
|
|
7464
|
-
const schemaObj =
|
|
7857
|
+
const schemaObj = _chunkFY7DAKA5js.zodToJsonSchema.call(void 0, value);
|
|
7465
7858
|
properties[name] = schemaObj;
|
|
7466
7859
|
if (!("default" in schemaObj)) {
|
|
7467
7860
|
required.push(name);
|
|
@@ -7490,11 +7883,11 @@ var ProjectNameIdMap = (_class10 = class {constructor() { _class10.prototype.__i
|
|
|
7490
7883
|
__init19() {this.idToName = {}}
|
|
7491
7884
|
async getId(projectName) {
|
|
7492
7885
|
if (!(projectName in this.nameToId)) {
|
|
7493
|
-
const response = await
|
|
7886
|
+
const response = await _chunkFY7DAKA5js._internalGetGlobalState.call(void 0, ).appConn().post_json("api/project/register", {
|
|
7494
7887
|
project_name: projectName
|
|
7495
7888
|
});
|
|
7496
7889
|
const result = _v3.z.object({
|
|
7497
|
-
project:
|
|
7890
|
+
project: _chunkFY7DAKA5js.Project
|
|
7498
7891
|
}).parse(response);
|
|
7499
7892
|
const projectId = result.project.id;
|
|
7500
7893
|
this.nameToId[projectName] = projectId;
|
|
@@ -7504,10 +7897,10 @@ var ProjectNameIdMap = (_class10 = class {constructor() { _class10.prototype.__i
|
|
|
7504
7897
|
}
|
|
7505
7898
|
async getName(projectId) {
|
|
7506
7899
|
if (!(projectId in this.idToName)) {
|
|
7507
|
-
const response = await
|
|
7900
|
+
const response = await _chunkFY7DAKA5js._internalGetGlobalState.call(void 0, ).appConn().post_json("api/project/get", {
|
|
7508
7901
|
id: projectId
|
|
7509
7902
|
});
|
|
7510
|
-
const result = _v3.z.array(
|
|
7903
|
+
const result = _v3.z.array(_chunkFY7DAKA5js.Project).nonempty().parse(response);
|
|
7511
7904
|
const projectName = result[0].name;
|
|
7512
7905
|
this.idToName[projectId] = projectName;
|
|
7513
7906
|
this.nameToId[projectName] = projectId;
|
|
@@ -7527,16 +7920,16 @@ var ProjectNameIdMap = (_class10 = class {constructor() { _class10.prototype.__i
|
|
|
7527
7920
|
var evalBodySchema = _v3.z.object({
|
|
7528
7921
|
name: _v3.z.string(),
|
|
7529
7922
|
parameters: _v3.z.record(_v3.z.string(), _v3.z.unknown()).nullish(),
|
|
7530
|
-
data:
|
|
7923
|
+
data: _chunkFY7DAKA5js.RunEval.shape.data,
|
|
7531
7924
|
scores: _v3.z.array(
|
|
7532
7925
|
_v3.z.object({
|
|
7533
|
-
function_id:
|
|
7926
|
+
function_id: _chunkFY7DAKA5js.FunctionId,
|
|
7534
7927
|
name: _v3.z.string()
|
|
7535
7928
|
})
|
|
7536
7929
|
).nullish(),
|
|
7537
7930
|
experiment_name: _v3.z.string().nullish(),
|
|
7538
7931
|
project_id: _v3.z.string().nullish(),
|
|
7539
|
-
parent:
|
|
7932
|
+
parent: _chunkFY7DAKA5js.InvokeParent.optional(),
|
|
7540
7933
|
stream: _v3.z.boolean().optional()
|
|
7541
7934
|
});
|
|
7542
7935
|
var staticParametersSchema = _v3.z.record(
|
|
@@ -7544,7 +7937,7 @@ var staticParametersSchema = _v3.z.record(
|
|
|
7544
7937
|
_v3.z.union([
|
|
7545
7938
|
_v3.z.object({
|
|
7546
7939
|
type: _v3.z.literal("prompt"),
|
|
7547
|
-
default:
|
|
7940
|
+
default: _chunkFY7DAKA5js.PromptData.optional(),
|
|
7548
7941
|
description: _v3.z.string().optional()
|
|
7549
7942
|
}),
|
|
7550
7943
|
_v3.z.object({
|
|
@@ -7600,7 +7993,16 @@ var evaluatorDefinitionsSchema = _v3.z.record(
|
|
|
7600
7993
|
);
|
|
7601
7994
|
|
|
7602
7995
|
// src/node/index.ts
|
|
7603
|
-
|
|
7996
|
+
_chunkFY7DAKA5js.configureNode.call(void 0, );
|
|
7997
|
+
|
|
7998
|
+
|
|
7999
|
+
|
|
8000
|
+
|
|
8001
|
+
|
|
8002
|
+
|
|
8003
|
+
|
|
8004
|
+
|
|
8005
|
+
|
|
7604
8006
|
|
|
7605
8007
|
|
|
7606
8008
|
|
|
@@ -7757,4 +8159,4 @@ _chunk37RLJF2Ujs.configureNode.call(void 0, );
|
|
|
7757
8159
|
|
|
7758
8160
|
|
|
7759
8161
|
|
|
7760
|
-
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;
|