braintrust 0.0.159 → 0.0.161
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/dist/browser.d.mts +37 -8
- package/dist/browser.d.ts +37 -8
- package/dist/browser.js +28 -3
- package/dist/browser.mjs +28 -3
- package/dist/cli.js +24 -6
- package/dist/index.d.mts +37 -8
- package/dist/index.d.ts +37 -8
- package/dist/index.js +28 -3
- package/dist/index.mjs +28 -3
- package/package.json +2 -2
package/dist/browser.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GitMetadataSettings, LogFeedbackFullArgs, ExperimentEvent, BackgroundLogEvent, ExperimentLogFullArgs, ExperimentLogPartialArgs, IdField, SpanType, RepoInfo, DEFAULT_IS_LEGACY_DATASET, TRANSACTION_ID_FIELD, TransactionId, SpanObjectTypeV3, DatasetRecord } from '@braintrust/core';
|
|
1
|
+
import { GitMetadataSettings, LogFeedbackFullArgs, ExperimentEvent, BackgroundLogEvent, ExperimentLogFullArgs, ExperimentLogPartialArgs, IdField, SpanType, SpanComponentsV3, RepoInfo, DEFAULT_IS_LEGACY_DATASET, TRANSACTION_ID_FIELD, TransactionId, SpanObjectTypeV3, DatasetRecord } from '@braintrust/core';
|
|
2
2
|
import { PromptData, OpenAIMessage, Tools, AnyModelParam, Message, Prompt as Prompt$1, PromptSessionEvent, StreamingMode } from '@braintrust/core/typespecs';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
@@ -274,6 +274,10 @@ interface ParentSpanIds {
|
|
|
274
274
|
spanId: string;
|
|
275
275
|
rootSpanId: string;
|
|
276
276
|
}
|
|
277
|
+
declare function spanComponentsToObjectId({ components, state, }: {
|
|
278
|
+
components: SpanComponentsV3;
|
|
279
|
+
state?: BraintrustState;
|
|
280
|
+
}): Promise<string>;
|
|
277
281
|
declare class Logger<IsAsyncFlush extends boolean> implements Exportable {
|
|
278
282
|
private state;
|
|
279
283
|
private lazyMetadata;
|
|
@@ -1125,6 +1129,30 @@ declare const braintrustStreamChunkSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
1125
1129
|
}, {
|
|
1126
1130
|
data: string;
|
|
1127
1131
|
type: "error";
|
|
1132
|
+
}>, z.ZodObject<{
|
|
1133
|
+
type: z.ZodLiteral<"console">;
|
|
1134
|
+
data: z.ZodObject<{
|
|
1135
|
+
stream: z.ZodEnum<["stderr", "stdout"]>;
|
|
1136
|
+
message: z.ZodString;
|
|
1137
|
+
}, "strip", z.ZodTypeAny, {
|
|
1138
|
+
message: string;
|
|
1139
|
+
stream: "stderr" | "stdout";
|
|
1140
|
+
}, {
|
|
1141
|
+
message: string;
|
|
1142
|
+
stream: "stderr" | "stdout";
|
|
1143
|
+
}>;
|
|
1144
|
+
}, "strip", z.ZodTypeAny, {
|
|
1145
|
+
data: {
|
|
1146
|
+
message: string;
|
|
1147
|
+
stream: "stderr" | "stdout";
|
|
1148
|
+
};
|
|
1149
|
+
type: "console";
|
|
1150
|
+
}, {
|
|
1151
|
+
data: {
|
|
1152
|
+
message: string;
|
|
1153
|
+
stream: "stderr" | "stdout";
|
|
1154
|
+
};
|
|
1155
|
+
type: "console";
|
|
1128
1156
|
}>, z.ZodObject<{
|
|
1129
1157
|
type: z.ZodLiteral<"progress">;
|
|
1130
1158
|
data: z.ZodObject<{
|
|
@@ -1133,7 +1161,7 @@ declare const braintrustStreamChunkSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
1133
1161
|
format: z.ZodEnum<["llm", "code", "global"]>;
|
|
1134
1162
|
output_type: z.ZodEnum<["completion", "score", "any"]>;
|
|
1135
1163
|
name: z.ZodString;
|
|
1136
|
-
event: z.ZodEnum<["text_delta", "json_delta", "error", "start", "done"]>;
|
|
1164
|
+
event: z.ZodEnum<["text_delta", "json_delta", "error", "console", "start", "done"]>;
|
|
1137
1165
|
data: z.ZodString;
|
|
1138
1166
|
}, "strip", z.ZodTypeAny, {
|
|
1139
1167
|
format: "code" | "global" | "llm";
|
|
@@ -1141,7 +1169,7 @@ declare const braintrustStreamChunkSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
1141
1169
|
name: string;
|
|
1142
1170
|
id: string;
|
|
1143
1171
|
object_type: "prompt" | "tool" | "scorer" | "task";
|
|
1144
|
-
event: "error" | "text_delta" | "json_delta" | "start" | "done";
|
|
1172
|
+
event: "error" | "text_delta" | "json_delta" | "console" | "start" | "done";
|
|
1145
1173
|
output_type: "completion" | "score" | "any";
|
|
1146
1174
|
}, {
|
|
1147
1175
|
format: "code" | "global" | "llm";
|
|
@@ -1149,7 +1177,7 @@ declare const braintrustStreamChunkSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
1149
1177
|
name: string;
|
|
1150
1178
|
id: string;
|
|
1151
1179
|
object_type: "prompt" | "tool" | "scorer" | "task";
|
|
1152
|
-
event: "error" | "text_delta" | "json_delta" | "start" | "done";
|
|
1180
|
+
event: "error" | "text_delta" | "json_delta" | "console" | "start" | "done";
|
|
1153
1181
|
output_type: "completion" | "score" | "any";
|
|
1154
1182
|
}>;
|
|
1155
1183
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -1159,7 +1187,7 @@ declare const braintrustStreamChunkSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
1159
1187
|
name: string;
|
|
1160
1188
|
id: string;
|
|
1161
1189
|
object_type: "prompt" | "tool" | "scorer" | "task";
|
|
1162
|
-
event: "error" | "text_delta" | "json_delta" | "start" | "done";
|
|
1190
|
+
event: "error" | "text_delta" | "json_delta" | "console" | "start" | "done";
|
|
1163
1191
|
output_type: "completion" | "score" | "any";
|
|
1164
1192
|
};
|
|
1165
1193
|
type: "progress";
|
|
@@ -1170,7 +1198,7 @@ declare const braintrustStreamChunkSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
1170
1198
|
name: string;
|
|
1171
1199
|
id: string;
|
|
1172
1200
|
object_type: "prompt" | "tool" | "scorer" | "task";
|
|
1173
|
-
event: "error" | "text_delta" | "json_delta" | "start" | "done";
|
|
1201
|
+
event: "error" | "text_delta" | "json_delta" | "console" | "start" | "done";
|
|
1174
1202
|
output_type: "completion" | "score" | "any";
|
|
1175
1203
|
};
|
|
1176
1204
|
type: "progress";
|
|
@@ -1455,6 +1483,7 @@ declare const braintrust_newId: typeof newId;
|
|
|
1455
1483
|
declare const braintrust_parseCachedHeader: typeof parseCachedHeader;
|
|
1456
1484
|
declare const braintrust_renderMessage: typeof renderMessage;
|
|
1457
1485
|
declare const braintrust_setFetch: typeof setFetch;
|
|
1486
|
+
declare const braintrust_spanComponentsToObjectId: typeof spanComponentsToObjectId;
|
|
1458
1487
|
declare const braintrust_startSpan: typeof startSpan;
|
|
1459
1488
|
declare const braintrust_summarize: typeof summarize;
|
|
1460
1489
|
declare const braintrust_traceable: typeof traceable;
|
|
@@ -1468,7 +1497,7 @@ declare const braintrust_wrapOpenAI: typeof wrapOpenAI;
|
|
|
1468
1497
|
declare const braintrust_wrapOpenAIv4: typeof wrapOpenAIv4;
|
|
1469
1498
|
declare const braintrust_wrapTraced: typeof wrapTraced;
|
|
1470
1499
|
declare namespace braintrust {
|
|
1471
|
-
export { type braintrust_AnyDataset as AnyDataset, type braintrust_BackgroundLoggerOpts as BackgroundLoggerOpts, type braintrust_BaseMetadata as BaseMetadata, braintrust_BraintrustState as BraintrustState, braintrust_BraintrustStream as BraintrustStream, type braintrust_BraintrustStreamChunk as BraintrustStreamChunk, type braintrust_ChatPrompt as ChatPrompt, type braintrust_CompiledPrompt as CompiledPrompt, type braintrust_CompiledPromptParams as CompiledPromptParams, type braintrust_CompletionPrompt as CompletionPrompt, type braintrust_DataSummary as DataSummary, braintrust_Dataset as Dataset, type braintrust_DatasetSummary as DatasetSummary, type braintrust_DefaultMetadataType as DefaultMetadataType, type braintrust_DefaultPromptArgs as DefaultPromptArgs, type braintrust_EndSpanArgs as EndSpanArgs, type braintrust_EvalCase as EvalCase, braintrust_Experiment as Experiment, type braintrust_ExperimentSummary as ExperimentSummary, type braintrust_Exportable as Exportable, braintrust_FailedHTTPResponse as FailedHTTPResponse, type braintrust_FullInitOptions as FullInitOptions, type braintrust_FullLoginOptions as FullLoginOptions, type braintrust_InitOptions as InitOptions, type braintrust_InvokeFunctionArgs as InvokeFunctionArgs, type braintrust_InvokeReturn as InvokeReturn, braintrust_LEGACY_CACHED_HEADER as LEGACY_CACHED_HEADER, 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_NoopSpan as NoopSpan, type braintrust_ObjectMetadata as ObjectMetadata, type braintrust_PromiseUnless as PromiseUnless, braintrust_Prompt as Prompt, type braintrust_PromptRowWithId as PromptRowWithId, braintrust_ReadonlyExperiment as ReadonlyExperiment, type braintrust_ScoreSummary as ScoreSummary, type braintrust_SerializedBraintrustState as SerializedBraintrustState, type braintrust_SetCurrentArg as SetCurrentArg, type braintrust_Span as Span, braintrust_SpanImpl as SpanImpl, type braintrust_StartSpanArgs as StartSpanArgs, type braintrust_WithTransactionId as WithTransactionId, braintrust_X_CACHED_HEADER as X_CACHED_HEADER, braintrust__internalGetGlobalState as _internalGetGlobalState, braintrust__internalSetInitialState as _internalSetInitialState, braintrust_braintrustStreamChunkSchema as braintrustStreamChunkSchema, braintrust_createFinalValuePassThroughStream as createFinalValuePassThroughStream, braintrust_currentExperiment as currentExperiment, braintrust_currentLogger as currentLogger, braintrust_currentSpan as currentSpan, braintrust_devNullWritableStream as devNullWritableStream, braintrust_flush as flush, braintrust_getSpanParentObject as getSpanParentObject, braintrust_init as init, braintrust_initDataset as initDataset, braintrust_initExperiment as initExperiment, 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_renderMessage as renderMessage, braintrust_setFetch as setFetch, braintrust_startSpan as startSpan, braintrust_summarize as summarize, 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_wrapOpenAI as wrapOpenAI, braintrust_wrapOpenAIv4 as wrapOpenAIv4, braintrust_wrapTraced as wrapTraced };
|
|
1500
|
+
export { type braintrust_AnyDataset as AnyDataset, type braintrust_BackgroundLoggerOpts as BackgroundLoggerOpts, type braintrust_BaseMetadata as BaseMetadata, braintrust_BraintrustState as BraintrustState, braintrust_BraintrustStream as BraintrustStream, type braintrust_BraintrustStreamChunk as BraintrustStreamChunk, type braintrust_ChatPrompt as ChatPrompt, type braintrust_CompiledPrompt as CompiledPrompt, type braintrust_CompiledPromptParams as CompiledPromptParams, type braintrust_CompletionPrompt as CompletionPrompt, type braintrust_DataSummary as DataSummary, braintrust_Dataset as Dataset, type braintrust_DatasetSummary as DatasetSummary, type braintrust_DefaultMetadataType as DefaultMetadataType, type braintrust_DefaultPromptArgs as DefaultPromptArgs, type braintrust_EndSpanArgs as EndSpanArgs, type braintrust_EvalCase as EvalCase, braintrust_Experiment as Experiment, type braintrust_ExperimentSummary as ExperimentSummary, type braintrust_Exportable as Exportable, braintrust_FailedHTTPResponse as FailedHTTPResponse, type braintrust_FullInitOptions as FullInitOptions, type braintrust_FullLoginOptions as FullLoginOptions, type braintrust_InitOptions as InitOptions, type braintrust_InvokeFunctionArgs as InvokeFunctionArgs, type braintrust_InvokeReturn as InvokeReturn, braintrust_LEGACY_CACHED_HEADER as LEGACY_CACHED_HEADER, 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_NoopSpan as NoopSpan, type braintrust_ObjectMetadata as ObjectMetadata, type braintrust_PromiseUnless as PromiseUnless, braintrust_Prompt as Prompt, type braintrust_PromptRowWithId as PromptRowWithId, braintrust_ReadonlyExperiment as ReadonlyExperiment, type braintrust_ScoreSummary as ScoreSummary, type braintrust_SerializedBraintrustState as SerializedBraintrustState, type braintrust_SetCurrentArg as SetCurrentArg, type braintrust_Span as Span, braintrust_SpanImpl as SpanImpl, type braintrust_StartSpanArgs as StartSpanArgs, type braintrust_WithTransactionId as WithTransactionId, braintrust_X_CACHED_HEADER as X_CACHED_HEADER, braintrust__internalGetGlobalState as _internalGetGlobalState, braintrust__internalSetInitialState as _internalSetInitialState, braintrust_braintrustStreamChunkSchema as braintrustStreamChunkSchema, braintrust_createFinalValuePassThroughStream as createFinalValuePassThroughStream, braintrust_currentExperiment as currentExperiment, braintrust_currentLogger as currentLogger, braintrust_currentSpan as currentSpan, braintrust_devNullWritableStream as devNullWritableStream, braintrust_flush as flush, braintrust_getSpanParentObject as getSpanParentObject, braintrust_init as init, braintrust_initDataset as initDataset, braintrust_initExperiment as initExperiment, 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_renderMessage as renderMessage, braintrust_setFetch as setFetch, braintrust_spanComponentsToObjectId as spanComponentsToObjectId, braintrust_startSpan as startSpan, braintrust_summarize as summarize, 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_wrapOpenAI as wrapOpenAI, braintrust_wrapOpenAIv4 as wrapOpenAIv4, braintrust_wrapTraced as wrapTraced };
|
|
1472
1501
|
}
|
|
1473
1502
|
|
|
1474
|
-
export { type AnyDataset, type BackgroundLoggerOpts, type BaseMetadata, BraintrustState, BraintrustStream, type BraintrustStreamChunk, type ChatPrompt, type CompiledPrompt, type CompiledPromptParams, type CompletionPrompt, type DataSummary, Dataset, type DatasetSummary, type DefaultMetadataType, type DefaultPromptArgs, type EndSpanArgs, type EvalCase, Experiment, type ExperimentSummary, type Exportable, FailedHTTPResponse, type FullInitOptions, type FullLoginOptions, type InitOptions, type InvokeFunctionArgs, type InvokeReturn, LEGACY_CACHED_HEADER, type LogOptions, Logger, type LoginOptions, type MetricSummary, NOOP_SPAN, NoopSpan, type ObjectMetadata, type PromiseUnless, Prompt, type PromptRowWithId, ReadonlyExperiment, type ScoreSummary, type SerializedBraintrustState, type SetCurrentArg, type Span, SpanImpl, type StartSpanArgs, type WithTransactionId, X_CACHED_HEADER, _internalGetGlobalState, _internalSetInitialState, braintrustStreamChunkSchema, createFinalValuePassThroughStream, currentExperiment, currentLogger, currentSpan, braintrust as default, devNullWritableStream, flush, getSpanParentObject, init, initDataset, initExperiment, initLogger, invoke, loadPrompt, log, logError, login, loginToState, newId, parseCachedHeader, renderMessage, setFetch, startSpan, summarize, traceable, traced, updateSpan, withCurrent, withDataset, withExperiment, withLogger, wrapOpenAI, wrapOpenAIv4, wrapTraced };
|
|
1503
|
+
export { type AnyDataset, type BackgroundLoggerOpts, type BaseMetadata, BraintrustState, BraintrustStream, type BraintrustStreamChunk, type ChatPrompt, type CompiledPrompt, type CompiledPromptParams, type CompletionPrompt, type DataSummary, Dataset, type DatasetSummary, type DefaultMetadataType, type DefaultPromptArgs, type EndSpanArgs, type EvalCase, Experiment, type ExperimentSummary, type Exportable, FailedHTTPResponse, type FullInitOptions, type FullLoginOptions, type InitOptions, type InvokeFunctionArgs, type InvokeReturn, LEGACY_CACHED_HEADER, type LogOptions, Logger, type LoginOptions, type MetricSummary, NOOP_SPAN, NoopSpan, type ObjectMetadata, type PromiseUnless, Prompt, type PromptRowWithId, ReadonlyExperiment, type ScoreSummary, type SerializedBraintrustState, type SetCurrentArg, type Span, SpanImpl, type StartSpanArgs, type WithTransactionId, X_CACHED_HEADER, _internalGetGlobalState, _internalSetInitialState, braintrustStreamChunkSchema, createFinalValuePassThroughStream, currentExperiment, currentLogger, currentSpan, braintrust as default, devNullWritableStream, flush, getSpanParentObject, init, initDataset, initExperiment, initLogger, invoke, loadPrompt, log, logError, login, loginToState, newId, parseCachedHeader, renderMessage, setFetch, spanComponentsToObjectId, startSpan, summarize, traceable, traced, updateSpan, withCurrent, withDataset, withExperiment, withLogger, wrapOpenAI, wrapOpenAIv4, wrapTraced };
|
package/dist/browser.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GitMetadataSettings, LogFeedbackFullArgs, ExperimentEvent, BackgroundLogEvent, ExperimentLogFullArgs, ExperimentLogPartialArgs, IdField, SpanType, RepoInfo, DEFAULT_IS_LEGACY_DATASET, TRANSACTION_ID_FIELD, TransactionId, SpanObjectTypeV3, DatasetRecord } from '@braintrust/core';
|
|
1
|
+
import { GitMetadataSettings, LogFeedbackFullArgs, ExperimentEvent, BackgroundLogEvent, ExperimentLogFullArgs, ExperimentLogPartialArgs, IdField, SpanType, SpanComponentsV3, RepoInfo, DEFAULT_IS_LEGACY_DATASET, TRANSACTION_ID_FIELD, TransactionId, SpanObjectTypeV3, DatasetRecord } from '@braintrust/core';
|
|
2
2
|
import { PromptData, OpenAIMessage, Tools, AnyModelParam, Message, Prompt as Prompt$1, PromptSessionEvent, StreamingMode } from '@braintrust/core/typespecs';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
@@ -274,6 +274,10 @@ interface ParentSpanIds {
|
|
|
274
274
|
spanId: string;
|
|
275
275
|
rootSpanId: string;
|
|
276
276
|
}
|
|
277
|
+
declare function spanComponentsToObjectId({ components, state, }: {
|
|
278
|
+
components: SpanComponentsV3;
|
|
279
|
+
state?: BraintrustState;
|
|
280
|
+
}): Promise<string>;
|
|
277
281
|
declare class Logger<IsAsyncFlush extends boolean> implements Exportable {
|
|
278
282
|
private state;
|
|
279
283
|
private lazyMetadata;
|
|
@@ -1125,6 +1129,30 @@ declare const braintrustStreamChunkSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
1125
1129
|
}, {
|
|
1126
1130
|
data: string;
|
|
1127
1131
|
type: "error";
|
|
1132
|
+
}>, z.ZodObject<{
|
|
1133
|
+
type: z.ZodLiteral<"console">;
|
|
1134
|
+
data: z.ZodObject<{
|
|
1135
|
+
stream: z.ZodEnum<["stderr", "stdout"]>;
|
|
1136
|
+
message: z.ZodString;
|
|
1137
|
+
}, "strip", z.ZodTypeAny, {
|
|
1138
|
+
message: string;
|
|
1139
|
+
stream: "stderr" | "stdout";
|
|
1140
|
+
}, {
|
|
1141
|
+
message: string;
|
|
1142
|
+
stream: "stderr" | "stdout";
|
|
1143
|
+
}>;
|
|
1144
|
+
}, "strip", z.ZodTypeAny, {
|
|
1145
|
+
data: {
|
|
1146
|
+
message: string;
|
|
1147
|
+
stream: "stderr" | "stdout";
|
|
1148
|
+
};
|
|
1149
|
+
type: "console";
|
|
1150
|
+
}, {
|
|
1151
|
+
data: {
|
|
1152
|
+
message: string;
|
|
1153
|
+
stream: "stderr" | "stdout";
|
|
1154
|
+
};
|
|
1155
|
+
type: "console";
|
|
1128
1156
|
}>, z.ZodObject<{
|
|
1129
1157
|
type: z.ZodLiteral<"progress">;
|
|
1130
1158
|
data: z.ZodObject<{
|
|
@@ -1133,7 +1161,7 @@ declare const braintrustStreamChunkSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
1133
1161
|
format: z.ZodEnum<["llm", "code", "global"]>;
|
|
1134
1162
|
output_type: z.ZodEnum<["completion", "score", "any"]>;
|
|
1135
1163
|
name: z.ZodString;
|
|
1136
|
-
event: z.ZodEnum<["text_delta", "json_delta", "error", "start", "done"]>;
|
|
1164
|
+
event: z.ZodEnum<["text_delta", "json_delta", "error", "console", "start", "done"]>;
|
|
1137
1165
|
data: z.ZodString;
|
|
1138
1166
|
}, "strip", z.ZodTypeAny, {
|
|
1139
1167
|
format: "code" | "global" | "llm";
|
|
@@ -1141,7 +1169,7 @@ declare const braintrustStreamChunkSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
1141
1169
|
name: string;
|
|
1142
1170
|
id: string;
|
|
1143
1171
|
object_type: "prompt" | "tool" | "scorer" | "task";
|
|
1144
|
-
event: "error" | "text_delta" | "json_delta" | "start" | "done";
|
|
1172
|
+
event: "error" | "text_delta" | "json_delta" | "console" | "start" | "done";
|
|
1145
1173
|
output_type: "completion" | "score" | "any";
|
|
1146
1174
|
}, {
|
|
1147
1175
|
format: "code" | "global" | "llm";
|
|
@@ -1149,7 +1177,7 @@ declare const braintrustStreamChunkSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
1149
1177
|
name: string;
|
|
1150
1178
|
id: string;
|
|
1151
1179
|
object_type: "prompt" | "tool" | "scorer" | "task";
|
|
1152
|
-
event: "error" | "text_delta" | "json_delta" | "start" | "done";
|
|
1180
|
+
event: "error" | "text_delta" | "json_delta" | "console" | "start" | "done";
|
|
1153
1181
|
output_type: "completion" | "score" | "any";
|
|
1154
1182
|
}>;
|
|
1155
1183
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -1159,7 +1187,7 @@ declare const braintrustStreamChunkSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
1159
1187
|
name: string;
|
|
1160
1188
|
id: string;
|
|
1161
1189
|
object_type: "prompt" | "tool" | "scorer" | "task";
|
|
1162
|
-
event: "error" | "text_delta" | "json_delta" | "start" | "done";
|
|
1190
|
+
event: "error" | "text_delta" | "json_delta" | "console" | "start" | "done";
|
|
1163
1191
|
output_type: "completion" | "score" | "any";
|
|
1164
1192
|
};
|
|
1165
1193
|
type: "progress";
|
|
@@ -1170,7 +1198,7 @@ declare const braintrustStreamChunkSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
1170
1198
|
name: string;
|
|
1171
1199
|
id: string;
|
|
1172
1200
|
object_type: "prompt" | "tool" | "scorer" | "task";
|
|
1173
|
-
event: "error" | "text_delta" | "json_delta" | "start" | "done";
|
|
1201
|
+
event: "error" | "text_delta" | "json_delta" | "console" | "start" | "done";
|
|
1174
1202
|
output_type: "completion" | "score" | "any";
|
|
1175
1203
|
};
|
|
1176
1204
|
type: "progress";
|
|
@@ -1455,6 +1483,7 @@ declare const braintrust_newId: typeof newId;
|
|
|
1455
1483
|
declare const braintrust_parseCachedHeader: typeof parseCachedHeader;
|
|
1456
1484
|
declare const braintrust_renderMessage: typeof renderMessage;
|
|
1457
1485
|
declare const braintrust_setFetch: typeof setFetch;
|
|
1486
|
+
declare const braintrust_spanComponentsToObjectId: typeof spanComponentsToObjectId;
|
|
1458
1487
|
declare const braintrust_startSpan: typeof startSpan;
|
|
1459
1488
|
declare const braintrust_summarize: typeof summarize;
|
|
1460
1489
|
declare const braintrust_traceable: typeof traceable;
|
|
@@ -1468,7 +1497,7 @@ declare const braintrust_wrapOpenAI: typeof wrapOpenAI;
|
|
|
1468
1497
|
declare const braintrust_wrapOpenAIv4: typeof wrapOpenAIv4;
|
|
1469
1498
|
declare const braintrust_wrapTraced: typeof wrapTraced;
|
|
1470
1499
|
declare namespace braintrust {
|
|
1471
|
-
export { type braintrust_AnyDataset as AnyDataset, type braintrust_BackgroundLoggerOpts as BackgroundLoggerOpts, type braintrust_BaseMetadata as BaseMetadata, braintrust_BraintrustState as BraintrustState, braintrust_BraintrustStream as BraintrustStream, type braintrust_BraintrustStreamChunk as BraintrustStreamChunk, type braintrust_ChatPrompt as ChatPrompt, type braintrust_CompiledPrompt as CompiledPrompt, type braintrust_CompiledPromptParams as CompiledPromptParams, type braintrust_CompletionPrompt as CompletionPrompt, type braintrust_DataSummary as DataSummary, braintrust_Dataset as Dataset, type braintrust_DatasetSummary as DatasetSummary, type braintrust_DefaultMetadataType as DefaultMetadataType, type braintrust_DefaultPromptArgs as DefaultPromptArgs, type braintrust_EndSpanArgs as EndSpanArgs, type braintrust_EvalCase as EvalCase, braintrust_Experiment as Experiment, type braintrust_ExperimentSummary as ExperimentSummary, type braintrust_Exportable as Exportable, braintrust_FailedHTTPResponse as FailedHTTPResponse, type braintrust_FullInitOptions as FullInitOptions, type braintrust_FullLoginOptions as FullLoginOptions, type braintrust_InitOptions as InitOptions, type braintrust_InvokeFunctionArgs as InvokeFunctionArgs, type braintrust_InvokeReturn as InvokeReturn, braintrust_LEGACY_CACHED_HEADER as LEGACY_CACHED_HEADER, 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_NoopSpan as NoopSpan, type braintrust_ObjectMetadata as ObjectMetadata, type braintrust_PromiseUnless as PromiseUnless, braintrust_Prompt as Prompt, type braintrust_PromptRowWithId as PromptRowWithId, braintrust_ReadonlyExperiment as ReadonlyExperiment, type braintrust_ScoreSummary as ScoreSummary, type braintrust_SerializedBraintrustState as SerializedBraintrustState, type braintrust_SetCurrentArg as SetCurrentArg, type braintrust_Span as Span, braintrust_SpanImpl as SpanImpl, type braintrust_StartSpanArgs as StartSpanArgs, type braintrust_WithTransactionId as WithTransactionId, braintrust_X_CACHED_HEADER as X_CACHED_HEADER, braintrust__internalGetGlobalState as _internalGetGlobalState, braintrust__internalSetInitialState as _internalSetInitialState, braintrust_braintrustStreamChunkSchema as braintrustStreamChunkSchema, braintrust_createFinalValuePassThroughStream as createFinalValuePassThroughStream, braintrust_currentExperiment as currentExperiment, braintrust_currentLogger as currentLogger, braintrust_currentSpan as currentSpan, braintrust_devNullWritableStream as devNullWritableStream, braintrust_flush as flush, braintrust_getSpanParentObject as getSpanParentObject, braintrust_init as init, braintrust_initDataset as initDataset, braintrust_initExperiment as initExperiment, 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_renderMessage as renderMessage, braintrust_setFetch as setFetch, braintrust_startSpan as startSpan, braintrust_summarize as summarize, 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_wrapOpenAI as wrapOpenAI, braintrust_wrapOpenAIv4 as wrapOpenAIv4, braintrust_wrapTraced as wrapTraced };
|
|
1500
|
+
export { type braintrust_AnyDataset as AnyDataset, type braintrust_BackgroundLoggerOpts as BackgroundLoggerOpts, type braintrust_BaseMetadata as BaseMetadata, braintrust_BraintrustState as BraintrustState, braintrust_BraintrustStream as BraintrustStream, type braintrust_BraintrustStreamChunk as BraintrustStreamChunk, type braintrust_ChatPrompt as ChatPrompt, type braintrust_CompiledPrompt as CompiledPrompt, type braintrust_CompiledPromptParams as CompiledPromptParams, type braintrust_CompletionPrompt as CompletionPrompt, type braintrust_DataSummary as DataSummary, braintrust_Dataset as Dataset, type braintrust_DatasetSummary as DatasetSummary, type braintrust_DefaultMetadataType as DefaultMetadataType, type braintrust_DefaultPromptArgs as DefaultPromptArgs, type braintrust_EndSpanArgs as EndSpanArgs, type braintrust_EvalCase as EvalCase, braintrust_Experiment as Experiment, type braintrust_ExperimentSummary as ExperimentSummary, type braintrust_Exportable as Exportable, braintrust_FailedHTTPResponse as FailedHTTPResponse, type braintrust_FullInitOptions as FullInitOptions, type braintrust_FullLoginOptions as FullLoginOptions, type braintrust_InitOptions as InitOptions, type braintrust_InvokeFunctionArgs as InvokeFunctionArgs, type braintrust_InvokeReturn as InvokeReturn, braintrust_LEGACY_CACHED_HEADER as LEGACY_CACHED_HEADER, 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_NoopSpan as NoopSpan, type braintrust_ObjectMetadata as ObjectMetadata, type braintrust_PromiseUnless as PromiseUnless, braintrust_Prompt as Prompt, type braintrust_PromptRowWithId as PromptRowWithId, braintrust_ReadonlyExperiment as ReadonlyExperiment, type braintrust_ScoreSummary as ScoreSummary, type braintrust_SerializedBraintrustState as SerializedBraintrustState, type braintrust_SetCurrentArg as SetCurrentArg, type braintrust_Span as Span, braintrust_SpanImpl as SpanImpl, type braintrust_StartSpanArgs as StartSpanArgs, type braintrust_WithTransactionId as WithTransactionId, braintrust_X_CACHED_HEADER as X_CACHED_HEADER, braintrust__internalGetGlobalState as _internalGetGlobalState, braintrust__internalSetInitialState as _internalSetInitialState, braintrust_braintrustStreamChunkSchema as braintrustStreamChunkSchema, braintrust_createFinalValuePassThroughStream as createFinalValuePassThroughStream, braintrust_currentExperiment as currentExperiment, braintrust_currentLogger as currentLogger, braintrust_currentSpan as currentSpan, braintrust_devNullWritableStream as devNullWritableStream, braintrust_flush as flush, braintrust_getSpanParentObject as getSpanParentObject, braintrust_init as init, braintrust_initDataset as initDataset, braintrust_initExperiment as initExperiment, 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_renderMessage as renderMessage, braintrust_setFetch as setFetch, braintrust_spanComponentsToObjectId as spanComponentsToObjectId, braintrust_startSpan as startSpan, braintrust_summarize as summarize, 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_wrapOpenAI as wrapOpenAI, braintrust_wrapOpenAIv4 as wrapOpenAIv4, braintrust_wrapTraced as wrapTraced };
|
|
1472
1501
|
}
|
|
1473
1502
|
|
|
1474
|
-
export { type AnyDataset, type BackgroundLoggerOpts, type BaseMetadata, BraintrustState, BraintrustStream, type BraintrustStreamChunk, type ChatPrompt, type CompiledPrompt, type CompiledPromptParams, type CompletionPrompt, type DataSummary, Dataset, type DatasetSummary, type DefaultMetadataType, type DefaultPromptArgs, type EndSpanArgs, type EvalCase, Experiment, type ExperimentSummary, type Exportable, FailedHTTPResponse, type FullInitOptions, type FullLoginOptions, type InitOptions, type InvokeFunctionArgs, type InvokeReturn, LEGACY_CACHED_HEADER, type LogOptions, Logger, type LoginOptions, type MetricSummary, NOOP_SPAN, NoopSpan, type ObjectMetadata, type PromiseUnless, Prompt, type PromptRowWithId, ReadonlyExperiment, type ScoreSummary, type SerializedBraintrustState, type SetCurrentArg, type Span, SpanImpl, type StartSpanArgs, type WithTransactionId, X_CACHED_HEADER, _internalGetGlobalState, _internalSetInitialState, braintrustStreamChunkSchema, createFinalValuePassThroughStream, currentExperiment, currentLogger, currentSpan, braintrust as default, devNullWritableStream, flush, getSpanParentObject, init, initDataset, initExperiment, initLogger, invoke, loadPrompt, log, logError, login, loginToState, newId, parseCachedHeader, renderMessage, setFetch, startSpan, summarize, traceable, traced, updateSpan, withCurrent, withDataset, withExperiment, withLogger, wrapOpenAI, wrapOpenAIv4, wrapTraced };
|
|
1503
|
+
export { type AnyDataset, type BackgroundLoggerOpts, type BaseMetadata, BraintrustState, BraintrustStream, type BraintrustStreamChunk, type ChatPrompt, type CompiledPrompt, type CompiledPromptParams, type CompletionPrompt, type DataSummary, Dataset, type DatasetSummary, type DefaultMetadataType, type DefaultPromptArgs, type EndSpanArgs, type EvalCase, Experiment, type ExperimentSummary, type Exportable, FailedHTTPResponse, type FullInitOptions, type FullLoginOptions, type InitOptions, type InvokeFunctionArgs, type InvokeReturn, LEGACY_CACHED_HEADER, type LogOptions, Logger, type LoginOptions, type MetricSummary, NOOP_SPAN, NoopSpan, type ObjectMetadata, type PromiseUnless, Prompt, type PromptRowWithId, ReadonlyExperiment, type ScoreSummary, type SerializedBraintrustState, type SetCurrentArg, type Span, SpanImpl, type StartSpanArgs, type WithTransactionId, X_CACHED_HEADER, _internalGetGlobalState, _internalSetInitialState, braintrustStreamChunkSchema, createFinalValuePassThroughStream, currentExperiment, currentLogger, currentSpan, braintrust as default, devNullWritableStream, flush, getSpanParentObject, init, initDataset, initExperiment, initLogger, invoke, loadPrompt, log, logError, login, loginToState, newId, parseCachedHeader, renderMessage, setFetch, spanComponentsToObjectId, startSpan, summarize, traceable, traced, updateSpan, withCurrent, withDataset, withExperiment, withLogger, wrapOpenAI, wrapOpenAIv4, wrapTraced };
|
package/dist/browser.js
CHANGED
|
@@ -68,6 +68,7 @@ __export(browser_exports, {
|
|
|
68
68
|
parseCachedHeader: () => parseCachedHeader,
|
|
69
69
|
renderMessage: () => renderMessage,
|
|
70
70
|
setFetch: () => setFetch,
|
|
71
|
+
spanComponentsToObjectId: () => spanComponentsToObjectId,
|
|
71
72
|
startSpan: () => startSpan,
|
|
72
73
|
summarize: () => summarize,
|
|
73
74
|
traceable: () => traceable,
|
|
@@ -179,6 +180,10 @@ var braintrustStreamChunkSchema = import_zod.z.union([
|
|
|
179
180
|
type: import_zod.z.literal("error"),
|
|
180
181
|
data: import_zod.z.string()
|
|
181
182
|
}),
|
|
183
|
+
import_zod.z.object({
|
|
184
|
+
type: import_zod.z.literal("console"),
|
|
185
|
+
data: import_typespecs.sseConsoleEventDataSchema
|
|
186
|
+
}),
|
|
182
187
|
import_zod.z.object({
|
|
183
188
|
type: import_zod.z.literal("progress"),
|
|
184
189
|
data: import_typespecs.sseProgressEventDataSchema
|
|
@@ -264,7 +269,7 @@ var BraintrustStream = class _BraintrustStream {
|
|
|
264
269
|
return this.memoizedFinalValue;
|
|
265
270
|
}
|
|
266
271
|
this.memoizedFinalValue = new Promise((resolve, reject) => {
|
|
267
|
-
|
|
272
|
+
this.stream.pipeThrough(createFinalValuePassThroughStream(resolve, reject)).pipeTo(devNullWritableStream());
|
|
268
273
|
});
|
|
269
274
|
return this.memoizedFinalValue;
|
|
270
275
|
}
|
|
@@ -298,7 +303,7 @@ function btStreamParser() {
|
|
|
298
303
|
case "error":
|
|
299
304
|
controller.enqueue({
|
|
300
305
|
type: "error",
|
|
301
|
-
data: event.data
|
|
306
|
+
data: JSON.parse(event.data)
|
|
302
307
|
});
|
|
303
308
|
break;
|
|
304
309
|
case "progress":
|
|
@@ -307,6 +312,12 @@ function btStreamParser() {
|
|
|
307
312
|
data: import_typespecs.sseProgressEventDataSchema.parse(JSON.parse(event.data))
|
|
308
313
|
});
|
|
309
314
|
break;
|
|
315
|
+
case "console":
|
|
316
|
+
controller.enqueue({
|
|
317
|
+
type: "console",
|
|
318
|
+
data: import_typespecs.sseConsoleEventDataSchema.parse(JSON.parse(event.data))
|
|
319
|
+
});
|
|
320
|
+
break;
|
|
310
321
|
case "start":
|
|
311
322
|
controller.enqueue({
|
|
312
323
|
type: "start",
|
|
@@ -373,6 +384,7 @@ function createFinalValuePassThroughStream(onFinal, onError) {
|
|
|
373
384
|
case "progress":
|
|
374
385
|
case "start":
|
|
375
386
|
case "done":
|
|
387
|
+
case "console":
|
|
376
388
|
break;
|
|
377
389
|
default:
|
|
378
390
|
const _type = chunkType;
|
|
@@ -586,7 +598,9 @@ var BraintrustState = class _BraintrustState {
|
|
|
586
598
|
}
|
|
587
599
|
const newState = await loginToState({
|
|
588
600
|
...this.loginParams,
|
|
589
|
-
...
|
|
601
|
+
...Object.fromEntries(
|
|
602
|
+
Object.entries(loginParams).filter(([k, v]) => !isEmpty(v))
|
|
603
|
+
)
|
|
590
604
|
});
|
|
591
605
|
this.copyLoginInfo(newState);
|
|
592
606
|
}
|
|
@@ -896,6 +910,15 @@ function spanComponentsToObjectIdLambda(state, components) {
|
|
|
896
910
|
throw new Error(`Unknown object type: ${x}`);
|
|
897
911
|
}
|
|
898
912
|
}
|
|
913
|
+
async function spanComponentsToObjectId({
|
|
914
|
+
components,
|
|
915
|
+
state
|
|
916
|
+
}) {
|
|
917
|
+
return await spanComponentsToObjectIdLambda(
|
|
918
|
+
state ?? _globalState,
|
|
919
|
+
components
|
|
920
|
+
)();
|
|
921
|
+
}
|
|
899
922
|
function startSpanParentArgs(args) {
|
|
900
923
|
let argParentObjectId = void 0;
|
|
901
924
|
let argParentSpanIds = void 0;
|
|
@@ -3216,6 +3239,7 @@ __export(exports_browser_exports, {
|
|
|
3216
3239
|
parseCachedHeader: () => parseCachedHeader,
|
|
3217
3240
|
renderMessage: () => renderMessage,
|
|
3218
3241
|
setFetch: () => setFetch,
|
|
3242
|
+
spanComponentsToObjectId: () => spanComponentsToObjectId,
|
|
3219
3243
|
startSpan: () => startSpan,
|
|
3220
3244
|
summarize: () => summarize,
|
|
3221
3245
|
traceable: () => traceable,
|
|
@@ -3719,6 +3743,7 @@ var browser_default = exports_browser_exports;
|
|
|
3719
3743
|
parseCachedHeader,
|
|
3720
3744
|
renderMessage,
|
|
3721
3745
|
setFetch,
|
|
3746
|
+
spanComponentsToObjectId,
|
|
3722
3747
|
startSpan,
|
|
3723
3748
|
summarize,
|
|
3724
3749
|
traceable,
|
package/dist/browser.mjs
CHANGED
|
@@ -110,6 +110,7 @@ import { z as z2 } from "zod";
|
|
|
110
110
|
// src/functions/stream.ts
|
|
111
111
|
import {
|
|
112
112
|
callEventSchema,
|
|
113
|
+
sseConsoleEventDataSchema,
|
|
113
114
|
sseProgressEventDataSchema
|
|
114
115
|
} from "@braintrust/core/typespecs";
|
|
115
116
|
import {
|
|
@@ -129,6 +130,10 @@ var braintrustStreamChunkSchema = z.union([
|
|
|
129
130
|
type: z.literal("error"),
|
|
130
131
|
data: z.string()
|
|
131
132
|
}),
|
|
133
|
+
z.object({
|
|
134
|
+
type: z.literal("console"),
|
|
135
|
+
data: sseConsoleEventDataSchema
|
|
136
|
+
}),
|
|
132
137
|
z.object({
|
|
133
138
|
type: z.literal("progress"),
|
|
134
139
|
data: sseProgressEventDataSchema
|
|
@@ -214,7 +219,7 @@ var BraintrustStream = class _BraintrustStream {
|
|
|
214
219
|
return this.memoizedFinalValue;
|
|
215
220
|
}
|
|
216
221
|
this.memoizedFinalValue = new Promise((resolve, reject) => {
|
|
217
|
-
|
|
222
|
+
this.stream.pipeThrough(createFinalValuePassThroughStream(resolve, reject)).pipeTo(devNullWritableStream());
|
|
218
223
|
});
|
|
219
224
|
return this.memoizedFinalValue;
|
|
220
225
|
}
|
|
@@ -248,7 +253,7 @@ function btStreamParser() {
|
|
|
248
253
|
case "error":
|
|
249
254
|
controller.enqueue({
|
|
250
255
|
type: "error",
|
|
251
|
-
data: event.data
|
|
256
|
+
data: JSON.parse(event.data)
|
|
252
257
|
});
|
|
253
258
|
break;
|
|
254
259
|
case "progress":
|
|
@@ -257,6 +262,12 @@ function btStreamParser() {
|
|
|
257
262
|
data: sseProgressEventDataSchema.parse(JSON.parse(event.data))
|
|
258
263
|
});
|
|
259
264
|
break;
|
|
265
|
+
case "console":
|
|
266
|
+
controller.enqueue({
|
|
267
|
+
type: "console",
|
|
268
|
+
data: sseConsoleEventDataSchema.parse(JSON.parse(event.data))
|
|
269
|
+
});
|
|
270
|
+
break;
|
|
260
271
|
case "start":
|
|
261
272
|
controller.enqueue({
|
|
262
273
|
type: "start",
|
|
@@ -323,6 +334,7 @@ function createFinalValuePassThroughStream(onFinal, onError) {
|
|
|
323
334
|
case "progress":
|
|
324
335
|
case "start":
|
|
325
336
|
case "done":
|
|
337
|
+
case "console":
|
|
326
338
|
break;
|
|
327
339
|
default:
|
|
328
340
|
const _type = chunkType;
|
|
@@ -536,7 +548,9 @@ var BraintrustState = class _BraintrustState {
|
|
|
536
548
|
}
|
|
537
549
|
const newState = await loginToState({
|
|
538
550
|
...this.loginParams,
|
|
539
|
-
...
|
|
551
|
+
...Object.fromEntries(
|
|
552
|
+
Object.entries(loginParams).filter(([k, v]) => !isEmpty(v))
|
|
553
|
+
)
|
|
540
554
|
});
|
|
541
555
|
this.copyLoginInfo(newState);
|
|
542
556
|
}
|
|
@@ -846,6 +860,15 @@ function spanComponentsToObjectIdLambda(state, components) {
|
|
|
846
860
|
throw new Error(`Unknown object type: ${x}`);
|
|
847
861
|
}
|
|
848
862
|
}
|
|
863
|
+
async function spanComponentsToObjectId({
|
|
864
|
+
components,
|
|
865
|
+
state
|
|
866
|
+
}) {
|
|
867
|
+
return await spanComponentsToObjectIdLambda(
|
|
868
|
+
state ?? _globalState,
|
|
869
|
+
components
|
|
870
|
+
)();
|
|
871
|
+
}
|
|
849
872
|
function startSpanParentArgs(args) {
|
|
850
873
|
let argParentObjectId = void 0;
|
|
851
874
|
let argParentSpanIds = void 0;
|
|
@@ -3166,6 +3189,7 @@ __export(exports_browser_exports, {
|
|
|
3166
3189
|
parseCachedHeader: () => parseCachedHeader,
|
|
3167
3190
|
renderMessage: () => renderMessage,
|
|
3168
3191
|
setFetch: () => setFetch,
|
|
3192
|
+
spanComponentsToObjectId: () => spanComponentsToObjectId,
|
|
3169
3193
|
startSpan: () => startSpan,
|
|
3170
3194
|
summarize: () => summarize,
|
|
3171
3195
|
traceable: () => traceable,
|
|
@@ -3671,6 +3695,7 @@ export {
|
|
|
3671
3695
|
parseCachedHeader,
|
|
3672
3696
|
renderMessage,
|
|
3673
3697
|
setFetch,
|
|
3698
|
+
spanComponentsToObjectId,
|
|
3674
3699
|
startSpan,
|
|
3675
3700
|
summarize,
|
|
3676
3701
|
traceable,
|
package/dist/cli.js
CHANGED
|
@@ -1236,7 +1236,7 @@ var require_package = __commonJS({
|
|
|
1236
1236
|
"package.json"(exports2, module2) {
|
|
1237
1237
|
module2.exports = {
|
|
1238
1238
|
name: "braintrust",
|
|
1239
|
-
version: "0.0.
|
|
1239
|
+
version: "0.0.161",
|
|
1240
1240
|
description: "SDK for integrating Braintrust",
|
|
1241
1241
|
repository: {
|
|
1242
1242
|
type: "git",
|
|
@@ -1306,7 +1306,7 @@ var require_package = __commonJS({
|
|
|
1306
1306
|
},
|
|
1307
1307
|
dependencies: {
|
|
1308
1308
|
"@ai-sdk/provider": "^0.0.11",
|
|
1309
|
-
"@braintrust/core": "0.0.
|
|
1309
|
+
"@braintrust/core": "0.0.58",
|
|
1310
1310
|
"@next/env": "^14.2.3",
|
|
1311
1311
|
"@vercel/functions": "^1.0.2",
|
|
1312
1312
|
ai: "^3.2.16",
|
|
@@ -1449,6 +1449,10 @@ var braintrustStreamChunkSchema = import_zod.z.union([
|
|
|
1449
1449
|
type: import_zod.z.literal("error"),
|
|
1450
1450
|
data: import_zod.z.string()
|
|
1451
1451
|
}),
|
|
1452
|
+
import_zod.z.object({
|
|
1453
|
+
type: import_zod.z.literal("console"),
|
|
1454
|
+
data: import_typespecs.sseConsoleEventDataSchema
|
|
1455
|
+
}),
|
|
1452
1456
|
import_zod.z.object({
|
|
1453
1457
|
type: import_zod.z.literal("progress"),
|
|
1454
1458
|
data: import_typespecs.sseProgressEventDataSchema
|
|
@@ -1534,7 +1538,7 @@ var BraintrustStream = class _BraintrustStream {
|
|
|
1534
1538
|
return this.memoizedFinalValue;
|
|
1535
1539
|
}
|
|
1536
1540
|
this.memoizedFinalValue = new Promise((resolve2, reject2) => {
|
|
1537
|
-
|
|
1541
|
+
this.stream.pipeThrough(createFinalValuePassThroughStream(resolve2, reject2)).pipeTo(devNullWritableStream());
|
|
1538
1542
|
});
|
|
1539
1543
|
return this.memoizedFinalValue;
|
|
1540
1544
|
}
|
|
@@ -1568,7 +1572,7 @@ function btStreamParser() {
|
|
|
1568
1572
|
case "error":
|
|
1569
1573
|
controller.enqueue({
|
|
1570
1574
|
type: "error",
|
|
1571
|
-
data: event.data
|
|
1575
|
+
data: JSON.parse(event.data)
|
|
1572
1576
|
});
|
|
1573
1577
|
break;
|
|
1574
1578
|
case "progress":
|
|
@@ -1577,6 +1581,12 @@ function btStreamParser() {
|
|
|
1577
1581
|
data: import_typespecs.sseProgressEventDataSchema.parse(JSON.parse(event.data))
|
|
1578
1582
|
});
|
|
1579
1583
|
break;
|
|
1584
|
+
case "console":
|
|
1585
|
+
controller.enqueue({
|
|
1586
|
+
type: "console",
|
|
1587
|
+
data: import_typespecs.sseConsoleEventDataSchema.parse(JSON.parse(event.data))
|
|
1588
|
+
});
|
|
1589
|
+
break;
|
|
1580
1590
|
case "start":
|
|
1581
1591
|
controller.enqueue({
|
|
1582
1592
|
type: "start",
|
|
@@ -1643,6 +1653,7 @@ function createFinalValuePassThroughStream(onFinal, onError) {
|
|
|
1643
1653
|
case "progress":
|
|
1644
1654
|
case "start":
|
|
1645
1655
|
case "done":
|
|
1656
|
+
case "console":
|
|
1646
1657
|
break;
|
|
1647
1658
|
default:
|
|
1648
1659
|
const _type = chunkType;
|
|
@@ -1856,7 +1867,9 @@ var BraintrustState = class _BraintrustState {
|
|
|
1856
1867
|
}
|
|
1857
1868
|
const newState = await loginToState({
|
|
1858
1869
|
...this.loginParams,
|
|
1859
|
-
...
|
|
1870
|
+
...Object.fromEntries(
|
|
1871
|
+
Object.entries(loginParams).filter(([k, v]) => !isEmpty(v))
|
|
1872
|
+
)
|
|
1860
1873
|
});
|
|
1861
1874
|
this.copyLoginInfo(newState);
|
|
1862
1875
|
}
|
|
@@ -6451,13 +6464,18 @@ async function uploadBundles({
|
|
|
6451
6464
|
});
|
|
6452
6465
|
bundleStream.on("error", reject2);
|
|
6453
6466
|
});
|
|
6454
|
-
await fetch(pathInfo.url, {
|
|
6467
|
+
const resp = await fetch(pathInfo.url, {
|
|
6455
6468
|
method: "PUT",
|
|
6456
6469
|
body: bundleData,
|
|
6457
6470
|
headers: {
|
|
6458
6471
|
"Content-Encoding": "gzip"
|
|
6459
6472
|
}
|
|
6460
6473
|
});
|
|
6474
|
+
if (!resp.ok) {
|
|
6475
|
+
throw new Error(
|
|
6476
|
+
`Failed to upload bundle: ${resp.status} ${await resp.text()}`
|
|
6477
|
+
);
|
|
6478
|
+
}
|
|
6461
6479
|
return true;
|
|
6462
6480
|
})();
|
|
6463
6481
|
const sourceMapContext = await sourceMapContextPromise;
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GitMetadataSettings, LogFeedbackFullArgs, ExperimentEvent, BackgroundLogEvent, ExperimentLogFullArgs, ExperimentLogPartialArgs, IdField, SpanType, RepoInfo, DEFAULT_IS_LEGACY_DATASET, TRANSACTION_ID_FIELD, TransactionId, SpanObjectTypeV3, DatasetRecord, Score, CommentEvent, InputField, InputsField, LogCommentFullArgs, OtherExperimentLogFields, ParentExperimentIds, ParentProjectLogIds } from '@braintrust/core';
|
|
1
|
+
import { GitMetadataSettings, LogFeedbackFullArgs, ExperimentEvent, BackgroundLogEvent, ExperimentLogFullArgs, ExperimentLogPartialArgs, IdField, SpanType, SpanComponentsV3, RepoInfo, DEFAULT_IS_LEGACY_DATASET, TRANSACTION_ID_FIELD, TransactionId, SpanObjectTypeV3, DatasetRecord, Score, CommentEvent, InputField, InputsField, LogCommentFullArgs, OtherExperimentLogFields, ParentExperimentIds, ParentProjectLogIds } from '@braintrust/core';
|
|
2
2
|
export { CommentEvent, DatasetRecord, ExperimentLogFullArgs, ExperimentLogPartialArgs, IdField, InputField, InputsField, LogCommentFullArgs, LogFeedbackFullArgs, OtherExperimentLogFields, ParentExperimentIds, ParentProjectLogIds } from '@braintrust/core';
|
|
3
3
|
import { PromptData, OpenAIMessage, Tools, AnyModelParam, Message, Prompt as Prompt$1, PromptSessionEvent, StreamingMode, FunctionType, IfExists, SavedFunctionId, ModelParams } from '@braintrust/core/typespecs';
|
|
4
4
|
import { z } from 'zod';
|
|
@@ -275,6 +275,10 @@ interface ParentSpanIds {
|
|
|
275
275
|
spanId: string;
|
|
276
276
|
rootSpanId: string;
|
|
277
277
|
}
|
|
278
|
+
declare function spanComponentsToObjectId({ components, state, }: {
|
|
279
|
+
components: SpanComponentsV3;
|
|
280
|
+
state?: BraintrustState;
|
|
281
|
+
}): Promise<string>;
|
|
278
282
|
declare class Logger<IsAsyncFlush extends boolean> implements Exportable {
|
|
279
283
|
private state;
|
|
280
284
|
private lazyMetadata;
|
|
@@ -1126,6 +1130,30 @@ declare const braintrustStreamChunkSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
1126
1130
|
}, {
|
|
1127
1131
|
data: string;
|
|
1128
1132
|
type: "error";
|
|
1133
|
+
}>, z.ZodObject<{
|
|
1134
|
+
type: z.ZodLiteral<"console">;
|
|
1135
|
+
data: z.ZodObject<{
|
|
1136
|
+
stream: z.ZodEnum<["stderr", "stdout"]>;
|
|
1137
|
+
message: z.ZodString;
|
|
1138
|
+
}, "strip", z.ZodTypeAny, {
|
|
1139
|
+
message: string;
|
|
1140
|
+
stream: "stderr" | "stdout";
|
|
1141
|
+
}, {
|
|
1142
|
+
message: string;
|
|
1143
|
+
stream: "stderr" | "stdout";
|
|
1144
|
+
}>;
|
|
1145
|
+
}, "strip", z.ZodTypeAny, {
|
|
1146
|
+
data: {
|
|
1147
|
+
message: string;
|
|
1148
|
+
stream: "stderr" | "stdout";
|
|
1149
|
+
};
|
|
1150
|
+
type: "console";
|
|
1151
|
+
}, {
|
|
1152
|
+
data: {
|
|
1153
|
+
message: string;
|
|
1154
|
+
stream: "stderr" | "stdout";
|
|
1155
|
+
};
|
|
1156
|
+
type: "console";
|
|
1129
1157
|
}>, z.ZodObject<{
|
|
1130
1158
|
type: z.ZodLiteral<"progress">;
|
|
1131
1159
|
data: z.ZodObject<{
|
|
@@ -1134,7 +1162,7 @@ declare const braintrustStreamChunkSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
1134
1162
|
format: z.ZodEnum<["llm", "code", "global"]>;
|
|
1135
1163
|
output_type: z.ZodEnum<["completion", "score", "any"]>;
|
|
1136
1164
|
name: z.ZodString;
|
|
1137
|
-
event: z.ZodEnum<["text_delta", "json_delta", "error", "start", "done"]>;
|
|
1165
|
+
event: z.ZodEnum<["text_delta", "json_delta", "error", "console", "start", "done"]>;
|
|
1138
1166
|
data: z.ZodString;
|
|
1139
1167
|
}, "strip", z.ZodTypeAny, {
|
|
1140
1168
|
format: "code" | "global" | "llm";
|
|
@@ -1142,7 +1170,7 @@ declare const braintrustStreamChunkSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
1142
1170
|
name: string;
|
|
1143
1171
|
id: string;
|
|
1144
1172
|
object_type: "prompt" | "tool" | "scorer" | "task";
|
|
1145
|
-
event: "error" | "text_delta" | "json_delta" | "start" | "done";
|
|
1173
|
+
event: "error" | "text_delta" | "json_delta" | "console" | "start" | "done";
|
|
1146
1174
|
output_type: "completion" | "score" | "any";
|
|
1147
1175
|
}, {
|
|
1148
1176
|
format: "code" | "global" | "llm";
|
|
@@ -1150,7 +1178,7 @@ declare const braintrustStreamChunkSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
1150
1178
|
name: string;
|
|
1151
1179
|
id: string;
|
|
1152
1180
|
object_type: "prompt" | "tool" | "scorer" | "task";
|
|
1153
|
-
event: "error" | "text_delta" | "json_delta" | "start" | "done";
|
|
1181
|
+
event: "error" | "text_delta" | "json_delta" | "console" | "start" | "done";
|
|
1154
1182
|
output_type: "completion" | "score" | "any";
|
|
1155
1183
|
}>;
|
|
1156
1184
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -1160,7 +1188,7 @@ declare const braintrustStreamChunkSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
1160
1188
|
name: string;
|
|
1161
1189
|
id: string;
|
|
1162
1190
|
object_type: "prompt" | "tool" | "scorer" | "task";
|
|
1163
|
-
event: "error" | "text_delta" | "json_delta" | "start" | "done";
|
|
1191
|
+
event: "error" | "text_delta" | "json_delta" | "console" | "start" | "done";
|
|
1164
1192
|
output_type: "completion" | "score" | "any";
|
|
1165
1193
|
};
|
|
1166
1194
|
type: "progress";
|
|
@@ -1171,7 +1199,7 @@ declare const braintrustStreamChunkSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
1171
1199
|
name: string;
|
|
1172
1200
|
id: string;
|
|
1173
1201
|
object_type: "prompt" | "tool" | "scorer" | "task";
|
|
1174
|
-
event: "error" | "text_delta" | "json_delta" | "start" | "done";
|
|
1202
|
+
event: "error" | "text_delta" | "json_delta" | "console" | "start" | "done";
|
|
1175
1203
|
output_type: "completion" | "score" | "any";
|
|
1176
1204
|
};
|
|
1177
1205
|
type: "progress";
|
|
@@ -1810,6 +1838,7 @@ declare const braintrust_projects: typeof projects;
|
|
|
1810
1838
|
declare const braintrust_renderMessage: typeof renderMessage;
|
|
1811
1839
|
declare const braintrust_reportFailures: typeof reportFailures;
|
|
1812
1840
|
declare const braintrust_setFetch: typeof setFetch;
|
|
1841
|
+
declare const braintrust_spanComponentsToObjectId: typeof spanComponentsToObjectId;
|
|
1813
1842
|
declare const braintrust_startSpan: typeof startSpan;
|
|
1814
1843
|
declare const braintrust_summarize: typeof summarize;
|
|
1815
1844
|
declare const braintrust_toolFunctionDefinitionSchema: typeof toolFunctionDefinitionSchema;
|
|
@@ -1825,7 +1854,7 @@ declare const braintrust_wrapOpenAI: typeof wrapOpenAI;
|
|
|
1825
1854
|
declare const braintrust_wrapOpenAIv4: typeof wrapOpenAIv4;
|
|
1826
1855
|
declare const braintrust_wrapTraced: typeof wrapTraced;
|
|
1827
1856
|
declare namespace braintrust {
|
|
1828
|
-
export { type braintrust_AnyDataset as AnyDataset, type braintrust_BackgroundLoggerOpts as BackgroundLoggerOpts, braintrust_BaseExperiment as BaseExperiment, type braintrust_BaseMetadata as BaseMetadata, braintrust_BraintrustState as BraintrustState, braintrust_BraintrustStream as BraintrustStream, type braintrust_BraintrustStreamChunk as BraintrustStreamChunk, type braintrust_ChatPrompt as ChatPrompt, braintrust_CodeFunction as CodeFunction, braintrust_CodePrompt as CodePrompt, braintrust_CommentEvent as CommentEvent, 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, braintrust_DatasetRecord as DatasetRecord, type braintrust_DatasetSummary as DatasetSummary, type braintrust_DefaultMetadataType as DefaultMetadataType, type braintrust_DefaultPromptArgs as DefaultPromptArgs, type braintrust_EndSpanArgs as EndSpanArgs, braintrust_Eval as Eval, type braintrust_EvalCase as EvalCase, type braintrust_EvalResult as EvalResult, 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, braintrust_ExperimentLogFullArgs as ExperimentLogFullArgs, braintrust_ExperimentLogPartialArgs as ExperimentLogPartialArgs, type braintrust_ExperimentSummary as ExperimentSummary, type braintrust_Exportable as Exportable, braintrust_FailedHTTPResponse as FailedHTTPResponse, type braintrust_FullInitOptions as FullInitOptions, type braintrust_FullLoginOptions as FullLoginOptions, braintrust_IdField as IdField, type braintrust_InitOptions as InitOptions, braintrust_InputField as InputField, braintrust_InputsField as InputsField, type braintrust_InvokeFunctionArgs as InvokeFunctionArgs, type braintrust_InvokeReturn as InvokeReturn, braintrust_LEGACY_CACHED_HEADER as LEGACY_CACHED_HEADER, braintrust_LazyValue as LazyValue, braintrust_LogCommentFullArgs as LogCommentFullArgs, braintrust_LogFeedbackFullArgs as LogFeedbackFullArgs, 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_NoopSpan as NoopSpan, type braintrust_ObjectMetadata as ObjectMetadata, braintrust_OtherExperimentLogFields as OtherExperimentLogFields, braintrust_ParentExperimentIds as ParentExperimentIds, braintrust_ParentProjectLogIds as ParentProjectLogIds, braintrust_Project as Project, type braintrust_PromiseUnless as PromiseUnless, braintrust_Prompt as Prompt, braintrust_PromptBuilder as PromptBuilder, type braintrust_PromptOpts as PromptOpts, type braintrust_PromptRowWithId as PromptRowWithId, braintrust_ReadonlyExperiment as ReadonlyExperiment, braintrust_Reporter as Reporter, type braintrust_ReporterBody as ReporterBody, type braintrust_ScoreSummary as ScoreSummary, type braintrust_SerializedBraintrustState as SerializedBraintrustState, type braintrust_SetCurrentArg as SetCurrentArg, type braintrust_Span as Span, type braintrust_SpanContext as SpanContext, braintrust_SpanImpl as SpanImpl, type braintrust_StartSpanArgs as StartSpanArgs, braintrust_ToolBuilder as ToolBuilder, type braintrust_ToolFunctionDefinition as ToolFunctionDefinition, type braintrust_ToolOpts as ToolOpts, type braintrust_WithTransactionId as WithTransactionId, braintrust_X_CACHED_HEADER as X_CACHED_HEADER, 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_devNullWritableStream as devNullWritableStream, braintrust_flush as flush, braintrust_getSpanParentObject as getSpanParentObject, braintrust_init as init, braintrust_initDataset as initDataset, braintrust_initExperiment as initExperiment, 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_projects as projects, braintrust_renderMessage as renderMessage, braintrust_reportFailures as reportFailures, braintrust_setFetch as setFetch, 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_wrapAISDKModel as wrapAISDKModel, braintrust_wrapOpenAI as wrapOpenAI, braintrust_wrapOpenAIv4 as wrapOpenAIv4, braintrust_wrapTraced as wrapTraced };
|
|
1857
|
+
export { type braintrust_AnyDataset as AnyDataset, type braintrust_BackgroundLoggerOpts as BackgroundLoggerOpts, braintrust_BaseExperiment as BaseExperiment, type braintrust_BaseMetadata as BaseMetadata, braintrust_BraintrustState as BraintrustState, braintrust_BraintrustStream as BraintrustStream, type braintrust_BraintrustStreamChunk as BraintrustStreamChunk, type braintrust_ChatPrompt as ChatPrompt, braintrust_CodeFunction as CodeFunction, braintrust_CodePrompt as CodePrompt, braintrust_CommentEvent as CommentEvent, 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, braintrust_DatasetRecord as DatasetRecord, type braintrust_DatasetSummary as DatasetSummary, type braintrust_DefaultMetadataType as DefaultMetadataType, type braintrust_DefaultPromptArgs as DefaultPromptArgs, type braintrust_EndSpanArgs as EndSpanArgs, braintrust_Eval as Eval, type braintrust_EvalCase as EvalCase, type braintrust_EvalResult as EvalResult, 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, braintrust_ExperimentLogFullArgs as ExperimentLogFullArgs, braintrust_ExperimentLogPartialArgs as ExperimentLogPartialArgs, type braintrust_ExperimentSummary as ExperimentSummary, type braintrust_Exportable as Exportable, braintrust_FailedHTTPResponse as FailedHTTPResponse, type braintrust_FullInitOptions as FullInitOptions, type braintrust_FullLoginOptions as FullLoginOptions, braintrust_IdField as IdField, type braintrust_InitOptions as InitOptions, braintrust_InputField as InputField, braintrust_InputsField as InputsField, type braintrust_InvokeFunctionArgs as InvokeFunctionArgs, type braintrust_InvokeReturn as InvokeReturn, braintrust_LEGACY_CACHED_HEADER as LEGACY_CACHED_HEADER, braintrust_LazyValue as LazyValue, braintrust_LogCommentFullArgs as LogCommentFullArgs, braintrust_LogFeedbackFullArgs as LogFeedbackFullArgs, 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_NoopSpan as NoopSpan, type braintrust_ObjectMetadata as ObjectMetadata, braintrust_OtherExperimentLogFields as OtherExperimentLogFields, braintrust_ParentExperimentIds as ParentExperimentIds, braintrust_ParentProjectLogIds as ParentProjectLogIds, braintrust_Project as Project, type braintrust_PromiseUnless as PromiseUnless, braintrust_Prompt as Prompt, braintrust_PromptBuilder as PromptBuilder, type braintrust_PromptOpts as PromptOpts, type braintrust_PromptRowWithId as PromptRowWithId, braintrust_ReadonlyExperiment as ReadonlyExperiment, braintrust_Reporter as Reporter, type braintrust_ReporterBody as ReporterBody, type braintrust_ScoreSummary as ScoreSummary, type braintrust_SerializedBraintrustState as SerializedBraintrustState, type braintrust_SetCurrentArg as SetCurrentArg, type braintrust_Span as Span, type braintrust_SpanContext as SpanContext, braintrust_SpanImpl as SpanImpl, type braintrust_StartSpanArgs as StartSpanArgs, braintrust_ToolBuilder as ToolBuilder, type braintrust_ToolFunctionDefinition as ToolFunctionDefinition, type braintrust_ToolOpts as ToolOpts, type braintrust_WithTransactionId as WithTransactionId, braintrust_X_CACHED_HEADER as X_CACHED_HEADER, 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_devNullWritableStream as devNullWritableStream, braintrust_flush as flush, braintrust_getSpanParentObject as getSpanParentObject, braintrust_init as init, braintrust_initDataset as initDataset, braintrust_initExperiment as initExperiment, 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_projects as projects, braintrust_renderMessage as renderMessage, braintrust_reportFailures as reportFailures, 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_wrapAISDKModel as wrapAISDKModel, braintrust_wrapOpenAI as wrapOpenAI, braintrust_wrapOpenAIv4 as wrapOpenAIv4, braintrust_wrapTraced as wrapTraced };
|
|
1829
1858
|
}
|
|
1830
1859
|
|
|
1831
1860
|
/**
|
|
@@ -1881,4 +1910,4 @@ declare namespace braintrust {
|
|
|
1881
1910
|
* @module braintrust
|
|
1882
1911
|
*/
|
|
1883
1912
|
|
|
1884
|
-
export { type AnyDataset, type BackgroundLoggerOpts, BaseExperiment, type BaseMetadata, BraintrustState, BraintrustStream, type BraintrustStreamChunk, type ChatPrompt, CodeFunction, CodePrompt, type CompiledPrompt, type CompiledPromptParams, type CompletionPrompt, type CreateProjectOpts, type DataSummary, Dataset, type DatasetSummary, type DefaultMetadataType, type DefaultPromptArgs, type EndSpanArgs, Eval, type EvalCase, type EvalResult, type EvalScorer, type EvalScorerArgs, type EvalTask, type Evaluator, type EvaluatorDef, type EvaluatorFile, Experiment, type ExperimentSummary, type Exportable, FailedHTTPResponse, type FullInitOptions, type FullLoginOptions, type InitOptions, type InvokeFunctionArgs, type InvokeReturn, LEGACY_CACHED_HEADER, LazyValue, type LogOptions, Logger, type LoginOptions, type MetricSummary, NOOP_SPAN, NoopSpan, type ObjectMetadata, Project, type PromiseUnless, Prompt, PromptBuilder, type PromptOpts, type PromptRowWithId, ReadonlyExperiment, Reporter, type ReporterBody, type ScoreSummary, type SerializedBraintrustState, type SetCurrentArg, type Span, type SpanContext, SpanImpl, type StartSpanArgs, ToolBuilder, type ToolFunctionDefinition, type ToolOpts, type WithTransactionId, X_CACHED_HEADER, _internalGetGlobalState, _internalSetInitialState, braintrustStreamChunkSchema, buildLocalSummary, createFinalValuePassThroughStream, currentExperiment, currentLogger, currentSpan, braintrust as default, devNullWritableStream, flush, getSpanParentObject, init, initDataset, initExperiment, initLogger, invoke, loadPrompt, log, logError, login, loginToState, newId, parseCachedHeader, projects, renderMessage, reportFailures, setFetch, startSpan, summarize, toolFunctionDefinitionSchema, traceable, traced, updateSpan, withCurrent, withDataset, withExperiment, withLogger, wrapAISDKModel, wrapOpenAI, wrapOpenAIv4, wrapTraced };
|
|
1913
|
+
export { type AnyDataset, type BackgroundLoggerOpts, BaseExperiment, type BaseMetadata, BraintrustState, BraintrustStream, type BraintrustStreamChunk, type ChatPrompt, CodeFunction, CodePrompt, type CompiledPrompt, type CompiledPromptParams, type CompletionPrompt, type CreateProjectOpts, type DataSummary, Dataset, type DatasetSummary, type DefaultMetadataType, type DefaultPromptArgs, type EndSpanArgs, Eval, type EvalCase, type EvalResult, type EvalScorer, type EvalScorerArgs, type EvalTask, type Evaluator, type EvaluatorDef, type EvaluatorFile, Experiment, type ExperimentSummary, type Exportable, FailedHTTPResponse, type FullInitOptions, type FullLoginOptions, type InitOptions, type InvokeFunctionArgs, type InvokeReturn, LEGACY_CACHED_HEADER, LazyValue, type LogOptions, Logger, type LoginOptions, type MetricSummary, NOOP_SPAN, NoopSpan, type ObjectMetadata, Project, type PromiseUnless, Prompt, PromptBuilder, type PromptOpts, type PromptRowWithId, ReadonlyExperiment, Reporter, type ReporterBody, type ScoreSummary, type SerializedBraintrustState, type SetCurrentArg, type Span, type SpanContext, SpanImpl, type StartSpanArgs, ToolBuilder, type ToolFunctionDefinition, type ToolOpts, type WithTransactionId, X_CACHED_HEADER, _internalGetGlobalState, _internalSetInitialState, braintrustStreamChunkSchema, buildLocalSummary, createFinalValuePassThroughStream, currentExperiment, currentLogger, currentSpan, braintrust as default, devNullWritableStream, flush, getSpanParentObject, init, initDataset, initExperiment, initLogger, invoke, loadPrompt, log, logError, login, loginToState, newId, parseCachedHeader, projects, renderMessage, reportFailures, setFetch, spanComponentsToObjectId, startSpan, summarize, toolFunctionDefinitionSchema, traceable, traced, updateSpan, withCurrent, withDataset, withExperiment, withLogger, wrapAISDKModel, wrapOpenAI, wrapOpenAIv4, wrapTraced };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GitMetadataSettings, LogFeedbackFullArgs, ExperimentEvent, BackgroundLogEvent, ExperimentLogFullArgs, ExperimentLogPartialArgs, IdField, SpanType, RepoInfo, DEFAULT_IS_LEGACY_DATASET, TRANSACTION_ID_FIELD, TransactionId, SpanObjectTypeV3, DatasetRecord, Score, CommentEvent, InputField, InputsField, LogCommentFullArgs, OtherExperimentLogFields, ParentExperimentIds, ParentProjectLogIds } from '@braintrust/core';
|
|
1
|
+
import { GitMetadataSettings, LogFeedbackFullArgs, ExperimentEvent, BackgroundLogEvent, ExperimentLogFullArgs, ExperimentLogPartialArgs, IdField, SpanType, SpanComponentsV3, RepoInfo, DEFAULT_IS_LEGACY_DATASET, TRANSACTION_ID_FIELD, TransactionId, SpanObjectTypeV3, DatasetRecord, Score, CommentEvent, InputField, InputsField, LogCommentFullArgs, OtherExperimentLogFields, ParentExperimentIds, ParentProjectLogIds } from '@braintrust/core';
|
|
2
2
|
export { CommentEvent, DatasetRecord, ExperimentLogFullArgs, ExperimentLogPartialArgs, IdField, InputField, InputsField, LogCommentFullArgs, LogFeedbackFullArgs, OtherExperimentLogFields, ParentExperimentIds, ParentProjectLogIds } from '@braintrust/core';
|
|
3
3
|
import { PromptData, OpenAIMessage, Tools, AnyModelParam, Message, Prompt as Prompt$1, PromptSessionEvent, StreamingMode, FunctionType, IfExists, SavedFunctionId, ModelParams } from '@braintrust/core/typespecs';
|
|
4
4
|
import { z } from 'zod';
|
|
@@ -275,6 +275,10 @@ interface ParentSpanIds {
|
|
|
275
275
|
spanId: string;
|
|
276
276
|
rootSpanId: string;
|
|
277
277
|
}
|
|
278
|
+
declare function spanComponentsToObjectId({ components, state, }: {
|
|
279
|
+
components: SpanComponentsV3;
|
|
280
|
+
state?: BraintrustState;
|
|
281
|
+
}): Promise<string>;
|
|
278
282
|
declare class Logger<IsAsyncFlush extends boolean> implements Exportable {
|
|
279
283
|
private state;
|
|
280
284
|
private lazyMetadata;
|
|
@@ -1126,6 +1130,30 @@ declare const braintrustStreamChunkSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
1126
1130
|
}, {
|
|
1127
1131
|
data: string;
|
|
1128
1132
|
type: "error";
|
|
1133
|
+
}>, z.ZodObject<{
|
|
1134
|
+
type: z.ZodLiteral<"console">;
|
|
1135
|
+
data: z.ZodObject<{
|
|
1136
|
+
stream: z.ZodEnum<["stderr", "stdout"]>;
|
|
1137
|
+
message: z.ZodString;
|
|
1138
|
+
}, "strip", z.ZodTypeAny, {
|
|
1139
|
+
message: string;
|
|
1140
|
+
stream: "stderr" | "stdout";
|
|
1141
|
+
}, {
|
|
1142
|
+
message: string;
|
|
1143
|
+
stream: "stderr" | "stdout";
|
|
1144
|
+
}>;
|
|
1145
|
+
}, "strip", z.ZodTypeAny, {
|
|
1146
|
+
data: {
|
|
1147
|
+
message: string;
|
|
1148
|
+
stream: "stderr" | "stdout";
|
|
1149
|
+
};
|
|
1150
|
+
type: "console";
|
|
1151
|
+
}, {
|
|
1152
|
+
data: {
|
|
1153
|
+
message: string;
|
|
1154
|
+
stream: "stderr" | "stdout";
|
|
1155
|
+
};
|
|
1156
|
+
type: "console";
|
|
1129
1157
|
}>, z.ZodObject<{
|
|
1130
1158
|
type: z.ZodLiteral<"progress">;
|
|
1131
1159
|
data: z.ZodObject<{
|
|
@@ -1134,7 +1162,7 @@ declare const braintrustStreamChunkSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
1134
1162
|
format: z.ZodEnum<["llm", "code", "global"]>;
|
|
1135
1163
|
output_type: z.ZodEnum<["completion", "score", "any"]>;
|
|
1136
1164
|
name: z.ZodString;
|
|
1137
|
-
event: z.ZodEnum<["text_delta", "json_delta", "error", "start", "done"]>;
|
|
1165
|
+
event: z.ZodEnum<["text_delta", "json_delta", "error", "console", "start", "done"]>;
|
|
1138
1166
|
data: z.ZodString;
|
|
1139
1167
|
}, "strip", z.ZodTypeAny, {
|
|
1140
1168
|
format: "code" | "global" | "llm";
|
|
@@ -1142,7 +1170,7 @@ declare const braintrustStreamChunkSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
1142
1170
|
name: string;
|
|
1143
1171
|
id: string;
|
|
1144
1172
|
object_type: "prompt" | "tool" | "scorer" | "task";
|
|
1145
|
-
event: "error" | "text_delta" | "json_delta" | "start" | "done";
|
|
1173
|
+
event: "error" | "text_delta" | "json_delta" | "console" | "start" | "done";
|
|
1146
1174
|
output_type: "completion" | "score" | "any";
|
|
1147
1175
|
}, {
|
|
1148
1176
|
format: "code" | "global" | "llm";
|
|
@@ -1150,7 +1178,7 @@ declare const braintrustStreamChunkSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
1150
1178
|
name: string;
|
|
1151
1179
|
id: string;
|
|
1152
1180
|
object_type: "prompt" | "tool" | "scorer" | "task";
|
|
1153
|
-
event: "error" | "text_delta" | "json_delta" | "start" | "done";
|
|
1181
|
+
event: "error" | "text_delta" | "json_delta" | "console" | "start" | "done";
|
|
1154
1182
|
output_type: "completion" | "score" | "any";
|
|
1155
1183
|
}>;
|
|
1156
1184
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -1160,7 +1188,7 @@ declare const braintrustStreamChunkSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
1160
1188
|
name: string;
|
|
1161
1189
|
id: string;
|
|
1162
1190
|
object_type: "prompt" | "tool" | "scorer" | "task";
|
|
1163
|
-
event: "error" | "text_delta" | "json_delta" | "start" | "done";
|
|
1191
|
+
event: "error" | "text_delta" | "json_delta" | "console" | "start" | "done";
|
|
1164
1192
|
output_type: "completion" | "score" | "any";
|
|
1165
1193
|
};
|
|
1166
1194
|
type: "progress";
|
|
@@ -1171,7 +1199,7 @@ declare const braintrustStreamChunkSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
1171
1199
|
name: string;
|
|
1172
1200
|
id: string;
|
|
1173
1201
|
object_type: "prompt" | "tool" | "scorer" | "task";
|
|
1174
|
-
event: "error" | "text_delta" | "json_delta" | "start" | "done";
|
|
1202
|
+
event: "error" | "text_delta" | "json_delta" | "console" | "start" | "done";
|
|
1175
1203
|
output_type: "completion" | "score" | "any";
|
|
1176
1204
|
};
|
|
1177
1205
|
type: "progress";
|
|
@@ -1810,6 +1838,7 @@ declare const braintrust_projects: typeof projects;
|
|
|
1810
1838
|
declare const braintrust_renderMessage: typeof renderMessage;
|
|
1811
1839
|
declare const braintrust_reportFailures: typeof reportFailures;
|
|
1812
1840
|
declare const braintrust_setFetch: typeof setFetch;
|
|
1841
|
+
declare const braintrust_spanComponentsToObjectId: typeof spanComponentsToObjectId;
|
|
1813
1842
|
declare const braintrust_startSpan: typeof startSpan;
|
|
1814
1843
|
declare const braintrust_summarize: typeof summarize;
|
|
1815
1844
|
declare const braintrust_toolFunctionDefinitionSchema: typeof toolFunctionDefinitionSchema;
|
|
@@ -1825,7 +1854,7 @@ declare const braintrust_wrapOpenAI: typeof wrapOpenAI;
|
|
|
1825
1854
|
declare const braintrust_wrapOpenAIv4: typeof wrapOpenAIv4;
|
|
1826
1855
|
declare const braintrust_wrapTraced: typeof wrapTraced;
|
|
1827
1856
|
declare namespace braintrust {
|
|
1828
|
-
export { type braintrust_AnyDataset as AnyDataset, type braintrust_BackgroundLoggerOpts as BackgroundLoggerOpts, braintrust_BaseExperiment as BaseExperiment, type braintrust_BaseMetadata as BaseMetadata, braintrust_BraintrustState as BraintrustState, braintrust_BraintrustStream as BraintrustStream, type braintrust_BraintrustStreamChunk as BraintrustStreamChunk, type braintrust_ChatPrompt as ChatPrompt, braintrust_CodeFunction as CodeFunction, braintrust_CodePrompt as CodePrompt, braintrust_CommentEvent as CommentEvent, 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, braintrust_DatasetRecord as DatasetRecord, type braintrust_DatasetSummary as DatasetSummary, type braintrust_DefaultMetadataType as DefaultMetadataType, type braintrust_DefaultPromptArgs as DefaultPromptArgs, type braintrust_EndSpanArgs as EndSpanArgs, braintrust_Eval as Eval, type braintrust_EvalCase as EvalCase, type braintrust_EvalResult as EvalResult, 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, braintrust_ExperimentLogFullArgs as ExperimentLogFullArgs, braintrust_ExperimentLogPartialArgs as ExperimentLogPartialArgs, type braintrust_ExperimentSummary as ExperimentSummary, type braintrust_Exportable as Exportable, braintrust_FailedHTTPResponse as FailedHTTPResponse, type braintrust_FullInitOptions as FullInitOptions, type braintrust_FullLoginOptions as FullLoginOptions, braintrust_IdField as IdField, type braintrust_InitOptions as InitOptions, braintrust_InputField as InputField, braintrust_InputsField as InputsField, type braintrust_InvokeFunctionArgs as InvokeFunctionArgs, type braintrust_InvokeReturn as InvokeReturn, braintrust_LEGACY_CACHED_HEADER as LEGACY_CACHED_HEADER, braintrust_LazyValue as LazyValue, braintrust_LogCommentFullArgs as LogCommentFullArgs, braintrust_LogFeedbackFullArgs as LogFeedbackFullArgs, 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_NoopSpan as NoopSpan, type braintrust_ObjectMetadata as ObjectMetadata, braintrust_OtherExperimentLogFields as OtherExperimentLogFields, braintrust_ParentExperimentIds as ParentExperimentIds, braintrust_ParentProjectLogIds as ParentProjectLogIds, braintrust_Project as Project, type braintrust_PromiseUnless as PromiseUnless, braintrust_Prompt as Prompt, braintrust_PromptBuilder as PromptBuilder, type braintrust_PromptOpts as PromptOpts, type braintrust_PromptRowWithId as PromptRowWithId, braintrust_ReadonlyExperiment as ReadonlyExperiment, braintrust_Reporter as Reporter, type braintrust_ReporterBody as ReporterBody, type braintrust_ScoreSummary as ScoreSummary, type braintrust_SerializedBraintrustState as SerializedBraintrustState, type braintrust_SetCurrentArg as SetCurrentArg, type braintrust_Span as Span, type braintrust_SpanContext as SpanContext, braintrust_SpanImpl as SpanImpl, type braintrust_StartSpanArgs as StartSpanArgs, braintrust_ToolBuilder as ToolBuilder, type braintrust_ToolFunctionDefinition as ToolFunctionDefinition, type braintrust_ToolOpts as ToolOpts, type braintrust_WithTransactionId as WithTransactionId, braintrust_X_CACHED_HEADER as X_CACHED_HEADER, 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_devNullWritableStream as devNullWritableStream, braintrust_flush as flush, braintrust_getSpanParentObject as getSpanParentObject, braintrust_init as init, braintrust_initDataset as initDataset, braintrust_initExperiment as initExperiment, 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_projects as projects, braintrust_renderMessage as renderMessage, braintrust_reportFailures as reportFailures, braintrust_setFetch as setFetch, 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_wrapAISDKModel as wrapAISDKModel, braintrust_wrapOpenAI as wrapOpenAI, braintrust_wrapOpenAIv4 as wrapOpenAIv4, braintrust_wrapTraced as wrapTraced };
|
|
1857
|
+
export { type braintrust_AnyDataset as AnyDataset, type braintrust_BackgroundLoggerOpts as BackgroundLoggerOpts, braintrust_BaseExperiment as BaseExperiment, type braintrust_BaseMetadata as BaseMetadata, braintrust_BraintrustState as BraintrustState, braintrust_BraintrustStream as BraintrustStream, type braintrust_BraintrustStreamChunk as BraintrustStreamChunk, type braintrust_ChatPrompt as ChatPrompt, braintrust_CodeFunction as CodeFunction, braintrust_CodePrompt as CodePrompt, braintrust_CommentEvent as CommentEvent, 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, braintrust_DatasetRecord as DatasetRecord, type braintrust_DatasetSummary as DatasetSummary, type braintrust_DefaultMetadataType as DefaultMetadataType, type braintrust_DefaultPromptArgs as DefaultPromptArgs, type braintrust_EndSpanArgs as EndSpanArgs, braintrust_Eval as Eval, type braintrust_EvalCase as EvalCase, type braintrust_EvalResult as EvalResult, 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, braintrust_ExperimentLogFullArgs as ExperimentLogFullArgs, braintrust_ExperimentLogPartialArgs as ExperimentLogPartialArgs, type braintrust_ExperimentSummary as ExperimentSummary, type braintrust_Exportable as Exportable, braintrust_FailedHTTPResponse as FailedHTTPResponse, type braintrust_FullInitOptions as FullInitOptions, type braintrust_FullLoginOptions as FullLoginOptions, braintrust_IdField as IdField, type braintrust_InitOptions as InitOptions, braintrust_InputField as InputField, braintrust_InputsField as InputsField, type braintrust_InvokeFunctionArgs as InvokeFunctionArgs, type braintrust_InvokeReturn as InvokeReturn, braintrust_LEGACY_CACHED_HEADER as LEGACY_CACHED_HEADER, braintrust_LazyValue as LazyValue, braintrust_LogCommentFullArgs as LogCommentFullArgs, braintrust_LogFeedbackFullArgs as LogFeedbackFullArgs, 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_NoopSpan as NoopSpan, type braintrust_ObjectMetadata as ObjectMetadata, braintrust_OtherExperimentLogFields as OtherExperimentLogFields, braintrust_ParentExperimentIds as ParentExperimentIds, braintrust_ParentProjectLogIds as ParentProjectLogIds, braintrust_Project as Project, type braintrust_PromiseUnless as PromiseUnless, braintrust_Prompt as Prompt, braintrust_PromptBuilder as PromptBuilder, type braintrust_PromptOpts as PromptOpts, type braintrust_PromptRowWithId as PromptRowWithId, braintrust_ReadonlyExperiment as ReadonlyExperiment, braintrust_Reporter as Reporter, type braintrust_ReporterBody as ReporterBody, type braintrust_ScoreSummary as ScoreSummary, type braintrust_SerializedBraintrustState as SerializedBraintrustState, type braintrust_SetCurrentArg as SetCurrentArg, type braintrust_Span as Span, type braintrust_SpanContext as SpanContext, braintrust_SpanImpl as SpanImpl, type braintrust_StartSpanArgs as StartSpanArgs, braintrust_ToolBuilder as ToolBuilder, type braintrust_ToolFunctionDefinition as ToolFunctionDefinition, type braintrust_ToolOpts as ToolOpts, type braintrust_WithTransactionId as WithTransactionId, braintrust_X_CACHED_HEADER as X_CACHED_HEADER, 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_devNullWritableStream as devNullWritableStream, braintrust_flush as flush, braintrust_getSpanParentObject as getSpanParentObject, braintrust_init as init, braintrust_initDataset as initDataset, braintrust_initExperiment as initExperiment, 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_projects as projects, braintrust_renderMessage as renderMessage, braintrust_reportFailures as reportFailures, 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_wrapAISDKModel as wrapAISDKModel, braintrust_wrapOpenAI as wrapOpenAI, braintrust_wrapOpenAIv4 as wrapOpenAIv4, braintrust_wrapTraced as wrapTraced };
|
|
1829
1858
|
}
|
|
1830
1859
|
|
|
1831
1860
|
/**
|
|
@@ -1881,4 +1910,4 @@ declare namespace braintrust {
|
|
|
1881
1910
|
* @module braintrust
|
|
1882
1911
|
*/
|
|
1883
1912
|
|
|
1884
|
-
export { type AnyDataset, type BackgroundLoggerOpts, BaseExperiment, type BaseMetadata, BraintrustState, BraintrustStream, type BraintrustStreamChunk, type ChatPrompt, CodeFunction, CodePrompt, type CompiledPrompt, type CompiledPromptParams, type CompletionPrompt, type CreateProjectOpts, type DataSummary, Dataset, type DatasetSummary, type DefaultMetadataType, type DefaultPromptArgs, type EndSpanArgs, Eval, type EvalCase, type EvalResult, type EvalScorer, type EvalScorerArgs, type EvalTask, type Evaluator, type EvaluatorDef, type EvaluatorFile, Experiment, type ExperimentSummary, type Exportable, FailedHTTPResponse, type FullInitOptions, type FullLoginOptions, type InitOptions, type InvokeFunctionArgs, type InvokeReturn, LEGACY_CACHED_HEADER, LazyValue, type LogOptions, Logger, type LoginOptions, type MetricSummary, NOOP_SPAN, NoopSpan, type ObjectMetadata, Project, type PromiseUnless, Prompt, PromptBuilder, type PromptOpts, type PromptRowWithId, ReadonlyExperiment, Reporter, type ReporterBody, type ScoreSummary, type SerializedBraintrustState, type SetCurrentArg, type Span, type SpanContext, SpanImpl, type StartSpanArgs, ToolBuilder, type ToolFunctionDefinition, type ToolOpts, type WithTransactionId, X_CACHED_HEADER, _internalGetGlobalState, _internalSetInitialState, braintrustStreamChunkSchema, buildLocalSummary, createFinalValuePassThroughStream, currentExperiment, currentLogger, currentSpan, braintrust as default, devNullWritableStream, flush, getSpanParentObject, init, initDataset, initExperiment, initLogger, invoke, loadPrompt, log, logError, login, loginToState, newId, parseCachedHeader, projects, renderMessage, reportFailures, setFetch, startSpan, summarize, toolFunctionDefinitionSchema, traceable, traced, updateSpan, withCurrent, withDataset, withExperiment, withLogger, wrapAISDKModel, wrapOpenAI, wrapOpenAIv4, wrapTraced };
|
|
1913
|
+
export { type AnyDataset, type BackgroundLoggerOpts, BaseExperiment, type BaseMetadata, BraintrustState, BraintrustStream, type BraintrustStreamChunk, type ChatPrompt, CodeFunction, CodePrompt, type CompiledPrompt, type CompiledPromptParams, type CompletionPrompt, type CreateProjectOpts, type DataSummary, Dataset, type DatasetSummary, type DefaultMetadataType, type DefaultPromptArgs, type EndSpanArgs, Eval, type EvalCase, type EvalResult, type EvalScorer, type EvalScorerArgs, type EvalTask, type Evaluator, type EvaluatorDef, type EvaluatorFile, Experiment, type ExperimentSummary, type Exportable, FailedHTTPResponse, type FullInitOptions, type FullLoginOptions, type InitOptions, type InvokeFunctionArgs, type InvokeReturn, LEGACY_CACHED_HEADER, LazyValue, type LogOptions, Logger, type LoginOptions, type MetricSummary, NOOP_SPAN, NoopSpan, type ObjectMetadata, Project, type PromiseUnless, Prompt, PromptBuilder, type PromptOpts, type PromptRowWithId, ReadonlyExperiment, Reporter, type ReporterBody, type ScoreSummary, type SerializedBraintrustState, type SetCurrentArg, type Span, type SpanContext, SpanImpl, type StartSpanArgs, ToolBuilder, type ToolFunctionDefinition, type ToolOpts, type WithTransactionId, X_CACHED_HEADER, _internalGetGlobalState, _internalSetInitialState, braintrustStreamChunkSchema, buildLocalSummary, createFinalValuePassThroughStream, currentExperiment, currentLogger, currentSpan, braintrust as default, devNullWritableStream, flush, getSpanParentObject, init, initDataset, initExperiment, initLogger, invoke, loadPrompt, log, logError, login, loginToState, newId, parseCachedHeader, projects, renderMessage, reportFailures, setFetch, spanComponentsToObjectId, startSpan, summarize, toolFunctionDefinitionSchema, traceable, traced, updateSpan, withCurrent, withDataset, withExperiment, withLogger, wrapAISDKModel, wrapOpenAI, wrapOpenAIv4, wrapTraced };
|
package/dist/index.js
CHANGED
|
@@ -80,6 +80,7 @@ __export(src_exports, {
|
|
|
80
80
|
renderMessage: () => renderMessage,
|
|
81
81
|
reportFailures: () => reportFailures,
|
|
82
82
|
setFetch: () => setFetch,
|
|
83
|
+
spanComponentsToObjectId: () => spanComponentsToObjectId,
|
|
83
84
|
startSpan: () => startSpan,
|
|
84
85
|
summarize: () => summarize,
|
|
85
86
|
toolFunctionDefinitionSchema: () => toolFunctionDefinitionSchema,
|
|
@@ -412,6 +413,10 @@ var braintrustStreamChunkSchema = import_zod.z.union([
|
|
|
412
413
|
type: import_zod.z.literal("error"),
|
|
413
414
|
data: import_zod.z.string()
|
|
414
415
|
}),
|
|
416
|
+
import_zod.z.object({
|
|
417
|
+
type: import_zod.z.literal("console"),
|
|
418
|
+
data: import_typespecs.sseConsoleEventDataSchema
|
|
419
|
+
}),
|
|
415
420
|
import_zod.z.object({
|
|
416
421
|
type: import_zod.z.literal("progress"),
|
|
417
422
|
data: import_typespecs.sseProgressEventDataSchema
|
|
@@ -497,7 +502,7 @@ var BraintrustStream = class _BraintrustStream {
|
|
|
497
502
|
return this.memoizedFinalValue;
|
|
498
503
|
}
|
|
499
504
|
this.memoizedFinalValue = new Promise((resolve, reject2) => {
|
|
500
|
-
|
|
505
|
+
this.stream.pipeThrough(createFinalValuePassThroughStream(resolve, reject2)).pipeTo(devNullWritableStream());
|
|
501
506
|
});
|
|
502
507
|
return this.memoizedFinalValue;
|
|
503
508
|
}
|
|
@@ -531,7 +536,7 @@ function btStreamParser() {
|
|
|
531
536
|
case "error":
|
|
532
537
|
controller.enqueue({
|
|
533
538
|
type: "error",
|
|
534
|
-
data: event.data
|
|
539
|
+
data: JSON.parse(event.data)
|
|
535
540
|
});
|
|
536
541
|
break;
|
|
537
542
|
case "progress":
|
|
@@ -540,6 +545,12 @@ function btStreamParser() {
|
|
|
540
545
|
data: import_typespecs.sseProgressEventDataSchema.parse(JSON.parse(event.data))
|
|
541
546
|
});
|
|
542
547
|
break;
|
|
548
|
+
case "console":
|
|
549
|
+
controller.enqueue({
|
|
550
|
+
type: "console",
|
|
551
|
+
data: import_typespecs.sseConsoleEventDataSchema.parse(JSON.parse(event.data))
|
|
552
|
+
});
|
|
553
|
+
break;
|
|
543
554
|
case "start":
|
|
544
555
|
controller.enqueue({
|
|
545
556
|
type: "start",
|
|
@@ -606,6 +617,7 @@ function createFinalValuePassThroughStream(onFinal, onError) {
|
|
|
606
617
|
case "progress":
|
|
607
618
|
case "start":
|
|
608
619
|
case "done":
|
|
620
|
+
case "console":
|
|
609
621
|
break;
|
|
610
622
|
default:
|
|
611
623
|
const _type = chunkType;
|
|
@@ -819,7 +831,9 @@ var BraintrustState = class _BraintrustState {
|
|
|
819
831
|
}
|
|
820
832
|
const newState = await loginToState({
|
|
821
833
|
...this.loginParams,
|
|
822
|
-
...
|
|
834
|
+
...Object.fromEntries(
|
|
835
|
+
Object.entries(loginParams).filter(([k, v]) => !isEmpty(v))
|
|
836
|
+
)
|
|
823
837
|
});
|
|
824
838
|
this.copyLoginInfo(newState);
|
|
825
839
|
}
|
|
@@ -1129,6 +1143,15 @@ function spanComponentsToObjectIdLambda(state, components) {
|
|
|
1129
1143
|
throw new Error(`Unknown object type: ${x}`);
|
|
1130
1144
|
}
|
|
1131
1145
|
}
|
|
1146
|
+
async function spanComponentsToObjectId({
|
|
1147
|
+
components,
|
|
1148
|
+
state
|
|
1149
|
+
}) {
|
|
1150
|
+
return await spanComponentsToObjectIdLambda(
|
|
1151
|
+
state ?? _globalState,
|
|
1152
|
+
components
|
|
1153
|
+
)();
|
|
1154
|
+
}
|
|
1132
1155
|
function startSpanParentArgs(args) {
|
|
1133
1156
|
let argParentObjectId = void 0;
|
|
1134
1157
|
let argParentSpanIds = void 0;
|
|
@@ -3456,6 +3479,7 @@ __export(exports_node_exports, {
|
|
|
3456
3479
|
renderMessage: () => renderMessage,
|
|
3457
3480
|
reportFailures: () => reportFailures,
|
|
3458
3481
|
setFetch: () => setFetch,
|
|
3482
|
+
spanComponentsToObjectId: () => spanComponentsToObjectId,
|
|
3459
3483
|
startSpan: () => startSpan,
|
|
3460
3484
|
summarize: () => summarize,
|
|
3461
3485
|
toolFunctionDefinitionSchema: () => toolFunctionDefinitionSchema,
|
|
@@ -5975,6 +5999,7 @@ var src_default = exports_node_exports;
|
|
|
5975
5999
|
renderMessage,
|
|
5976
6000
|
reportFailures,
|
|
5977
6001
|
setFetch,
|
|
6002
|
+
spanComponentsToObjectId,
|
|
5978
6003
|
startSpan,
|
|
5979
6004
|
summarize,
|
|
5980
6005
|
toolFunctionDefinitionSchema,
|
package/dist/index.mjs
CHANGED
|
@@ -329,6 +329,7 @@ import { z as z2 } from "zod";
|
|
|
329
329
|
// src/functions/stream.ts
|
|
330
330
|
import {
|
|
331
331
|
callEventSchema,
|
|
332
|
+
sseConsoleEventDataSchema,
|
|
332
333
|
sseProgressEventDataSchema
|
|
333
334
|
} from "@braintrust/core/typespecs";
|
|
334
335
|
import {
|
|
@@ -348,6 +349,10 @@ var braintrustStreamChunkSchema = z.union([
|
|
|
348
349
|
type: z.literal("error"),
|
|
349
350
|
data: z.string()
|
|
350
351
|
}),
|
|
352
|
+
z.object({
|
|
353
|
+
type: z.literal("console"),
|
|
354
|
+
data: sseConsoleEventDataSchema
|
|
355
|
+
}),
|
|
351
356
|
z.object({
|
|
352
357
|
type: z.literal("progress"),
|
|
353
358
|
data: sseProgressEventDataSchema
|
|
@@ -433,7 +438,7 @@ var BraintrustStream = class _BraintrustStream {
|
|
|
433
438
|
return this.memoizedFinalValue;
|
|
434
439
|
}
|
|
435
440
|
this.memoizedFinalValue = new Promise((resolve, reject2) => {
|
|
436
|
-
|
|
441
|
+
this.stream.pipeThrough(createFinalValuePassThroughStream(resolve, reject2)).pipeTo(devNullWritableStream());
|
|
437
442
|
});
|
|
438
443
|
return this.memoizedFinalValue;
|
|
439
444
|
}
|
|
@@ -467,7 +472,7 @@ function btStreamParser() {
|
|
|
467
472
|
case "error":
|
|
468
473
|
controller.enqueue({
|
|
469
474
|
type: "error",
|
|
470
|
-
data: event.data
|
|
475
|
+
data: JSON.parse(event.data)
|
|
471
476
|
});
|
|
472
477
|
break;
|
|
473
478
|
case "progress":
|
|
@@ -476,6 +481,12 @@ function btStreamParser() {
|
|
|
476
481
|
data: sseProgressEventDataSchema.parse(JSON.parse(event.data))
|
|
477
482
|
});
|
|
478
483
|
break;
|
|
484
|
+
case "console":
|
|
485
|
+
controller.enqueue({
|
|
486
|
+
type: "console",
|
|
487
|
+
data: sseConsoleEventDataSchema.parse(JSON.parse(event.data))
|
|
488
|
+
});
|
|
489
|
+
break;
|
|
479
490
|
case "start":
|
|
480
491
|
controller.enqueue({
|
|
481
492
|
type: "start",
|
|
@@ -542,6 +553,7 @@ function createFinalValuePassThroughStream(onFinal, onError) {
|
|
|
542
553
|
case "progress":
|
|
543
554
|
case "start":
|
|
544
555
|
case "done":
|
|
556
|
+
case "console":
|
|
545
557
|
break;
|
|
546
558
|
default:
|
|
547
559
|
const _type = chunkType;
|
|
@@ -755,7 +767,9 @@ var BraintrustState = class _BraintrustState {
|
|
|
755
767
|
}
|
|
756
768
|
const newState = await loginToState({
|
|
757
769
|
...this.loginParams,
|
|
758
|
-
...
|
|
770
|
+
...Object.fromEntries(
|
|
771
|
+
Object.entries(loginParams).filter(([k, v]) => !isEmpty(v))
|
|
772
|
+
)
|
|
759
773
|
});
|
|
760
774
|
this.copyLoginInfo(newState);
|
|
761
775
|
}
|
|
@@ -1065,6 +1079,15 @@ function spanComponentsToObjectIdLambda(state, components) {
|
|
|
1065
1079
|
throw new Error(`Unknown object type: ${x}`);
|
|
1066
1080
|
}
|
|
1067
1081
|
}
|
|
1082
|
+
async function spanComponentsToObjectId({
|
|
1083
|
+
components,
|
|
1084
|
+
state
|
|
1085
|
+
}) {
|
|
1086
|
+
return await spanComponentsToObjectIdLambda(
|
|
1087
|
+
state ?? _globalState,
|
|
1088
|
+
components
|
|
1089
|
+
)();
|
|
1090
|
+
}
|
|
1068
1091
|
function startSpanParentArgs(args) {
|
|
1069
1092
|
let argParentObjectId = void 0;
|
|
1070
1093
|
let argParentSpanIds = void 0;
|
|
@@ -3392,6 +3415,7 @@ __export(exports_node_exports, {
|
|
|
3392
3415
|
renderMessage: () => renderMessage,
|
|
3393
3416
|
reportFailures: () => reportFailures,
|
|
3394
3417
|
setFetch: () => setFetch,
|
|
3418
|
+
spanComponentsToObjectId: () => spanComponentsToObjectId,
|
|
3395
3419
|
startSpan: () => startSpan,
|
|
3396
3420
|
summarize: () => summarize,
|
|
3397
3421
|
toolFunctionDefinitionSchema: () => toolFunctionDefinitionSchema,
|
|
@@ -5913,6 +5937,7 @@ export {
|
|
|
5913
5937
|
renderMessage,
|
|
5914
5938
|
reportFailures,
|
|
5915
5939
|
setFetch,
|
|
5940
|
+
spanComponentsToObjectId,
|
|
5916
5941
|
startSpan,
|
|
5917
5942
|
summarize,
|
|
5918
5943
|
toolFunctionDefinitionSchema,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "braintrust",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.161",
|
|
4
4
|
"description": "SDK for integrating Braintrust",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
},
|
|
71
71
|
"dependencies": {
|
|
72
72
|
"@ai-sdk/provider": "^0.0.11",
|
|
73
|
-
"@braintrust/core": "0.0.
|
|
73
|
+
"@braintrust/core": "0.0.58",
|
|
74
74
|
"@next/env": "^14.2.3",
|
|
75
75
|
"@vercel/functions": "^1.0.2",
|
|
76
76
|
"ai": "^3.2.16",
|