braintrust 0.4.0 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dev/dist/index.d.mts +24 -0
- package/dev/dist/index.d.ts +24 -0
- package/dev/dist/index.js +7782 -5614
- package/dev/dist/index.mjs +7702 -5534
- package/dist/browser.d.mts +37 -2
- package/dist/browser.d.ts +37 -2
- package/dist/browser.js +7876 -5539
- package/dist/browser.mjs +8643 -6306
- package/dist/cli.js +8054 -5894
- package/dist/index.d.mts +46 -7
- package/dist/index.d.ts +46 -7
- package/dist/index.js +11013 -10164
- package/dist/index.mjs +10943 -10094
- package/package.json +1 -1
package/dev/dist/index.d.mts
CHANGED
|
@@ -7302,6 +7302,10 @@ declare class LazyValue<T> {
|
|
|
7302
7302
|
get hasSucceeded(): boolean;
|
|
7303
7303
|
}
|
|
7304
7304
|
|
|
7305
|
+
interface ContextParentSpanIds {
|
|
7306
|
+
rootSpanId: string;
|
|
7307
|
+
spanParents: string[];
|
|
7308
|
+
}
|
|
7305
7309
|
type SetCurrentArg = {
|
|
7306
7310
|
setCurrent?: boolean;
|
|
7307
7311
|
};
|
|
@@ -7450,8 +7454,19 @@ interface Span extends Exportable {
|
|
|
7450
7454
|
*/
|
|
7451
7455
|
startSpanWithParents(spanId: string, spanParents: string[], args?: StartSpanArgs): Span;
|
|
7452
7456
|
state(): BraintrustState;
|
|
7457
|
+
/**
|
|
7458
|
+
* Internal method to get the OTEL parent string for this span.
|
|
7459
|
+
* This is used by OtelContextManager to set the braintrust.parent attribute.
|
|
7460
|
+
* @returns A string like "project_id:X" or "experiment_id:X", or undefined if no parent
|
|
7461
|
+
*/
|
|
7462
|
+
_getOtelParent(): string | undefined;
|
|
7453
7463
|
kind: "span";
|
|
7454
7464
|
}
|
|
7465
|
+
declare abstract class ContextManager {
|
|
7466
|
+
abstract getParentSpanIds(): ContextParentSpanIds | undefined;
|
|
7467
|
+
abstract runInContext<R>(span: Span, callback: () => R): R;
|
|
7468
|
+
abstract getCurrentSpan(): Span | undefined;
|
|
7469
|
+
}
|
|
7455
7470
|
/**
|
|
7456
7471
|
* A fake implementation of the Span API which does nothing. This can be used as the default span.
|
|
7457
7472
|
*/
|
|
@@ -7475,6 +7490,7 @@ declare class NoopSpan implements Span {
|
|
|
7475
7490
|
setAttributes(_args: Omit<StartSpanArgs, "event">): void;
|
|
7476
7491
|
startSpanWithParents(_spanId: string, _spanParents: string[], _args?: StartSpanArgs): Span;
|
|
7477
7492
|
state(): BraintrustState;
|
|
7493
|
+
_getOtelParent(): string | undefined;
|
|
7478
7494
|
toString(): string;
|
|
7479
7495
|
}
|
|
7480
7496
|
declare const NOOP_SPAN: NoopSpan;
|
|
@@ -7549,10 +7565,12 @@ declare class BraintrustState {
|
|
|
7549
7565
|
private _proxyConn;
|
|
7550
7566
|
promptCache: PromptCache;
|
|
7551
7567
|
private _idGenerator;
|
|
7568
|
+
private _contextManager;
|
|
7552
7569
|
constructor(loginParams: LoginOptions);
|
|
7553
7570
|
resetLoginInfo(): void;
|
|
7554
7571
|
resetIdGenState(): void;
|
|
7555
7572
|
get idGenerator(): IDGenerator;
|
|
7573
|
+
get contextManager(): ContextManager;
|
|
7556
7574
|
copyLoginInfo(other: BraintrustState): void;
|
|
7557
7575
|
serialize(): SerializedBraintrustState;
|
|
7558
7576
|
static deserialize(serialized: unknown, opts?: LoginOptions): BraintrustState;
|
|
@@ -7850,6 +7868,12 @@ declare class Experiment extends ObjectFetcher<ExperimentEvent> implements Expor
|
|
|
7850
7868
|
kind: "experiment";
|
|
7851
7869
|
constructor(state: BraintrustState, lazyMetadata: LazyValue<ProjectExperimentMetadata>, dataset?: AnyDataset);
|
|
7852
7870
|
get id(): Promise<string>;
|
|
7871
|
+
/**
|
|
7872
|
+
* Wait for the experiment ID to be resolved. This is useful for ensuring the ID
|
|
7873
|
+
* is available synchronously in child spans (for OTEL parent attributes).
|
|
7874
|
+
* @internal
|
|
7875
|
+
*/
|
|
7876
|
+
_waitForId(): Promise<void>;
|
|
7853
7877
|
get name(): Promise<string>;
|
|
7854
7878
|
get project(): Promise<ObjectMetadata>;
|
|
7855
7879
|
private parentObjectType;
|
package/dev/dist/index.d.ts
CHANGED
|
@@ -7302,6 +7302,10 @@ declare class LazyValue<T> {
|
|
|
7302
7302
|
get hasSucceeded(): boolean;
|
|
7303
7303
|
}
|
|
7304
7304
|
|
|
7305
|
+
interface ContextParentSpanIds {
|
|
7306
|
+
rootSpanId: string;
|
|
7307
|
+
spanParents: string[];
|
|
7308
|
+
}
|
|
7305
7309
|
type SetCurrentArg = {
|
|
7306
7310
|
setCurrent?: boolean;
|
|
7307
7311
|
};
|
|
@@ -7450,8 +7454,19 @@ interface Span extends Exportable {
|
|
|
7450
7454
|
*/
|
|
7451
7455
|
startSpanWithParents(spanId: string, spanParents: string[], args?: StartSpanArgs): Span;
|
|
7452
7456
|
state(): BraintrustState;
|
|
7457
|
+
/**
|
|
7458
|
+
* Internal method to get the OTEL parent string for this span.
|
|
7459
|
+
* This is used by OtelContextManager to set the braintrust.parent attribute.
|
|
7460
|
+
* @returns A string like "project_id:X" or "experiment_id:X", or undefined if no parent
|
|
7461
|
+
*/
|
|
7462
|
+
_getOtelParent(): string | undefined;
|
|
7453
7463
|
kind: "span";
|
|
7454
7464
|
}
|
|
7465
|
+
declare abstract class ContextManager {
|
|
7466
|
+
abstract getParentSpanIds(): ContextParentSpanIds | undefined;
|
|
7467
|
+
abstract runInContext<R>(span: Span, callback: () => R): R;
|
|
7468
|
+
abstract getCurrentSpan(): Span | undefined;
|
|
7469
|
+
}
|
|
7455
7470
|
/**
|
|
7456
7471
|
* A fake implementation of the Span API which does nothing. This can be used as the default span.
|
|
7457
7472
|
*/
|
|
@@ -7475,6 +7490,7 @@ declare class NoopSpan implements Span {
|
|
|
7475
7490
|
setAttributes(_args: Omit<StartSpanArgs, "event">): void;
|
|
7476
7491
|
startSpanWithParents(_spanId: string, _spanParents: string[], _args?: StartSpanArgs): Span;
|
|
7477
7492
|
state(): BraintrustState;
|
|
7493
|
+
_getOtelParent(): string | undefined;
|
|
7478
7494
|
toString(): string;
|
|
7479
7495
|
}
|
|
7480
7496
|
declare const NOOP_SPAN: NoopSpan;
|
|
@@ -7549,10 +7565,12 @@ declare class BraintrustState {
|
|
|
7549
7565
|
private _proxyConn;
|
|
7550
7566
|
promptCache: PromptCache;
|
|
7551
7567
|
private _idGenerator;
|
|
7568
|
+
private _contextManager;
|
|
7552
7569
|
constructor(loginParams: LoginOptions);
|
|
7553
7570
|
resetLoginInfo(): void;
|
|
7554
7571
|
resetIdGenState(): void;
|
|
7555
7572
|
get idGenerator(): IDGenerator;
|
|
7573
|
+
get contextManager(): ContextManager;
|
|
7556
7574
|
copyLoginInfo(other: BraintrustState): void;
|
|
7557
7575
|
serialize(): SerializedBraintrustState;
|
|
7558
7576
|
static deserialize(serialized: unknown, opts?: LoginOptions): BraintrustState;
|
|
@@ -7850,6 +7868,12 @@ declare class Experiment extends ObjectFetcher<ExperimentEvent> implements Expor
|
|
|
7850
7868
|
kind: "experiment";
|
|
7851
7869
|
constructor(state: BraintrustState, lazyMetadata: LazyValue<ProjectExperimentMetadata>, dataset?: AnyDataset);
|
|
7852
7870
|
get id(): Promise<string>;
|
|
7871
|
+
/**
|
|
7872
|
+
* Wait for the experiment ID to be resolved. This is useful for ensuring the ID
|
|
7873
|
+
* is available synchronously in child spans (for OTEL parent attributes).
|
|
7874
|
+
* @internal
|
|
7875
|
+
*/
|
|
7876
|
+
_waitForId(): Promise<void>;
|
|
7853
7877
|
get name(): Promise<string>;
|
|
7854
7878
|
get project(): Promise<ObjectMetadata>;
|
|
7855
7879
|
private parentObjectType;
|