braintrust 0.0.176 → 0.0.178
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 +210 -6
- package/dist/browser.d.ts +210 -6
- package/dist/browser.js +276 -15
- package/dist/browser.mjs +275 -15
- package/dist/cli.js +253 -37
- package/dist/index.d.mts +213 -44
- package/dist/index.d.ts +213 -44
- package/dist/index.js +296 -31
- package/dist/index.mjs +295 -29
- package/package.json +2 -2
package/dist/browser.d.mts
CHANGED
|
@@ -16,6 +16,173 @@ declare class LazyValue<T> {
|
|
|
16
16
|
get hasComputed(): boolean;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
/**
|
|
20
|
+
* Options for configuring an LRUCache instance.
|
|
21
|
+
*/
|
|
22
|
+
interface LRUCacheOptions {
|
|
23
|
+
/**
|
|
24
|
+
* Maximum number of items to store in the cache.
|
|
25
|
+
* If not specified, the cache will grow unbounded.
|
|
26
|
+
*/
|
|
27
|
+
max?: number;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* A Least Recently Used (LRU) cache implementation.
|
|
31
|
+
*
|
|
32
|
+
* This cache maintains items in order of use, evicting the least recently used item
|
|
33
|
+
* when the cache reaches its maximum size (if specified). Items are considered "used"
|
|
34
|
+
* when they are either added to the cache or retrieved from it.
|
|
35
|
+
*
|
|
36
|
+
* If no maximum size is specified, the cache will grow unbounded.
|
|
37
|
+
*
|
|
38
|
+
* @template K - The type of keys stored in the cache.
|
|
39
|
+
* @template V - The type of values stored in the cache.
|
|
40
|
+
*/
|
|
41
|
+
declare class LRUCache<K, V> {
|
|
42
|
+
private cache;
|
|
43
|
+
private readonly maxSize?;
|
|
44
|
+
constructor(options?: LRUCacheOptions);
|
|
45
|
+
/**
|
|
46
|
+
* Retrieves a value from the cache.
|
|
47
|
+
* If the key exists, the item is marked as most recently used.
|
|
48
|
+
*
|
|
49
|
+
* @param key - The key to look up.
|
|
50
|
+
* @returns The cached value if found, undefined otherwise.
|
|
51
|
+
*/
|
|
52
|
+
get(key: K): V | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* Stores a value in the cache.
|
|
55
|
+
* If the key already exists, the value is updated and marked as most recently used.
|
|
56
|
+
* If the cache is at its maximum size, the least recently used item is evicted.
|
|
57
|
+
*
|
|
58
|
+
* @param key - The key to store.
|
|
59
|
+
* @param value - The value to store.
|
|
60
|
+
*/
|
|
61
|
+
set(key: K, value: V): void;
|
|
62
|
+
/**
|
|
63
|
+
* Removes all items from the cache.
|
|
64
|
+
*/
|
|
65
|
+
clear(): void;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Configuration options for DiskCache.
|
|
70
|
+
*/
|
|
71
|
+
interface DiskCacheOptions {
|
|
72
|
+
/**
|
|
73
|
+
* Directory where cache files will be stored.
|
|
74
|
+
*/
|
|
75
|
+
cacheDir: string;
|
|
76
|
+
/**
|
|
77
|
+
* Maximum number of entries to store in the cache.
|
|
78
|
+
* If not specified, the cache will grow unbounded.
|
|
79
|
+
*/
|
|
80
|
+
max?: number;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* A persistent filesystem-based cache implementation.
|
|
84
|
+
*
|
|
85
|
+
* This cache stores entries as compressed files on disk and implements an LRU eviction
|
|
86
|
+
* policy based on file modification times (mtime). While access times (atime) would be more
|
|
87
|
+
* semantically accurate for LRU, we use mtime because:
|
|
88
|
+
*
|
|
89
|
+
* 1. Many modern filesystems mount with noatime for performance reasons.
|
|
90
|
+
* 2. Even when atime updates are enabled, they may be subject to update delays.
|
|
91
|
+
* 3. mtime updates are more reliably supported across different filesystems.
|
|
92
|
+
*
|
|
93
|
+
* @template T - The type of values stored in the cache.
|
|
94
|
+
*/
|
|
95
|
+
declare class DiskCache<T> {
|
|
96
|
+
private readonly dir;
|
|
97
|
+
private readonly max?;
|
|
98
|
+
/**
|
|
99
|
+
* Creates a new DiskCache instance.
|
|
100
|
+
* @param options - Configuration options for the cache.
|
|
101
|
+
*/
|
|
102
|
+
constructor(options: DiskCacheOptions);
|
|
103
|
+
/**
|
|
104
|
+
* Gets the file path for a cache entry.
|
|
105
|
+
* @param key - The cache key to get the path for.
|
|
106
|
+
* @returns The full filesystem path for the cache entry.
|
|
107
|
+
*/
|
|
108
|
+
private getEntryPath;
|
|
109
|
+
/**
|
|
110
|
+
* Retrieves a value from the cache.
|
|
111
|
+
* Updates the entry's access time when read.
|
|
112
|
+
*
|
|
113
|
+
* @param key - The key to look up in the cache.
|
|
114
|
+
* @returns The cached value if found, undefined otherwise.
|
|
115
|
+
* @throws If there is an error reading from the disk cache (except for file not found).
|
|
116
|
+
*/
|
|
117
|
+
get(key: string): Promise<T | undefined>;
|
|
118
|
+
/**
|
|
119
|
+
* Stores a value in the cache.
|
|
120
|
+
* If the cache is at its maximum size, the least recently used entries will be evicted.
|
|
121
|
+
*
|
|
122
|
+
* @param key - The key to store the value under.
|
|
123
|
+
* @param value - The value to store in the cache.
|
|
124
|
+
*/
|
|
125
|
+
set(key: string, value: T): Promise<void>;
|
|
126
|
+
/**
|
|
127
|
+
* Evicts the oldest entries from the cache until it is under the maximum size.
|
|
128
|
+
* @param entries - List of all cache entry filenames.
|
|
129
|
+
*/
|
|
130
|
+
private evictOldest;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Identifies a prompt in the cache using either project ID or project name along with the slug.
|
|
135
|
+
*/
|
|
136
|
+
interface PromptKey {
|
|
137
|
+
/**
|
|
138
|
+
* The slug identifier for the prompt within its project.
|
|
139
|
+
*/
|
|
140
|
+
slug: string;
|
|
141
|
+
/**
|
|
142
|
+
* The version of the prompt.
|
|
143
|
+
*/
|
|
144
|
+
version: string;
|
|
145
|
+
/**
|
|
146
|
+
* The ID of the project containing the prompt.
|
|
147
|
+
* Either projectId or projectName must be provided.
|
|
148
|
+
*/
|
|
149
|
+
projectId?: string;
|
|
150
|
+
/**
|
|
151
|
+
* The name of the project containing the prompt.
|
|
152
|
+
* Either projectId or projectName must be provided.
|
|
153
|
+
*/
|
|
154
|
+
projectName?: string;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* A two-layer cache for Braintrust prompts with both in-memory and filesystem storage.
|
|
158
|
+
*
|
|
159
|
+
* This cache implements either a one or two-layer caching strategy:
|
|
160
|
+
* 1. A fast in-memory LRU cache for frequently accessed prompts.
|
|
161
|
+
* 2. An optional persistent filesystem-based cache that serves as a backing store.
|
|
162
|
+
*/
|
|
163
|
+
declare class PromptCache {
|
|
164
|
+
private readonly memoryCache;
|
|
165
|
+
private readonly diskCache?;
|
|
166
|
+
constructor(options: {
|
|
167
|
+
memoryCache: LRUCache<string, Prompt>;
|
|
168
|
+
diskCache?: DiskCache<Prompt>;
|
|
169
|
+
});
|
|
170
|
+
/**
|
|
171
|
+
* Retrieves a prompt from the cache.
|
|
172
|
+
* First checks the in-memory LRU cache, then falls back to checking the disk cache if available.
|
|
173
|
+
*/
|
|
174
|
+
get(key: PromptKey): Promise<Prompt | undefined>;
|
|
175
|
+
/**
|
|
176
|
+
* Stores a prompt in the cache.
|
|
177
|
+
* Writes to the in-memory cache and the disk cache if available.
|
|
178
|
+
*
|
|
179
|
+
* @param key - The key to store the value under.
|
|
180
|
+
* @param value - The value to store in the cache.
|
|
181
|
+
* @throws If there is an error writing to the disk cache.
|
|
182
|
+
*/
|
|
183
|
+
set(key: PromptKey, value: Prompt): Promise<void>;
|
|
184
|
+
}
|
|
185
|
+
|
|
19
186
|
type SetCurrentArg = {
|
|
20
187
|
setCurrent?: boolean;
|
|
21
188
|
};
|
|
@@ -217,6 +384,7 @@ declare class BraintrustState {
|
|
|
217
384
|
private _appConn;
|
|
218
385
|
private _apiConn;
|
|
219
386
|
private _proxyConn;
|
|
387
|
+
promptCache: PromptCache;
|
|
220
388
|
constructor(loginParams: LoginOptions);
|
|
221
389
|
resetLoginInfo(): void;
|
|
222
390
|
copyLoginInfo(other: BraintrustState): void;
|
|
@@ -658,7 +826,7 @@ type InitLoggerOptions<IsAsyncFlush> = FullLoginOptions & {
|
|
|
658
826
|
* @param options Additional options for configuring init().
|
|
659
827
|
* @param options.projectName The name of the project to log into. If unspecified, will default to the Global project.
|
|
660
828
|
* @param options.projectId The id of the project to log into. This takes precedence over projectName if specified.
|
|
661
|
-
* @param options.asyncFlush If true, will log asynchronously in the background. Otherwise, will log synchronously. (
|
|
829
|
+
* @param options.asyncFlush If true, will log asynchronously in the background. Otherwise, will log synchronously. (true by default)
|
|
662
830
|
* @param options.appUrl The URL of the Braintrust App. Defaults to https://www.braintrust.dev.
|
|
663
831
|
* @param options.apiKey The API key to use. If the parameter is not specified, will try to use the `BRAINTRUST_API_KEY` environment variable. If no API
|
|
664
832
|
* key is specified, will prompt the user to login.
|
|
@@ -667,7 +835,7 @@ type InitLoggerOptions<IsAsyncFlush> = FullLoginOptions & {
|
|
|
667
835
|
* @param setCurrent If true (the default), set the global current-experiment to the newly-created one.
|
|
668
836
|
* @returns The newly created Logger.
|
|
669
837
|
*/
|
|
670
|
-
declare function initLogger<IsAsyncFlush extends boolean =
|
|
838
|
+
declare function initLogger<IsAsyncFlush extends boolean = true>(options?: Readonly<InitLoggerOptions<IsAsyncFlush>>): Logger<IsAsyncFlush>;
|
|
671
839
|
type LoadPromptOptions = FullLoginOptions & {
|
|
672
840
|
projectName?: string;
|
|
673
841
|
projectId?: string;
|
|
@@ -805,7 +973,7 @@ declare function logError(span: Span, error: unknown): void;
|
|
|
805
973
|
*
|
|
806
974
|
* See {@link Span.traced} for full details.
|
|
807
975
|
*/
|
|
808
|
-
declare function traced<IsAsyncFlush extends boolean =
|
|
976
|
+
declare function traced<IsAsyncFlush extends boolean = true, R = void>(callback: (span: Span) => R, args?: StartSpanArgs & SetCurrentArg & AsyncFlushArg<IsAsyncFlush> & OptionalStateArg): PromiseUnless<IsAsyncFlush, R>;
|
|
809
977
|
/**
|
|
810
978
|
* Wrap a function with `traced`, using the arguments as `input` and return value as `output`.
|
|
811
979
|
* Any functions wrapped this way will automatically be traced, similar to the `@traced` decorator
|
|
@@ -828,7 +996,7 @@ declare function traced<IsAsyncFlush extends boolean = false, R = void>(callback
|
|
|
828
996
|
* @param args Span-level arguments (e.g. a custom name or type) to pass to `traced`.
|
|
829
997
|
* @returns The wrapped function.
|
|
830
998
|
*/
|
|
831
|
-
declare function wrapTraced<F extends (...args: any[]) => any, IsAsyncFlush extends boolean =
|
|
999
|
+
declare function wrapTraced<F extends (...args: any[]) => any, IsAsyncFlush extends boolean = true>(fn: F, args?: StartSpanArgs & SetCurrentArg & AsyncFlushArg<IsAsyncFlush>): IsAsyncFlush extends false ? (...args: Parameters<F>) => Promise<Awaited<ReturnType<F>>> : F;
|
|
832
1000
|
/**
|
|
833
1001
|
* A synonym for `wrapTraced`. If you're porting from systems that use `traceable`, you can use this to
|
|
834
1002
|
* make your codebase more consistent.
|
|
@@ -1553,6 +1721,41 @@ type InvokeReturn<Stream extends boolean, Output> = Stream extends true ? Braint
|
|
|
1553
1721
|
* @returns The output of the function.
|
|
1554
1722
|
*/
|
|
1555
1723
|
declare function invoke<Input, Output, Stream extends boolean = false>(args: InvokeFunctionArgs<Input, Output, Stream> & FullLoginOptions): Promise<InvokeReturn<Stream, Output>>;
|
|
1724
|
+
/**
|
|
1725
|
+
* Creates a function that can be used as a task or scorer in the Braintrust evaluation framework.
|
|
1726
|
+
* The returned function wraps a Braintrust function and can be passed directly to Eval().
|
|
1727
|
+
*
|
|
1728
|
+
* When used as a task:
|
|
1729
|
+
* ```ts
|
|
1730
|
+
* const myFunction = initFunction({projectName: "myproject", slug: "myfunction"});
|
|
1731
|
+
* await Eval("test", {
|
|
1732
|
+
* task: myFunction,
|
|
1733
|
+
* data: testData,
|
|
1734
|
+
* scores: [...]
|
|
1735
|
+
* });
|
|
1736
|
+
* ```
|
|
1737
|
+
*
|
|
1738
|
+
* When used as a scorer:
|
|
1739
|
+
* ```ts
|
|
1740
|
+
* const myScorer = initFunction({projectName: "myproject", slug: "myscorer"});
|
|
1741
|
+
* await Eval("test", {
|
|
1742
|
+
* task: someTask,
|
|
1743
|
+
* data: testData,
|
|
1744
|
+
* scores: [myScorer]
|
|
1745
|
+
* });
|
|
1746
|
+
* ```
|
|
1747
|
+
*
|
|
1748
|
+
* @param options Options for the function.
|
|
1749
|
+
* @param options.projectName The project name containing the function.
|
|
1750
|
+
* @param options.slug The slug of the function to invoke.
|
|
1751
|
+
* @param options.version Optional version of the function to use. Defaults to latest.
|
|
1752
|
+
* @returns A function that can be used as a task or scorer in Eval().
|
|
1753
|
+
*/
|
|
1754
|
+
declare function initFunction({ projectName, slug, version, }: {
|
|
1755
|
+
projectName: string;
|
|
1756
|
+
slug: string;
|
|
1757
|
+
version?: string;
|
|
1758
|
+
}): (input: any) => Promise<any>;
|
|
1556
1759
|
|
|
1557
1760
|
interface BetaLike {
|
|
1558
1761
|
chat: {
|
|
@@ -1663,6 +1866,7 @@ declare const braintrust_getSpanParentObject: typeof getSpanParentObject;
|
|
|
1663
1866
|
declare const braintrust_init: typeof init;
|
|
1664
1867
|
declare const braintrust_initDataset: typeof initDataset;
|
|
1665
1868
|
declare const braintrust_initExperiment: typeof initExperiment;
|
|
1869
|
+
declare const braintrust_initFunction: typeof initFunction;
|
|
1666
1870
|
declare const braintrust_initLogger: typeof initLogger;
|
|
1667
1871
|
declare const braintrust_invoke: typeof invoke;
|
|
1668
1872
|
declare const braintrust_loadPrompt: typeof loadPrompt;
|
|
@@ -1689,7 +1893,7 @@ declare const braintrust_wrapOpenAI: typeof wrapOpenAI;
|
|
|
1689
1893
|
declare const braintrust_wrapOpenAIv4: typeof wrapOpenAIv4;
|
|
1690
1894
|
declare const braintrust_wrapTraced: typeof wrapTraced;
|
|
1691
1895
|
declare namespace braintrust {
|
|
1692
|
-
export { type braintrust_AnyDataset as AnyDataset, braintrust_Attachment as Attachment, type braintrust_AttachmentParams as AttachmentParams, 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_ReadonlyAttachment as ReadonlyAttachment, 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__exportsForTestingOnly as _exportsForTestingOnly, 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_permalink as permalink, 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 };
|
|
1896
|
+
export { type braintrust_AnyDataset as AnyDataset, braintrust_Attachment as Attachment, type braintrust_AttachmentParams as AttachmentParams, 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_ReadonlyAttachment as ReadonlyAttachment, 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__exportsForTestingOnly as _exportsForTestingOnly, 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_initFunction as initFunction, braintrust_initLogger as initLogger, braintrust_invoke as invoke, braintrust_loadPrompt as loadPrompt, braintrust_log as log, braintrust_logError as logError, braintrust_login as login, braintrust_loginToState as loginToState, braintrust_newId as newId, braintrust_parseCachedHeader as parseCachedHeader, braintrust_permalink as permalink, braintrust_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 };
|
|
1693
1897
|
}
|
|
1694
1898
|
|
|
1695
|
-
export { type AnyDataset, Attachment, type AttachmentParams, 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, ReadonlyAttachment, ReadonlyExperiment, type ScoreSummary, type SerializedBraintrustState, type SetCurrentArg, type Span, SpanImpl, type StartSpanArgs, type WithTransactionId, X_CACHED_HEADER, _exportsForTestingOnly, _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, permalink, renderMessage, setFetch, spanComponentsToObjectId, startSpan, summarize, traceable, traced, updateSpan, withCurrent, withDataset, withExperiment, withLogger, wrapOpenAI, wrapOpenAIv4, wrapTraced };
|
|
1899
|
+
export { type AnyDataset, Attachment, type AttachmentParams, 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, ReadonlyAttachment, ReadonlyExperiment, type ScoreSummary, type SerializedBraintrustState, type SetCurrentArg, type Span, SpanImpl, type StartSpanArgs, type WithTransactionId, X_CACHED_HEADER, _exportsForTestingOnly, _internalGetGlobalState, _internalSetInitialState, braintrustStreamChunkSchema, createFinalValuePassThroughStream, currentExperiment, currentLogger, currentSpan, braintrust as default, devNullWritableStream, flush, getSpanParentObject, init, initDataset, initExperiment, initFunction, initLogger, invoke, loadPrompt, log, logError, login, loginToState, newId, parseCachedHeader, permalink, renderMessage, setFetch, spanComponentsToObjectId, startSpan, summarize, traceable, traced, updateSpan, withCurrent, withDataset, withExperiment, withLogger, wrapOpenAI, wrapOpenAIv4, wrapTraced };
|
package/dist/browser.d.ts
CHANGED
|
@@ -16,6 +16,173 @@ declare class LazyValue<T> {
|
|
|
16
16
|
get hasComputed(): boolean;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
/**
|
|
20
|
+
* Options for configuring an LRUCache instance.
|
|
21
|
+
*/
|
|
22
|
+
interface LRUCacheOptions {
|
|
23
|
+
/**
|
|
24
|
+
* Maximum number of items to store in the cache.
|
|
25
|
+
* If not specified, the cache will grow unbounded.
|
|
26
|
+
*/
|
|
27
|
+
max?: number;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* A Least Recently Used (LRU) cache implementation.
|
|
31
|
+
*
|
|
32
|
+
* This cache maintains items in order of use, evicting the least recently used item
|
|
33
|
+
* when the cache reaches its maximum size (if specified). Items are considered "used"
|
|
34
|
+
* when they are either added to the cache or retrieved from it.
|
|
35
|
+
*
|
|
36
|
+
* If no maximum size is specified, the cache will grow unbounded.
|
|
37
|
+
*
|
|
38
|
+
* @template K - The type of keys stored in the cache.
|
|
39
|
+
* @template V - The type of values stored in the cache.
|
|
40
|
+
*/
|
|
41
|
+
declare class LRUCache<K, V> {
|
|
42
|
+
private cache;
|
|
43
|
+
private readonly maxSize?;
|
|
44
|
+
constructor(options?: LRUCacheOptions);
|
|
45
|
+
/**
|
|
46
|
+
* Retrieves a value from the cache.
|
|
47
|
+
* If the key exists, the item is marked as most recently used.
|
|
48
|
+
*
|
|
49
|
+
* @param key - The key to look up.
|
|
50
|
+
* @returns The cached value if found, undefined otherwise.
|
|
51
|
+
*/
|
|
52
|
+
get(key: K): V | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* Stores a value in the cache.
|
|
55
|
+
* If the key already exists, the value is updated and marked as most recently used.
|
|
56
|
+
* If the cache is at its maximum size, the least recently used item is evicted.
|
|
57
|
+
*
|
|
58
|
+
* @param key - The key to store.
|
|
59
|
+
* @param value - The value to store.
|
|
60
|
+
*/
|
|
61
|
+
set(key: K, value: V): void;
|
|
62
|
+
/**
|
|
63
|
+
* Removes all items from the cache.
|
|
64
|
+
*/
|
|
65
|
+
clear(): void;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Configuration options for DiskCache.
|
|
70
|
+
*/
|
|
71
|
+
interface DiskCacheOptions {
|
|
72
|
+
/**
|
|
73
|
+
* Directory where cache files will be stored.
|
|
74
|
+
*/
|
|
75
|
+
cacheDir: string;
|
|
76
|
+
/**
|
|
77
|
+
* Maximum number of entries to store in the cache.
|
|
78
|
+
* If not specified, the cache will grow unbounded.
|
|
79
|
+
*/
|
|
80
|
+
max?: number;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* A persistent filesystem-based cache implementation.
|
|
84
|
+
*
|
|
85
|
+
* This cache stores entries as compressed files on disk and implements an LRU eviction
|
|
86
|
+
* policy based on file modification times (mtime). While access times (atime) would be more
|
|
87
|
+
* semantically accurate for LRU, we use mtime because:
|
|
88
|
+
*
|
|
89
|
+
* 1. Many modern filesystems mount with noatime for performance reasons.
|
|
90
|
+
* 2. Even when atime updates are enabled, they may be subject to update delays.
|
|
91
|
+
* 3. mtime updates are more reliably supported across different filesystems.
|
|
92
|
+
*
|
|
93
|
+
* @template T - The type of values stored in the cache.
|
|
94
|
+
*/
|
|
95
|
+
declare class DiskCache<T> {
|
|
96
|
+
private readonly dir;
|
|
97
|
+
private readonly max?;
|
|
98
|
+
/**
|
|
99
|
+
* Creates a new DiskCache instance.
|
|
100
|
+
* @param options - Configuration options for the cache.
|
|
101
|
+
*/
|
|
102
|
+
constructor(options: DiskCacheOptions);
|
|
103
|
+
/**
|
|
104
|
+
* Gets the file path for a cache entry.
|
|
105
|
+
* @param key - The cache key to get the path for.
|
|
106
|
+
* @returns The full filesystem path for the cache entry.
|
|
107
|
+
*/
|
|
108
|
+
private getEntryPath;
|
|
109
|
+
/**
|
|
110
|
+
* Retrieves a value from the cache.
|
|
111
|
+
* Updates the entry's access time when read.
|
|
112
|
+
*
|
|
113
|
+
* @param key - The key to look up in the cache.
|
|
114
|
+
* @returns The cached value if found, undefined otherwise.
|
|
115
|
+
* @throws If there is an error reading from the disk cache (except for file not found).
|
|
116
|
+
*/
|
|
117
|
+
get(key: string): Promise<T | undefined>;
|
|
118
|
+
/**
|
|
119
|
+
* Stores a value in the cache.
|
|
120
|
+
* If the cache is at its maximum size, the least recently used entries will be evicted.
|
|
121
|
+
*
|
|
122
|
+
* @param key - The key to store the value under.
|
|
123
|
+
* @param value - The value to store in the cache.
|
|
124
|
+
*/
|
|
125
|
+
set(key: string, value: T): Promise<void>;
|
|
126
|
+
/**
|
|
127
|
+
* Evicts the oldest entries from the cache until it is under the maximum size.
|
|
128
|
+
* @param entries - List of all cache entry filenames.
|
|
129
|
+
*/
|
|
130
|
+
private evictOldest;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Identifies a prompt in the cache using either project ID or project name along with the slug.
|
|
135
|
+
*/
|
|
136
|
+
interface PromptKey {
|
|
137
|
+
/**
|
|
138
|
+
* The slug identifier for the prompt within its project.
|
|
139
|
+
*/
|
|
140
|
+
slug: string;
|
|
141
|
+
/**
|
|
142
|
+
* The version of the prompt.
|
|
143
|
+
*/
|
|
144
|
+
version: string;
|
|
145
|
+
/**
|
|
146
|
+
* The ID of the project containing the prompt.
|
|
147
|
+
* Either projectId or projectName must be provided.
|
|
148
|
+
*/
|
|
149
|
+
projectId?: string;
|
|
150
|
+
/**
|
|
151
|
+
* The name of the project containing the prompt.
|
|
152
|
+
* Either projectId or projectName must be provided.
|
|
153
|
+
*/
|
|
154
|
+
projectName?: string;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* A two-layer cache for Braintrust prompts with both in-memory and filesystem storage.
|
|
158
|
+
*
|
|
159
|
+
* This cache implements either a one or two-layer caching strategy:
|
|
160
|
+
* 1. A fast in-memory LRU cache for frequently accessed prompts.
|
|
161
|
+
* 2. An optional persistent filesystem-based cache that serves as a backing store.
|
|
162
|
+
*/
|
|
163
|
+
declare class PromptCache {
|
|
164
|
+
private readonly memoryCache;
|
|
165
|
+
private readonly diskCache?;
|
|
166
|
+
constructor(options: {
|
|
167
|
+
memoryCache: LRUCache<string, Prompt>;
|
|
168
|
+
diskCache?: DiskCache<Prompt>;
|
|
169
|
+
});
|
|
170
|
+
/**
|
|
171
|
+
* Retrieves a prompt from the cache.
|
|
172
|
+
* First checks the in-memory LRU cache, then falls back to checking the disk cache if available.
|
|
173
|
+
*/
|
|
174
|
+
get(key: PromptKey): Promise<Prompt | undefined>;
|
|
175
|
+
/**
|
|
176
|
+
* Stores a prompt in the cache.
|
|
177
|
+
* Writes to the in-memory cache and the disk cache if available.
|
|
178
|
+
*
|
|
179
|
+
* @param key - The key to store the value under.
|
|
180
|
+
* @param value - The value to store in the cache.
|
|
181
|
+
* @throws If there is an error writing to the disk cache.
|
|
182
|
+
*/
|
|
183
|
+
set(key: PromptKey, value: Prompt): Promise<void>;
|
|
184
|
+
}
|
|
185
|
+
|
|
19
186
|
type SetCurrentArg = {
|
|
20
187
|
setCurrent?: boolean;
|
|
21
188
|
};
|
|
@@ -217,6 +384,7 @@ declare class BraintrustState {
|
|
|
217
384
|
private _appConn;
|
|
218
385
|
private _apiConn;
|
|
219
386
|
private _proxyConn;
|
|
387
|
+
promptCache: PromptCache;
|
|
220
388
|
constructor(loginParams: LoginOptions);
|
|
221
389
|
resetLoginInfo(): void;
|
|
222
390
|
copyLoginInfo(other: BraintrustState): void;
|
|
@@ -658,7 +826,7 @@ type InitLoggerOptions<IsAsyncFlush> = FullLoginOptions & {
|
|
|
658
826
|
* @param options Additional options for configuring init().
|
|
659
827
|
* @param options.projectName The name of the project to log into. If unspecified, will default to the Global project.
|
|
660
828
|
* @param options.projectId The id of the project to log into. This takes precedence over projectName if specified.
|
|
661
|
-
* @param options.asyncFlush If true, will log asynchronously in the background. Otherwise, will log synchronously. (
|
|
829
|
+
* @param options.asyncFlush If true, will log asynchronously in the background. Otherwise, will log synchronously. (true by default)
|
|
662
830
|
* @param options.appUrl The URL of the Braintrust App. Defaults to https://www.braintrust.dev.
|
|
663
831
|
* @param options.apiKey The API key to use. If the parameter is not specified, will try to use the `BRAINTRUST_API_KEY` environment variable. If no API
|
|
664
832
|
* key is specified, will prompt the user to login.
|
|
@@ -667,7 +835,7 @@ type InitLoggerOptions<IsAsyncFlush> = FullLoginOptions & {
|
|
|
667
835
|
* @param setCurrent If true (the default), set the global current-experiment to the newly-created one.
|
|
668
836
|
* @returns The newly created Logger.
|
|
669
837
|
*/
|
|
670
|
-
declare function initLogger<IsAsyncFlush extends boolean =
|
|
838
|
+
declare function initLogger<IsAsyncFlush extends boolean = true>(options?: Readonly<InitLoggerOptions<IsAsyncFlush>>): Logger<IsAsyncFlush>;
|
|
671
839
|
type LoadPromptOptions = FullLoginOptions & {
|
|
672
840
|
projectName?: string;
|
|
673
841
|
projectId?: string;
|
|
@@ -805,7 +973,7 @@ declare function logError(span: Span, error: unknown): void;
|
|
|
805
973
|
*
|
|
806
974
|
* See {@link Span.traced} for full details.
|
|
807
975
|
*/
|
|
808
|
-
declare function traced<IsAsyncFlush extends boolean =
|
|
976
|
+
declare function traced<IsAsyncFlush extends boolean = true, R = void>(callback: (span: Span) => R, args?: StartSpanArgs & SetCurrentArg & AsyncFlushArg<IsAsyncFlush> & OptionalStateArg): PromiseUnless<IsAsyncFlush, R>;
|
|
809
977
|
/**
|
|
810
978
|
* Wrap a function with `traced`, using the arguments as `input` and return value as `output`.
|
|
811
979
|
* Any functions wrapped this way will automatically be traced, similar to the `@traced` decorator
|
|
@@ -828,7 +996,7 @@ declare function traced<IsAsyncFlush extends boolean = false, R = void>(callback
|
|
|
828
996
|
* @param args Span-level arguments (e.g. a custom name or type) to pass to `traced`.
|
|
829
997
|
* @returns The wrapped function.
|
|
830
998
|
*/
|
|
831
|
-
declare function wrapTraced<F extends (...args: any[]) => any, IsAsyncFlush extends boolean =
|
|
999
|
+
declare function wrapTraced<F extends (...args: any[]) => any, IsAsyncFlush extends boolean = true>(fn: F, args?: StartSpanArgs & SetCurrentArg & AsyncFlushArg<IsAsyncFlush>): IsAsyncFlush extends false ? (...args: Parameters<F>) => Promise<Awaited<ReturnType<F>>> : F;
|
|
832
1000
|
/**
|
|
833
1001
|
* A synonym for `wrapTraced`. If you're porting from systems that use `traceable`, you can use this to
|
|
834
1002
|
* make your codebase more consistent.
|
|
@@ -1553,6 +1721,41 @@ type InvokeReturn<Stream extends boolean, Output> = Stream extends true ? Braint
|
|
|
1553
1721
|
* @returns The output of the function.
|
|
1554
1722
|
*/
|
|
1555
1723
|
declare function invoke<Input, Output, Stream extends boolean = false>(args: InvokeFunctionArgs<Input, Output, Stream> & FullLoginOptions): Promise<InvokeReturn<Stream, Output>>;
|
|
1724
|
+
/**
|
|
1725
|
+
* Creates a function that can be used as a task or scorer in the Braintrust evaluation framework.
|
|
1726
|
+
* The returned function wraps a Braintrust function and can be passed directly to Eval().
|
|
1727
|
+
*
|
|
1728
|
+
* When used as a task:
|
|
1729
|
+
* ```ts
|
|
1730
|
+
* const myFunction = initFunction({projectName: "myproject", slug: "myfunction"});
|
|
1731
|
+
* await Eval("test", {
|
|
1732
|
+
* task: myFunction,
|
|
1733
|
+
* data: testData,
|
|
1734
|
+
* scores: [...]
|
|
1735
|
+
* });
|
|
1736
|
+
* ```
|
|
1737
|
+
*
|
|
1738
|
+
* When used as a scorer:
|
|
1739
|
+
* ```ts
|
|
1740
|
+
* const myScorer = initFunction({projectName: "myproject", slug: "myscorer"});
|
|
1741
|
+
* await Eval("test", {
|
|
1742
|
+
* task: someTask,
|
|
1743
|
+
* data: testData,
|
|
1744
|
+
* scores: [myScorer]
|
|
1745
|
+
* });
|
|
1746
|
+
* ```
|
|
1747
|
+
*
|
|
1748
|
+
* @param options Options for the function.
|
|
1749
|
+
* @param options.projectName The project name containing the function.
|
|
1750
|
+
* @param options.slug The slug of the function to invoke.
|
|
1751
|
+
* @param options.version Optional version of the function to use. Defaults to latest.
|
|
1752
|
+
* @returns A function that can be used as a task or scorer in Eval().
|
|
1753
|
+
*/
|
|
1754
|
+
declare function initFunction({ projectName, slug, version, }: {
|
|
1755
|
+
projectName: string;
|
|
1756
|
+
slug: string;
|
|
1757
|
+
version?: string;
|
|
1758
|
+
}): (input: any) => Promise<any>;
|
|
1556
1759
|
|
|
1557
1760
|
interface BetaLike {
|
|
1558
1761
|
chat: {
|
|
@@ -1663,6 +1866,7 @@ declare const braintrust_getSpanParentObject: typeof getSpanParentObject;
|
|
|
1663
1866
|
declare const braintrust_init: typeof init;
|
|
1664
1867
|
declare const braintrust_initDataset: typeof initDataset;
|
|
1665
1868
|
declare const braintrust_initExperiment: typeof initExperiment;
|
|
1869
|
+
declare const braintrust_initFunction: typeof initFunction;
|
|
1666
1870
|
declare const braintrust_initLogger: typeof initLogger;
|
|
1667
1871
|
declare const braintrust_invoke: typeof invoke;
|
|
1668
1872
|
declare const braintrust_loadPrompt: typeof loadPrompt;
|
|
@@ -1689,7 +1893,7 @@ declare const braintrust_wrapOpenAI: typeof wrapOpenAI;
|
|
|
1689
1893
|
declare const braintrust_wrapOpenAIv4: typeof wrapOpenAIv4;
|
|
1690
1894
|
declare const braintrust_wrapTraced: typeof wrapTraced;
|
|
1691
1895
|
declare namespace braintrust {
|
|
1692
|
-
export { type braintrust_AnyDataset as AnyDataset, braintrust_Attachment as Attachment, type braintrust_AttachmentParams as AttachmentParams, 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_ReadonlyAttachment as ReadonlyAttachment, 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__exportsForTestingOnly as _exportsForTestingOnly, 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_permalink as permalink, 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 };
|
|
1896
|
+
export { type braintrust_AnyDataset as AnyDataset, braintrust_Attachment as Attachment, type braintrust_AttachmentParams as AttachmentParams, 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_ReadonlyAttachment as ReadonlyAttachment, 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__exportsForTestingOnly as _exportsForTestingOnly, 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_initFunction as initFunction, braintrust_initLogger as initLogger, braintrust_invoke as invoke, braintrust_loadPrompt as loadPrompt, braintrust_log as log, braintrust_logError as logError, braintrust_login as login, braintrust_loginToState as loginToState, braintrust_newId as newId, braintrust_parseCachedHeader as parseCachedHeader, braintrust_permalink as permalink, braintrust_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 };
|
|
1693
1897
|
}
|
|
1694
1898
|
|
|
1695
|
-
export { type AnyDataset, Attachment, type AttachmentParams, 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, ReadonlyAttachment, ReadonlyExperiment, type ScoreSummary, type SerializedBraintrustState, type SetCurrentArg, type Span, SpanImpl, type StartSpanArgs, type WithTransactionId, X_CACHED_HEADER, _exportsForTestingOnly, _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, permalink, renderMessage, setFetch, spanComponentsToObjectId, startSpan, summarize, traceable, traced, updateSpan, withCurrent, withDataset, withExperiment, withLogger, wrapOpenAI, wrapOpenAIv4, wrapTraced };
|
|
1899
|
+
export { type AnyDataset, Attachment, type AttachmentParams, 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, ReadonlyAttachment, ReadonlyExperiment, type ScoreSummary, type SerializedBraintrustState, type SetCurrentArg, type Span, SpanImpl, type StartSpanArgs, type WithTransactionId, X_CACHED_HEADER, _exportsForTestingOnly, _internalGetGlobalState, _internalSetInitialState, braintrustStreamChunkSchema, createFinalValuePassThroughStream, currentExperiment, currentLogger, currentSpan, braintrust as default, devNullWritableStream, flush, getSpanParentObject, init, initDataset, initExperiment, initFunction, initLogger, invoke, loadPrompt, log, logError, login, loginToState, newId, parseCachedHeader, permalink, renderMessage, setFetch, spanComponentsToObjectId, startSpan, summarize, traceable, traced, updateSpan, withCurrent, withDataset, withExperiment, withLogger, wrapOpenAI, wrapOpenAIv4, wrapTraced };
|