braintrust 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dev/dist/index.js +17 -4
- package/dev/dist/index.mjs +17 -4
- package/dist/browser.d.mts +29 -2
- package/dist/browser.d.ts +29 -2
- package/dist/browser.js +263 -47
- package/dist/browser.mjs +221 -5
- package/dist/cli.js +23 -8
- package/dist/index.d.mts +76 -4
- package/dist/index.d.ts +76 -4
- package/dist/index.js +517 -76
- package/dist/index.mjs +457 -16
- package/package.json +6 -4
package/dist/browser.mjs
CHANGED
|
@@ -2997,6 +2997,110 @@ function traced(callback, args) {
|
|
|
2997
2997
|
})();
|
|
2998
2998
|
}
|
|
2999
2999
|
}
|
|
3000
|
+
function isGeneratorFunction(fn) {
|
|
3001
|
+
return Object.prototype.toString.call(fn) === "[object GeneratorFunction]";
|
|
3002
|
+
}
|
|
3003
|
+
function isAsyncGeneratorFunction(fn) {
|
|
3004
|
+
return Object.prototype.toString.call(fn) === "[object AsyncGeneratorFunction]";
|
|
3005
|
+
}
|
|
3006
|
+
function wrapTracedSyncGenerator(fn, spanArgs, noTraceIO) {
|
|
3007
|
+
const wrapper = function* (...fnArgs) {
|
|
3008
|
+
const span = startSpan(spanArgs);
|
|
3009
|
+
try {
|
|
3010
|
+
if (!noTraceIO) {
|
|
3011
|
+
span.log({ input: fnArgs });
|
|
3012
|
+
}
|
|
3013
|
+
const envValue = isomorph_default.getEnv("BRAINTRUST_MAX_GENERATOR_ITEMS");
|
|
3014
|
+
const maxItems = envValue !== void 0 ? Number(envValue) : 1e3;
|
|
3015
|
+
if (!noTraceIO && maxItems !== 0) {
|
|
3016
|
+
let collected = [];
|
|
3017
|
+
let truncated = false;
|
|
3018
|
+
const gen = generatorWithCurrent(span, fn.apply(this, fnArgs));
|
|
3019
|
+
try {
|
|
3020
|
+
for (const value of gen) {
|
|
3021
|
+
if (maxItems === -1 || !truncated && collected.length < maxItems) {
|
|
3022
|
+
collected.push(value);
|
|
3023
|
+
} else {
|
|
3024
|
+
truncated = true;
|
|
3025
|
+
collected = [];
|
|
3026
|
+
console.warn(
|
|
3027
|
+
`Generator output exceeded limit of ${maxItems} items, output not logged. Increase BRAINTRUST_MAX_GENERATOR_ITEMS or set to -1 to disable limit.`
|
|
3028
|
+
);
|
|
3029
|
+
}
|
|
3030
|
+
yield value;
|
|
3031
|
+
}
|
|
3032
|
+
if (!truncated) {
|
|
3033
|
+
span.log({ output: collected });
|
|
3034
|
+
}
|
|
3035
|
+
} catch (error) {
|
|
3036
|
+
logError(span, error);
|
|
3037
|
+
if (!truncated && collected.length > 0) {
|
|
3038
|
+
span.log({ output: collected });
|
|
3039
|
+
}
|
|
3040
|
+
throw error;
|
|
3041
|
+
}
|
|
3042
|
+
} else {
|
|
3043
|
+
const gen = generatorWithCurrent(span, fn.apply(this, fnArgs));
|
|
3044
|
+
for (const value of gen) {
|
|
3045
|
+
yield value;
|
|
3046
|
+
}
|
|
3047
|
+
}
|
|
3048
|
+
} finally {
|
|
3049
|
+
span.end();
|
|
3050
|
+
}
|
|
3051
|
+
};
|
|
3052
|
+
Object.defineProperty(wrapper, "name", { value: fn.name });
|
|
3053
|
+
return wrapper;
|
|
3054
|
+
}
|
|
3055
|
+
function wrapTracedAsyncGenerator(fn, spanArgs, noTraceIO) {
|
|
3056
|
+
const wrapper = async function* (...fnArgs) {
|
|
3057
|
+
const span = startSpan(spanArgs);
|
|
3058
|
+
try {
|
|
3059
|
+
if (!noTraceIO) {
|
|
3060
|
+
span.log({ input: fnArgs });
|
|
3061
|
+
}
|
|
3062
|
+
const envValue = isomorph_default.getEnv("BRAINTRUST_MAX_GENERATOR_ITEMS");
|
|
3063
|
+
const maxItems = envValue !== void 0 ? Number(envValue) : 1e3;
|
|
3064
|
+
if (!noTraceIO && maxItems !== 0) {
|
|
3065
|
+
let collected = [];
|
|
3066
|
+
let truncated = false;
|
|
3067
|
+
const gen = asyncGeneratorWithCurrent(span, fn.apply(this, fnArgs));
|
|
3068
|
+
try {
|
|
3069
|
+
for await (const value of gen) {
|
|
3070
|
+
if (maxItems === -1 || !truncated && collected.length < maxItems) {
|
|
3071
|
+
collected.push(value);
|
|
3072
|
+
} else {
|
|
3073
|
+
truncated = true;
|
|
3074
|
+
collected = [];
|
|
3075
|
+
console.warn(
|
|
3076
|
+
`Generator output exceeded limit of ${maxItems} items, output not logged. Increase BRAINTRUST_MAX_GENERATOR_ITEMS or set to -1 to disable limit.`
|
|
3077
|
+
);
|
|
3078
|
+
}
|
|
3079
|
+
yield value;
|
|
3080
|
+
}
|
|
3081
|
+
if (!truncated) {
|
|
3082
|
+
span.log({ output: collected });
|
|
3083
|
+
}
|
|
3084
|
+
} catch (error) {
|
|
3085
|
+
logError(span, error);
|
|
3086
|
+
if (!truncated && collected.length > 0) {
|
|
3087
|
+
span.log({ output: collected });
|
|
3088
|
+
}
|
|
3089
|
+
throw error;
|
|
3090
|
+
}
|
|
3091
|
+
} else {
|
|
3092
|
+
const gen = asyncGeneratorWithCurrent(span, fn.apply(this, fnArgs));
|
|
3093
|
+
for await (const value of gen) {
|
|
3094
|
+
yield value;
|
|
3095
|
+
}
|
|
3096
|
+
}
|
|
3097
|
+
} finally {
|
|
3098
|
+
span.end();
|
|
3099
|
+
}
|
|
3100
|
+
};
|
|
3101
|
+
Object.defineProperty(wrapper, "name", { value: fn.name });
|
|
3102
|
+
return wrapper;
|
|
3103
|
+
}
|
|
3000
3104
|
function wrapTraced(fn, args) {
|
|
3001
3105
|
const spanArgs = {
|
|
3002
3106
|
name: fn.name,
|
|
@@ -3005,6 +3109,13 @@ function wrapTraced(fn, args) {
|
|
|
3005
3109
|
};
|
|
3006
3110
|
const hasExplicitInput = args && args.event && "input" in args.event && args.event.input !== void 0;
|
|
3007
3111
|
const hasExplicitOutput = args && args.event && args.event.output !== void 0;
|
|
3112
|
+
const noTraceIO = args?.noTraceIO || hasExplicitInput || hasExplicitOutput;
|
|
3113
|
+
if (isGeneratorFunction(fn)) {
|
|
3114
|
+
return wrapTracedSyncGenerator(fn, spanArgs, !!noTraceIO);
|
|
3115
|
+
}
|
|
3116
|
+
if (isAsyncGeneratorFunction(fn)) {
|
|
3117
|
+
return wrapTracedAsyncGenerator(fn, spanArgs, !!noTraceIO);
|
|
3118
|
+
}
|
|
3008
3119
|
if (args?.asyncFlush) {
|
|
3009
3120
|
return (...fnArgs) => traced((span) => {
|
|
3010
3121
|
if (!hasExplicitInput) {
|
|
@@ -3090,6 +3201,52 @@ function startSpanAndIsLogger(args) {
|
|
|
3090
3201
|
function withCurrent(span, callback, state = void 0) {
|
|
3091
3202
|
return (state ?? _globalState).currentSpan.run(span, () => callback(span));
|
|
3092
3203
|
}
|
|
3204
|
+
function* generatorWithCurrent(span, gen, state = void 0) {
|
|
3205
|
+
let nextValue;
|
|
3206
|
+
while (true) {
|
|
3207
|
+
const result = withCurrent(
|
|
3208
|
+
span,
|
|
3209
|
+
() => {
|
|
3210
|
+
try {
|
|
3211
|
+
return gen.next(nextValue);
|
|
3212
|
+
} catch (e) {
|
|
3213
|
+
return { value: void 0, done: true, error: e };
|
|
3214
|
+
}
|
|
3215
|
+
},
|
|
3216
|
+
state
|
|
3217
|
+
);
|
|
3218
|
+
if ("error" in result) {
|
|
3219
|
+
throw result.error;
|
|
3220
|
+
}
|
|
3221
|
+
if (result.done) {
|
|
3222
|
+
return result.value;
|
|
3223
|
+
}
|
|
3224
|
+
nextValue = yield result.value;
|
|
3225
|
+
}
|
|
3226
|
+
}
|
|
3227
|
+
async function* asyncGeneratorWithCurrent(span, gen, state = void 0) {
|
|
3228
|
+
let nextValue;
|
|
3229
|
+
while (true) {
|
|
3230
|
+
const result = await withCurrent(
|
|
3231
|
+
span,
|
|
3232
|
+
async () => {
|
|
3233
|
+
try {
|
|
3234
|
+
return await gen.next(nextValue);
|
|
3235
|
+
} catch (e) {
|
|
3236
|
+
return { value: void 0, done: true, error: e };
|
|
3237
|
+
}
|
|
3238
|
+
},
|
|
3239
|
+
state
|
|
3240
|
+
);
|
|
3241
|
+
if ("error" in result) {
|
|
3242
|
+
throw result.error;
|
|
3243
|
+
}
|
|
3244
|
+
if (result.done) {
|
|
3245
|
+
return result.value;
|
|
3246
|
+
}
|
|
3247
|
+
nextValue = yield result.value;
|
|
3248
|
+
}
|
|
3249
|
+
}
|
|
3093
3250
|
function withParent(parent, callback, state = void 0) {
|
|
3094
3251
|
return (state ?? _globalState).currentParent.run(parent, () => callback());
|
|
3095
3252
|
}
|
|
@@ -4563,6 +4720,11 @@ var Prompt = class _Prompt {
|
|
|
4563
4720
|
}
|
|
4564
4721
|
};
|
|
4565
4722
|
var TEST_API_KEY = "___TEST_API_KEY__THIS_IS_NOT_REAL___";
|
|
4723
|
+
function setInitialTestState() {
|
|
4724
|
+
if (!_internalGetGlobalState()) {
|
|
4725
|
+
_internalSetInitialState();
|
|
4726
|
+
}
|
|
4727
|
+
}
|
|
4566
4728
|
async function simulateLoginForTests() {
|
|
4567
4729
|
return await login({
|
|
4568
4730
|
apiKey: TEST_API_KEY,
|
|
@@ -4580,7 +4742,10 @@ var _exportsForTestingOnly = {
|
|
|
4580
4742
|
useTestBackgroundLogger,
|
|
4581
4743
|
clearTestBackgroundLogger,
|
|
4582
4744
|
simulateLoginForTests,
|
|
4583
|
-
simulateLogoutForTests
|
|
4745
|
+
simulateLogoutForTests,
|
|
4746
|
+
setInitialTestState,
|
|
4747
|
+
isGeneratorFunction,
|
|
4748
|
+
isAsyncGeneratorFunction
|
|
4584
4749
|
};
|
|
4585
4750
|
|
|
4586
4751
|
// src/browser-config.ts
|
|
@@ -4793,6 +4958,8 @@ function responsesProxy(openai) {
|
|
|
4793
4958
|
return responsesCreateProxy(target.create.bind(target));
|
|
4794
4959
|
} else if (name === "stream") {
|
|
4795
4960
|
return responsesStreamProxy(target.stream.bind(target));
|
|
4961
|
+
} else if (name === "parse") {
|
|
4962
|
+
return responsesParseProxy(target.parse.bind(target));
|
|
4796
4963
|
}
|
|
4797
4964
|
return Reflect.get(target, name, receiver);
|
|
4798
4965
|
}
|
|
@@ -4837,6 +5004,36 @@ function parseEventFromResponseCreateResult(result) {
|
|
|
4837
5004
|
metrics: parseMetricsFromUsage(result?.usage)
|
|
4838
5005
|
};
|
|
4839
5006
|
}
|
|
5007
|
+
function parseSpanFromResponseParseParams(params) {
|
|
5008
|
+
const input = [{ role: "user", content: params.input }];
|
|
5009
|
+
if (params.instructions) {
|
|
5010
|
+
input.push({ role: "system", content: params.instructions });
|
|
5011
|
+
}
|
|
5012
|
+
const spanArgs = {
|
|
5013
|
+
name: "openai.responses.parse",
|
|
5014
|
+
spanAttributes: {
|
|
5015
|
+
type: "llm"
|
|
5016
|
+
},
|
|
5017
|
+
event: {
|
|
5018
|
+
input,
|
|
5019
|
+
metadata: {
|
|
5020
|
+
...filterFrom(params, ["input", "instructions"]),
|
|
5021
|
+
provider: "openai"
|
|
5022
|
+
}
|
|
5023
|
+
},
|
|
5024
|
+
startTime: getCurrentUnixTimestamp()
|
|
5025
|
+
};
|
|
5026
|
+
return {
|
|
5027
|
+
span: startSpan(spanArgs),
|
|
5028
|
+
start: spanArgs.startTime
|
|
5029
|
+
};
|
|
5030
|
+
}
|
|
5031
|
+
function parseEventFromResponseParseResult(result) {
|
|
5032
|
+
return {
|
|
5033
|
+
output: result?.output_parsed || result?.output_text || "",
|
|
5034
|
+
metrics: parseMetricsFromUsage(result?.usage)
|
|
5035
|
+
};
|
|
5036
|
+
}
|
|
4840
5037
|
function traceResponseCreateStream(stream, timedSpan) {
|
|
4841
5038
|
const span = timedSpan.span;
|
|
4842
5039
|
let ttft = -1;
|
|
@@ -4911,6 +5108,16 @@ function responsesStreamProxy(target) {
|
|
|
4911
5108
|
}
|
|
4912
5109
|
});
|
|
4913
5110
|
}
|
|
5111
|
+
function responsesParseProxy(target) {
|
|
5112
|
+
const hooks = {
|
|
5113
|
+
name: "openai.responses.parse",
|
|
5114
|
+
toSpanFunc: parseSpanFromResponseParseParams,
|
|
5115
|
+
resultToEventFunc: parseEventFromResponseParseResult,
|
|
5116
|
+
traceStreamFunc: traceResponseCreateStream
|
|
5117
|
+
// Reuse the same stream tracing
|
|
5118
|
+
};
|
|
5119
|
+
return proxyCreate(target, hooks);
|
|
5120
|
+
}
|
|
4914
5121
|
var TOKEN_NAME_MAP = {
|
|
4915
5122
|
input_tokens: "prompt_tokens",
|
|
4916
5123
|
output_tokens: "completion_tokens",
|
|
@@ -5030,10 +5237,17 @@ function wrapOpenAI(openai) {
|
|
|
5030
5237
|
}
|
|
5031
5238
|
globalThis.__inherited_braintrust_wrap_openai = wrapOpenAI;
|
|
5032
5239
|
function wrapOpenAIv4(openai) {
|
|
5033
|
-
const completionProxy =
|
|
5034
|
-
|
|
5035
|
-
|
|
5036
|
-
|
|
5240
|
+
const completionProxy = new Proxy(openai.chat.completions, {
|
|
5241
|
+
get(target, name, receiver) {
|
|
5242
|
+
const baseVal = Reflect.get(target, name, receiver);
|
|
5243
|
+
if (name === "create") {
|
|
5244
|
+
return wrapChatCompletion(baseVal.bind(target));
|
|
5245
|
+
} else if (name === "parse") {
|
|
5246
|
+
return wrapBetaChatCompletionParse(baseVal.bind(target));
|
|
5247
|
+
}
|
|
5248
|
+
return baseVal;
|
|
5249
|
+
}
|
|
5250
|
+
});
|
|
5037
5251
|
const chatProxy = new Proxy(openai.chat, {
|
|
5038
5252
|
get(target, name, receiver) {
|
|
5039
5253
|
if (name === "completions") {
|
|
@@ -5427,6 +5641,8 @@ var evalBodySchema = z3.object({
|
|
|
5427
5641
|
name: z3.string()
|
|
5428
5642
|
})
|
|
5429
5643
|
).nullish(),
|
|
5644
|
+
experiment_name: z3.string().nullish(),
|
|
5645
|
+
project_id: z3.string().nullish(),
|
|
5430
5646
|
parent: invokeParent.optional(),
|
|
5431
5647
|
stream: z3.boolean().optional()
|
|
5432
5648
|
});
|
package/dist/cli.js
CHANGED
|
@@ -1232,7 +1232,7 @@ var require_package = __commonJS({
|
|
|
1232
1232
|
"package.json"(exports2, module2) {
|
|
1233
1233
|
module2.exports = {
|
|
1234
1234
|
name: "braintrust",
|
|
1235
|
-
version: "0.2.
|
|
1235
|
+
version: "0.2.2",
|
|
1236
1236
|
description: "SDK for integrating Braintrust",
|
|
1237
1237
|
repository: {
|
|
1238
1238
|
type: "git",
|
|
@@ -1283,11 +1283,13 @@ var require_package = __commonJS({
|
|
|
1283
1283
|
docs: "npx typedoc --options typedoc.json src/index.ts",
|
|
1284
1284
|
prepublishOnly: "../../scripts/node_prepublish_sdk.py",
|
|
1285
1285
|
postpublish: "../../scripts/node_postpublish_sdk.py",
|
|
1286
|
-
test: "vitest run --exclude src/wrappers/anthropic.test.ts --exclude src/wrappers/oai.test.ts --exclude src/otel.test.ts --exclude src/otel-no-deps.test.ts",
|
|
1286
|
+
test: "vitest run --exclude src/wrappers/anthropic.test.ts --exclude src/wrappers/oai.test.ts --exclude src/otel.test.ts --exclude src/otel-no-deps.test.ts --exclude src/wrappers/ai-sdk-v1.test.ts --exclude src/wrappers/ai-sdk-v2.test.ts",
|
|
1287
1287
|
"test:anthropic": "vitest run src/wrappers/anthropic.test.ts",
|
|
1288
1288
|
"test:openai": "vitest run src/wrappers/oai.test.ts",
|
|
1289
1289
|
"test:otel": "vitest run src/otel.test.ts",
|
|
1290
|
-
"test:otel-no-deps": "vitest run src/otel-no-deps.test.ts --reporter=verbose"
|
|
1290
|
+
"test:otel-no-deps": "vitest run src/otel-no-deps.test.ts --reporter=verbose",
|
|
1291
|
+
"test:ai-sdk-v1": "vitest run src/wrappers/ai-sdk-v1.test.ts",
|
|
1292
|
+
"test:ai-sdk-v2": "vitest run src/wrappers/ai-sdk-v2.test.ts src/wrappers/ai-sdk-v1.test.ts"
|
|
1291
1293
|
},
|
|
1292
1294
|
author: "",
|
|
1293
1295
|
license: "MIT",
|
|
@@ -1322,7 +1324,7 @@ var require_package = __commonJS({
|
|
|
1322
1324
|
},
|
|
1323
1325
|
dependencies: {
|
|
1324
1326
|
"@ai-sdk/provider": "^1.1.3",
|
|
1325
|
-
"@braintrust/core": "0.0.
|
|
1327
|
+
"@braintrust/core": "0.0.92",
|
|
1326
1328
|
"@next/env": "^14.2.3",
|
|
1327
1329
|
"@vercel/functions": "^1.0.2",
|
|
1328
1330
|
argparse: "^2.0.1",
|
|
@@ -8875,6 +8877,8 @@ var evalBodySchema = import_zod8.z.object({
|
|
|
8875
8877
|
name: import_zod8.z.string()
|
|
8876
8878
|
})
|
|
8877
8879
|
).nullish(),
|
|
8880
|
+
experiment_name: import_zod8.z.string().nullish(),
|
|
8881
|
+
project_id: import_zod8.z.string().nullish(),
|
|
8878
8882
|
parent: import_typespecs6.invokeParent.optional(),
|
|
8879
8883
|
stream: import_zod8.z.boolean().optional()
|
|
8880
8884
|
});
|
|
@@ -8957,7 +8961,16 @@ function runDevServer(evaluators, opts) {
|
|
|
8957
8961
|
"/eval",
|
|
8958
8962
|
checkAuthorized,
|
|
8959
8963
|
asyncHandler(async (req, res) => {
|
|
8960
|
-
const {
|
|
8964
|
+
const {
|
|
8965
|
+
name,
|
|
8966
|
+
parameters,
|
|
8967
|
+
parent,
|
|
8968
|
+
experiment_name,
|
|
8969
|
+
project_id,
|
|
8970
|
+
data,
|
|
8971
|
+
scores,
|
|
8972
|
+
stream
|
|
8973
|
+
} = evalBodySchema.parse(req.body);
|
|
8961
8974
|
const state = await cachedLogin({ apiKey: req.ctx?.token });
|
|
8962
8975
|
const evaluator = allEvaluators[name];
|
|
8963
8976
|
if (!evaluator) {
|
|
@@ -9016,17 +9029,19 @@ function runDevServer(evaluators, opts) {
|
|
|
9016
9029
|
) ?? []
|
|
9017
9030
|
),
|
|
9018
9031
|
task,
|
|
9019
|
-
state
|
|
9032
|
+
state,
|
|
9033
|
+
experimentName: experiment_name ?? void 0,
|
|
9034
|
+
projectId: project_id ?? void 0
|
|
9020
9035
|
},
|
|
9021
9036
|
{
|
|
9022
9037
|
// Avoid printing the bar to the console.
|
|
9023
9038
|
progress: {
|
|
9024
|
-
start: (
|
|
9039
|
+
start: () => {
|
|
9025
9040
|
},
|
|
9026
9041
|
stop: () => {
|
|
9027
9042
|
console.log("Finished running experiment");
|
|
9028
9043
|
},
|
|
9029
|
-
increment: (
|
|
9044
|
+
increment: () => {
|
|
9030
9045
|
}
|
|
9031
9046
|
},
|
|
9032
9047
|
stream: (data2) => {
|
package/dist/index.d.mts
CHANGED
|
@@ -1156,6 +1156,29 @@ declare function logError(span: Span$1, error: unknown): void;
|
|
|
1156
1156
|
* See {@link Span.traced} for full details.
|
|
1157
1157
|
*/
|
|
1158
1158
|
declare function traced<IsAsyncFlush extends boolean = true, R = void>(callback: (span: Span$1) => R, args?: StartSpanArgs & SetCurrentArg & AsyncFlushArg<IsAsyncFlush> & OptionalStateArg): PromiseUnless<IsAsyncFlush, R>;
|
|
1159
|
+
/**
|
|
1160
|
+
* Check if a function is a sync generator function.
|
|
1161
|
+
*
|
|
1162
|
+
* Note: This uses Object.prototype.toString which is sufficient for environments that
|
|
1163
|
+
* support generator functions (ES6+). While our code is compiled to ES2022, consumers
|
|
1164
|
+
* may run it in various environments. However, if generators aren't supported in their
|
|
1165
|
+
* environment, the generator functions themselves won't work anyway, making detection moot.
|
|
1166
|
+
*
|
|
1167
|
+
* @param fn The function to check.
|
|
1168
|
+
* @returns True if the function is a sync generator function.
|
|
1169
|
+
*/
|
|
1170
|
+
declare function isGeneratorFunction(fn: any): boolean;
|
|
1171
|
+
/**
|
|
1172
|
+
* Check if a function is an async generator function.
|
|
1173
|
+
*
|
|
1174
|
+
* Note: see isGeneratorFunction disclaimer
|
|
1175
|
+
* @param fn The function to check.
|
|
1176
|
+
* @returns True if the function is an async generator function.
|
|
1177
|
+
*/
|
|
1178
|
+
declare function isAsyncGeneratorFunction(fn: any): boolean;
|
|
1179
|
+
type WrapTracedArgs = {
|
|
1180
|
+
noTraceIO?: boolean;
|
|
1181
|
+
};
|
|
1159
1182
|
/**
|
|
1160
1183
|
* Wrap a function with `traced`, using the arguments as `input` and return value as `output`.
|
|
1161
1184
|
* Any functions wrapped this way will automatically be traced, similar to the `@traced` decorator
|
|
@@ -1181,7 +1204,7 @@ declare function traced<IsAsyncFlush extends boolean = true, R = void>(callback:
|
|
|
1181
1204
|
* @param args Span-level arguments (e.g. a custom name or type) to pass to `traced`.
|
|
1182
1205
|
* @returns The wrapped function.
|
|
1183
1206
|
*/
|
|
1184
|
-
declare function wrapTraced<F extends (...args: any[]) => any, IsAsyncFlush extends boolean = true>(fn: F, args?: StartSpanArgs & SetCurrentArg & AsyncFlushArg<IsAsyncFlush>): IsAsyncFlush extends false ? (...args: Parameters<F>) => Promise<Awaited<ReturnType<F>>> : F;
|
|
1207
|
+
declare function wrapTraced<F extends (...args: any[]) => any, IsAsyncFlush extends boolean = true>(fn: F, args?: StartSpanArgs & SetCurrentArg & AsyncFlushArg<IsAsyncFlush> & WrapTracedArgs): IsAsyncFlush extends false ? (...args: Parameters<F>) => Promise<Awaited<ReturnType<F>>> : F;
|
|
1185
1208
|
/**
|
|
1186
1209
|
* A synonym for `wrapTraced`. If you're porting from systems that use `traceable`, you can use this to
|
|
1187
1210
|
* make your codebase more consistent.
|
|
@@ -1691,6 +1714,7 @@ interface DatasetSummary {
|
|
|
1691
1714
|
datasetUrl: string;
|
|
1692
1715
|
dataSummary: DataSummary | undefined;
|
|
1693
1716
|
}
|
|
1717
|
+
declare function setInitialTestState(): void;
|
|
1694
1718
|
declare function simulateLoginForTests(): Promise<BraintrustState>;
|
|
1695
1719
|
declare function simulateLogoutForTests(): BraintrustState;
|
|
1696
1720
|
declare const _exportsForTestingOnly: {
|
|
@@ -1700,6 +1724,9 @@ declare const _exportsForTestingOnly: {
|
|
|
1700
1724
|
clearTestBackgroundLogger: typeof clearTestBackgroundLogger;
|
|
1701
1725
|
simulateLoginForTests: typeof simulateLoginForTests;
|
|
1702
1726
|
simulateLogoutForTests: typeof simulateLogoutForTests;
|
|
1727
|
+
setInitialTestState: typeof setInitialTestState;
|
|
1728
|
+
isGeneratorFunction: typeof isGeneratorFunction;
|
|
1729
|
+
isAsyncGeneratorFunction: typeof isAsyncGeneratorFunction;
|
|
1703
1730
|
};
|
|
1704
1731
|
|
|
1705
1732
|
declare const braintrustStreamChunkSchema: z.ZodUnion<[z.ZodObject<{
|
|
@@ -7134,7 +7161,7 @@ declare global {
|
|
|
7134
7161
|
* not configured, nothing will be traced. If this is not an `OpenAI` object, this function is
|
|
7135
7162
|
* a no-op.
|
|
7136
7163
|
*
|
|
7137
|
-
* Currently, this
|
|
7164
|
+
* Currently, this supports both the `v4` and `v5` API.
|
|
7138
7165
|
*
|
|
7139
7166
|
* @param openai
|
|
7140
7167
|
* @returns The wrapped `OpenAI` object.
|
|
@@ -7145,6 +7172,50 @@ declare const LEGACY_CACHED_HEADER = "x-cached";
|
|
|
7145
7172
|
declare const X_CACHED_HEADER = "x-bt-cached";
|
|
7146
7173
|
declare function parseCachedHeader(value: string | null | undefined): number | undefined;
|
|
7147
7174
|
|
|
7175
|
+
interface LanguageModelV2Middleware<TModel = any, TCallOptions = any> {
|
|
7176
|
+
wrapGenerate?: (options: {
|
|
7177
|
+
doGenerate: () => any;
|
|
7178
|
+
doStream: () => any;
|
|
7179
|
+
params: TCallOptions;
|
|
7180
|
+
model: TModel;
|
|
7181
|
+
}) => Promise<any>;
|
|
7182
|
+
wrapStream?: (options: {
|
|
7183
|
+
doGenerate: () => any;
|
|
7184
|
+
doStream: () => any;
|
|
7185
|
+
params: TCallOptions;
|
|
7186
|
+
model: TModel;
|
|
7187
|
+
}) => Promise<any>;
|
|
7188
|
+
}
|
|
7189
|
+
/**
|
|
7190
|
+
* Configuration options for the AI SDK middleware
|
|
7191
|
+
*/
|
|
7192
|
+
interface MiddlewareConfig {
|
|
7193
|
+
/** Enable debug logging */
|
|
7194
|
+
debug?: boolean;
|
|
7195
|
+
/** Name identifier for the middleware instance */
|
|
7196
|
+
name?: string;
|
|
7197
|
+
}
|
|
7198
|
+
/**
|
|
7199
|
+
* Creates a Braintrust middleware for AI SDK v2 that automatically traces
|
|
7200
|
+
* generateText and streamText calls with comprehensive metadata and metrics.
|
|
7201
|
+
*
|
|
7202
|
+
* @param config - Configuration options for the middleware
|
|
7203
|
+
* @returns A middleware object compatible with AI SDK v2's wrapLanguageModel
|
|
7204
|
+
*
|
|
7205
|
+
* @example
|
|
7206
|
+
* ```typescript
|
|
7207
|
+
* import { wrapLanguageModel } from "ai";
|
|
7208
|
+
* import { openai } from "@ai-sdk/openai";
|
|
7209
|
+
* import { BraintrustMiddleware } from "braintrust";
|
|
7210
|
+
*
|
|
7211
|
+
* const model = wrapLanguageModel({
|
|
7212
|
+
* model: openai("gpt-4"),
|
|
7213
|
+
* middleware: BraintrustMiddleware({ debug: true, name: "MyMiddleware" })
|
|
7214
|
+
* });
|
|
7215
|
+
* ```
|
|
7216
|
+
*/
|
|
7217
|
+
declare function BraintrustMiddleware(config?: MiddlewareConfig): LanguageModelV2Middleware<any, any>;
|
|
7218
|
+
|
|
7148
7219
|
/**
|
|
7149
7220
|
* Wrap an ai-sdk model (created with `.chat()`, `.completion()`, etc.) to add tracing. If Braintrust is
|
|
7150
7221
|
* not configured, this is a no-op
|
|
@@ -7406,6 +7477,7 @@ declare const braintrust_BaseExperiment: typeof BaseExperiment;
|
|
|
7406
7477
|
type braintrust_BaseMetadata = BaseMetadata;
|
|
7407
7478
|
type braintrust_BraintrustExporter = BraintrustExporter;
|
|
7408
7479
|
declare const braintrust_BraintrustExporter: typeof BraintrustExporter;
|
|
7480
|
+
declare const braintrust_BraintrustMiddleware: typeof BraintrustMiddleware;
|
|
7409
7481
|
type braintrust_BraintrustSpanProcessor = BraintrustSpanProcessor;
|
|
7410
7482
|
declare const braintrust_BraintrustSpanProcessor: typeof BraintrustSpanProcessor;
|
|
7411
7483
|
type braintrust_BraintrustState = BraintrustState;
|
|
@@ -7564,7 +7636,7 @@ declare const braintrust_wrapOpenAI: typeof wrapOpenAI;
|
|
|
7564
7636
|
declare const braintrust_wrapOpenAIv4: typeof wrapOpenAIv4;
|
|
7565
7637
|
declare const braintrust_wrapTraced: typeof wrapTraced;
|
|
7566
7638
|
declare namespace braintrust {
|
|
7567
|
-
export { braintrust_AISpanProcessor as AISpanProcessor, type braintrust_AnyDataset as AnyDataset, braintrust_Attachment as Attachment, type braintrust_AttachmentParams as AttachmentParams, type braintrust_BackgroundLoggerOpts as BackgroundLoggerOpts, braintrust_BaseAttachment as BaseAttachment, braintrust_BaseExperiment as BaseExperiment, type braintrust_BaseMetadata as BaseMetadata, braintrust_BraintrustExporter as BraintrustExporter, braintrust_BraintrustSpanProcessor as BraintrustSpanProcessor, braintrust_BraintrustState as BraintrustState, braintrust_BraintrustStream as BraintrustStream, type braintrust_BraintrustStreamChunk as BraintrustStreamChunk, type braintrust_ChatPrompt as ChatPrompt, braintrust_CodeFunction as CodeFunction, type braintrust_CodeOpts as CodeOpts, braintrust_CodePrompt as CodePrompt, type braintrust_CompiledPrompt as CompiledPrompt, type braintrust_CompiledPromptParams as CompiledPromptParams, type braintrust_CompletionPrompt as CompletionPrompt, type braintrust_CreateProjectOpts as CreateProjectOpts, type braintrust_DataSummary as DataSummary, braintrust_Dataset as Dataset, type braintrust_DatasetSummary as DatasetSummary, type braintrust_DefaultMetadataType as DefaultMetadataType, type braintrust_DefaultPromptArgs as DefaultPromptArgs, braintrust_ERR_PERMALINK as ERR_PERMALINK, type braintrust_EndSpanArgs as EndSpanArgs, braintrust_Eval as Eval, type braintrust_EvalCase as EvalCase, type braintrust_EvalHooks as EvalHooks, type braintrust_EvalResult as EvalResult, braintrust_EvalResultWithSummary as EvalResultWithSummary, type braintrust_EvalScorer as EvalScorer, type braintrust_EvalScorerArgs as EvalScorerArgs, type braintrust_EvalTask as EvalTask, type braintrust_Evaluator as Evaluator, type braintrust_EvaluatorDef as EvaluatorDef, type braintrust_EvaluatorFile as EvaluatorFile, braintrust_Experiment as Experiment, type braintrust_ExperimentSummary as ExperimentSummary, type braintrust_Exportable as Exportable, braintrust_ExternalAttachment as ExternalAttachment, type braintrust_ExternalAttachmentParams as ExternalAttachmentParams, braintrust_FailedHTTPResponse as FailedHTTPResponse, type braintrust_FullInitOptions as FullInitOptions, type braintrust_FullLoginOptions as FullLoginOptions, type braintrust_FunctionEvent as FunctionEvent, braintrust_INTERNAL_BTQL_LIMIT as INTERNAL_BTQL_LIMIT, type braintrust_InitOptions as InitOptions, type braintrust_InvokeFunctionArgs as InvokeFunctionArgs, type braintrust_InvokeReturn as InvokeReturn, braintrust_LEGACY_CACHED_HEADER as LEGACY_CACHED_HEADER, braintrust_LazyValue as LazyValue, type braintrust_LogOptions as LogOptions, braintrust_Logger as Logger, type braintrust_LoginOptions as LoginOptions, type braintrust_MetricSummary as MetricSummary, braintrust_NOOP_SPAN as NOOP_SPAN, braintrust_NOOP_SPAN_PERMALINK as NOOP_SPAN_PERMALINK, braintrust_NoopSpan as NoopSpan, type braintrust_ObjectMetadata as ObjectMetadata, braintrust_Project as Project, braintrust_ProjectNameIdMap as ProjectNameIdMap, type braintrust_PromiseUnless as PromiseUnless, braintrust_Prompt as Prompt, braintrust_PromptBuilder as PromptBuilder, type braintrust_PromptContents as PromptContents, type braintrust_PromptDefinition as PromptDefinition, type braintrust_PromptDefinitionWithTools as PromptDefinitionWithTools, type braintrust_PromptOpts as PromptOpts, type braintrust_PromptRowWithId as PromptRowWithId, braintrust_ReadonlyAttachment as ReadonlyAttachment, braintrust_ReadonlyExperiment as ReadonlyExperiment, braintrust_Reporter as Reporter, type braintrust_ReporterBody as ReporterBody, type braintrust_ScoreSummary as ScoreSummary, braintrust_ScorerBuilder as ScorerBuilder, type braintrust_ScorerOpts as ScorerOpts, type braintrust_SerializedBraintrustState as SerializedBraintrustState, type braintrust_SetCurrentArg as SetCurrentArg, type Span$1 as Span, type braintrust_SpanContext as SpanContext, braintrust_SpanImpl as SpanImpl, type braintrust_StartSpanArgs as StartSpanArgs, braintrust_TestBackgroundLogger as TestBackgroundLogger, braintrust_ToolBuilder as ToolBuilder, type braintrust_WithTransactionId as WithTransactionId, braintrust_X_CACHED_HEADER as X_CACHED_HEADER, braintrust__exportsForTestingOnly as _exportsForTestingOnly, braintrust__internalGetGlobalState as _internalGetGlobalState, braintrust__internalSetInitialState as _internalSetInitialState, braintrust_braintrustStreamChunkSchema as braintrustStreamChunkSchema, braintrust_buildLocalSummary as buildLocalSummary, braintrust_createFinalValuePassThroughStream as createFinalValuePassThroughStream, braintrust_currentExperiment as currentExperiment, braintrust_currentLogger as currentLogger, braintrust_currentSpan as currentSpan, braintrust_defaultErrorScoreHandler as defaultErrorScoreHandler, braintrust_deserializePlainStringAsJSON as deserializePlainStringAsJSON, braintrust_devNullWritableStream as devNullWritableStream, braintrust_flush as flush, braintrust_getSpanParentObject as getSpanParentObject, graphFramework as graph, braintrust_init as init, braintrust_initDataset as initDataset, braintrust_initExperiment as initExperiment, braintrust_initFunction as initFunction, braintrust_initLogger as initLogger, braintrust_invoke as invoke, braintrust_loadPrompt as loadPrompt, braintrust_log as log, braintrust_logError as logError, braintrust_login as login, braintrust_loginToState as loginToState, braintrust_newId as newId, braintrust_parseCachedHeader as parseCachedHeader, braintrust_permalink as permalink, braintrust_projects as projects, braintrust_promptContentsSchema as promptContentsSchema, braintrust_promptDefinitionSchema as promptDefinitionSchema, braintrust_promptDefinitionToPromptData as promptDefinitionToPromptData, braintrust_promptDefinitionWithToolsSchema as promptDefinitionWithToolsSchema, braintrust_renderMessage as renderMessage, braintrust_renderPromptParams as renderPromptParams, braintrust_reportFailures as reportFailures, braintrust_runEvaluator as runEvaluator, braintrust_setFetch as setFetch, braintrust_spanComponentsToObjectId as spanComponentsToObjectId, braintrust_startSpan as startSpan, braintrust_summarize as summarize, braintrust_toolFunctionDefinitionSchema as toolFunctionDefinitionSchema, braintrust_traceable as traceable, braintrust_traced as traced, braintrust_updateSpan as updateSpan, braintrust_withCurrent as withCurrent, braintrust_withDataset as withDataset, braintrust_withExperiment as withExperiment, braintrust_withLogger as withLogger, braintrust_withParent as withParent, braintrust_wrapAISDKModel as wrapAISDKModel, braintrust_wrapAnthropic as wrapAnthropic, braintrust_wrapOpenAI as wrapOpenAI, braintrust_wrapOpenAIv4 as wrapOpenAIv4, braintrust_wrapTraced as wrapTraced };
|
|
7639
|
+
export { braintrust_AISpanProcessor as AISpanProcessor, type braintrust_AnyDataset as AnyDataset, braintrust_Attachment as Attachment, type braintrust_AttachmentParams as AttachmentParams, type braintrust_BackgroundLoggerOpts as BackgroundLoggerOpts, braintrust_BaseAttachment as BaseAttachment, braintrust_BaseExperiment as BaseExperiment, type braintrust_BaseMetadata as BaseMetadata, braintrust_BraintrustExporter as BraintrustExporter, braintrust_BraintrustMiddleware as BraintrustMiddleware, braintrust_BraintrustSpanProcessor as BraintrustSpanProcessor, braintrust_BraintrustState as BraintrustState, braintrust_BraintrustStream as BraintrustStream, type braintrust_BraintrustStreamChunk as BraintrustStreamChunk, type braintrust_ChatPrompt as ChatPrompt, braintrust_CodeFunction as CodeFunction, type braintrust_CodeOpts as CodeOpts, braintrust_CodePrompt as CodePrompt, type braintrust_CompiledPrompt as CompiledPrompt, type braintrust_CompiledPromptParams as CompiledPromptParams, type braintrust_CompletionPrompt as CompletionPrompt, type braintrust_CreateProjectOpts as CreateProjectOpts, type braintrust_DataSummary as DataSummary, braintrust_Dataset as Dataset, type braintrust_DatasetSummary as DatasetSummary, type braintrust_DefaultMetadataType as DefaultMetadataType, type braintrust_DefaultPromptArgs as DefaultPromptArgs, braintrust_ERR_PERMALINK as ERR_PERMALINK, type braintrust_EndSpanArgs as EndSpanArgs, braintrust_Eval as Eval, type braintrust_EvalCase as EvalCase, type braintrust_EvalHooks as EvalHooks, type braintrust_EvalResult as EvalResult, braintrust_EvalResultWithSummary as EvalResultWithSummary, type braintrust_EvalScorer as EvalScorer, type braintrust_EvalScorerArgs as EvalScorerArgs, type braintrust_EvalTask as EvalTask, type braintrust_Evaluator as Evaluator, type braintrust_EvaluatorDef as EvaluatorDef, type braintrust_EvaluatorFile as EvaluatorFile, braintrust_Experiment as Experiment, type braintrust_ExperimentSummary as ExperimentSummary, type braintrust_Exportable as Exportable, braintrust_ExternalAttachment as ExternalAttachment, type braintrust_ExternalAttachmentParams as ExternalAttachmentParams, braintrust_FailedHTTPResponse as FailedHTTPResponse, type braintrust_FullInitOptions as FullInitOptions, type braintrust_FullLoginOptions as FullLoginOptions, type braintrust_FunctionEvent as FunctionEvent, braintrust_INTERNAL_BTQL_LIMIT as INTERNAL_BTQL_LIMIT, type braintrust_InitOptions as InitOptions, type braintrust_InvokeFunctionArgs as InvokeFunctionArgs, type braintrust_InvokeReturn as InvokeReturn, braintrust_LEGACY_CACHED_HEADER as LEGACY_CACHED_HEADER, braintrust_LazyValue as LazyValue, type braintrust_LogOptions as LogOptions, braintrust_Logger as Logger, type braintrust_LoginOptions as LoginOptions, type braintrust_MetricSummary as MetricSummary, braintrust_NOOP_SPAN as NOOP_SPAN, braintrust_NOOP_SPAN_PERMALINK as NOOP_SPAN_PERMALINK, braintrust_NoopSpan as NoopSpan, type braintrust_ObjectMetadata as ObjectMetadata, braintrust_Project as Project, braintrust_ProjectNameIdMap as ProjectNameIdMap, type braintrust_PromiseUnless as PromiseUnless, braintrust_Prompt as Prompt, braintrust_PromptBuilder as PromptBuilder, type braintrust_PromptContents as PromptContents, type braintrust_PromptDefinition as PromptDefinition, type braintrust_PromptDefinitionWithTools as PromptDefinitionWithTools, type braintrust_PromptOpts as PromptOpts, type braintrust_PromptRowWithId as PromptRowWithId, braintrust_ReadonlyAttachment as ReadonlyAttachment, braintrust_ReadonlyExperiment as ReadonlyExperiment, braintrust_Reporter as Reporter, type braintrust_ReporterBody as ReporterBody, type braintrust_ScoreSummary as ScoreSummary, braintrust_ScorerBuilder as ScorerBuilder, type braintrust_ScorerOpts as ScorerOpts, type braintrust_SerializedBraintrustState as SerializedBraintrustState, type braintrust_SetCurrentArg as SetCurrentArg, type Span$1 as Span, type braintrust_SpanContext as SpanContext, braintrust_SpanImpl as SpanImpl, type braintrust_StartSpanArgs as StartSpanArgs, braintrust_TestBackgroundLogger as TestBackgroundLogger, braintrust_ToolBuilder as ToolBuilder, type braintrust_WithTransactionId as WithTransactionId, braintrust_X_CACHED_HEADER as X_CACHED_HEADER, braintrust__exportsForTestingOnly as _exportsForTestingOnly, braintrust__internalGetGlobalState as _internalGetGlobalState, braintrust__internalSetInitialState as _internalSetInitialState, braintrust_braintrustStreamChunkSchema as braintrustStreamChunkSchema, braintrust_buildLocalSummary as buildLocalSummary, braintrust_createFinalValuePassThroughStream as createFinalValuePassThroughStream, braintrust_currentExperiment as currentExperiment, braintrust_currentLogger as currentLogger, braintrust_currentSpan as currentSpan, braintrust_defaultErrorScoreHandler as defaultErrorScoreHandler, braintrust_deserializePlainStringAsJSON as deserializePlainStringAsJSON, braintrust_devNullWritableStream as devNullWritableStream, braintrust_flush as flush, braintrust_getSpanParentObject as getSpanParentObject, graphFramework as graph, braintrust_init as init, braintrust_initDataset as initDataset, braintrust_initExperiment as initExperiment, braintrust_initFunction as initFunction, braintrust_initLogger as initLogger, braintrust_invoke as invoke, braintrust_loadPrompt as loadPrompt, braintrust_log as log, braintrust_logError as logError, braintrust_login as login, braintrust_loginToState as loginToState, braintrust_newId as newId, braintrust_parseCachedHeader as parseCachedHeader, braintrust_permalink as permalink, braintrust_projects as projects, braintrust_promptContentsSchema as promptContentsSchema, braintrust_promptDefinitionSchema as promptDefinitionSchema, braintrust_promptDefinitionToPromptData as promptDefinitionToPromptData, braintrust_promptDefinitionWithToolsSchema as promptDefinitionWithToolsSchema, braintrust_renderMessage as renderMessage, braintrust_renderPromptParams as renderPromptParams, braintrust_reportFailures as reportFailures, braintrust_runEvaluator as runEvaluator, braintrust_setFetch as setFetch, braintrust_spanComponentsToObjectId as spanComponentsToObjectId, braintrust_startSpan as startSpan, braintrust_summarize as summarize, braintrust_toolFunctionDefinitionSchema as toolFunctionDefinitionSchema, braintrust_traceable as traceable, braintrust_traced as traced, braintrust_updateSpan as updateSpan, braintrust_withCurrent as withCurrent, braintrust_withDataset as withDataset, braintrust_withExperiment as withExperiment, braintrust_withLogger as withLogger, braintrust_withParent as withParent, braintrust_wrapAISDKModel as wrapAISDKModel, braintrust_wrapAnthropic as wrapAnthropic, braintrust_wrapOpenAI as wrapOpenAI, braintrust_wrapOpenAIv4 as wrapOpenAIv4, braintrust_wrapTraced as wrapTraced };
|
|
7568
7640
|
}
|
|
7569
7641
|
|
|
7570
7642
|
type EvaluatorManifest = Record<string, EvaluatorDef<unknown, unknown, unknown, BaseMetadata>>;
|
|
@@ -14792,4 +14864,4 @@ type EvaluatorDefinitions = z.infer<typeof evaluatorDefinitionsSchema>;
|
|
|
14792
14864
|
* @module braintrust
|
|
14793
14865
|
*/
|
|
14794
14866
|
|
|
14795
|
-
export { AISpanProcessor, type AnyDataset, Attachment, type AttachmentParams, type BackgroundLoggerOpts, BaseAttachment, BaseExperiment, type BaseMetadata, BraintrustExporter, BraintrustSpanProcessor, BraintrustState, BraintrustStream, type BraintrustStreamChunk, type ChatPrompt, CodeFunction, type CodeOpts, CodePrompt, type CompiledPrompt, type CompiledPromptParams, type CompletionPrompt, type CreateProjectOpts, type DataSummary, Dataset, type DatasetSummary, type DefaultMetadataType, type DefaultPromptArgs, ERR_PERMALINK, type EndSpanArgs, Eval, type EvalCase, type EvalHooks, type EvalParameterSerializedSchema, type EvalParameters, type EvalResult, EvalResultWithSummary, type EvalScorer, type EvalScorerArgs, type EvalTask, type Evaluator, type EvaluatorDef, type EvaluatorDefinition, type EvaluatorDefinitions, type EvaluatorFile, type EvaluatorManifest, Experiment, type ExperimentSummary, type Exportable, ExternalAttachment, type ExternalAttachmentParams, FailedHTTPResponse, type FullInitOptions, type FullLoginOptions, type FunctionEvent, INTERNAL_BTQL_LIMIT, type InitOptions, type InvokeFunctionArgs, type InvokeReturn, LEGACY_CACHED_HEADER, LazyValue, type LogOptions, Logger, type LoginOptions, type MetricSummary, NOOP_SPAN, NOOP_SPAN_PERMALINK, NoopSpan, type ObjectMetadata, Project, ProjectNameIdMap, type PromiseUnless, Prompt, PromptBuilder, type PromptContents, type PromptDefinition, type PromptDefinitionWithTools, type PromptOpts, type PromptRowWithId, ReadonlyAttachment, ReadonlyExperiment, Reporter, type ReporterBody, type ScoreSummary, ScorerBuilder, type ScorerOpts, type SerializedBraintrustState, type SetCurrentArg, type Span$1 as Span, type SpanContext, SpanImpl, type StartSpanArgs, TestBackgroundLogger, ToolBuilder, type WithTransactionId, X_CACHED_HEADER, _exportsForTestingOnly, _internalGetGlobalState, _internalSetInitialState, braintrustStreamChunkSchema, buildLocalSummary, createFinalValuePassThroughStream, currentExperiment, currentLogger, currentSpan, braintrust as default, defaultErrorScoreHandler, deserializePlainStringAsJSON, devNullWritableStream, evaluatorDefinitionSchema, evaluatorDefinitionsSchema, flush, getSpanParentObject, graphFramework as graph, init, initDataset, initExperiment, initFunction, initLogger, invoke, loadPrompt, log, logError, login, loginToState, newId, parseCachedHeader, permalink, projects, promptContentsSchema, promptDefinitionSchema, promptDefinitionToPromptData, promptDefinitionWithToolsSchema, renderMessage, renderPromptParams, reportFailures, runEvaluator, setFetch, spanComponentsToObjectId, startSpan, summarize, traceable, traced, updateSpan, withCurrent, withDataset, withExperiment, withLogger, withParent, wrapAISDKModel, wrapAnthropic, wrapOpenAI, wrapOpenAIv4, wrapTraced };
|
|
14867
|
+
export { AISpanProcessor, type AnyDataset, Attachment, type AttachmentParams, type BackgroundLoggerOpts, BaseAttachment, BaseExperiment, type BaseMetadata, BraintrustExporter, BraintrustMiddleware, BraintrustSpanProcessor, BraintrustState, BraintrustStream, type BraintrustStreamChunk, type ChatPrompt, CodeFunction, type CodeOpts, CodePrompt, type CompiledPrompt, type CompiledPromptParams, type CompletionPrompt, type CreateProjectOpts, type DataSummary, Dataset, type DatasetSummary, type DefaultMetadataType, type DefaultPromptArgs, ERR_PERMALINK, type EndSpanArgs, Eval, type EvalCase, type EvalHooks, type EvalParameterSerializedSchema, type EvalParameters, type EvalResult, EvalResultWithSummary, type EvalScorer, type EvalScorerArgs, type EvalTask, type Evaluator, type EvaluatorDef, type EvaluatorDefinition, type EvaluatorDefinitions, type EvaluatorFile, type EvaluatorManifest, Experiment, type ExperimentSummary, type Exportable, ExternalAttachment, type ExternalAttachmentParams, FailedHTTPResponse, type FullInitOptions, type FullLoginOptions, type FunctionEvent, INTERNAL_BTQL_LIMIT, type InitOptions, type InvokeFunctionArgs, type InvokeReturn, LEGACY_CACHED_HEADER, LazyValue, type LogOptions, Logger, type LoginOptions, type MetricSummary, NOOP_SPAN, NOOP_SPAN_PERMALINK, NoopSpan, type ObjectMetadata, Project, ProjectNameIdMap, type PromiseUnless, Prompt, PromptBuilder, type PromptContents, type PromptDefinition, type PromptDefinitionWithTools, type PromptOpts, type PromptRowWithId, ReadonlyAttachment, ReadonlyExperiment, Reporter, type ReporterBody, type ScoreSummary, ScorerBuilder, type ScorerOpts, type SerializedBraintrustState, type SetCurrentArg, type Span$1 as Span, type SpanContext, SpanImpl, type StartSpanArgs, TestBackgroundLogger, ToolBuilder, type WithTransactionId, X_CACHED_HEADER, _exportsForTestingOnly, _internalGetGlobalState, _internalSetInitialState, braintrustStreamChunkSchema, buildLocalSummary, createFinalValuePassThroughStream, currentExperiment, currentLogger, currentSpan, braintrust as default, defaultErrorScoreHandler, deserializePlainStringAsJSON, devNullWritableStream, evaluatorDefinitionSchema, evaluatorDefinitionsSchema, flush, getSpanParentObject, graphFramework as graph, init, initDataset, initExperiment, initFunction, initLogger, invoke, loadPrompt, log, logError, login, loginToState, newId, parseCachedHeader, permalink, projects, promptContentsSchema, promptDefinitionSchema, promptDefinitionToPromptData, promptDefinitionWithToolsSchema, renderMessage, renderPromptParams, reportFailures, runEvaluator, setFetch, spanComponentsToObjectId, startSpan, summarize, traceable, traced, updateSpan, withCurrent, withDataset, withExperiment, withLogger, withParent, wrapAISDKModel, wrapAnthropic, wrapOpenAI, wrapOpenAIv4, wrapTraced };
|