braintrust 0.0.166 → 0.0.167
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 +135 -39
- package/dist/browser.d.ts +135 -39
- package/dist/browser.js +317 -85
- package/dist/browser.mjs +318 -87
- package/dist/cli.js +299 -65
- package/dist/index.d.mts +135 -39
- package/dist/index.d.ts +135 -39
- package/dist/index.js +318 -85
- package/dist/index.mjs +319 -87
- package/package.json +7 -2
- package/typedoc.json +1 -0
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LogFeedbackFullArgs, ExperimentEvent, BackgroundLogEvent, ExperimentLogFullArgs, ExperimentLogPartialArgs, IdField, SpanType, SpanComponentsV3, 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
|
-
import { GitMetadataSettings, RepoInfo, PromptData, OpenAIMessage, Tools, AnyModelParam, Message, Prompt as Prompt$1, PromptSessionEvent, StreamingMode, FunctionType, IfExists, SavedFunctionId, ModelParams } from '@braintrust/core/typespecs';
|
|
3
|
+
import { GitMetadataSettings, AttachmentReference, RepoInfo, 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';
|
|
5
5
|
|
|
6
6
|
interface IsoAsyncLocalStorage<T> {
|
|
@@ -35,16 +35,14 @@ type EndSpanArgs = {
|
|
|
35
35
|
};
|
|
36
36
|
interface Exportable {
|
|
37
37
|
/**
|
|
38
|
-
* Return a serialized representation of the object that can be used to start subspans in other places. See
|
|
38
|
+
* Return a serialized representation of the object that can be used to start subspans in other places. See {@link Span.traced} for more details.
|
|
39
39
|
*/
|
|
40
40
|
export(): Promise<string>;
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
43
43
|
* A Span encapsulates logged data and metrics for a unit of work. This interface is shared by all span implementations.
|
|
44
44
|
*
|
|
45
|
-
* We suggest using one of the various `traced` methods, instead of creating Spans directly.
|
|
46
|
-
*
|
|
47
|
-
* See `Span.traced` for full details.
|
|
45
|
+
* We suggest using one of the various `traced` methods, instead of creating Spans directly. See {@link Span.traced} for full details.
|
|
48
46
|
*/
|
|
49
47
|
interface Span extends Exportable {
|
|
50
48
|
/**
|
|
@@ -54,13 +52,13 @@ interface Span extends Exportable {
|
|
|
54
52
|
/**
|
|
55
53
|
* Incrementally update the current span with new data. The event will be batched and uploaded behind the scenes.
|
|
56
54
|
*
|
|
57
|
-
* @param event: Data to be logged. See
|
|
55
|
+
* @param event: Data to be logged. See {@link Experiment.log} for full details.
|
|
58
56
|
*/
|
|
59
57
|
log(event: ExperimentLogPartialArgs): void;
|
|
60
58
|
/**
|
|
61
59
|
* Add feedback to the current span. Unlike `Experiment.logFeedback` and `Logger.logFeedback`, this method does not accept an id parameter, because it logs feedback to the current span.
|
|
62
60
|
*
|
|
63
|
-
* @param event: Data to be logged. See
|
|
61
|
+
* @param event: Data to be logged. See {@link Experiment.logFeedback} for full details.
|
|
64
62
|
*/
|
|
65
63
|
logFeedback(event: Omit<LogFeedbackFullArgs, "id">): void;
|
|
66
64
|
/**
|
|
@@ -75,8 +73,8 @@ interface Span extends Exportable {
|
|
|
75
73
|
* @param args.start_time Optional start time of the span, as a timestamp in seconds.
|
|
76
74
|
* @param args.setCurrent If true (the default), the span will be marked as the currently-active span for the duration of the callback.
|
|
77
75
|
* @param args.parent Optional parent info string for the span. The string can be generated from `[Span,Experiment,Logger].export`. If not provided, the current span will be used (depending on context). This is useful for adding spans to an existing trace.
|
|
78
|
-
* @param args.event Data to be logged. See
|
|
79
|
-
* @
|
|
76
|
+
* @param args.event Data to be logged. See {@link Experiment.log} for full details.
|
|
77
|
+
* @returns The result of running `callback`.
|
|
80
78
|
*/
|
|
81
79
|
traced<R>(callback: (span: Span) => R, args?: StartSpanArgs & SetCurrentArg): R;
|
|
82
80
|
/**
|
|
@@ -84,7 +82,7 @@ interface Span extends Exportable {
|
|
|
84
82
|
* where you cannot use callbacks. However, spans started with `startSpan` will not be marked as the "current span",
|
|
85
83
|
* so `currentSpan()` and `traced()` will be no-ops. If you want to mark a span as current, use `traced` instead.
|
|
86
84
|
*
|
|
87
|
-
* See
|
|
85
|
+
* See {@link Span.traced} for full details.
|
|
88
86
|
*
|
|
89
87
|
* @returns The newly-created `Span`
|
|
90
88
|
*/
|
|
@@ -212,7 +210,15 @@ declare class BraintrustState {
|
|
|
212
210
|
bgLogger(): BackgroundLogger;
|
|
213
211
|
loginReplaceApiConn(apiConn: HTTPConnection): void;
|
|
214
212
|
}
|
|
213
|
+
/**
|
|
214
|
+
* This function should be invoked exactly once after configuring the `iso`
|
|
215
|
+
* object based on the platform. See js/src/node.ts for an example.
|
|
216
|
+
* @internal
|
|
217
|
+
*/
|
|
215
218
|
declare function _internalSetInitialState(): void;
|
|
219
|
+
/**
|
|
220
|
+
* @internal
|
|
221
|
+
*/
|
|
216
222
|
declare const _internalGetGlobalState: () => BraintrustState;
|
|
217
223
|
declare class FailedHTTPResponse extends Error {
|
|
218
224
|
status: number;
|
|
@@ -259,13 +265,72 @@ interface LogOptions<IsAsyncFlush> {
|
|
|
259
265
|
computeMetadataArgs?: Record<string, any>;
|
|
260
266
|
}
|
|
261
267
|
type PromiseUnless<B, R> = B extends true ? R : Promise<Awaited<R>>;
|
|
268
|
+
interface AttachmentParams {
|
|
269
|
+
data: string | Blob | ArrayBuffer;
|
|
270
|
+
filename: string;
|
|
271
|
+
contentType: string;
|
|
272
|
+
state?: BraintrustState;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Represents an attachment to be uploaded and the associated metadata.
|
|
276
|
+
* `Attachment` objects can be inserted anywhere in an event, allowing you to
|
|
277
|
+
* log arbitrary file data. The SDK will asynchronously upload the file to
|
|
278
|
+
* object storage and replace the `Attachment` object with an
|
|
279
|
+
* `AttachmentReference`.
|
|
280
|
+
*/
|
|
281
|
+
declare class Attachment {
|
|
282
|
+
/**
|
|
283
|
+
* The object that replaces this `Attachment` at upload time.
|
|
284
|
+
*/
|
|
285
|
+
readonly reference: AttachmentReference;
|
|
286
|
+
private readonly uploader;
|
|
287
|
+
private readonly data;
|
|
288
|
+
private readonly state?;
|
|
289
|
+
private readonly dataDebugString;
|
|
290
|
+
/**
|
|
291
|
+
* Construct an attachment.
|
|
292
|
+
*
|
|
293
|
+
* @param data A string representing the path of the file on disk, or a
|
|
294
|
+
* `Blob`/`ArrayBuffer` with the file's contents. The caller is responsible
|
|
295
|
+
* for ensuring the file/blob/buffer is not modified until upload is complete.
|
|
296
|
+
*
|
|
297
|
+
* @param filename The desired name of the file in Braintrust after uploading.
|
|
298
|
+
* This parameter is for visualization purposes only and has no effect on
|
|
299
|
+
* attachment storage.
|
|
300
|
+
*
|
|
301
|
+
* @param contentType The MIME type of the file.
|
|
302
|
+
*
|
|
303
|
+
* @param state (Optional) For internal use.
|
|
304
|
+
*/
|
|
305
|
+
constructor({ data, filename, contentType, state }: AttachmentParams);
|
|
306
|
+
/**
|
|
307
|
+
* On first access, (1) reads the attachment from disk if needed, (2)
|
|
308
|
+
* authenticates with the data plane to request a signed URL, (3) uploads to
|
|
309
|
+
* object store, and (4) updates the attachment.
|
|
310
|
+
*
|
|
311
|
+
* @returns The attachment status.
|
|
312
|
+
*/
|
|
313
|
+
upload(): Promise<{
|
|
314
|
+
upload_status: "error" | "done" | "uploading";
|
|
315
|
+
error_message?: string | undefined;
|
|
316
|
+
}>;
|
|
317
|
+
/**
|
|
318
|
+
* A human-readable description for logging and debugging.
|
|
319
|
+
*
|
|
320
|
+
* @returns The debug object. The return type is not stable and may change in
|
|
321
|
+
* a future release.
|
|
322
|
+
*/
|
|
323
|
+
debugInfo(): Record<string, unknown>;
|
|
324
|
+
private initUploader;
|
|
325
|
+
private initData;
|
|
326
|
+
}
|
|
262
327
|
/**
|
|
263
328
|
* Update a span using the output of `span.export()`. It is important that you only resume updating
|
|
264
329
|
* to a span once the original span has been fully written and flushed, since otherwise updates to
|
|
265
330
|
* the span may conflict with the original span.
|
|
266
331
|
*
|
|
267
332
|
* @param exported The output of `span.export()`.
|
|
268
|
-
* @param event The event data to update the span with. See
|
|
333
|
+
* @param event The event data to update the span with. See {@link Experiment.log} for a full list of valid fields.
|
|
269
334
|
* @param state (optional) Login state to use. If not provided, the global state will be used.
|
|
270
335
|
*/
|
|
271
336
|
declare function updateSpan({ exported, state, ...event }: {
|
|
@@ -312,7 +377,7 @@ declare class Logger<IsAsyncFlush extends boolean> implements Exportable {
|
|
|
312
377
|
* @param event.id: (Optional) a unique identifier for the event. If you don't provide one, BrainTrust will generate one for you.
|
|
313
378
|
* @param options Additional logging options
|
|
314
379
|
* @param options.allowConcurrentWithSpans in rare cases where you need to log at the top level separately from spans on the logger elsewhere, set this to true.
|
|
315
|
-
*
|
|
380
|
+
* @returns The `id` of the logged event.
|
|
316
381
|
*/
|
|
317
382
|
log(event: Readonly<StartSpanEventArgs>, options?: {
|
|
318
383
|
allowConcurrentWithSpans?: boolean;
|
|
@@ -320,7 +385,7 @@ declare class Logger<IsAsyncFlush extends boolean> implements Exportable {
|
|
|
320
385
|
/**
|
|
321
386
|
* Create a new toplevel span underneath the logger. The name defaults to "root".
|
|
322
387
|
*
|
|
323
|
-
* See
|
|
388
|
+
* See {@link Span.traced} for full details.
|
|
324
389
|
*/
|
|
325
390
|
traced<R>(callback: (span: Span) => R, args?: StartSpanArgs & SetCurrentArg): PromiseUnless<IsAsyncFlush, R>;
|
|
326
391
|
/**
|
|
@@ -328,7 +393,7 @@ declare class Logger<IsAsyncFlush extends boolean> implements Exportable {
|
|
|
328
393
|
* where you cannot use callbacks. However, spans started with `startSpan` will not be marked as the "current span",
|
|
329
394
|
* so `currentSpan()` and `traced()` will be no-ops. If you want to mark a span as current, use `traced` instead.
|
|
330
395
|
*
|
|
331
|
-
* See
|
|
396
|
+
* See {@link traced} for full details.
|
|
332
397
|
*/
|
|
333
398
|
startSpan(args?: StartSpanArgs): Span;
|
|
334
399
|
private startSpanImpl;
|
|
@@ -348,11 +413,13 @@ declare class Logger<IsAsyncFlush extends boolean> implements Exportable {
|
|
|
348
413
|
* Update a span in the experiment using its id. It is important that you only update a span once the original span has been fully written and flushed,
|
|
349
414
|
* since otherwise updates to the span may conflict with the original span.
|
|
350
415
|
*
|
|
351
|
-
* @param event The event data to update the span with. Must include `id`. See
|
|
416
|
+
* @param event The event data to update the span with. Must include `id`. See {@link Experiment.log} for a full list of valid fields.
|
|
352
417
|
*/
|
|
353
418
|
updateSpan(event: Omit<Partial<ExperimentEvent>, "id"> & Required<Pick<ExperimentEvent, "id">>): void;
|
|
354
419
|
/**
|
|
355
|
-
* Return a serialized representation of the logger that can be used to start subspans in other places.
|
|
420
|
+
* Return a serialized representation of the logger that can be used to start subspans in other places.
|
|
421
|
+
*
|
|
422
|
+
* See {@link Span.startSpan} for more details.
|
|
356
423
|
*/
|
|
357
424
|
export(): Promise<string>;
|
|
358
425
|
flush(): Promise<void>;
|
|
@@ -449,11 +516,11 @@ declare function initExperiment<IsOpen extends boolean = false>(options: Readonl
|
|
|
449
516
|
*/
|
|
450
517
|
declare function initExperiment<IsOpen extends boolean = false>(project: string, options?: Readonly<InitOptions<IsOpen>>): InitializedExperiment<IsOpen>;
|
|
451
518
|
/**
|
|
452
|
-
*
|
|
519
|
+
* @deprecated Use {@link init} instead.
|
|
453
520
|
*/
|
|
454
521
|
declare function withExperiment<R>(project: string, callback: (experiment: Experiment) => R, options?: Readonly<InitOptions<false> & SetCurrentArg>): R;
|
|
455
522
|
/**
|
|
456
|
-
*
|
|
523
|
+
* @deprecated Use {@link initLogger} instead.
|
|
457
524
|
*/
|
|
458
525
|
declare function withLogger<IsAsyncFlush extends boolean = false, R = void>(callback: (logger: Logger<IsAsyncFlush>) => R, options?: Readonly<InitLoggerOptions<IsAsyncFlush> & SetCurrentArg>): R;
|
|
459
526
|
type UseOutputOption<IsLegacyDataset extends boolean> = {
|
|
@@ -488,12 +555,13 @@ type FullInitDatasetOptions<IsLegacyDataset extends boolean> = {
|
|
|
488
555
|
declare function initDataset<IsLegacyDataset extends boolean = typeof DEFAULT_IS_LEGACY_DATASET>(options: Readonly<FullInitDatasetOptions<IsLegacyDataset>>): Dataset<IsLegacyDataset>;
|
|
489
556
|
/**
|
|
490
557
|
* Legacy form of `initDataset` which accepts the project name as the first
|
|
491
|
-
* parameter, separately from the remaining options.
|
|
492
|
-
*
|
|
558
|
+
* parameter, separately from the remaining options.
|
|
559
|
+
*
|
|
560
|
+
* See `initDataset(options)` for full details.
|
|
493
561
|
*/
|
|
494
562
|
declare function initDataset<IsLegacyDataset extends boolean = typeof DEFAULT_IS_LEGACY_DATASET>(project: string, options?: Readonly<InitDatasetOptions<IsLegacyDataset>>): Dataset<IsLegacyDataset>;
|
|
495
563
|
/**
|
|
496
|
-
*
|
|
564
|
+
* @deprecated Use {@link initDataset} instead.
|
|
497
565
|
*/
|
|
498
566
|
declare function withDataset<R, IsLegacyDataset extends boolean = typeof DEFAULT_IS_LEGACY_DATASET>(project: string, callback: (dataset: Dataset<IsLegacyDataset>) => R, options?: Readonly<InitDatasetOptions<IsLegacyDataset>>): R;
|
|
499
567
|
type AsyncFlushArg<IsAsyncFlush> = {
|
|
@@ -606,7 +674,7 @@ declare function loginToState(options?: LoginOptions): Promise<BraintrustState>;
|
|
|
606
674
|
/**
|
|
607
675
|
* Log a single event to the current experiment. The event will be batched and uploaded behind the scenes.
|
|
608
676
|
*
|
|
609
|
-
* @param event The event to log. See
|
|
677
|
+
* @param event The event to log. See {@link Experiment.log} for full details.
|
|
610
678
|
* @returns The `id` of the logged event.
|
|
611
679
|
*/
|
|
612
680
|
declare function log(event: ExperimentLogFullArgs): string;
|
|
@@ -626,17 +694,17 @@ type OptionalStateArg = {
|
|
|
626
694
|
state?: BraintrustState;
|
|
627
695
|
};
|
|
628
696
|
/**
|
|
629
|
-
* Returns the currently-active experiment (set by
|
|
697
|
+
* Returns the currently-active experiment (set by {@link init}). Returns undefined if no current experiment has been set.
|
|
630
698
|
*/
|
|
631
699
|
declare function currentExperiment(options?: OptionalStateArg): Experiment | undefined;
|
|
632
700
|
/**
|
|
633
|
-
* Returns the currently-active logger (set by
|
|
701
|
+
* Returns the currently-active logger (set by {@link initLogger}). Returns undefined if no current logger has been set.
|
|
634
702
|
*/
|
|
635
703
|
declare function currentLogger<IsAsyncFlush extends boolean>(options?: AsyncFlushArg<IsAsyncFlush> & OptionalStateArg): Logger<IsAsyncFlush> | undefined;
|
|
636
704
|
/**
|
|
637
705
|
* Return the currently-active span for logging (set by one of the `traced` methods). If there is no active span, returns a no-op span object, which supports the same interface as spans but does no logging.
|
|
638
706
|
*
|
|
639
|
-
* See
|
|
707
|
+
* See {@link Span} for full details.
|
|
640
708
|
*/
|
|
641
709
|
declare function currentSpan(options?: OptionalStateArg): Span;
|
|
642
710
|
/**
|
|
@@ -652,7 +720,7 @@ declare function logError(span: Span, error: unknown): void;
|
|
|
652
720
|
*
|
|
653
721
|
* and creates a span under the first one that is active. Alternatively, if `parent` is specified, it creates a span under the specified parent row. If none of these are active, it returns a no-op span object.
|
|
654
722
|
*
|
|
655
|
-
* See
|
|
723
|
+
* See {@link Span.traced} for full details.
|
|
656
724
|
*/
|
|
657
725
|
declare function traced<IsAsyncFlush extends boolean = false, R = void>(callback: (span: Span) => R, args?: StartSpanArgs & SetCurrentArg & AsyncFlushArg<IsAsyncFlush> & OptionalStateArg): PromiseUnless<IsAsyncFlush, R>;
|
|
658
726
|
/**
|
|
@@ -688,7 +756,7 @@ declare const traceable: typeof wrapTraced;
|
|
|
688
756
|
* where you cannot use callbacks. However, spans started with `startSpan` will not be marked as the "current span",
|
|
689
757
|
* so `currentSpan()` and `traced()` will be no-ops. If you want to mark a span as current, use `traced` instead.
|
|
690
758
|
*
|
|
691
|
-
* See
|
|
759
|
+
* See {@link traced} for full details.
|
|
692
760
|
*/
|
|
693
761
|
declare function startSpan<IsAsyncFlush extends boolean = false>(args?: StartSpanArgs & AsyncFlushArg<IsAsyncFlush> & OptionalStateArg): Span;
|
|
694
762
|
/**
|
|
@@ -706,6 +774,20 @@ declare function setFetch(fetch: typeof globalThis.fetch): void;
|
|
|
706
774
|
* Runs the provided callback with the span as the current span.
|
|
707
775
|
*/
|
|
708
776
|
declare function withCurrent<R>(span: Span, callback: (span: Span) => R, state?: BraintrustState): R;
|
|
777
|
+
/**
|
|
778
|
+
* Creates a deep copy of the given event. Replaces references to user objects
|
|
779
|
+
* with placeholder strings to ensure serializability, except for
|
|
780
|
+
* {@link Attachment} objects, which are preserved and not deep-copied.
|
|
781
|
+
*/
|
|
782
|
+
declare function deepCopyEvent<T extends Partial<BackgroundLogEvent>>(event: T): T;
|
|
783
|
+
/**
|
|
784
|
+
* Helper function for uploading attachments. Recursively extracts `Attachment`
|
|
785
|
+
* values and replaces them with their associated `AttachmentReference` objects.
|
|
786
|
+
*
|
|
787
|
+
* @param event The event to filter. Will be modified in-place.
|
|
788
|
+
* @param attachments Flat array of extracted attachments (output parameter).
|
|
789
|
+
*/
|
|
790
|
+
declare function extractAttachments(event: Record<string, any>, attachments: Attachment[]): void;
|
|
709
791
|
type WithTransactionId<R> = R & {
|
|
710
792
|
[TRANSACTION_ID_FIELD]: TransactionId;
|
|
711
793
|
};
|
|
@@ -772,10 +854,10 @@ declare class Experiment extends ObjectFetcher<ExperimentEvent> implements Expor
|
|
|
772
854
|
* @param event.metrics: (Optional) a dictionary of metrics to log. The following keys are populated automatically: "start", "end".
|
|
773
855
|
* @param event.id: (Optional) a unique identifier for the event. If you don't provide one, BrainTrust will generate one for you.
|
|
774
856
|
* @param event.dataset_record_id: (Optional) the id of the dataset record that this event is associated with. This field is required if and only if the experiment is associated with a dataset.
|
|
775
|
-
* @param event.inputs: (Deprecated) the same as `input` (will be removed in a future version).
|
|
857
|
+
* @deprecated @param event.inputs: (Deprecated) the same as `input` (will be removed in a future version).
|
|
776
858
|
* @param options Additional logging options
|
|
777
859
|
* @param options.allowConcurrentWithSpans in rare cases where you need to log at the top level separately from spans on the experiment elsewhere, set this to true.
|
|
778
|
-
*
|
|
860
|
+
* @returns The `id` of the logged event.
|
|
779
861
|
*/
|
|
780
862
|
log(event: Readonly<ExperimentLogFullArgs>, options?: {
|
|
781
863
|
allowConcurrentWithSpans?: boolean;
|
|
@@ -783,7 +865,7 @@ declare class Experiment extends ObjectFetcher<ExperimentEvent> implements Expor
|
|
|
783
865
|
/**
|
|
784
866
|
* Create a new toplevel span underneath the experiment. The name defaults to "root".
|
|
785
867
|
*
|
|
786
|
-
* See
|
|
868
|
+
* See {@link Span.traced} for full details.
|
|
787
869
|
*/
|
|
788
870
|
traced<R>(callback: (span: Span) => R, args?: StartSpanArgs & SetCurrentArg): R;
|
|
789
871
|
/**
|
|
@@ -791,7 +873,7 @@ declare class Experiment extends ObjectFetcher<ExperimentEvent> implements Expor
|
|
|
791
873
|
* where you cannot use callbacks. However, spans started with `startSpan` will not be marked as the "current span",
|
|
792
874
|
* so `currentSpan()` and `traced()` will be no-ops. If you want to mark a span as current, use `traced` instead.
|
|
793
875
|
*
|
|
794
|
-
* See
|
|
876
|
+
* See {@link traced} for full details.
|
|
795
877
|
*/
|
|
796
878
|
startSpan(args?: StartSpanArgs): Span;
|
|
797
879
|
private startSpanImpl;
|
|
@@ -827,11 +909,13 @@ declare class Experiment extends ObjectFetcher<ExperimentEvent> implements Expor
|
|
|
827
909
|
* Update a span in the experiment using its id. It is important that you only update a span once the original span has been fully written and flushed,
|
|
828
910
|
* since otherwise updates to the span may conflict with the original span.
|
|
829
911
|
*
|
|
830
|
-
* @param event The event data to update the span with. Must include `id`. See
|
|
912
|
+
* @param event The event data to update the span with. Must include `id`. See {@link Experiment.log} for a full list of valid fields.
|
|
831
913
|
*/
|
|
832
914
|
updateSpan(event: Omit<Partial<ExperimentEvent>, "id"> & Required<Pick<ExperimentEvent, "id">>): void;
|
|
833
915
|
/**
|
|
834
|
-
* Return a serialized representation of the experiment that can be used to start subspans in other places.
|
|
916
|
+
* Return a serialized representation of the experiment that can be used to start subspans in other places.
|
|
917
|
+
*
|
|
918
|
+
* See {@link Span.startSpan} for more details.
|
|
835
919
|
*/
|
|
836
920
|
export(): Promise<string>;
|
|
837
921
|
/**
|
|
@@ -839,7 +923,7 @@ declare class Experiment extends ObjectFetcher<ExperimentEvent> implements Expor
|
|
|
839
923
|
*/
|
|
840
924
|
flush(): Promise<void>;
|
|
841
925
|
/**
|
|
842
|
-
* This function is deprecated. You can simply remove it from your code.
|
|
926
|
+
* @deprecated This function is deprecated. You can simply remove it from your code.
|
|
843
927
|
*/
|
|
844
928
|
close(): Promise<string>;
|
|
845
929
|
}
|
|
@@ -857,9 +941,9 @@ declare class ReadonlyExperiment extends ObjectFetcher<ExperimentEvent> {
|
|
|
857
941
|
}
|
|
858
942
|
declare function newId(): string;
|
|
859
943
|
/**
|
|
860
|
-
* Primary implementation of the `Span` interface. See
|
|
944
|
+
* Primary implementation of the `Span` interface. See {@link Span} for full details on each method.
|
|
861
945
|
*
|
|
862
|
-
* We suggest using one of the various `traced` methods, instead of creating Spans directly. See
|
|
946
|
+
* We suggest using one of the various `traced` methods, instead of creating Spans directly. See {@link Span.startSpan} for full details.
|
|
863
947
|
*/
|
|
864
948
|
declare class SpanImpl implements Span {
|
|
865
949
|
private state;
|
|
@@ -970,7 +1054,7 @@ declare class Dataset<IsLegacyDataset extends boolean = typeof DEFAULT_IS_LEGACY
|
|
|
970
1054
|
*/
|
|
971
1055
|
flush(): Promise<void>;
|
|
972
1056
|
/**
|
|
973
|
-
* This function is deprecated. You can simply remove it from your code.
|
|
1057
|
+
* @deprecated This function is deprecated. You can simply remove it from your code.
|
|
974
1058
|
*/
|
|
975
1059
|
close(): Promise<string>;
|
|
976
1060
|
}
|
|
@@ -1109,6 +1193,14 @@ interface DatasetSummary {
|
|
|
1109
1193
|
datasetUrl: string;
|
|
1110
1194
|
dataSummary: DataSummary;
|
|
1111
1195
|
}
|
|
1196
|
+
/**
|
|
1197
|
+
* Allows accessing helper functions for testing.
|
|
1198
|
+
* @internal
|
|
1199
|
+
*/
|
|
1200
|
+
declare const _exportsForTestingOnly: {
|
|
1201
|
+
extractAttachments: typeof extractAttachments;
|
|
1202
|
+
deepCopyEvent: typeof deepCopyEvent;
|
|
1203
|
+
};
|
|
1112
1204
|
|
|
1113
1205
|
declare const braintrustStreamChunkSchema: z.ZodUnion<[z.ZodObject<{
|
|
1114
1206
|
type: z.ZodLiteral<"text_delta">;
|
|
@@ -1731,6 +1823,9 @@ declare function parseCachedHeader(value: string | null | undefined): number | u
|
|
|
1731
1823
|
declare function wrapAISDKModel<T extends object>(model: T): T;
|
|
1732
1824
|
|
|
1733
1825
|
type braintrust_AnyDataset = AnyDataset;
|
|
1826
|
+
type braintrust_Attachment = Attachment;
|
|
1827
|
+
declare const braintrust_Attachment: typeof Attachment;
|
|
1828
|
+
type braintrust_AttachmentParams = AttachmentParams;
|
|
1734
1829
|
type braintrust_BackgroundLoggerOpts = BackgroundLoggerOpts;
|
|
1735
1830
|
declare const braintrust_BaseExperiment: typeof BaseExperiment;
|
|
1736
1831
|
type braintrust_BaseMetadata = BaseMetadata;
|
|
@@ -1826,6 +1921,7 @@ type braintrust_ToolFunctionDefinition = ToolFunctionDefinition;
|
|
|
1826
1921
|
type braintrust_ToolOpts<Params, Returns, Fn extends GenericFunction<Params, Returns>> = ToolOpts<Params, Returns, Fn>;
|
|
1827
1922
|
type braintrust_WithTransactionId<R> = WithTransactionId<R>;
|
|
1828
1923
|
declare const braintrust_X_CACHED_HEADER: typeof X_CACHED_HEADER;
|
|
1924
|
+
declare const braintrust__exportsForTestingOnly: typeof _exportsForTestingOnly;
|
|
1829
1925
|
declare const braintrust__internalGetGlobalState: typeof _internalGetGlobalState;
|
|
1830
1926
|
declare const braintrust__internalSetInitialState: typeof _internalSetInitialState;
|
|
1831
1927
|
declare const braintrust_braintrustStreamChunkSchema: typeof braintrustStreamChunkSchema;
|
|
@@ -1870,7 +1966,7 @@ declare const braintrust_wrapOpenAI: typeof wrapOpenAI;
|
|
|
1870
1966
|
declare const braintrust_wrapOpenAIv4: typeof wrapOpenAIv4;
|
|
1871
1967
|
declare const braintrust_wrapTraced: typeof wrapTraced;
|
|
1872
1968
|
declare namespace braintrust {
|
|
1873
|
-
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_permalink as permalink, 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 };
|
|
1969
|
+
export { type braintrust_AnyDataset as AnyDataset, braintrust_Attachment as Attachment, type braintrust_AttachmentParams as AttachmentParams, 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__exportsForTestingOnly as _exportsForTestingOnly, braintrust__internalGetGlobalState as _internalGetGlobalState, braintrust__internalSetInitialState as _internalSetInitialState, braintrust_braintrustStreamChunkSchema as braintrustStreamChunkSchema, braintrust_buildLocalSummary as buildLocalSummary, braintrust_createFinalValuePassThroughStream as createFinalValuePassThroughStream, braintrust_currentExperiment as currentExperiment, braintrust_currentLogger as currentLogger, braintrust_currentSpan as currentSpan, braintrust_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_permalink as permalink, 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 };
|
|
1874
1970
|
}
|
|
1875
1971
|
|
|
1876
1972
|
/**
|
|
@@ -1926,4 +2022,4 @@ declare namespace braintrust {
|
|
|
1926
2022
|
* @module braintrust
|
|
1927
2023
|
*/
|
|
1928
2024
|
|
|
1929
|
-
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, permalink, projects, renderMessage, reportFailures, setFetch, spanComponentsToObjectId, startSpan, summarize, toolFunctionDefinitionSchema, traceable, traced, updateSpan, withCurrent, withDataset, withExperiment, withLogger, wrapAISDKModel, wrapOpenAI, wrapOpenAIv4, wrapTraced };
|
|
2025
|
+
export { type AnyDataset, Attachment, type AttachmentParams, 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, _exportsForTestingOnly, _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, permalink, projects, renderMessage, reportFailures, setFetch, spanComponentsToObjectId, startSpan, summarize, toolFunctionDefinitionSchema, traceable, traced, updateSpan, withCurrent, withDataset, withExperiment, withLogger, wrapAISDKModel, wrapOpenAI, wrapOpenAIv4, wrapTraced };
|