braintrust 0.0.203 → 0.0.205
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 +3879 -0
- package/dev/dist/index.d.ts +3879 -0
- package/dev/dist/index.js +6301 -0
- package/dev/dist/index.mjs +6314 -0
- package/dist/browser.d.mts +1280 -147
- package/dist/browser.d.ts +1280 -147
- package/dist/browser.js +120 -29
- package/dist/browser.mjs +119 -29
- package/dist/cli.js +140 -45
- package/dist/index.d.mts +2558 -194
- package/dist/index.d.ts +2558 -194
- package/dist/index.js +4735 -4705
- package/dist/index.mjs +4604 -4593
- package/package.json +8 -4
- package/CHANGELOG.md +0 -3
- package/Makefile +0 -69
- package/dev/authorize.ts +0 -172
- package/dev/errorHandler.ts +0 -37
- package/dev/index.ts +0 -1
- package/dev/server.ts +0 -413
- package/dev/stream.ts +0 -14
- package/dev/types.ts +0 -63
- package/docs/interfaces/_meta.json +0 -5
- package/examples/anthropic_beta_example.ts +0 -59
- package/examples/anthropic_example.ts +0 -35
- package/examples/anthropic_streaming_example.ts +0 -37
- package/examples/anthropic_tools_example.ts +0 -62
- package/examples/openai_completions_example.ts +0 -25
- package/examples/openai_responses_example.ts +0 -32
- package/examples/openai_responses_stream_example.ts +0 -29
- package/examples/run_all +0 -14
- package/examples/tracing_example.ts +0 -23
- package/tsup.config.ts +0 -30
- package/turbo.json +0 -9
- package/typedoc.json +0 -20
- package/vitest.config.js +0 -6
|
@@ -0,0 +1,3879 @@
|
|
|
1
|
+
import { TRANSACTION_ID_FIELD, TransactionId, ExperimentEvent, DEFAULT_IS_LEGACY_DATASET, DatasetRecord, ExperimentLogFullArgs, ExperimentLogPartialArgs, LogFeedbackFullArgs, SpanType, IdField, BackgroundLogEvent, Score } from '@braintrust/core';
|
|
2
|
+
import { GitMetadataSettings, Prompt as Prompt$1, PromptSessionEvent, PromptData, AnyModelParam, OpenAIMessage, Tools, Message, PromptBlockData, IfExists, SavedFunctionId, ToolFunctionDefinition, FunctionType, SSEProgressEventData, RepoInfo, ObjectReference } from '@braintrust/core/typespecs';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
|
|
5
|
+
type GenericFunction<Input, Output> = ((input: Input) => Output) | ((input: Input) => Promise<Output>);
|
|
6
|
+
|
|
7
|
+
interface IsoAsyncLocalStorage<T> {
|
|
8
|
+
enterWith(store: T): void;
|
|
9
|
+
run<R>(store: T | undefined, callback: () => R): R;
|
|
10
|
+
getStore(): T | undefined;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Options for configuring an LRUCache instance.
|
|
15
|
+
*/
|
|
16
|
+
interface LRUCacheOptions {
|
|
17
|
+
/**
|
|
18
|
+
* Maximum number of items to store in the cache.
|
|
19
|
+
* If not specified, the cache will grow unbounded.
|
|
20
|
+
*/
|
|
21
|
+
max?: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* A Least Recently Used (LRU) cache implementation.
|
|
25
|
+
*
|
|
26
|
+
* This cache maintains items in order of use, evicting the least recently used item
|
|
27
|
+
* when the cache reaches its maximum size (if specified). Items are considered "used"
|
|
28
|
+
* when they are either added to the cache or retrieved from it.
|
|
29
|
+
*
|
|
30
|
+
* If no maximum size is specified, the cache will grow unbounded.
|
|
31
|
+
*
|
|
32
|
+
* @template K - The type of keys stored in the cache.
|
|
33
|
+
* @template V - The type of values stored in the cache.
|
|
34
|
+
*/
|
|
35
|
+
declare class LRUCache<K, V> {
|
|
36
|
+
private cache;
|
|
37
|
+
private readonly maxSize?;
|
|
38
|
+
constructor(options?: LRUCacheOptions);
|
|
39
|
+
/**
|
|
40
|
+
* Retrieves a value from the cache.
|
|
41
|
+
* If the key exists, the item is marked as most recently used.
|
|
42
|
+
*
|
|
43
|
+
* @param key - The key to look up.
|
|
44
|
+
* @returns The cached value if found, undefined otherwise.
|
|
45
|
+
*/
|
|
46
|
+
get(key: K): V | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* Stores a value in the cache.
|
|
49
|
+
* If the key already exists, the value is updated and marked as most recently used.
|
|
50
|
+
* If the cache is at its maximum size, the least recently used item is evicted.
|
|
51
|
+
*
|
|
52
|
+
* @param key - The key to store.
|
|
53
|
+
* @param value - The value to store.
|
|
54
|
+
*/
|
|
55
|
+
set(key: K, value: V): void;
|
|
56
|
+
/**
|
|
57
|
+
* Removes all items from the cache.
|
|
58
|
+
*/
|
|
59
|
+
clear(): void;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Configuration options for DiskCache.
|
|
64
|
+
*/
|
|
65
|
+
interface DiskCacheOptions {
|
|
66
|
+
/**
|
|
67
|
+
* Directory where cache files will be stored.
|
|
68
|
+
*/
|
|
69
|
+
cacheDir: string;
|
|
70
|
+
/**
|
|
71
|
+
* Maximum number of entries to store in the cache.
|
|
72
|
+
* If not specified, the cache will grow unbounded.
|
|
73
|
+
*/
|
|
74
|
+
max?: number;
|
|
75
|
+
logWarnings?: boolean;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* A persistent filesystem-based cache implementation.
|
|
79
|
+
*
|
|
80
|
+
* This cache stores entries as compressed files on disk and implements an LRU eviction
|
|
81
|
+
* policy based on file modification times (mtime). While access times (atime) would be more
|
|
82
|
+
* semantically accurate for LRU, we use mtime because:
|
|
83
|
+
*
|
|
84
|
+
* 1. Many modern filesystems mount with noatime for performance reasons.
|
|
85
|
+
* 2. Even when atime updates are enabled, they may be subject to update delays.
|
|
86
|
+
* 3. mtime updates are more reliably supported across different filesystems.
|
|
87
|
+
*
|
|
88
|
+
* @template T - The type of values stored in the cache.
|
|
89
|
+
*/
|
|
90
|
+
declare class DiskCache<T> {
|
|
91
|
+
private readonly dir;
|
|
92
|
+
private readonly max?;
|
|
93
|
+
private readonly logWarnings;
|
|
94
|
+
/**
|
|
95
|
+
* Creates a new DiskCache instance.
|
|
96
|
+
* @param options - Configuration options for the cache.
|
|
97
|
+
*/
|
|
98
|
+
constructor(options: DiskCacheOptions);
|
|
99
|
+
private getEntryPath;
|
|
100
|
+
/**
|
|
101
|
+
* Retrieves a value from the cache.
|
|
102
|
+
* Updates the entry's access time when read.
|
|
103
|
+
*
|
|
104
|
+
* @param key - The key to look up in the cache.
|
|
105
|
+
* @returns The cached value if found, undefined otherwise.
|
|
106
|
+
*/
|
|
107
|
+
get(key: string): Promise<T | undefined>;
|
|
108
|
+
/**
|
|
109
|
+
* Stores a value in the cache.
|
|
110
|
+
* If the cache is at its maximum size, the least recently used entries will be evicted.
|
|
111
|
+
*
|
|
112
|
+
* @param key - The key to store the value under.
|
|
113
|
+
* @param value - The value to store in the cache.
|
|
114
|
+
*/
|
|
115
|
+
set(key: string, value: T): Promise<void>;
|
|
116
|
+
private evictOldestIfFull;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Identifies a prompt in the cache using either project ID or project name along with the slug.
|
|
121
|
+
*/
|
|
122
|
+
interface PromptKey {
|
|
123
|
+
/**
|
|
124
|
+
* The slug identifier for the prompt within its project.
|
|
125
|
+
*/
|
|
126
|
+
slug: string;
|
|
127
|
+
/**
|
|
128
|
+
* The version of the prompt.
|
|
129
|
+
*/
|
|
130
|
+
version: string;
|
|
131
|
+
/**
|
|
132
|
+
* The ID of the project containing the prompt.
|
|
133
|
+
* Either projectId or projectName must be provided.
|
|
134
|
+
*/
|
|
135
|
+
projectId?: string;
|
|
136
|
+
/**
|
|
137
|
+
* The name of the project containing the prompt.
|
|
138
|
+
* Either projectId or projectName must be provided.
|
|
139
|
+
*/
|
|
140
|
+
projectName?: string;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* A two-layer cache for Braintrust prompts with both in-memory and filesystem storage.
|
|
144
|
+
*
|
|
145
|
+
* This cache implements either a one or two-layer caching strategy:
|
|
146
|
+
* 1. A fast in-memory LRU cache for frequently accessed prompts.
|
|
147
|
+
* 2. An optional persistent filesystem-based cache that serves as a backing store.
|
|
148
|
+
*/
|
|
149
|
+
declare class PromptCache {
|
|
150
|
+
private readonly memoryCache;
|
|
151
|
+
private readonly diskCache?;
|
|
152
|
+
constructor(options: {
|
|
153
|
+
memoryCache: LRUCache<string, Prompt>;
|
|
154
|
+
diskCache?: DiskCache<Prompt>;
|
|
155
|
+
});
|
|
156
|
+
/**
|
|
157
|
+
* Retrieves a prompt from the cache.
|
|
158
|
+
* First checks the in-memory LRU cache, then falls back to checking the disk cache if available.
|
|
159
|
+
*/
|
|
160
|
+
get(key: PromptKey): Promise<Prompt | undefined>;
|
|
161
|
+
/**
|
|
162
|
+
* Stores a prompt in the cache.
|
|
163
|
+
* Writes to the in-memory cache and the disk cache if available.
|
|
164
|
+
*
|
|
165
|
+
* @param key - The key to store the value under.
|
|
166
|
+
* @param value - The value to store in the cache.
|
|
167
|
+
* @throws If there is an error writing to the disk cache.
|
|
168
|
+
*/
|
|
169
|
+
set(key: PromptKey, value: Prompt): Promise<void>;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
declare class LazyValue<T> {
|
|
173
|
+
private callable;
|
|
174
|
+
private resolvedValue;
|
|
175
|
+
private value;
|
|
176
|
+
constructor(callable: () => Promise<T>);
|
|
177
|
+
get(): Promise<T>;
|
|
178
|
+
getSync(): {
|
|
179
|
+
resolved: boolean;
|
|
180
|
+
value: T | undefined;
|
|
181
|
+
};
|
|
182
|
+
get hasSucceeded(): boolean;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
type SetCurrentArg = {
|
|
186
|
+
setCurrent?: boolean;
|
|
187
|
+
};
|
|
188
|
+
type StartSpanEventArgs = ExperimentLogPartialArgs & Partial<IdField>;
|
|
189
|
+
type StartSpanArgs = {
|
|
190
|
+
name?: string;
|
|
191
|
+
type?: SpanType;
|
|
192
|
+
spanAttributes?: Record<any, any>;
|
|
193
|
+
startTime?: number;
|
|
194
|
+
parent?: string;
|
|
195
|
+
event?: StartSpanEventArgs;
|
|
196
|
+
propagatedEvent?: StartSpanEventArgs;
|
|
197
|
+
};
|
|
198
|
+
type EndSpanArgs = {
|
|
199
|
+
endTime?: number;
|
|
200
|
+
};
|
|
201
|
+
interface Exportable {
|
|
202
|
+
/**
|
|
203
|
+
* Return a serialized representation of the object that can be used to start subspans in other places. See {@link Span.traced} for more details.
|
|
204
|
+
*/
|
|
205
|
+
export(): Promise<string>;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* A Span encapsulates logged data and metrics for a unit of work. This interface is shared by all span implementations.
|
|
209
|
+
*
|
|
210
|
+
* We suggest using one of the various `traced` methods, instead of creating Spans directly. See {@link Span.traced} for full details.
|
|
211
|
+
*/
|
|
212
|
+
interface Span extends Exportable {
|
|
213
|
+
/**
|
|
214
|
+
* Row ID of the span.
|
|
215
|
+
*/
|
|
216
|
+
id: string;
|
|
217
|
+
/**
|
|
218
|
+
* Span ID of the span.
|
|
219
|
+
*/
|
|
220
|
+
spanId: string;
|
|
221
|
+
/**
|
|
222
|
+
* Root span ID of the span.
|
|
223
|
+
*/
|
|
224
|
+
rootSpanId: string;
|
|
225
|
+
/**
|
|
226
|
+
* Parent span IDs of the span.
|
|
227
|
+
*/
|
|
228
|
+
spanParents: string[];
|
|
229
|
+
/**
|
|
230
|
+
* Incrementally update the current span with new data. The event will be batched and uploaded behind the scenes.
|
|
231
|
+
*
|
|
232
|
+
* @param event: Data to be logged. See {@link Experiment.log} for full details.
|
|
233
|
+
*/
|
|
234
|
+
log(event: ExperimentLogPartialArgs): void;
|
|
235
|
+
/**
|
|
236
|
+
* 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.
|
|
237
|
+
*
|
|
238
|
+
* @param event: Data to be logged. See {@link Experiment.logFeedback} for full details.
|
|
239
|
+
*/
|
|
240
|
+
logFeedback(event: Omit<LogFeedbackFullArgs, "id">): void;
|
|
241
|
+
/**
|
|
242
|
+
* Create a new span and run the provided callback. This is useful if you want to log more detailed trace information beyond the scope of a single log event. Data logged over several calls to `Span.log` will be merged into one logical row.
|
|
243
|
+
*
|
|
244
|
+
* Spans created within `traced` are ended automatically. By default, the span is marked as current, so they can be accessed using `braintrust.currentSpan`.
|
|
245
|
+
*
|
|
246
|
+
* @param callback The function to be run under the span context.
|
|
247
|
+
* @param args.name Optional name of the span. If not provided, a name will be inferred from the call stack.
|
|
248
|
+
* @param args.type Optional type of the span. If not provided, the type will be unset.
|
|
249
|
+
* @param args.span_attributes Optional additional attributes to attach to the span, such as a type name.
|
|
250
|
+
* @param args.start_time Optional start time of the span, as a timestamp in seconds.
|
|
251
|
+
* @param args.setCurrent If true (the default), the span will be marked as the currently-active span for the duration of the callback.
|
|
252
|
+
* @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.
|
|
253
|
+
* @param args.event Data to be logged. See {@link Experiment.log} for full details.
|
|
254
|
+
* @returns The result of running `callback`.
|
|
255
|
+
*/
|
|
256
|
+
traced<R>(callback: (span: Span) => R, args?: StartSpanArgs & SetCurrentArg): R;
|
|
257
|
+
/**
|
|
258
|
+
* Lower-level alternative to `traced`. This allows you to start a span yourself, and can be useful in situations
|
|
259
|
+
* where you cannot use callbacks. However, spans started with `startSpan` will not be marked as the "current span",
|
|
260
|
+
* so `currentSpan()` and `traced()` will be no-ops. If you want to mark a span as current, use `traced` instead.
|
|
261
|
+
*
|
|
262
|
+
* See {@link Span.traced} for full details.
|
|
263
|
+
*
|
|
264
|
+
* @returns The newly-created `Span`
|
|
265
|
+
*/
|
|
266
|
+
startSpan(args?: StartSpanArgs): Span;
|
|
267
|
+
/**
|
|
268
|
+
* Log an end time to the span (defaults to the current time). Returns the logged time.
|
|
269
|
+
*
|
|
270
|
+
* Will be invoked automatically if the span is constructed with `traced`.
|
|
271
|
+
*
|
|
272
|
+
* @param args.endTime Optional end time of the span, as a timestamp in seconds.
|
|
273
|
+
* @returns The end time logged to the span metrics.
|
|
274
|
+
*/
|
|
275
|
+
end(args?: EndSpanArgs): number;
|
|
276
|
+
/**
|
|
277
|
+
* Serialize the identifiers of this span. The return value can be used to
|
|
278
|
+
* identify this span when starting a subspan elsewhere, such as another
|
|
279
|
+
* process or service, without needing to access this `Span` object. See the
|
|
280
|
+
* parameters of {@link Span.startSpan} for usage details.
|
|
281
|
+
*
|
|
282
|
+
* Callers should treat the return value as opaque. The serialization format
|
|
283
|
+
* may change from time to time. If parsing is needed, use
|
|
284
|
+
* `SpanComponentsV3.fromStr`.
|
|
285
|
+
*
|
|
286
|
+
* @returns Serialized representation of this span's identifiers.
|
|
287
|
+
*/
|
|
288
|
+
export(): Promise<string>;
|
|
289
|
+
/**
|
|
290
|
+
* Format a permalink to the Braintrust application for viewing this span.
|
|
291
|
+
*
|
|
292
|
+
* Links can be generated at any time, but they will only become viewable
|
|
293
|
+
* after the span and its root have been flushed to the server and ingested.
|
|
294
|
+
*
|
|
295
|
+
* This function can block resolving data with the server. For production
|
|
296
|
+
* applications it's preferable to call {@link Span.link} instead.
|
|
297
|
+
*
|
|
298
|
+
* @returns A promise which resolves to a permalink to the span.
|
|
299
|
+
*/
|
|
300
|
+
permalink(): Promise<string>;
|
|
301
|
+
/**
|
|
302
|
+
* Format a link to the Braintrust application for viewing this span.
|
|
303
|
+
*
|
|
304
|
+
* Links can be generated at any time, but they will only become viewable
|
|
305
|
+
* after the span and its root have been flushed to the server and ingested.
|
|
306
|
+
*
|
|
307
|
+
* There are certain conditions that a Span doesn'thave enough information
|
|
308
|
+
* to return a stable link (e.g. during an unresolved experiment). In this case
|
|
309
|
+
* or if there's an error generating link, we'll return a placeholder link.
|
|
310
|
+
*
|
|
311
|
+
* @returns A link to the span.
|
|
312
|
+
*/
|
|
313
|
+
link(): string;
|
|
314
|
+
/**
|
|
315
|
+
* Flush any pending rows to the server.
|
|
316
|
+
*/
|
|
317
|
+
flush(): Promise<void>;
|
|
318
|
+
/**
|
|
319
|
+
* Alias for `end`.
|
|
320
|
+
*/
|
|
321
|
+
close(args?: EndSpanArgs): number;
|
|
322
|
+
/**
|
|
323
|
+
* Set the span's name, type, or other attributes after it's created.
|
|
324
|
+
*/
|
|
325
|
+
setAttributes(args: Omit<StartSpanArgs, "event">): void;
|
|
326
|
+
/**
|
|
327
|
+
* Start a span with a specific id and parent span ids.
|
|
328
|
+
*/
|
|
329
|
+
startSpanWithParents(spanId: string, spanParents: string[], args?: StartSpanArgs): Span;
|
|
330
|
+
state(): BraintrustState;
|
|
331
|
+
kind: "span";
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* A fake implementation of the Span API which does nothing. This can be used as the default span.
|
|
335
|
+
*/
|
|
336
|
+
declare class NoopSpan implements Span {
|
|
337
|
+
id: string;
|
|
338
|
+
spanId: string;
|
|
339
|
+
rootSpanId: string;
|
|
340
|
+
spanParents: string[];
|
|
341
|
+
kind: "span";
|
|
342
|
+
constructor();
|
|
343
|
+
log(_: ExperimentLogPartialArgs): void;
|
|
344
|
+
logFeedback(_event: Omit<LogFeedbackFullArgs, "id">): void;
|
|
345
|
+
traced<R>(callback: (span: Span) => R, _1?: StartSpanArgs & SetCurrentArg): R;
|
|
346
|
+
startSpan(_1?: StartSpanArgs): this;
|
|
347
|
+
end(args?: EndSpanArgs): number;
|
|
348
|
+
export(): Promise<string>;
|
|
349
|
+
permalink(): Promise<string>;
|
|
350
|
+
link(): string;
|
|
351
|
+
flush(): Promise<void>;
|
|
352
|
+
close(args?: EndSpanArgs): number;
|
|
353
|
+
setAttributes(_args: Omit<StartSpanArgs, "event">): void;
|
|
354
|
+
startSpanWithParents(_spanId: string, _spanParents: string[], _args?: StartSpanArgs): Span;
|
|
355
|
+
state(): BraintrustState;
|
|
356
|
+
}
|
|
357
|
+
declare const NOOP_SPAN: NoopSpan;
|
|
358
|
+
declare global {
|
|
359
|
+
var __inherited_braintrust_state: BraintrustState;
|
|
360
|
+
}
|
|
361
|
+
declare const loginSchema: z.ZodObject<{
|
|
362
|
+
appUrl: z.ZodString;
|
|
363
|
+
appPublicUrl: z.ZodString;
|
|
364
|
+
orgName: z.ZodString;
|
|
365
|
+
apiUrl: z.ZodString;
|
|
366
|
+
proxyUrl: z.ZodString;
|
|
367
|
+
loginToken: z.ZodString;
|
|
368
|
+
orgId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
369
|
+
gitMetadataSettings: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
370
|
+
collect: z.ZodEnum<["all", "none", "some"]>;
|
|
371
|
+
fields: z.ZodOptional<z.ZodArray<z.ZodEnum<["dirty", "tag", "commit", "branch", "author_name", "author_email", "commit_message", "commit_time", "git_diff"]>, "many">>;
|
|
372
|
+
}, "strict", z.ZodTypeAny, {
|
|
373
|
+
collect: "some" | "none" | "all";
|
|
374
|
+
fields?: ("dirty" | "tag" | "commit" | "branch" | "author_name" | "author_email" | "commit_message" | "commit_time" | "git_diff")[] | undefined;
|
|
375
|
+
}, {
|
|
376
|
+
collect: "some" | "none" | "all";
|
|
377
|
+
fields?: ("dirty" | "tag" | "commit" | "branch" | "author_name" | "author_email" | "commit_message" | "commit_time" | "git_diff")[] | undefined;
|
|
378
|
+
}>>>;
|
|
379
|
+
}, "strict", z.ZodTypeAny, {
|
|
380
|
+
appUrl: string;
|
|
381
|
+
appPublicUrl: string;
|
|
382
|
+
orgName: string;
|
|
383
|
+
apiUrl: string;
|
|
384
|
+
proxyUrl: string;
|
|
385
|
+
loginToken: string;
|
|
386
|
+
orgId?: string | null | undefined;
|
|
387
|
+
gitMetadataSettings?: {
|
|
388
|
+
collect: "some" | "none" | "all";
|
|
389
|
+
fields?: ("dirty" | "tag" | "commit" | "branch" | "author_name" | "author_email" | "commit_message" | "commit_time" | "git_diff")[] | undefined;
|
|
390
|
+
} | null | undefined;
|
|
391
|
+
}, {
|
|
392
|
+
appUrl: string;
|
|
393
|
+
appPublicUrl: string;
|
|
394
|
+
orgName: string;
|
|
395
|
+
apiUrl: string;
|
|
396
|
+
proxyUrl: string;
|
|
397
|
+
loginToken: string;
|
|
398
|
+
orgId?: string | null | undefined;
|
|
399
|
+
gitMetadataSettings?: {
|
|
400
|
+
collect: "some" | "none" | "all";
|
|
401
|
+
fields?: ("dirty" | "tag" | "commit" | "branch" | "author_name" | "author_email" | "commit_message" | "commit_time" | "git_diff")[] | undefined;
|
|
402
|
+
} | null | undefined;
|
|
403
|
+
}>;
|
|
404
|
+
type SerializedBraintrustState = z.infer<typeof loginSchema>;
|
|
405
|
+
declare class BraintrustState {
|
|
406
|
+
private loginParams;
|
|
407
|
+
id: string;
|
|
408
|
+
currentExperiment: Experiment | undefined;
|
|
409
|
+
currentLogger: Logger<false> | undefined;
|
|
410
|
+
currentParent: IsoAsyncLocalStorage<string>;
|
|
411
|
+
currentSpan: IsoAsyncLocalStorage<Span>;
|
|
412
|
+
private _bgLogger;
|
|
413
|
+
private _overrideBgLogger;
|
|
414
|
+
appUrl: string | null;
|
|
415
|
+
appPublicUrl: string | null;
|
|
416
|
+
loginToken: string | null;
|
|
417
|
+
orgId: string | null;
|
|
418
|
+
orgName: string | null;
|
|
419
|
+
apiUrl: string | null;
|
|
420
|
+
proxyUrl: string | null;
|
|
421
|
+
loggedIn: boolean;
|
|
422
|
+
gitMetadataSettings?: GitMetadataSettings;
|
|
423
|
+
fetch: typeof globalThis.fetch;
|
|
424
|
+
private _appConn;
|
|
425
|
+
private _apiConn;
|
|
426
|
+
private _proxyConn;
|
|
427
|
+
promptCache: PromptCache;
|
|
428
|
+
constructor(loginParams: LoginOptions);
|
|
429
|
+
resetLoginInfo(): void;
|
|
430
|
+
copyLoginInfo(other: BraintrustState): void;
|
|
431
|
+
serialize(): SerializedBraintrustState;
|
|
432
|
+
static deserialize(serialized: unknown, opts?: LoginOptions): BraintrustState;
|
|
433
|
+
setFetch(fetch: typeof globalThis.fetch): void;
|
|
434
|
+
login(loginParams: LoginOptions & {
|
|
435
|
+
forceLogin?: boolean;
|
|
436
|
+
}): Promise<void>;
|
|
437
|
+
appConn(): HTTPConnection;
|
|
438
|
+
apiConn(): HTTPConnection;
|
|
439
|
+
proxyConn(): HTTPConnection;
|
|
440
|
+
bgLogger(): BackgroundLogger;
|
|
441
|
+
httpLogger(): HTTPBackgroundLogger;
|
|
442
|
+
setOverrideBgLogger(logger: BackgroundLogger | null): void;
|
|
443
|
+
loginReplaceApiConn(apiConn: HTTPConnection): void;
|
|
444
|
+
disable(): void;
|
|
445
|
+
}
|
|
446
|
+
declare class HTTPConnection {
|
|
447
|
+
base_url: string;
|
|
448
|
+
token: string | null;
|
|
449
|
+
headers: Record<string, string>;
|
|
450
|
+
fetch: typeof globalThis.fetch;
|
|
451
|
+
constructor(base_url: string, fetch: typeof globalThis.fetch);
|
|
452
|
+
setFetch(fetch: typeof globalThis.fetch): void;
|
|
453
|
+
ping(): Promise<boolean>;
|
|
454
|
+
make_long_lived(): void;
|
|
455
|
+
static sanitize_token(token: string): string;
|
|
456
|
+
set_token(token: string): void;
|
|
457
|
+
_reset(): void;
|
|
458
|
+
get(path: string, params?: Record<string, string | string[] | undefined> | undefined, config?: RequestInit): Promise<Response>;
|
|
459
|
+
post(path: string, params?: Record<string, unknown> | string, config?: RequestInit): Promise<Response>;
|
|
460
|
+
get_json(object_type: string, args?: Record<string, string | string[] | undefined> | undefined, retries?: number): Promise<any>;
|
|
461
|
+
post_json(object_type: string, args?: Record<string, unknown> | string | undefined): Promise<any>;
|
|
462
|
+
}
|
|
463
|
+
interface ObjectMetadata {
|
|
464
|
+
id: string;
|
|
465
|
+
name: string;
|
|
466
|
+
fullInfo: Record<string, unknown>;
|
|
467
|
+
}
|
|
468
|
+
interface ProjectExperimentMetadata {
|
|
469
|
+
project: ObjectMetadata;
|
|
470
|
+
experiment: ObjectMetadata;
|
|
471
|
+
}
|
|
472
|
+
interface ProjectDatasetMetadata {
|
|
473
|
+
project: ObjectMetadata;
|
|
474
|
+
dataset: ObjectMetadata;
|
|
475
|
+
}
|
|
476
|
+
interface OrgProjectMetadata {
|
|
477
|
+
org_id: string;
|
|
478
|
+
project: ObjectMetadata;
|
|
479
|
+
}
|
|
480
|
+
interface LogOptions<IsAsyncFlush> {
|
|
481
|
+
asyncFlush?: IsAsyncFlush;
|
|
482
|
+
computeMetadataArgs?: Record<string, any>;
|
|
483
|
+
}
|
|
484
|
+
type PromiseUnless<B, R> = B extends true ? R : Promise<Awaited<R>>;
|
|
485
|
+
declare class Logger<IsAsyncFlush extends boolean> implements Exportable {
|
|
486
|
+
private state;
|
|
487
|
+
private lazyMetadata;
|
|
488
|
+
private _asyncFlush;
|
|
489
|
+
private computeMetadataArgs;
|
|
490
|
+
private lastStartTime;
|
|
491
|
+
private lazyId;
|
|
492
|
+
private calledStartSpan;
|
|
493
|
+
kind: "logger";
|
|
494
|
+
constructor(state: BraintrustState, lazyMetadata: LazyValue<OrgProjectMetadata>, logOptions?: LogOptions<IsAsyncFlush>);
|
|
495
|
+
get org_id(): Promise<string>;
|
|
496
|
+
get project(): Promise<ObjectMetadata>;
|
|
497
|
+
get id(): Promise<string>;
|
|
498
|
+
private parentObjectType;
|
|
499
|
+
/**
|
|
500
|
+
* Log a single event. The event will be batched and uploaded behind the scenes if `logOptions.asyncFlush` is true.
|
|
501
|
+
*
|
|
502
|
+
* @param event The event to log.
|
|
503
|
+
* @param event.input: (Optional) the arguments that uniquely define a user input (an arbitrary, JSON serializable object).
|
|
504
|
+
* @param event.output: (Optional) the output of your application, including post-processing (an arbitrary, JSON serializable object), that allows you to determine whether the result is correct or not. For example, in an app that generates SQL queries, the `output` should be the _result_ of the SQL query generated by the model, not the query itself, because there may be multiple valid queries that answer a single question.
|
|
505
|
+
* @param event.expected: (Optional) the ground truth value (an arbitrary, JSON serializable object) that you'd compare to `output` to determine if your `output` value is correct or not. Braintrust currently does not compare `output` to `expected` for you, since there are so many different ways to do that correctly. Instead, these values are just used to help you navigate while digging into analyses. However, we may later use these values to re-score outputs or fine-tune your models.
|
|
506
|
+
* @param event.error: (Optional) The error that occurred, if any. If you use tracing to run an experiment, errors are automatically logged when your code throws an exception.
|
|
507
|
+
* @param event.scores: (Optional) a dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety of signals that help you determine how accurate the outputs are compared to what you expect and diagnose failures. For example, a summarization app might have one score that tells you how accurate the summary is, and another that measures the word similarity between the generated and grouth truth summary. The word similarity score could help you determine whether the summarization was covering similar concepts or not. You can use these scores to help you sort, filter, and compare logs.
|
|
508
|
+
* @param event.metadata: (Optional) a dictionary with additional data about the test example, model outputs, or just about anything else that's relevant, that you can use to help find and analyze examples later. For example, you could log the `prompt`, example's `id`, or anything else that would be useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys must be strings.
|
|
509
|
+
* @param event.metrics: (Optional) a dictionary of metrics to log. The following keys are populated automatically: "start", "end".
|
|
510
|
+
* @param event.id: (Optional) a unique identifier for the event. If you don't provide one, BrainTrust will generate one for you.
|
|
511
|
+
* @param options Additional logging options
|
|
512
|
+
* @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.
|
|
513
|
+
* @returns The `id` of the logged event.
|
|
514
|
+
*/
|
|
515
|
+
log(event: Readonly<StartSpanEventArgs>, options?: {
|
|
516
|
+
allowConcurrentWithSpans?: boolean;
|
|
517
|
+
}): PromiseUnless<IsAsyncFlush, string>;
|
|
518
|
+
/**
|
|
519
|
+
* Create a new toplevel span underneath the logger. The name defaults to "root".
|
|
520
|
+
*
|
|
521
|
+
* See {@link Span.traced} for full details.
|
|
522
|
+
*/
|
|
523
|
+
traced<R>(callback: (span: Span) => R, args?: StartSpanArgs & SetCurrentArg): PromiseUnless<IsAsyncFlush, R>;
|
|
524
|
+
/**
|
|
525
|
+
* Lower-level alternative to `traced`. This allows you to start a span yourself, and can be useful in situations
|
|
526
|
+
* where you cannot use callbacks. However, spans started with `startSpan` will not be marked as the "current span",
|
|
527
|
+
* so `currentSpan()` and `traced()` will be no-ops. If you want to mark a span as current, use `traced` instead.
|
|
528
|
+
*
|
|
529
|
+
* See {@link traced} for full details.
|
|
530
|
+
*/
|
|
531
|
+
startSpan(args?: StartSpanArgs): Span;
|
|
532
|
+
private startSpanImpl;
|
|
533
|
+
/**
|
|
534
|
+
* Log feedback to an event. Feedback is used to save feedback scores, set an expected value, or add a comment.
|
|
535
|
+
*
|
|
536
|
+
* @param event
|
|
537
|
+
* @param event.id The id of the event to log feedback for. This is the `id` returned by `log` or accessible as the `id` field of a span.
|
|
538
|
+
* @param event.scores (Optional) a dictionary of numeric values (between 0 and 1) to log. These scores will be merged into the existing scores for the event.
|
|
539
|
+
* @param event.expected (Optional) the ground truth value (an arbitrary, JSON serializable object) that you'd compare to `output` to determine if your `output` value is correct or not.
|
|
540
|
+
* @param event.comment (Optional) an optional comment string to log about the event.
|
|
541
|
+
* @param event.metadata (Optional) a dictionary with additional data about the feedback. If you have a `user_id`, you can log it here and access it in the Braintrust UI. Note, this metadata does not correspond to the main event itself, but rather the audit log attached to the event.
|
|
542
|
+
* @param event.source (Optional) the source of the feedback. Must be one of "external" (default), "app", or "api".
|
|
543
|
+
*/
|
|
544
|
+
logFeedback(event: LogFeedbackFullArgs): void;
|
|
545
|
+
/**
|
|
546
|
+
* 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,
|
|
547
|
+
* since otherwise updates to the span may conflict with the original span.
|
|
548
|
+
*
|
|
549
|
+
* @param event The event data to update the span with. Must include `id`. See {@link Experiment.log} for a full list of valid fields.
|
|
550
|
+
*/
|
|
551
|
+
updateSpan(event: Omit<Partial<ExperimentEvent>, "id"> & Required<Pick<ExperimentEvent, "id">>): void;
|
|
552
|
+
/**
|
|
553
|
+
* Return a serialized representation of the logger that can be used to start subspans in other places.
|
|
554
|
+
*
|
|
555
|
+
* See {@link Span.startSpan} for more details.
|
|
556
|
+
*/
|
|
557
|
+
export(): Promise<string>;
|
|
558
|
+
flush(): Promise<void>;
|
|
559
|
+
get asyncFlush(): IsAsyncFlush | undefined;
|
|
560
|
+
}
|
|
561
|
+
interface BackgroundLoggerOpts {
|
|
562
|
+
noExitFlush?: boolean;
|
|
563
|
+
onFlushError?: (error: unknown) => void;
|
|
564
|
+
}
|
|
565
|
+
interface BackgroundLogger {
|
|
566
|
+
log(items: LazyValue<BackgroundLogEvent>[]): void;
|
|
567
|
+
flush(): Promise<void>;
|
|
568
|
+
}
|
|
569
|
+
declare class HTTPBackgroundLogger implements BackgroundLogger {
|
|
570
|
+
private apiConn;
|
|
571
|
+
private items;
|
|
572
|
+
private activeFlush;
|
|
573
|
+
private activeFlushResolved;
|
|
574
|
+
private activeFlushError;
|
|
575
|
+
private onFlushError?;
|
|
576
|
+
syncFlush: boolean;
|
|
577
|
+
maxRequestSize: number;
|
|
578
|
+
defaultBatchSize: number;
|
|
579
|
+
numTries: number;
|
|
580
|
+
queueDropExceedingMaxsize: number | undefined;
|
|
581
|
+
queueDropLoggingPeriod: number;
|
|
582
|
+
failedPublishPayloadsDir: string | undefined;
|
|
583
|
+
allPublishPayloadsDir: string | undefined;
|
|
584
|
+
private _disabled;
|
|
585
|
+
private queueDropLoggingState;
|
|
586
|
+
constructor(apiConn: LazyValue<HTTPConnection>, opts?: BackgroundLoggerOpts);
|
|
587
|
+
log(items: LazyValue<BackgroundLogEvent>[]): void;
|
|
588
|
+
flush(): Promise<void>;
|
|
589
|
+
private flushOnce;
|
|
590
|
+
private unwrapLazyValues;
|
|
591
|
+
private submitLogsRequest;
|
|
592
|
+
private registerDroppedItemCount;
|
|
593
|
+
private dumpDroppedEvents;
|
|
594
|
+
private static writePayloadToDir;
|
|
595
|
+
private triggerActiveFlush;
|
|
596
|
+
private logFailedPayloadsDir;
|
|
597
|
+
internalReplaceApiConn(apiConn: HTTPConnection): void;
|
|
598
|
+
disable(): void;
|
|
599
|
+
}
|
|
600
|
+
type AsyncFlushArg<IsAsyncFlush> = {
|
|
601
|
+
asyncFlush?: IsAsyncFlush;
|
|
602
|
+
};
|
|
603
|
+
/**
|
|
604
|
+
* Options for logging in to Braintrust.
|
|
605
|
+
*/
|
|
606
|
+
interface LoginOptions {
|
|
607
|
+
/**
|
|
608
|
+
* The URL of the Braintrust App. Defaults to https://www.braintrust.dev. You should not need
|
|
609
|
+
* to change this unless you are doing the "Full" deployment.
|
|
610
|
+
*/
|
|
611
|
+
appUrl?: string;
|
|
612
|
+
/**
|
|
613
|
+
* The API key to use. If the parameter is not specified, will try to use the `BRAINTRUST_API_KEY` environment variable.
|
|
614
|
+
*/
|
|
615
|
+
apiKey?: string;
|
|
616
|
+
/**
|
|
617
|
+
* The name of a specific organization to connect to. Since API keys are scoped to organizations, this parameter is usually
|
|
618
|
+
* unnecessary unless you are logging in with a JWT.
|
|
619
|
+
*/
|
|
620
|
+
orgName?: string;
|
|
621
|
+
/**
|
|
622
|
+
* A custom fetch implementation to use.
|
|
623
|
+
*/
|
|
624
|
+
fetch?: typeof globalThis.fetch;
|
|
625
|
+
/**
|
|
626
|
+
* By default, the SDK installs an event handler that flushes pending writes on the `beforeExit` event.
|
|
627
|
+
* If true, this event handler will _not_ be installed.
|
|
628
|
+
*/
|
|
629
|
+
noExitFlush?: boolean;
|
|
630
|
+
/**
|
|
631
|
+
* Calls this function if there's an error in the background flusher.
|
|
632
|
+
*/
|
|
633
|
+
onFlushError?: (error: unknown) => void;
|
|
634
|
+
}
|
|
635
|
+
type OptionalStateArg = {
|
|
636
|
+
state?: BraintrustState;
|
|
637
|
+
};
|
|
638
|
+
/**
|
|
639
|
+
* 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.
|
|
640
|
+
*
|
|
641
|
+
* See {@link Span} for full details.
|
|
642
|
+
*/
|
|
643
|
+
declare function currentSpan(options?: OptionalStateArg): Span;
|
|
644
|
+
/**
|
|
645
|
+
* Lower-level alternative to `traced`. This allows you to start a span yourself, and can be useful in situations
|
|
646
|
+
* where you cannot use callbacks. However, spans started with `startSpan` will not be marked as the "current span",
|
|
647
|
+
* so `currentSpan()` and `traced()` will be no-ops. If you want to mark a span as current, use `traced` instead.
|
|
648
|
+
*
|
|
649
|
+
* See {@link traced} for full details.
|
|
650
|
+
*/
|
|
651
|
+
declare function startSpan<IsAsyncFlush extends boolean = true>(args?: StartSpanArgs & AsyncFlushArg<IsAsyncFlush> & OptionalStateArg): Span;
|
|
652
|
+
/**
|
|
653
|
+
* Runs the provided callback with the span as the current span.
|
|
654
|
+
*/
|
|
655
|
+
declare function withCurrent<R>(span: Span, callback: (span: Span) => R, state?: BraintrustState | undefined): R;
|
|
656
|
+
type WithTransactionId<R> = R & {
|
|
657
|
+
[TRANSACTION_ID_FIELD]: TransactionId;
|
|
658
|
+
};
|
|
659
|
+
declare class ObjectFetcher<RecordType> implements AsyncIterable<WithTransactionId<RecordType>> {
|
|
660
|
+
private objectType;
|
|
661
|
+
private pinnedVersion;
|
|
662
|
+
private mutateRecord?;
|
|
663
|
+
private _internal_btql?;
|
|
664
|
+
private _fetchedData;
|
|
665
|
+
constructor(objectType: "dataset" | "experiment", pinnedVersion: string | undefined, mutateRecord?: ((r: any) => WithTransactionId<RecordType>) | undefined, _internal_btql?: Record<string, unknown> | undefined);
|
|
666
|
+
get id(): Promise<string>;
|
|
667
|
+
protected getState(): Promise<BraintrustState>;
|
|
668
|
+
fetch(): AsyncGenerator<WithTransactionId<RecordType>>;
|
|
669
|
+
[Symbol.asyncIterator](): AsyncIterator<WithTransactionId<RecordType>>;
|
|
670
|
+
fetchedData(): Promise<WithTransactionId<RecordType>[]>;
|
|
671
|
+
clearCache(): void;
|
|
672
|
+
version(): Promise<string | undefined>;
|
|
673
|
+
}
|
|
674
|
+
type BaseMetadata = Record<string, unknown> | void;
|
|
675
|
+
type DefaultMetadataType = void;
|
|
676
|
+
type EvalCase<Input, Expected, Metadata> = {
|
|
677
|
+
input: Input;
|
|
678
|
+
tags?: string[];
|
|
679
|
+
id?: string;
|
|
680
|
+
_xact_id?: TransactionId;
|
|
681
|
+
created?: string | null;
|
|
682
|
+
upsert_id?: string;
|
|
683
|
+
} & (Expected extends void ? object : {
|
|
684
|
+
expected: Expected;
|
|
685
|
+
}) & (Metadata extends void ? object : {
|
|
686
|
+
metadata: Metadata;
|
|
687
|
+
});
|
|
688
|
+
/**
|
|
689
|
+
* An experiment is a collection of logged events, such as model inputs and outputs, which represent
|
|
690
|
+
* a snapshot of your application at a particular point in time. An experiment is meant to capture more
|
|
691
|
+
* than just the model you use, and includes the data you use to test, pre- and post- processing code,
|
|
692
|
+
* comparison metrics (scores), and any other metadata you want to include.
|
|
693
|
+
*
|
|
694
|
+
* Experiments are associated with a project, and two experiments are meant to be easily comparable via
|
|
695
|
+
* their `inputs`. You can change the attributes of the experiments in a project (e.g. scoring functions)
|
|
696
|
+
* over time, simply by changing what you log.
|
|
697
|
+
*
|
|
698
|
+
* You should not create `Experiment` objects directly. Instead, use the `braintrust.init()` method.
|
|
699
|
+
*/
|
|
700
|
+
declare class Experiment extends ObjectFetcher<ExperimentEvent> implements Exportable {
|
|
701
|
+
private readonly lazyMetadata;
|
|
702
|
+
readonly dataset?: AnyDataset;
|
|
703
|
+
private lastStartTime;
|
|
704
|
+
private lazyId;
|
|
705
|
+
private calledStartSpan;
|
|
706
|
+
private state;
|
|
707
|
+
kind: "experiment";
|
|
708
|
+
constructor(state: BraintrustState, lazyMetadata: LazyValue<ProjectExperimentMetadata>, dataset?: AnyDataset);
|
|
709
|
+
get id(): Promise<string>;
|
|
710
|
+
get name(): Promise<string>;
|
|
711
|
+
get project(): Promise<ObjectMetadata>;
|
|
712
|
+
private parentObjectType;
|
|
713
|
+
protected getState(): Promise<BraintrustState>;
|
|
714
|
+
/**
|
|
715
|
+
* Log a single event to the experiment. The event will be batched and uploaded behind the scenes.
|
|
716
|
+
*
|
|
717
|
+
* @param event The event to log.
|
|
718
|
+
* @param event.input: The arguments that uniquely define a test case (an arbitrary, JSON serializable object). Later on, Braintrust will use the `input` to know whether two test cases are the same between experiments, so they should not contain experiment-specific state. A simple rule of thumb is that if you run the same experiment twice, the `input` should be identical.
|
|
719
|
+
* @param event.output: The output of your application, including post-processing (an arbitrary, JSON serializable object), that allows you to determine whether the result is correct or not. For example, in an app that generates SQL queries, the `output` should be the _result_ of the SQL query generated by the model, not the query itself, because there may be multiple valid queries that answer a single question.
|
|
720
|
+
* @param event.expected: (Optional) The ground truth value (an arbitrary, JSON serializable object) that you'd compare to `output` to determine if your `output` value is correct or not. Braintrust currently does not compare `output` to `expected` for you, since there are so many different ways to do that correctly. Instead, these values are just used to help you navigate your experiments while digging into analyses. However, we may later use these values to re-score outputs or fine-tune your models.
|
|
721
|
+
* @param event.error: (Optional) The error that occurred, if any. If you use tracing to run an experiment, errors are automatically logged when your code throws an exception.
|
|
722
|
+
* @param event.scores: A dictionary of numeric values (between 0 and 1) to log. The scores should give you a variety of signals that help you determine how accurate the outputs are compared to what you expect and diagnose failures. For example, a summarization app might have one score that tells you how accurate the summary is, and another that measures the word similarity between the generated and grouth truth summary. The word similarity score could help you determine whether the summarization was covering similar concepts or not. You can use these scores to help you sort, filter, and compare experiments.
|
|
723
|
+
* @param event.metadata: (Optional) a dictionary with additional data about the test example, model outputs, or just about anything else that's relevant, that you can use to help find and analyze examples later. For example, you could log the `prompt`, example's `id`, or anything else that would be useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys must be strings.
|
|
724
|
+
* @param event.metrics: (Optional) a dictionary of metrics to log. The following keys are populated automatically: "start", "end".
|
|
725
|
+
* @param event.id: (Optional) a unique identifier for the event. If you don't provide one, BrainTrust will generate one for you.
|
|
726
|
+
* @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. This field is unused and will be removed in a future version.
|
|
727
|
+
* @param options Additional logging options
|
|
728
|
+
* @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.
|
|
729
|
+
* @returns The `id` of the logged event.
|
|
730
|
+
*/
|
|
731
|
+
log(event: Readonly<ExperimentLogFullArgs>, options?: {
|
|
732
|
+
allowConcurrentWithSpans?: boolean;
|
|
733
|
+
}): string;
|
|
734
|
+
/**
|
|
735
|
+
* Create a new toplevel span underneath the experiment. The name defaults to "root".
|
|
736
|
+
*
|
|
737
|
+
* See {@link Span.traced} for full details.
|
|
738
|
+
*/
|
|
739
|
+
traced<R>(callback: (span: Span) => R, args?: StartSpanArgs & SetCurrentArg): R;
|
|
740
|
+
/**
|
|
741
|
+
* Lower-level alternative to `traced`. This allows you to start a span yourself, and can be useful in situations
|
|
742
|
+
* where you cannot use callbacks. However, spans started with `startSpan` will not be marked as the "current span",
|
|
743
|
+
* so `currentSpan()` and `traced()` will be no-ops. If you want to mark a span as current, use `traced` instead.
|
|
744
|
+
*
|
|
745
|
+
* See {@link traced} for full details.
|
|
746
|
+
*/
|
|
747
|
+
startSpan(args?: StartSpanArgs): Span;
|
|
748
|
+
private startSpanImpl;
|
|
749
|
+
fetchBaseExperiment(): Promise<{
|
|
750
|
+
id: any;
|
|
751
|
+
name: any;
|
|
752
|
+
} | null>;
|
|
753
|
+
/**
|
|
754
|
+
* Summarize the experiment, including the scores (compared to the closest reference experiment) and metadata.
|
|
755
|
+
*
|
|
756
|
+
* @param options Options for summarizing the experiment.
|
|
757
|
+
* @param options.summarizeScores Whether to summarize the scores. If False, only the metadata will be returned.
|
|
758
|
+
* @param options.comparisonExperimentId The experiment to compare against. If None, the most recent experiment on the origin's main branch will be used.
|
|
759
|
+
* @returns A summary of the experiment, including the scores (compared to the closest reference experiment) and metadata.
|
|
760
|
+
*/
|
|
761
|
+
summarize(options?: {
|
|
762
|
+
readonly summarizeScores?: boolean;
|
|
763
|
+
readonly comparisonExperimentId?: string;
|
|
764
|
+
}): Promise<ExperimentSummary>;
|
|
765
|
+
/**
|
|
766
|
+
* Log feedback to an event in the experiment. Feedback is used to save feedback scores, set an expected value, or add a comment.
|
|
767
|
+
*
|
|
768
|
+
* @param event
|
|
769
|
+
* @param event.id The id of the event to log feedback for. This is the `id` returned by `log` or accessible as the `id` field of a span.
|
|
770
|
+
* @param event.scores (Optional) a dictionary of numeric values (between 0 and 1) to log. These scores will be merged into the existing scores for the event.
|
|
771
|
+
* @param event.expected (Optional) the ground truth value (an arbitrary, JSON serializable object) that you'd compare to `output` to determine if your `output` value is correct or not.
|
|
772
|
+
* @param event.comment (Optional) an optional comment string to log about the event.
|
|
773
|
+
* @param event.metadata (Optional) a dictionary with additional data about the feedback. If you have a `user_id`, you can log it here and access it in the Braintrust UI. Note, this metadata does not correspond to the main event itself, but rather the audit log attached to the event.
|
|
774
|
+
* @param event.source (Optional) the source of the feedback. Must be one of "external" (default), "app", or "api".
|
|
775
|
+
*/
|
|
776
|
+
logFeedback(event: LogFeedbackFullArgs): void;
|
|
777
|
+
/**
|
|
778
|
+
* 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,
|
|
779
|
+
* since otherwise updates to the span may conflict with the original span.
|
|
780
|
+
*
|
|
781
|
+
* @param event The event data to update the span with. Must include `id`. See {@link Experiment.log} for a full list of valid fields.
|
|
782
|
+
*/
|
|
783
|
+
updateSpan(event: Omit<Partial<ExperimentEvent>, "id"> & Required<Pick<ExperimentEvent, "id">>): void;
|
|
784
|
+
/**
|
|
785
|
+
* Return a serialized representation of the experiment that can be used to start subspans in other places.
|
|
786
|
+
*
|
|
787
|
+
* See {@link Span.startSpan} for more details.
|
|
788
|
+
*/
|
|
789
|
+
export(): Promise<string>;
|
|
790
|
+
/**
|
|
791
|
+
* Flush any pending rows to the server.
|
|
792
|
+
*/
|
|
793
|
+
flush(): Promise<void>;
|
|
794
|
+
/**
|
|
795
|
+
* @deprecated This function is deprecated. You can simply remove it from your code.
|
|
796
|
+
*/
|
|
797
|
+
close(): Promise<string>;
|
|
798
|
+
}
|
|
799
|
+
/**
|
|
800
|
+
* A dataset is a collection of records, such as model inputs and expected outputs, which represent
|
|
801
|
+
* data you can use to evaluate and fine-tune models. You can log production data to datasets,
|
|
802
|
+
* curate them with interesting examples, edit/delete records, and run evaluations against them.
|
|
803
|
+
*
|
|
804
|
+
* You should not create `Dataset` objects directly. Instead, use the `braintrust.initDataset()` method.
|
|
805
|
+
*/
|
|
806
|
+
declare class Dataset<IsLegacyDataset extends boolean = typeof DEFAULT_IS_LEGACY_DATASET> extends ObjectFetcher<DatasetRecord<IsLegacyDataset>> {
|
|
807
|
+
private state;
|
|
808
|
+
private readonly lazyMetadata;
|
|
809
|
+
private readonly __braintrust_dataset_marker;
|
|
810
|
+
private newRecords;
|
|
811
|
+
constructor(state: BraintrustState, lazyMetadata: LazyValue<ProjectDatasetMetadata>, pinnedVersion?: string, legacy?: IsLegacyDataset, _internal_btql?: Record<string, unknown>);
|
|
812
|
+
get id(): Promise<string>;
|
|
813
|
+
get name(): Promise<string>;
|
|
814
|
+
get project(): Promise<ObjectMetadata>;
|
|
815
|
+
protected getState(): Promise<BraintrustState>;
|
|
816
|
+
private validateEvent;
|
|
817
|
+
private createArgs;
|
|
818
|
+
/**
|
|
819
|
+
* Insert a single record to the dataset. The record will be batched and uploaded behind the scenes. If you pass in an `id`,
|
|
820
|
+
* and a record with that `id` already exists, it will be overwritten (upsert).
|
|
821
|
+
*
|
|
822
|
+
* @param event The event to log.
|
|
823
|
+
* @param event.input The argument that uniquely define an input case (an arbitrary, JSON serializable object).
|
|
824
|
+
* @param event.expected The output of your application, including post-processing (an arbitrary, JSON serializable object).
|
|
825
|
+
* @param event.tags (Optional) a list of strings that you can use to filter and group records later.
|
|
826
|
+
* @param event.metadata (Optional) a dictionary with additional data about the test example, model outputs, or just
|
|
827
|
+
* about anything else that's relevant, that you can use to help find and analyze examples later. For example, you could log the
|
|
828
|
+
* `prompt`, example's `id`, or anything else that would be useful to slice/dice later. The values in `metadata` can be any
|
|
829
|
+
* JSON-serializable type, but its keys must be strings.
|
|
830
|
+
* @param event.id (Optional) a unique identifier for the event. If you don't provide one, Braintrust will generate one for you.
|
|
831
|
+
* @param event.output: (Deprecated) The output of your application. Use `expected` instead.
|
|
832
|
+
* @returns The `id` of the logged record.
|
|
833
|
+
*/
|
|
834
|
+
insert({ input, expected, metadata, tags, id, output, }: {
|
|
835
|
+
readonly input?: unknown;
|
|
836
|
+
readonly expected?: unknown;
|
|
837
|
+
readonly tags?: string[];
|
|
838
|
+
readonly metadata?: Record<string, unknown>;
|
|
839
|
+
readonly id?: string;
|
|
840
|
+
readonly output?: unknown;
|
|
841
|
+
}): string;
|
|
842
|
+
/**
|
|
843
|
+
* Update fields of a single record in the dataset. The updated fields will be batched and uploaded behind the scenes.
|
|
844
|
+
* You must pass in an `id` of the record to update. Only the fields provided will be updated; other fields will remain unchanged.
|
|
845
|
+
*
|
|
846
|
+
* @param event The fields to update in the record.
|
|
847
|
+
* @param event.id The unique identifier of the record to update.
|
|
848
|
+
* @param event.input (Optional) The new input value for the record (an arbitrary, JSON serializable object).
|
|
849
|
+
* @param event.expected (Optional) The new expected output value for the record (an arbitrary, JSON serializable object).
|
|
850
|
+
* @param event.tags (Optional) A list of strings to update the tags of the record.
|
|
851
|
+
* @param event.metadata (Optional) A dictionary to update the metadata of the record. The values in `metadata` can be any
|
|
852
|
+
* JSON-serializable type, but its keys must be strings.
|
|
853
|
+
* @returns The `id` of the updated record.
|
|
854
|
+
*/
|
|
855
|
+
update({ input, expected, metadata, tags, id, }: {
|
|
856
|
+
readonly id: string;
|
|
857
|
+
readonly input?: unknown;
|
|
858
|
+
readonly expected?: unknown;
|
|
859
|
+
readonly tags?: string[];
|
|
860
|
+
readonly metadata?: Record<string, unknown>;
|
|
861
|
+
}): string;
|
|
862
|
+
delete(id: string): string;
|
|
863
|
+
/**
|
|
864
|
+
* Summarize the dataset, including high level metrics about its size and other metadata.
|
|
865
|
+
* @param summarizeData Whether to summarize the data. If false, only the metadata will be returned.
|
|
866
|
+
* @returns `DatasetSummary`
|
|
867
|
+
* @returns A summary of the dataset.
|
|
868
|
+
*/
|
|
869
|
+
summarize(options?: {
|
|
870
|
+
readonly summarizeData?: boolean;
|
|
871
|
+
}): Promise<DatasetSummary>;
|
|
872
|
+
/**
|
|
873
|
+
* Flush any pending rows to the server.
|
|
874
|
+
*/
|
|
875
|
+
flush(): Promise<void>;
|
|
876
|
+
/**
|
|
877
|
+
* @deprecated This function is deprecated. You can simply remove it from your code.
|
|
878
|
+
*/
|
|
879
|
+
close(): Promise<string>;
|
|
880
|
+
static isDataset(data: unknown): data is Dataset;
|
|
881
|
+
}
|
|
882
|
+
type CompiledPromptParams = Omit<NonNullable<PromptData["options"]>["params"], "use_cache"> & {
|
|
883
|
+
model: NonNullable<NonNullable<PromptData["options"]>["model"]>;
|
|
884
|
+
};
|
|
885
|
+
type ChatPrompt = {
|
|
886
|
+
messages: OpenAIMessage[];
|
|
887
|
+
tools?: Tools;
|
|
888
|
+
};
|
|
889
|
+
type CompletionPrompt = {
|
|
890
|
+
prompt: string;
|
|
891
|
+
};
|
|
892
|
+
type CompiledPrompt<Flavor extends "chat" | "completion"> = CompiledPromptParams & {
|
|
893
|
+
span_info?: {
|
|
894
|
+
name?: string;
|
|
895
|
+
spanAttributes?: Record<any, any>;
|
|
896
|
+
metadata: {
|
|
897
|
+
prompt: {
|
|
898
|
+
variables: Record<string, unknown>;
|
|
899
|
+
id: string;
|
|
900
|
+
project_id: string;
|
|
901
|
+
version: string;
|
|
902
|
+
};
|
|
903
|
+
};
|
|
904
|
+
};
|
|
905
|
+
} & (Flavor extends "chat" ? ChatPrompt : Flavor extends "completion" ? CompletionPrompt : {});
|
|
906
|
+
type DefaultPromptArgs = Partial<CompiledPromptParams & AnyModelParam & ChatPrompt & CompletionPrompt>;
|
|
907
|
+
type PromptRowWithId<HasId extends boolean = true, HasVersion extends boolean = true> = Omit<Prompt$1, "log_id" | "org_id" | "project_id" | "id" | "_xact_id"> & Partial<Pick<Prompt$1, "project_id">> & (HasId extends true ? Pick<Prompt$1, "id"> : Partial<Pick<Prompt$1, "id">>) & (HasVersion extends true ? Pick<Prompt$1, "_xact_id"> : Partial<Pick<Prompt$1, "_xact_id">>);
|
|
908
|
+
declare class Prompt<HasId extends boolean = true, HasVersion extends boolean = true> {
|
|
909
|
+
private metadata;
|
|
910
|
+
private defaults;
|
|
911
|
+
private noTrace;
|
|
912
|
+
private parsedPromptData;
|
|
913
|
+
private hasParsedPromptData;
|
|
914
|
+
private readonly __braintrust_prompt_marker;
|
|
915
|
+
constructor(metadata: PromptRowWithId<HasId, HasVersion> | PromptSessionEvent, defaults: DefaultPromptArgs, noTrace: boolean);
|
|
916
|
+
get id(): HasId extends true ? string : string | undefined;
|
|
917
|
+
get projectId(): string | undefined;
|
|
918
|
+
get name(): string;
|
|
919
|
+
get slug(): string;
|
|
920
|
+
get prompt(): PromptData["prompt"];
|
|
921
|
+
get version(): HasId extends true ? TransactionId : TransactionId | undefined;
|
|
922
|
+
get options(): NonNullable<PromptData["options"]>;
|
|
923
|
+
get promptData(): PromptData;
|
|
924
|
+
/**
|
|
925
|
+
* Build the prompt with the given formatting options. The args you pass in will
|
|
926
|
+
* be forwarded to the mustache template that defines the prompt and rendered with
|
|
927
|
+
* the `mustache-js` library.
|
|
928
|
+
*
|
|
929
|
+
* @param buildArgs Args to forward along to the prompt template.
|
|
930
|
+
*/
|
|
931
|
+
build<Flavor extends "chat" | "completion" = "chat">(buildArgs: unknown, options?: {
|
|
932
|
+
flavor?: Flavor;
|
|
933
|
+
messages?: Message[];
|
|
934
|
+
strict?: boolean;
|
|
935
|
+
}): CompiledPrompt<Flavor>;
|
|
936
|
+
private runBuild;
|
|
937
|
+
static renderPrompt({ prompt, buildArgs, options, }: {
|
|
938
|
+
prompt: PromptBlockData;
|
|
939
|
+
buildArgs: unknown;
|
|
940
|
+
options: {
|
|
941
|
+
strict?: boolean;
|
|
942
|
+
messages?: Message[];
|
|
943
|
+
};
|
|
944
|
+
}): PromptBlockData;
|
|
945
|
+
private getParsedPromptData;
|
|
946
|
+
static isPrompt(data: unknown): data is Prompt<boolean, boolean>;
|
|
947
|
+
static fromPromptData(name: string, promptData: PromptData): Prompt<false, false>;
|
|
948
|
+
}
|
|
949
|
+
type AnyDataset = Dataset<boolean>;
|
|
950
|
+
/**
|
|
951
|
+
* Summary of a score's performance.
|
|
952
|
+
* @property name Name of the score.
|
|
953
|
+
* @property score Average score across all examples.
|
|
954
|
+
* @property diff Difference in score between the current and reference experiment.
|
|
955
|
+
* @property improvements Number of improvements in the score.
|
|
956
|
+
* @property regressions Number of regressions in the score.
|
|
957
|
+
*/
|
|
958
|
+
interface ScoreSummary {
|
|
959
|
+
name: string;
|
|
960
|
+
score: number;
|
|
961
|
+
diff?: number;
|
|
962
|
+
improvements: number;
|
|
963
|
+
regressions: number;
|
|
964
|
+
}
|
|
965
|
+
/**
|
|
966
|
+
* Summary of a metric's performance.
|
|
967
|
+
* @property name Name of the metric.
|
|
968
|
+
* @property metric Average metric across all examples.
|
|
969
|
+
* @property unit Unit label for the metric.
|
|
970
|
+
* @property diff Difference in metric between the current and reference experiment.
|
|
971
|
+
* @property improvements Number of improvements in the metric.
|
|
972
|
+
* @property regressions Number of regressions in the metric.
|
|
973
|
+
*/
|
|
974
|
+
interface MetricSummary {
|
|
975
|
+
name: string;
|
|
976
|
+
metric: number;
|
|
977
|
+
unit: string;
|
|
978
|
+
diff?: number;
|
|
979
|
+
improvements: number;
|
|
980
|
+
regressions: number;
|
|
981
|
+
}
|
|
982
|
+
/**
|
|
983
|
+
* Summary of an experiment's scores and metadata.
|
|
984
|
+
* @property projectName Name of the project that the experiment belongs to.
|
|
985
|
+
* @property experimentName Name of the experiment.
|
|
986
|
+
* @property experimentId ID of the experiment. May be `undefined` if the eval was run locally.
|
|
987
|
+
* @property projectUrl URL to the project's page in the Braintrust app.
|
|
988
|
+
* @property experimentUrl URL to the experiment's page in the Braintrust app.
|
|
989
|
+
* @property comparisonExperimentName The experiment scores are baselined against.
|
|
990
|
+
* @property scores Summary of the experiment's scores.
|
|
991
|
+
*/
|
|
992
|
+
interface ExperimentSummary {
|
|
993
|
+
projectName: string;
|
|
994
|
+
experimentName: string;
|
|
995
|
+
projectId?: string;
|
|
996
|
+
experimentId?: string;
|
|
997
|
+
projectUrl?: string;
|
|
998
|
+
experimentUrl?: string;
|
|
999
|
+
comparisonExperimentName?: string;
|
|
1000
|
+
scores: Record<string, ScoreSummary>;
|
|
1001
|
+
metrics?: Record<string, MetricSummary>;
|
|
1002
|
+
}
|
|
1003
|
+
/**
|
|
1004
|
+
* Summary of a dataset's data.
|
|
1005
|
+
*
|
|
1006
|
+
* @property totalRecords Total records in the dataset.
|
|
1007
|
+
*/
|
|
1008
|
+
interface DataSummary {
|
|
1009
|
+
/**
|
|
1010
|
+
* New or updated records added in this session.
|
|
1011
|
+
*/
|
|
1012
|
+
newRecords: number;
|
|
1013
|
+
/**
|
|
1014
|
+
* Total records in the dataset.
|
|
1015
|
+
*/
|
|
1016
|
+
totalRecords: number;
|
|
1017
|
+
}
|
|
1018
|
+
/**
|
|
1019
|
+
* Summary of a dataset's scores and metadata.
|
|
1020
|
+
*
|
|
1021
|
+
* @property projectName Name of the project that the dataset belongs to.
|
|
1022
|
+
* @property datasetName Name of the dataset.
|
|
1023
|
+
* @property projectUrl URL to the project's page in the Braintrust app.
|
|
1024
|
+
* @property datasetUrl URL to the experiment's page in the Braintrust app.
|
|
1025
|
+
* @property dataSummary Summary of the dataset's data.
|
|
1026
|
+
*/
|
|
1027
|
+
interface DatasetSummary {
|
|
1028
|
+
projectName: string;
|
|
1029
|
+
datasetName: string;
|
|
1030
|
+
projectUrl: string;
|
|
1031
|
+
datasetUrl: string;
|
|
1032
|
+
dataSummary: DataSummary | undefined;
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
type NameOrId = {
|
|
1036
|
+
name: string;
|
|
1037
|
+
} | {
|
|
1038
|
+
id: string;
|
|
1039
|
+
};
|
|
1040
|
+
type CreateProjectOpts = NameOrId;
|
|
1041
|
+
declare class Project {
|
|
1042
|
+
readonly name?: string;
|
|
1043
|
+
readonly id?: string;
|
|
1044
|
+
tools: ToolBuilder;
|
|
1045
|
+
prompts: PromptBuilder;
|
|
1046
|
+
scorers: ScorerBuilder;
|
|
1047
|
+
constructor(args: CreateProjectOpts);
|
|
1048
|
+
}
|
|
1049
|
+
declare class ToolBuilder {
|
|
1050
|
+
private readonly project;
|
|
1051
|
+
private taskCounter;
|
|
1052
|
+
constructor(project: Project);
|
|
1053
|
+
create<Input, Output, Fn extends GenericFunction<Input, Output>>(opts: CodeOpts<Input, Output, Fn>): CodeFunction<Input, Output, Fn>;
|
|
1054
|
+
}
|
|
1055
|
+
declare class ScorerBuilder {
|
|
1056
|
+
private readonly project;
|
|
1057
|
+
private taskCounter;
|
|
1058
|
+
constructor(project: Project);
|
|
1059
|
+
create<Output, Input, Params, Returns, Fn extends GenericFunction<Exact<Params, ScorerArgs<Output, Input>>, Returns>>(opts: ScorerOpts<Output, Input, Params, Returns, Fn>): void;
|
|
1060
|
+
}
|
|
1061
|
+
type Schema<Input, Output> = Partial<{
|
|
1062
|
+
parameters: z.ZodSchema<Input>;
|
|
1063
|
+
returns: z.ZodSchema<Output>;
|
|
1064
|
+
}>;
|
|
1065
|
+
interface BaseFnOpts {
|
|
1066
|
+
name: string;
|
|
1067
|
+
slug: string;
|
|
1068
|
+
description: string;
|
|
1069
|
+
ifExists: IfExists;
|
|
1070
|
+
}
|
|
1071
|
+
type CodeOpts<Params, Returns, Fn extends GenericFunction<Params, Returns>> = Partial<BaseFnOpts> & {
|
|
1072
|
+
handler: Fn;
|
|
1073
|
+
} & Schema<Params, Returns>;
|
|
1074
|
+
type ScorerPromptOpts = Partial<BaseFnOpts> & PromptOpts<false, false, false, false> & {
|
|
1075
|
+
useCot: boolean;
|
|
1076
|
+
choiceScores: Record<string, number>;
|
|
1077
|
+
};
|
|
1078
|
+
type ScorerArgs<Output, Input> = {
|
|
1079
|
+
output: Output;
|
|
1080
|
+
expected?: Output;
|
|
1081
|
+
input?: Input;
|
|
1082
|
+
metadata?: Record<string, unknown>;
|
|
1083
|
+
};
|
|
1084
|
+
type Exact<T, Shape> = T extends Shape ? Exclude<keyof T, keyof Shape> extends never ? T : never : never;
|
|
1085
|
+
type ScorerOpts<Output, Input, Params, Returns, Fn extends GenericFunction<Exact<Params, ScorerArgs<Output, Input>>, Returns>> = CodeOpts<Exact<Params, ScorerArgs<Output, Input>>, Returns, Fn> | ScorerPromptOpts;
|
|
1086
|
+
declare class CodeFunction<Input, Output, Fn extends GenericFunction<Input, Output>> {
|
|
1087
|
+
readonly project: Project;
|
|
1088
|
+
readonly handler: Fn;
|
|
1089
|
+
readonly name: string;
|
|
1090
|
+
readonly slug: string;
|
|
1091
|
+
readonly type: FunctionType;
|
|
1092
|
+
readonly description?: string;
|
|
1093
|
+
readonly parameters?: z.ZodSchema<Input>;
|
|
1094
|
+
readonly returns?: z.ZodSchema<Output>;
|
|
1095
|
+
readonly ifExists?: IfExists;
|
|
1096
|
+
constructor(project: Project, opts: Omit<CodeOpts<Input, Output, Fn>, "name" | "slug"> & {
|
|
1097
|
+
name: string;
|
|
1098
|
+
slug: string;
|
|
1099
|
+
type: FunctionType;
|
|
1100
|
+
});
|
|
1101
|
+
key(): string;
|
|
1102
|
+
}
|
|
1103
|
+
type GenericCodeFunction = CodeFunction<any, any, GenericFunction<any, any>>;
|
|
1104
|
+
declare class CodePrompt {
|
|
1105
|
+
readonly project: Project;
|
|
1106
|
+
readonly name: string;
|
|
1107
|
+
readonly slug: string;
|
|
1108
|
+
readonly prompt: PromptData;
|
|
1109
|
+
readonly ifExists?: IfExists;
|
|
1110
|
+
readonly description?: string;
|
|
1111
|
+
readonly id?: string;
|
|
1112
|
+
readonly functionType?: FunctionType;
|
|
1113
|
+
readonly toolFunctions: (SavedFunctionId | GenericCodeFunction)[];
|
|
1114
|
+
constructor(project: Project, prompt: PromptData, toolFunctions: (SavedFunctionId | GenericCodeFunction)[], opts: Omit<PromptOpts<false, false, false, false>, "name" | "slug"> & {
|
|
1115
|
+
name: string;
|
|
1116
|
+
slug: string;
|
|
1117
|
+
}, functionType?: FunctionType);
|
|
1118
|
+
}
|
|
1119
|
+
interface PromptId {
|
|
1120
|
+
id: string;
|
|
1121
|
+
}
|
|
1122
|
+
interface PromptVersion {
|
|
1123
|
+
version: TransactionId;
|
|
1124
|
+
}
|
|
1125
|
+
interface PromptTools {
|
|
1126
|
+
tools: (GenericCodeFunction | SavedFunctionId | ToolFunctionDefinition)[];
|
|
1127
|
+
}
|
|
1128
|
+
interface PromptNoTrace {
|
|
1129
|
+
noTrace: boolean;
|
|
1130
|
+
}
|
|
1131
|
+
declare const promptDefinitionSchema: z.ZodIntersection<z.ZodUnion<[z.ZodObject<{
|
|
1132
|
+
prompt: z.ZodString;
|
|
1133
|
+
}, "strip", z.ZodTypeAny, {
|
|
1134
|
+
prompt: string;
|
|
1135
|
+
}, {
|
|
1136
|
+
prompt: string;
|
|
1137
|
+
}>, z.ZodObject<{
|
|
1138
|
+
messages: z.ZodArray<z.ZodUnion<[z.ZodUnion<[z.ZodObject<{
|
|
1139
|
+
content: z.ZodUnion<[z.ZodDefault<z.ZodString>, z.ZodArray<z.ZodObject<{
|
|
1140
|
+
text: z.ZodDefault<z.ZodString>;
|
|
1141
|
+
type: z.ZodLiteral<"text">;
|
|
1142
|
+
cache_control: z.ZodOptional<z.ZodObject<{
|
|
1143
|
+
type: z.ZodEnum<["ephemeral"]>;
|
|
1144
|
+
}, "strip", z.ZodTypeAny, {
|
|
1145
|
+
type: "ephemeral";
|
|
1146
|
+
}, {
|
|
1147
|
+
type: "ephemeral";
|
|
1148
|
+
}>>;
|
|
1149
|
+
}, "strip", z.ZodTypeAny, {
|
|
1150
|
+
type: "text";
|
|
1151
|
+
text: string;
|
|
1152
|
+
cache_control?: {
|
|
1153
|
+
type: "ephemeral";
|
|
1154
|
+
} | undefined;
|
|
1155
|
+
}, {
|
|
1156
|
+
type: "text";
|
|
1157
|
+
text?: string | undefined;
|
|
1158
|
+
cache_control?: {
|
|
1159
|
+
type: "ephemeral";
|
|
1160
|
+
} | undefined;
|
|
1161
|
+
}>, "many">]>;
|
|
1162
|
+
role: z.ZodLiteral<"system">;
|
|
1163
|
+
name: z.ZodOptional<z.ZodString>;
|
|
1164
|
+
}, "strip", z.ZodTypeAny, {
|
|
1165
|
+
content: (string | {
|
|
1166
|
+
type: "text";
|
|
1167
|
+
text: string;
|
|
1168
|
+
cache_control?: {
|
|
1169
|
+
type: "ephemeral";
|
|
1170
|
+
} | undefined;
|
|
1171
|
+
}[]) & (string | {
|
|
1172
|
+
type: "text";
|
|
1173
|
+
text: string;
|
|
1174
|
+
cache_control?: {
|
|
1175
|
+
type: "ephemeral";
|
|
1176
|
+
} | undefined;
|
|
1177
|
+
}[] | undefined);
|
|
1178
|
+
role: "system";
|
|
1179
|
+
name?: string | undefined;
|
|
1180
|
+
}, {
|
|
1181
|
+
role: "system";
|
|
1182
|
+
content?: string | {
|
|
1183
|
+
type: "text";
|
|
1184
|
+
text?: string | undefined;
|
|
1185
|
+
cache_control?: {
|
|
1186
|
+
type: "ephemeral";
|
|
1187
|
+
} | undefined;
|
|
1188
|
+
}[] | undefined;
|
|
1189
|
+
name?: string | undefined;
|
|
1190
|
+
}>, z.ZodObject<{
|
|
1191
|
+
content: z.ZodUnion<[z.ZodDefault<z.ZodString>, z.ZodArray<z.ZodUnion<[z.ZodObject<{
|
|
1192
|
+
text: z.ZodDefault<z.ZodString>;
|
|
1193
|
+
type: z.ZodLiteral<"text">;
|
|
1194
|
+
cache_control: z.ZodOptional<z.ZodObject<{
|
|
1195
|
+
type: z.ZodEnum<["ephemeral"]>;
|
|
1196
|
+
}, "strip", z.ZodTypeAny, {
|
|
1197
|
+
type: "ephemeral";
|
|
1198
|
+
}, {
|
|
1199
|
+
type: "ephemeral";
|
|
1200
|
+
}>>;
|
|
1201
|
+
}, "strip", z.ZodTypeAny, {
|
|
1202
|
+
type: "text";
|
|
1203
|
+
text: string;
|
|
1204
|
+
cache_control?: {
|
|
1205
|
+
type: "ephemeral";
|
|
1206
|
+
} | undefined;
|
|
1207
|
+
}, {
|
|
1208
|
+
type: "text";
|
|
1209
|
+
text?: string | undefined;
|
|
1210
|
+
cache_control?: {
|
|
1211
|
+
type: "ephemeral";
|
|
1212
|
+
} | undefined;
|
|
1213
|
+
}>, z.ZodObject<{
|
|
1214
|
+
image_url: z.ZodObject<{
|
|
1215
|
+
url: z.ZodString;
|
|
1216
|
+
detail: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"auto">, z.ZodLiteral<"low">, z.ZodLiteral<"high">]>>;
|
|
1217
|
+
}, "strip", z.ZodTypeAny, {
|
|
1218
|
+
url: string;
|
|
1219
|
+
detail?: "auto" | "low" | "high" | undefined;
|
|
1220
|
+
}, {
|
|
1221
|
+
url: string;
|
|
1222
|
+
detail?: "auto" | "low" | "high" | undefined;
|
|
1223
|
+
}>;
|
|
1224
|
+
type: z.ZodLiteral<"image_url">;
|
|
1225
|
+
}, "strip", z.ZodTypeAny, {
|
|
1226
|
+
type: "image_url";
|
|
1227
|
+
image_url: {
|
|
1228
|
+
url: string;
|
|
1229
|
+
detail?: "auto" | "low" | "high" | undefined;
|
|
1230
|
+
};
|
|
1231
|
+
}, {
|
|
1232
|
+
type: "image_url";
|
|
1233
|
+
image_url: {
|
|
1234
|
+
url: string;
|
|
1235
|
+
detail?: "auto" | "low" | "high" | undefined;
|
|
1236
|
+
};
|
|
1237
|
+
}>]>, "many">]>;
|
|
1238
|
+
role: z.ZodLiteral<"user">;
|
|
1239
|
+
name: z.ZodOptional<z.ZodString>;
|
|
1240
|
+
}, "strip", z.ZodTypeAny, {
|
|
1241
|
+
content: (string | ({
|
|
1242
|
+
type: "text";
|
|
1243
|
+
text: string;
|
|
1244
|
+
cache_control?: {
|
|
1245
|
+
type: "ephemeral";
|
|
1246
|
+
} | undefined;
|
|
1247
|
+
} | {
|
|
1248
|
+
type: "image_url";
|
|
1249
|
+
image_url: {
|
|
1250
|
+
url: string;
|
|
1251
|
+
detail?: "auto" | "low" | "high" | undefined;
|
|
1252
|
+
};
|
|
1253
|
+
})[]) & (string | ({
|
|
1254
|
+
type: "text";
|
|
1255
|
+
text: string;
|
|
1256
|
+
cache_control?: {
|
|
1257
|
+
type: "ephemeral";
|
|
1258
|
+
} | undefined;
|
|
1259
|
+
} | {
|
|
1260
|
+
type: "image_url";
|
|
1261
|
+
image_url: {
|
|
1262
|
+
url: string;
|
|
1263
|
+
detail?: "auto" | "low" | "high" | undefined;
|
|
1264
|
+
};
|
|
1265
|
+
})[] | undefined);
|
|
1266
|
+
role: "user";
|
|
1267
|
+
name?: string | undefined;
|
|
1268
|
+
}, {
|
|
1269
|
+
role: "user";
|
|
1270
|
+
content?: string | ({
|
|
1271
|
+
type: "text";
|
|
1272
|
+
text?: string | undefined;
|
|
1273
|
+
cache_control?: {
|
|
1274
|
+
type: "ephemeral";
|
|
1275
|
+
} | undefined;
|
|
1276
|
+
} | {
|
|
1277
|
+
type: "image_url";
|
|
1278
|
+
image_url: {
|
|
1279
|
+
url: string;
|
|
1280
|
+
detail?: "auto" | "low" | "high" | undefined;
|
|
1281
|
+
};
|
|
1282
|
+
})[] | undefined;
|
|
1283
|
+
name?: string | undefined;
|
|
1284
|
+
}>, z.ZodObject<{
|
|
1285
|
+
role: z.ZodLiteral<"assistant">;
|
|
1286
|
+
content: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodObject<{
|
|
1287
|
+
text: z.ZodDefault<z.ZodString>;
|
|
1288
|
+
type: z.ZodLiteral<"text">;
|
|
1289
|
+
cache_control: z.ZodOptional<z.ZodObject<{
|
|
1290
|
+
type: z.ZodEnum<["ephemeral"]>;
|
|
1291
|
+
}, "strip", z.ZodTypeAny, {
|
|
1292
|
+
type: "ephemeral";
|
|
1293
|
+
}, {
|
|
1294
|
+
type: "ephemeral";
|
|
1295
|
+
}>>;
|
|
1296
|
+
}, "strip", z.ZodTypeAny, {
|
|
1297
|
+
type: "text";
|
|
1298
|
+
text: string;
|
|
1299
|
+
cache_control?: {
|
|
1300
|
+
type: "ephemeral";
|
|
1301
|
+
} | undefined;
|
|
1302
|
+
}, {
|
|
1303
|
+
type: "text";
|
|
1304
|
+
text?: string | undefined;
|
|
1305
|
+
cache_control?: {
|
|
1306
|
+
type: "ephemeral";
|
|
1307
|
+
} | undefined;
|
|
1308
|
+
}>, "many">]>>>;
|
|
1309
|
+
function_call: z.ZodEffects<z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
1310
|
+
arguments: z.ZodString;
|
|
1311
|
+
name: z.ZodString;
|
|
1312
|
+
}, "strip", z.ZodTypeAny, {
|
|
1313
|
+
name: string;
|
|
1314
|
+
arguments: string;
|
|
1315
|
+
}, {
|
|
1316
|
+
name: string;
|
|
1317
|
+
arguments: string;
|
|
1318
|
+
}>>>, {
|
|
1319
|
+
name: string;
|
|
1320
|
+
arguments: string;
|
|
1321
|
+
} | undefined, {
|
|
1322
|
+
name: string;
|
|
1323
|
+
arguments: string;
|
|
1324
|
+
} | null | undefined>;
|
|
1325
|
+
name: z.ZodEffects<z.ZodOptional<z.ZodNullable<z.ZodString>>, string | undefined, string | null | undefined>;
|
|
1326
|
+
tool_calls: z.ZodEffects<z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
1327
|
+
id: z.ZodString;
|
|
1328
|
+
function: z.ZodObject<{
|
|
1329
|
+
arguments: z.ZodString;
|
|
1330
|
+
name: z.ZodString;
|
|
1331
|
+
}, "strip", z.ZodTypeAny, {
|
|
1332
|
+
name: string;
|
|
1333
|
+
arguments: string;
|
|
1334
|
+
}, {
|
|
1335
|
+
name: string;
|
|
1336
|
+
arguments: string;
|
|
1337
|
+
}>;
|
|
1338
|
+
type: z.ZodLiteral<"function">;
|
|
1339
|
+
}, "strip", z.ZodTypeAny, {
|
|
1340
|
+
function: {
|
|
1341
|
+
name: string;
|
|
1342
|
+
arguments: string;
|
|
1343
|
+
};
|
|
1344
|
+
type: "function";
|
|
1345
|
+
id: string;
|
|
1346
|
+
}, {
|
|
1347
|
+
function: {
|
|
1348
|
+
name: string;
|
|
1349
|
+
arguments: string;
|
|
1350
|
+
};
|
|
1351
|
+
type: "function";
|
|
1352
|
+
id: string;
|
|
1353
|
+
}>, "many">>>, {
|
|
1354
|
+
function: {
|
|
1355
|
+
name: string;
|
|
1356
|
+
arguments: string;
|
|
1357
|
+
};
|
|
1358
|
+
type: "function";
|
|
1359
|
+
id: string;
|
|
1360
|
+
}[] | undefined, {
|
|
1361
|
+
function: {
|
|
1362
|
+
name: string;
|
|
1363
|
+
arguments: string;
|
|
1364
|
+
};
|
|
1365
|
+
type: "function";
|
|
1366
|
+
id: string;
|
|
1367
|
+
}[] | null | undefined>;
|
|
1368
|
+
reasoning: z.ZodEffects<z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
1369
|
+
id: z.ZodEffects<z.ZodOptional<z.ZodNullable<z.ZodString>>, string | undefined, string | null | undefined>;
|
|
1370
|
+
content: z.ZodEffects<z.ZodOptional<z.ZodNullable<z.ZodString>>, string | undefined, string | null | undefined>;
|
|
1371
|
+
}, "strip", z.ZodTypeAny, {
|
|
1372
|
+
id?: string | undefined;
|
|
1373
|
+
content?: string | undefined;
|
|
1374
|
+
}, {
|
|
1375
|
+
id?: string | null | undefined;
|
|
1376
|
+
content?: string | null | undefined;
|
|
1377
|
+
}>, "many">>>, {
|
|
1378
|
+
id?: string | undefined;
|
|
1379
|
+
content?: string | undefined;
|
|
1380
|
+
}[] | undefined, {
|
|
1381
|
+
id?: string | null | undefined;
|
|
1382
|
+
content?: string | null | undefined;
|
|
1383
|
+
}[] | null | undefined>;
|
|
1384
|
+
}, "strip", z.ZodTypeAny, {
|
|
1385
|
+
role: "assistant";
|
|
1386
|
+
content?: string | {
|
|
1387
|
+
type: "text";
|
|
1388
|
+
text: string;
|
|
1389
|
+
cache_control?: {
|
|
1390
|
+
type: "ephemeral";
|
|
1391
|
+
} | undefined;
|
|
1392
|
+
}[] | null | undefined;
|
|
1393
|
+
function_call?: {
|
|
1394
|
+
name: string;
|
|
1395
|
+
arguments: string;
|
|
1396
|
+
} | undefined;
|
|
1397
|
+
name?: string | undefined;
|
|
1398
|
+
tool_calls?: {
|
|
1399
|
+
function: {
|
|
1400
|
+
name: string;
|
|
1401
|
+
arguments: string;
|
|
1402
|
+
};
|
|
1403
|
+
type: "function";
|
|
1404
|
+
id: string;
|
|
1405
|
+
}[] | undefined;
|
|
1406
|
+
reasoning?: {
|
|
1407
|
+
id?: string | undefined;
|
|
1408
|
+
content?: string | undefined;
|
|
1409
|
+
}[] | undefined;
|
|
1410
|
+
}, {
|
|
1411
|
+
role: "assistant";
|
|
1412
|
+
content?: string | {
|
|
1413
|
+
type: "text";
|
|
1414
|
+
text?: string | undefined;
|
|
1415
|
+
cache_control?: {
|
|
1416
|
+
type: "ephemeral";
|
|
1417
|
+
} | undefined;
|
|
1418
|
+
}[] | null | undefined;
|
|
1419
|
+
function_call?: {
|
|
1420
|
+
name: string;
|
|
1421
|
+
arguments: string;
|
|
1422
|
+
} | null | undefined;
|
|
1423
|
+
name?: string | null | undefined;
|
|
1424
|
+
tool_calls?: {
|
|
1425
|
+
function: {
|
|
1426
|
+
name: string;
|
|
1427
|
+
arguments: string;
|
|
1428
|
+
};
|
|
1429
|
+
type: "function";
|
|
1430
|
+
id: string;
|
|
1431
|
+
}[] | null | undefined;
|
|
1432
|
+
reasoning?: {
|
|
1433
|
+
id?: string | null | undefined;
|
|
1434
|
+
content?: string | null | undefined;
|
|
1435
|
+
}[] | null | undefined;
|
|
1436
|
+
}>, z.ZodObject<{
|
|
1437
|
+
content: z.ZodDefault<z.ZodString>;
|
|
1438
|
+
role: z.ZodLiteral<"tool">;
|
|
1439
|
+
tool_call_id: z.ZodDefault<z.ZodString>;
|
|
1440
|
+
}, "strip", z.ZodTypeAny, {
|
|
1441
|
+
content: string;
|
|
1442
|
+
role: "tool";
|
|
1443
|
+
tool_call_id: string;
|
|
1444
|
+
}, {
|
|
1445
|
+
role: "tool";
|
|
1446
|
+
content?: string | undefined;
|
|
1447
|
+
tool_call_id?: string | undefined;
|
|
1448
|
+
}>, z.ZodObject<{
|
|
1449
|
+
content: z.ZodNullable<z.ZodString>;
|
|
1450
|
+
name: z.ZodString;
|
|
1451
|
+
role: z.ZodLiteral<"function">;
|
|
1452
|
+
}, "strip", z.ZodTypeAny, {
|
|
1453
|
+
name: string;
|
|
1454
|
+
content: string | null;
|
|
1455
|
+
role: "function";
|
|
1456
|
+
}, {
|
|
1457
|
+
name: string;
|
|
1458
|
+
content: string | null;
|
|
1459
|
+
role: "function";
|
|
1460
|
+
}>]>, z.ZodObject<{
|
|
1461
|
+
role: z.ZodEnum<["model"]>;
|
|
1462
|
+
content: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1463
|
+
}, "strip", z.ZodTypeAny, {
|
|
1464
|
+
role: "model";
|
|
1465
|
+
content?: string | null | undefined;
|
|
1466
|
+
}, {
|
|
1467
|
+
role: "model";
|
|
1468
|
+
content?: string | null | undefined;
|
|
1469
|
+
}>]>, "many">;
|
|
1470
|
+
}, "strip", z.ZodTypeAny, {
|
|
1471
|
+
messages: ({
|
|
1472
|
+
content: (string | {
|
|
1473
|
+
type: "text";
|
|
1474
|
+
text: string;
|
|
1475
|
+
cache_control?: {
|
|
1476
|
+
type: "ephemeral";
|
|
1477
|
+
} | undefined;
|
|
1478
|
+
}[]) & (string | {
|
|
1479
|
+
type: "text";
|
|
1480
|
+
text: string;
|
|
1481
|
+
cache_control?: {
|
|
1482
|
+
type: "ephemeral";
|
|
1483
|
+
} | undefined;
|
|
1484
|
+
}[] | undefined);
|
|
1485
|
+
role: "system";
|
|
1486
|
+
name?: string | undefined;
|
|
1487
|
+
} | {
|
|
1488
|
+
content: (string | ({
|
|
1489
|
+
type: "text";
|
|
1490
|
+
text: string;
|
|
1491
|
+
cache_control?: {
|
|
1492
|
+
type: "ephemeral";
|
|
1493
|
+
} | undefined;
|
|
1494
|
+
} | {
|
|
1495
|
+
type: "image_url";
|
|
1496
|
+
image_url: {
|
|
1497
|
+
url: string;
|
|
1498
|
+
detail?: "auto" | "low" | "high" | undefined;
|
|
1499
|
+
};
|
|
1500
|
+
})[]) & (string | ({
|
|
1501
|
+
type: "text";
|
|
1502
|
+
text: string;
|
|
1503
|
+
cache_control?: {
|
|
1504
|
+
type: "ephemeral";
|
|
1505
|
+
} | undefined;
|
|
1506
|
+
} | {
|
|
1507
|
+
type: "image_url";
|
|
1508
|
+
image_url: {
|
|
1509
|
+
url: string;
|
|
1510
|
+
detail?: "auto" | "low" | "high" | undefined;
|
|
1511
|
+
};
|
|
1512
|
+
})[] | undefined);
|
|
1513
|
+
role: "user";
|
|
1514
|
+
name?: string | undefined;
|
|
1515
|
+
} | {
|
|
1516
|
+
role: "assistant";
|
|
1517
|
+
content?: string | {
|
|
1518
|
+
type: "text";
|
|
1519
|
+
text: string;
|
|
1520
|
+
cache_control?: {
|
|
1521
|
+
type: "ephemeral";
|
|
1522
|
+
} | undefined;
|
|
1523
|
+
}[] | null | undefined;
|
|
1524
|
+
function_call?: {
|
|
1525
|
+
name: string;
|
|
1526
|
+
arguments: string;
|
|
1527
|
+
} | undefined;
|
|
1528
|
+
name?: string | undefined;
|
|
1529
|
+
tool_calls?: {
|
|
1530
|
+
function: {
|
|
1531
|
+
name: string;
|
|
1532
|
+
arguments: string;
|
|
1533
|
+
};
|
|
1534
|
+
type: "function";
|
|
1535
|
+
id: string;
|
|
1536
|
+
}[] | undefined;
|
|
1537
|
+
reasoning?: {
|
|
1538
|
+
id?: string | undefined;
|
|
1539
|
+
content?: string | undefined;
|
|
1540
|
+
}[] | undefined;
|
|
1541
|
+
} | {
|
|
1542
|
+
content: string;
|
|
1543
|
+
role: "tool";
|
|
1544
|
+
tool_call_id: string;
|
|
1545
|
+
} | {
|
|
1546
|
+
name: string;
|
|
1547
|
+
content: string | null;
|
|
1548
|
+
role: "function";
|
|
1549
|
+
} | {
|
|
1550
|
+
role: "model";
|
|
1551
|
+
content?: string | null | undefined;
|
|
1552
|
+
})[];
|
|
1553
|
+
}, {
|
|
1554
|
+
messages: ({
|
|
1555
|
+
role: "system";
|
|
1556
|
+
content?: string | {
|
|
1557
|
+
type: "text";
|
|
1558
|
+
text?: string | undefined;
|
|
1559
|
+
cache_control?: {
|
|
1560
|
+
type: "ephemeral";
|
|
1561
|
+
} | undefined;
|
|
1562
|
+
}[] | undefined;
|
|
1563
|
+
name?: string | undefined;
|
|
1564
|
+
} | {
|
|
1565
|
+
role: "user";
|
|
1566
|
+
content?: string | ({
|
|
1567
|
+
type: "text";
|
|
1568
|
+
text?: string | undefined;
|
|
1569
|
+
cache_control?: {
|
|
1570
|
+
type: "ephemeral";
|
|
1571
|
+
} | undefined;
|
|
1572
|
+
} | {
|
|
1573
|
+
type: "image_url";
|
|
1574
|
+
image_url: {
|
|
1575
|
+
url: string;
|
|
1576
|
+
detail?: "auto" | "low" | "high" | undefined;
|
|
1577
|
+
};
|
|
1578
|
+
})[] | undefined;
|
|
1579
|
+
name?: string | undefined;
|
|
1580
|
+
} | {
|
|
1581
|
+
role: "assistant";
|
|
1582
|
+
content?: string | {
|
|
1583
|
+
type: "text";
|
|
1584
|
+
text?: string | undefined;
|
|
1585
|
+
cache_control?: {
|
|
1586
|
+
type: "ephemeral";
|
|
1587
|
+
} | undefined;
|
|
1588
|
+
}[] | null | undefined;
|
|
1589
|
+
function_call?: {
|
|
1590
|
+
name: string;
|
|
1591
|
+
arguments: string;
|
|
1592
|
+
} | null | undefined;
|
|
1593
|
+
name?: string | null | undefined;
|
|
1594
|
+
tool_calls?: {
|
|
1595
|
+
function: {
|
|
1596
|
+
name: string;
|
|
1597
|
+
arguments: string;
|
|
1598
|
+
};
|
|
1599
|
+
type: "function";
|
|
1600
|
+
id: string;
|
|
1601
|
+
}[] | null | undefined;
|
|
1602
|
+
reasoning?: {
|
|
1603
|
+
id?: string | null | undefined;
|
|
1604
|
+
content?: string | null | undefined;
|
|
1605
|
+
}[] | null | undefined;
|
|
1606
|
+
} | {
|
|
1607
|
+
role: "tool";
|
|
1608
|
+
content?: string | undefined;
|
|
1609
|
+
tool_call_id?: string | undefined;
|
|
1610
|
+
} | {
|
|
1611
|
+
name: string;
|
|
1612
|
+
content: string | null;
|
|
1613
|
+
role: "function";
|
|
1614
|
+
} | {
|
|
1615
|
+
role: "model";
|
|
1616
|
+
content?: string | null | undefined;
|
|
1617
|
+
})[];
|
|
1618
|
+
}>]>, z.ZodObject<{
|
|
1619
|
+
model: z.ZodString;
|
|
1620
|
+
params: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
|
|
1621
|
+
use_cache: z.ZodOptional<z.ZodBoolean>;
|
|
1622
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
1623
|
+
top_p: z.ZodOptional<z.ZodNumber>;
|
|
1624
|
+
max_tokens: z.ZodOptional<z.ZodNumber>;
|
|
1625
|
+
max_completion_tokens: z.ZodOptional<z.ZodNumber>;
|
|
1626
|
+
frequency_penalty: z.ZodOptional<z.ZodNumber>;
|
|
1627
|
+
presence_penalty: z.ZodOptional<z.ZodNumber>;
|
|
1628
|
+
response_format: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodObject<{
|
|
1629
|
+
type: z.ZodLiteral<"json_object">;
|
|
1630
|
+
}, "strip", z.ZodTypeAny, {
|
|
1631
|
+
type: "json_object";
|
|
1632
|
+
}, {
|
|
1633
|
+
type: "json_object";
|
|
1634
|
+
}>, z.ZodObject<{
|
|
1635
|
+
type: z.ZodLiteral<"json_schema">;
|
|
1636
|
+
json_schema: z.ZodObject<{
|
|
1637
|
+
name: z.ZodString;
|
|
1638
|
+
description: z.ZodOptional<z.ZodString>;
|
|
1639
|
+
schema: z.ZodOptional<z.ZodUnion<[z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodString]>>;
|
|
1640
|
+
strict: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
1641
|
+
}, "strip", z.ZodTypeAny, {
|
|
1642
|
+
name: string;
|
|
1643
|
+
description?: string | undefined;
|
|
1644
|
+
schema?: string | Record<string, unknown> | undefined;
|
|
1645
|
+
strict?: boolean | null | undefined;
|
|
1646
|
+
}, {
|
|
1647
|
+
name: string;
|
|
1648
|
+
description?: string | undefined;
|
|
1649
|
+
schema?: string | Record<string, unknown> | undefined;
|
|
1650
|
+
strict?: boolean | null | undefined;
|
|
1651
|
+
}>;
|
|
1652
|
+
}, "strip", z.ZodTypeAny, {
|
|
1653
|
+
type: "json_schema";
|
|
1654
|
+
json_schema: {
|
|
1655
|
+
name: string;
|
|
1656
|
+
description?: string | undefined;
|
|
1657
|
+
schema?: string | Record<string, unknown> | undefined;
|
|
1658
|
+
strict?: boolean | null | undefined;
|
|
1659
|
+
};
|
|
1660
|
+
}, {
|
|
1661
|
+
type: "json_schema";
|
|
1662
|
+
json_schema: {
|
|
1663
|
+
name: string;
|
|
1664
|
+
description?: string | undefined;
|
|
1665
|
+
schema?: string | Record<string, unknown> | undefined;
|
|
1666
|
+
strict?: boolean | null | undefined;
|
|
1667
|
+
};
|
|
1668
|
+
}>, z.ZodObject<{
|
|
1669
|
+
type: z.ZodLiteral<"text">;
|
|
1670
|
+
}, "strip", z.ZodTypeAny, {
|
|
1671
|
+
type: "text";
|
|
1672
|
+
}, {
|
|
1673
|
+
type: "text";
|
|
1674
|
+
}>]>>>;
|
|
1675
|
+
tool_choice: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"auto">, z.ZodLiteral<"none">, z.ZodLiteral<"required">, z.ZodObject<{
|
|
1676
|
+
type: z.ZodLiteral<"function">;
|
|
1677
|
+
function: z.ZodObject<{
|
|
1678
|
+
name: z.ZodString;
|
|
1679
|
+
}, "strip", z.ZodTypeAny, {
|
|
1680
|
+
name: string;
|
|
1681
|
+
}, {
|
|
1682
|
+
name: string;
|
|
1683
|
+
}>;
|
|
1684
|
+
}, "strip", z.ZodTypeAny, {
|
|
1685
|
+
function: {
|
|
1686
|
+
name: string;
|
|
1687
|
+
};
|
|
1688
|
+
type: "function";
|
|
1689
|
+
}, {
|
|
1690
|
+
function: {
|
|
1691
|
+
name: string;
|
|
1692
|
+
};
|
|
1693
|
+
type: "function";
|
|
1694
|
+
}>]>>;
|
|
1695
|
+
function_call: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"auto">, z.ZodLiteral<"none">, z.ZodObject<{
|
|
1696
|
+
name: z.ZodString;
|
|
1697
|
+
}, "strip", z.ZodTypeAny, {
|
|
1698
|
+
name: string;
|
|
1699
|
+
}, {
|
|
1700
|
+
name: string;
|
|
1701
|
+
}>]>>;
|
|
1702
|
+
n: z.ZodOptional<z.ZodNumber>;
|
|
1703
|
+
stop: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
1704
|
+
reasoning_effort: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
|
|
1705
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
1706
|
+
use_cache: z.ZodOptional<z.ZodBoolean>;
|
|
1707
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
1708
|
+
top_p: z.ZodOptional<z.ZodNumber>;
|
|
1709
|
+
max_tokens: z.ZodOptional<z.ZodNumber>;
|
|
1710
|
+
max_completion_tokens: z.ZodOptional<z.ZodNumber>;
|
|
1711
|
+
frequency_penalty: z.ZodOptional<z.ZodNumber>;
|
|
1712
|
+
presence_penalty: z.ZodOptional<z.ZodNumber>;
|
|
1713
|
+
response_format: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodObject<{
|
|
1714
|
+
type: z.ZodLiteral<"json_object">;
|
|
1715
|
+
}, "strip", z.ZodTypeAny, {
|
|
1716
|
+
type: "json_object";
|
|
1717
|
+
}, {
|
|
1718
|
+
type: "json_object";
|
|
1719
|
+
}>, z.ZodObject<{
|
|
1720
|
+
type: z.ZodLiteral<"json_schema">;
|
|
1721
|
+
json_schema: z.ZodObject<{
|
|
1722
|
+
name: z.ZodString;
|
|
1723
|
+
description: z.ZodOptional<z.ZodString>;
|
|
1724
|
+
schema: z.ZodOptional<z.ZodUnion<[z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodString]>>;
|
|
1725
|
+
strict: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
1726
|
+
}, "strip", z.ZodTypeAny, {
|
|
1727
|
+
name: string;
|
|
1728
|
+
description?: string | undefined;
|
|
1729
|
+
schema?: string | Record<string, unknown> | undefined;
|
|
1730
|
+
strict?: boolean | null | undefined;
|
|
1731
|
+
}, {
|
|
1732
|
+
name: string;
|
|
1733
|
+
description?: string | undefined;
|
|
1734
|
+
schema?: string | Record<string, unknown> | undefined;
|
|
1735
|
+
strict?: boolean | null | undefined;
|
|
1736
|
+
}>;
|
|
1737
|
+
}, "strip", z.ZodTypeAny, {
|
|
1738
|
+
type: "json_schema";
|
|
1739
|
+
json_schema: {
|
|
1740
|
+
name: string;
|
|
1741
|
+
description?: string | undefined;
|
|
1742
|
+
schema?: string | Record<string, unknown> | undefined;
|
|
1743
|
+
strict?: boolean | null | undefined;
|
|
1744
|
+
};
|
|
1745
|
+
}, {
|
|
1746
|
+
type: "json_schema";
|
|
1747
|
+
json_schema: {
|
|
1748
|
+
name: string;
|
|
1749
|
+
description?: string | undefined;
|
|
1750
|
+
schema?: string | Record<string, unknown> | undefined;
|
|
1751
|
+
strict?: boolean | null | undefined;
|
|
1752
|
+
};
|
|
1753
|
+
}>, z.ZodObject<{
|
|
1754
|
+
type: z.ZodLiteral<"text">;
|
|
1755
|
+
}, "strip", z.ZodTypeAny, {
|
|
1756
|
+
type: "text";
|
|
1757
|
+
}, {
|
|
1758
|
+
type: "text";
|
|
1759
|
+
}>]>>>;
|
|
1760
|
+
tool_choice: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"auto">, z.ZodLiteral<"none">, z.ZodLiteral<"required">, z.ZodObject<{
|
|
1761
|
+
type: z.ZodLiteral<"function">;
|
|
1762
|
+
function: z.ZodObject<{
|
|
1763
|
+
name: z.ZodString;
|
|
1764
|
+
}, "strip", z.ZodTypeAny, {
|
|
1765
|
+
name: string;
|
|
1766
|
+
}, {
|
|
1767
|
+
name: string;
|
|
1768
|
+
}>;
|
|
1769
|
+
}, "strip", z.ZodTypeAny, {
|
|
1770
|
+
function: {
|
|
1771
|
+
name: string;
|
|
1772
|
+
};
|
|
1773
|
+
type: "function";
|
|
1774
|
+
}, {
|
|
1775
|
+
function: {
|
|
1776
|
+
name: string;
|
|
1777
|
+
};
|
|
1778
|
+
type: "function";
|
|
1779
|
+
}>]>>;
|
|
1780
|
+
function_call: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"auto">, z.ZodLiteral<"none">, z.ZodObject<{
|
|
1781
|
+
name: z.ZodString;
|
|
1782
|
+
}, "strip", z.ZodTypeAny, {
|
|
1783
|
+
name: string;
|
|
1784
|
+
}, {
|
|
1785
|
+
name: string;
|
|
1786
|
+
}>]>>;
|
|
1787
|
+
n: z.ZodOptional<z.ZodNumber>;
|
|
1788
|
+
stop: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
1789
|
+
reasoning_effort: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
|
|
1790
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
1791
|
+
use_cache: z.ZodOptional<z.ZodBoolean>;
|
|
1792
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
1793
|
+
top_p: z.ZodOptional<z.ZodNumber>;
|
|
1794
|
+
max_tokens: z.ZodOptional<z.ZodNumber>;
|
|
1795
|
+
max_completion_tokens: z.ZodOptional<z.ZodNumber>;
|
|
1796
|
+
frequency_penalty: z.ZodOptional<z.ZodNumber>;
|
|
1797
|
+
presence_penalty: z.ZodOptional<z.ZodNumber>;
|
|
1798
|
+
response_format: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodObject<{
|
|
1799
|
+
type: z.ZodLiteral<"json_object">;
|
|
1800
|
+
}, "strip", z.ZodTypeAny, {
|
|
1801
|
+
type: "json_object";
|
|
1802
|
+
}, {
|
|
1803
|
+
type: "json_object";
|
|
1804
|
+
}>, z.ZodObject<{
|
|
1805
|
+
type: z.ZodLiteral<"json_schema">;
|
|
1806
|
+
json_schema: z.ZodObject<{
|
|
1807
|
+
name: z.ZodString;
|
|
1808
|
+
description: z.ZodOptional<z.ZodString>;
|
|
1809
|
+
schema: z.ZodOptional<z.ZodUnion<[z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodString]>>;
|
|
1810
|
+
strict: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
1811
|
+
}, "strip", z.ZodTypeAny, {
|
|
1812
|
+
name: string;
|
|
1813
|
+
description?: string | undefined;
|
|
1814
|
+
schema?: string | Record<string, unknown> | undefined;
|
|
1815
|
+
strict?: boolean | null | undefined;
|
|
1816
|
+
}, {
|
|
1817
|
+
name: string;
|
|
1818
|
+
description?: string | undefined;
|
|
1819
|
+
schema?: string | Record<string, unknown> | undefined;
|
|
1820
|
+
strict?: boolean | null | undefined;
|
|
1821
|
+
}>;
|
|
1822
|
+
}, "strip", z.ZodTypeAny, {
|
|
1823
|
+
type: "json_schema";
|
|
1824
|
+
json_schema: {
|
|
1825
|
+
name: string;
|
|
1826
|
+
description?: string | undefined;
|
|
1827
|
+
schema?: string | Record<string, unknown> | undefined;
|
|
1828
|
+
strict?: boolean | null | undefined;
|
|
1829
|
+
};
|
|
1830
|
+
}, {
|
|
1831
|
+
type: "json_schema";
|
|
1832
|
+
json_schema: {
|
|
1833
|
+
name: string;
|
|
1834
|
+
description?: string | undefined;
|
|
1835
|
+
schema?: string | Record<string, unknown> | undefined;
|
|
1836
|
+
strict?: boolean | null | undefined;
|
|
1837
|
+
};
|
|
1838
|
+
}>, z.ZodObject<{
|
|
1839
|
+
type: z.ZodLiteral<"text">;
|
|
1840
|
+
}, "strip", z.ZodTypeAny, {
|
|
1841
|
+
type: "text";
|
|
1842
|
+
}, {
|
|
1843
|
+
type: "text";
|
|
1844
|
+
}>]>>>;
|
|
1845
|
+
tool_choice: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"auto">, z.ZodLiteral<"none">, z.ZodLiteral<"required">, z.ZodObject<{
|
|
1846
|
+
type: z.ZodLiteral<"function">;
|
|
1847
|
+
function: z.ZodObject<{
|
|
1848
|
+
name: z.ZodString;
|
|
1849
|
+
}, "strip", z.ZodTypeAny, {
|
|
1850
|
+
name: string;
|
|
1851
|
+
}, {
|
|
1852
|
+
name: string;
|
|
1853
|
+
}>;
|
|
1854
|
+
}, "strip", z.ZodTypeAny, {
|
|
1855
|
+
function: {
|
|
1856
|
+
name: string;
|
|
1857
|
+
};
|
|
1858
|
+
type: "function";
|
|
1859
|
+
}, {
|
|
1860
|
+
function: {
|
|
1861
|
+
name: string;
|
|
1862
|
+
};
|
|
1863
|
+
type: "function";
|
|
1864
|
+
}>]>>;
|
|
1865
|
+
function_call: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"auto">, z.ZodLiteral<"none">, z.ZodObject<{
|
|
1866
|
+
name: z.ZodString;
|
|
1867
|
+
}, "strip", z.ZodTypeAny, {
|
|
1868
|
+
name: string;
|
|
1869
|
+
}, {
|
|
1870
|
+
name: string;
|
|
1871
|
+
}>]>>;
|
|
1872
|
+
n: z.ZodOptional<z.ZodNumber>;
|
|
1873
|
+
stop: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
1874
|
+
reasoning_effort: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
|
|
1875
|
+
}, z.ZodTypeAny, "passthrough">>, z.ZodObject<{
|
|
1876
|
+
use_cache: z.ZodOptional<z.ZodBoolean>;
|
|
1877
|
+
max_tokens: z.ZodNumber;
|
|
1878
|
+
temperature: z.ZodNumber;
|
|
1879
|
+
top_p: z.ZodOptional<z.ZodNumber>;
|
|
1880
|
+
top_k: z.ZodOptional<z.ZodNumber>;
|
|
1881
|
+
stop_sequences: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
1882
|
+
max_tokens_to_sample: z.ZodOptional<z.ZodNumber>;
|
|
1883
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
1884
|
+
use_cache: z.ZodOptional<z.ZodBoolean>;
|
|
1885
|
+
max_tokens: z.ZodNumber;
|
|
1886
|
+
temperature: z.ZodNumber;
|
|
1887
|
+
top_p: z.ZodOptional<z.ZodNumber>;
|
|
1888
|
+
top_k: z.ZodOptional<z.ZodNumber>;
|
|
1889
|
+
stop_sequences: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
1890
|
+
max_tokens_to_sample: z.ZodOptional<z.ZodNumber>;
|
|
1891
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
1892
|
+
use_cache: z.ZodOptional<z.ZodBoolean>;
|
|
1893
|
+
max_tokens: z.ZodNumber;
|
|
1894
|
+
temperature: z.ZodNumber;
|
|
1895
|
+
top_p: z.ZodOptional<z.ZodNumber>;
|
|
1896
|
+
top_k: z.ZodOptional<z.ZodNumber>;
|
|
1897
|
+
stop_sequences: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
1898
|
+
max_tokens_to_sample: z.ZodOptional<z.ZodNumber>;
|
|
1899
|
+
}, z.ZodTypeAny, "passthrough">>, z.ZodObject<{
|
|
1900
|
+
use_cache: z.ZodOptional<z.ZodBoolean>;
|
|
1901
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
1902
|
+
maxOutputTokens: z.ZodOptional<z.ZodNumber>;
|
|
1903
|
+
topP: z.ZodOptional<z.ZodNumber>;
|
|
1904
|
+
topK: z.ZodOptional<z.ZodNumber>;
|
|
1905
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
1906
|
+
use_cache: z.ZodOptional<z.ZodBoolean>;
|
|
1907
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
1908
|
+
maxOutputTokens: z.ZodOptional<z.ZodNumber>;
|
|
1909
|
+
topP: z.ZodOptional<z.ZodNumber>;
|
|
1910
|
+
topK: z.ZodOptional<z.ZodNumber>;
|
|
1911
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
1912
|
+
use_cache: z.ZodOptional<z.ZodBoolean>;
|
|
1913
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
1914
|
+
maxOutputTokens: z.ZodOptional<z.ZodNumber>;
|
|
1915
|
+
topP: z.ZodOptional<z.ZodNumber>;
|
|
1916
|
+
topK: z.ZodOptional<z.ZodNumber>;
|
|
1917
|
+
}, z.ZodTypeAny, "passthrough">>, z.ZodObject<{
|
|
1918
|
+
use_cache: z.ZodOptional<z.ZodBoolean>;
|
|
1919
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
1920
|
+
topK: z.ZodOptional<z.ZodNumber>;
|
|
1921
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
1922
|
+
use_cache: z.ZodOptional<z.ZodBoolean>;
|
|
1923
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
1924
|
+
topK: z.ZodOptional<z.ZodNumber>;
|
|
1925
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
1926
|
+
use_cache: z.ZodOptional<z.ZodBoolean>;
|
|
1927
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
1928
|
+
topK: z.ZodOptional<z.ZodNumber>;
|
|
1929
|
+
}, z.ZodTypeAny, "passthrough">>, z.ZodObject<{
|
|
1930
|
+
use_cache: z.ZodOptional<z.ZodBoolean>;
|
|
1931
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
1932
|
+
use_cache: z.ZodOptional<z.ZodBoolean>;
|
|
1933
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
1934
|
+
use_cache: z.ZodOptional<z.ZodBoolean>;
|
|
1935
|
+
}, z.ZodTypeAny, "passthrough">>]>>;
|
|
1936
|
+
}, "strip", z.ZodTypeAny, {
|
|
1937
|
+
model: string;
|
|
1938
|
+
params?: z.objectOutputType<{
|
|
1939
|
+
use_cache: z.ZodOptional<z.ZodBoolean>;
|
|
1940
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
1941
|
+
top_p: z.ZodOptional<z.ZodNumber>;
|
|
1942
|
+
max_tokens: z.ZodOptional<z.ZodNumber>;
|
|
1943
|
+
max_completion_tokens: z.ZodOptional<z.ZodNumber>;
|
|
1944
|
+
frequency_penalty: z.ZodOptional<z.ZodNumber>;
|
|
1945
|
+
presence_penalty: z.ZodOptional<z.ZodNumber>;
|
|
1946
|
+
response_format: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodObject<{
|
|
1947
|
+
type: z.ZodLiteral<"json_object">;
|
|
1948
|
+
}, "strip", z.ZodTypeAny, {
|
|
1949
|
+
type: "json_object";
|
|
1950
|
+
}, {
|
|
1951
|
+
type: "json_object";
|
|
1952
|
+
}>, z.ZodObject<{
|
|
1953
|
+
type: z.ZodLiteral<"json_schema">;
|
|
1954
|
+
json_schema: z.ZodObject<{
|
|
1955
|
+
name: z.ZodString;
|
|
1956
|
+
description: z.ZodOptional<z.ZodString>;
|
|
1957
|
+
schema: z.ZodOptional<z.ZodUnion<[z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodString]>>;
|
|
1958
|
+
strict: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
1959
|
+
}, "strip", z.ZodTypeAny, {
|
|
1960
|
+
name: string;
|
|
1961
|
+
description?: string | undefined;
|
|
1962
|
+
schema?: string | Record<string, unknown> | undefined;
|
|
1963
|
+
strict?: boolean | null | undefined;
|
|
1964
|
+
}, {
|
|
1965
|
+
name: string;
|
|
1966
|
+
description?: string | undefined;
|
|
1967
|
+
schema?: string | Record<string, unknown> | undefined;
|
|
1968
|
+
strict?: boolean | null | undefined;
|
|
1969
|
+
}>;
|
|
1970
|
+
}, "strip", z.ZodTypeAny, {
|
|
1971
|
+
type: "json_schema";
|
|
1972
|
+
json_schema: {
|
|
1973
|
+
name: string;
|
|
1974
|
+
description?: string | undefined;
|
|
1975
|
+
schema?: string | Record<string, unknown> | undefined;
|
|
1976
|
+
strict?: boolean | null | undefined;
|
|
1977
|
+
};
|
|
1978
|
+
}, {
|
|
1979
|
+
type: "json_schema";
|
|
1980
|
+
json_schema: {
|
|
1981
|
+
name: string;
|
|
1982
|
+
description?: string | undefined;
|
|
1983
|
+
schema?: string | Record<string, unknown> | undefined;
|
|
1984
|
+
strict?: boolean | null | undefined;
|
|
1985
|
+
};
|
|
1986
|
+
}>, z.ZodObject<{
|
|
1987
|
+
type: z.ZodLiteral<"text">;
|
|
1988
|
+
}, "strip", z.ZodTypeAny, {
|
|
1989
|
+
type: "text";
|
|
1990
|
+
}, {
|
|
1991
|
+
type: "text";
|
|
1992
|
+
}>]>>>;
|
|
1993
|
+
tool_choice: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"auto">, z.ZodLiteral<"none">, z.ZodLiteral<"required">, z.ZodObject<{
|
|
1994
|
+
type: z.ZodLiteral<"function">;
|
|
1995
|
+
function: z.ZodObject<{
|
|
1996
|
+
name: z.ZodString;
|
|
1997
|
+
}, "strip", z.ZodTypeAny, {
|
|
1998
|
+
name: string;
|
|
1999
|
+
}, {
|
|
2000
|
+
name: string;
|
|
2001
|
+
}>;
|
|
2002
|
+
}, "strip", z.ZodTypeAny, {
|
|
2003
|
+
function: {
|
|
2004
|
+
name: string;
|
|
2005
|
+
};
|
|
2006
|
+
type: "function";
|
|
2007
|
+
}, {
|
|
2008
|
+
function: {
|
|
2009
|
+
name: string;
|
|
2010
|
+
};
|
|
2011
|
+
type: "function";
|
|
2012
|
+
}>]>>;
|
|
2013
|
+
function_call: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"auto">, z.ZodLiteral<"none">, z.ZodObject<{
|
|
2014
|
+
name: z.ZodString;
|
|
2015
|
+
}, "strip", z.ZodTypeAny, {
|
|
2016
|
+
name: string;
|
|
2017
|
+
}, {
|
|
2018
|
+
name: string;
|
|
2019
|
+
}>]>>;
|
|
2020
|
+
n: z.ZodOptional<z.ZodNumber>;
|
|
2021
|
+
stop: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
2022
|
+
reasoning_effort: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
|
|
2023
|
+
}, z.ZodTypeAny, "passthrough"> | z.objectOutputType<{
|
|
2024
|
+
use_cache: z.ZodOptional<z.ZodBoolean>;
|
|
2025
|
+
max_tokens: z.ZodNumber;
|
|
2026
|
+
temperature: z.ZodNumber;
|
|
2027
|
+
top_p: z.ZodOptional<z.ZodNumber>;
|
|
2028
|
+
top_k: z.ZodOptional<z.ZodNumber>;
|
|
2029
|
+
stop_sequences: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
2030
|
+
max_tokens_to_sample: z.ZodOptional<z.ZodNumber>;
|
|
2031
|
+
}, z.ZodTypeAny, "passthrough"> | z.objectOutputType<{
|
|
2032
|
+
use_cache: z.ZodOptional<z.ZodBoolean>;
|
|
2033
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
2034
|
+
maxOutputTokens: z.ZodOptional<z.ZodNumber>;
|
|
2035
|
+
topP: z.ZodOptional<z.ZodNumber>;
|
|
2036
|
+
topK: z.ZodOptional<z.ZodNumber>;
|
|
2037
|
+
}, z.ZodTypeAny, "passthrough"> | z.objectOutputType<{
|
|
2038
|
+
use_cache: z.ZodOptional<z.ZodBoolean>;
|
|
2039
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
2040
|
+
topK: z.ZodOptional<z.ZodNumber>;
|
|
2041
|
+
}, z.ZodTypeAny, "passthrough"> | z.objectOutputType<{
|
|
2042
|
+
use_cache: z.ZodOptional<z.ZodBoolean>;
|
|
2043
|
+
}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
2044
|
+
}, {
|
|
2045
|
+
model: string;
|
|
2046
|
+
params?: z.objectInputType<{
|
|
2047
|
+
use_cache: z.ZodOptional<z.ZodBoolean>;
|
|
2048
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
2049
|
+
top_p: z.ZodOptional<z.ZodNumber>;
|
|
2050
|
+
max_tokens: z.ZodOptional<z.ZodNumber>;
|
|
2051
|
+
max_completion_tokens: z.ZodOptional<z.ZodNumber>;
|
|
2052
|
+
frequency_penalty: z.ZodOptional<z.ZodNumber>;
|
|
2053
|
+
presence_penalty: z.ZodOptional<z.ZodNumber>;
|
|
2054
|
+
response_format: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodObject<{
|
|
2055
|
+
type: z.ZodLiteral<"json_object">;
|
|
2056
|
+
}, "strip", z.ZodTypeAny, {
|
|
2057
|
+
type: "json_object";
|
|
2058
|
+
}, {
|
|
2059
|
+
type: "json_object";
|
|
2060
|
+
}>, z.ZodObject<{
|
|
2061
|
+
type: z.ZodLiteral<"json_schema">;
|
|
2062
|
+
json_schema: z.ZodObject<{
|
|
2063
|
+
name: z.ZodString;
|
|
2064
|
+
description: z.ZodOptional<z.ZodString>;
|
|
2065
|
+
schema: z.ZodOptional<z.ZodUnion<[z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodString]>>;
|
|
2066
|
+
strict: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
2067
|
+
}, "strip", z.ZodTypeAny, {
|
|
2068
|
+
name: string;
|
|
2069
|
+
description?: string | undefined;
|
|
2070
|
+
schema?: string | Record<string, unknown> | undefined;
|
|
2071
|
+
strict?: boolean | null | undefined;
|
|
2072
|
+
}, {
|
|
2073
|
+
name: string;
|
|
2074
|
+
description?: string | undefined;
|
|
2075
|
+
schema?: string | Record<string, unknown> | undefined;
|
|
2076
|
+
strict?: boolean | null | undefined;
|
|
2077
|
+
}>;
|
|
2078
|
+
}, "strip", z.ZodTypeAny, {
|
|
2079
|
+
type: "json_schema";
|
|
2080
|
+
json_schema: {
|
|
2081
|
+
name: string;
|
|
2082
|
+
description?: string | undefined;
|
|
2083
|
+
schema?: string | Record<string, unknown> | undefined;
|
|
2084
|
+
strict?: boolean | null | undefined;
|
|
2085
|
+
};
|
|
2086
|
+
}, {
|
|
2087
|
+
type: "json_schema";
|
|
2088
|
+
json_schema: {
|
|
2089
|
+
name: string;
|
|
2090
|
+
description?: string | undefined;
|
|
2091
|
+
schema?: string | Record<string, unknown> | undefined;
|
|
2092
|
+
strict?: boolean | null | undefined;
|
|
2093
|
+
};
|
|
2094
|
+
}>, z.ZodObject<{
|
|
2095
|
+
type: z.ZodLiteral<"text">;
|
|
2096
|
+
}, "strip", z.ZodTypeAny, {
|
|
2097
|
+
type: "text";
|
|
2098
|
+
}, {
|
|
2099
|
+
type: "text";
|
|
2100
|
+
}>]>>>;
|
|
2101
|
+
tool_choice: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"auto">, z.ZodLiteral<"none">, z.ZodLiteral<"required">, z.ZodObject<{
|
|
2102
|
+
type: z.ZodLiteral<"function">;
|
|
2103
|
+
function: z.ZodObject<{
|
|
2104
|
+
name: z.ZodString;
|
|
2105
|
+
}, "strip", z.ZodTypeAny, {
|
|
2106
|
+
name: string;
|
|
2107
|
+
}, {
|
|
2108
|
+
name: string;
|
|
2109
|
+
}>;
|
|
2110
|
+
}, "strip", z.ZodTypeAny, {
|
|
2111
|
+
function: {
|
|
2112
|
+
name: string;
|
|
2113
|
+
};
|
|
2114
|
+
type: "function";
|
|
2115
|
+
}, {
|
|
2116
|
+
function: {
|
|
2117
|
+
name: string;
|
|
2118
|
+
};
|
|
2119
|
+
type: "function";
|
|
2120
|
+
}>]>>;
|
|
2121
|
+
function_call: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"auto">, z.ZodLiteral<"none">, z.ZodObject<{
|
|
2122
|
+
name: z.ZodString;
|
|
2123
|
+
}, "strip", z.ZodTypeAny, {
|
|
2124
|
+
name: string;
|
|
2125
|
+
}, {
|
|
2126
|
+
name: string;
|
|
2127
|
+
}>]>>;
|
|
2128
|
+
n: z.ZodOptional<z.ZodNumber>;
|
|
2129
|
+
stop: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
2130
|
+
reasoning_effort: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
|
|
2131
|
+
}, z.ZodTypeAny, "passthrough"> | z.objectInputType<{
|
|
2132
|
+
use_cache: z.ZodOptional<z.ZodBoolean>;
|
|
2133
|
+
max_tokens: z.ZodNumber;
|
|
2134
|
+
temperature: z.ZodNumber;
|
|
2135
|
+
top_p: z.ZodOptional<z.ZodNumber>;
|
|
2136
|
+
top_k: z.ZodOptional<z.ZodNumber>;
|
|
2137
|
+
stop_sequences: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
2138
|
+
max_tokens_to_sample: z.ZodOptional<z.ZodNumber>;
|
|
2139
|
+
}, z.ZodTypeAny, "passthrough"> | z.objectInputType<{
|
|
2140
|
+
use_cache: z.ZodOptional<z.ZodBoolean>;
|
|
2141
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
2142
|
+
maxOutputTokens: z.ZodOptional<z.ZodNumber>;
|
|
2143
|
+
topP: z.ZodOptional<z.ZodNumber>;
|
|
2144
|
+
topK: z.ZodOptional<z.ZodNumber>;
|
|
2145
|
+
}, z.ZodTypeAny, "passthrough"> | z.objectInputType<{
|
|
2146
|
+
use_cache: z.ZodOptional<z.ZodBoolean>;
|
|
2147
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
2148
|
+
topK: z.ZodOptional<z.ZodNumber>;
|
|
2149
|
+
}, z.ZodTypeAny, "passthrough"> | z.objectInputType<{
|
|
2150
|
+
use_cache: z.ZodOptional<z.ZodBoolean>;
|
|
2151
|
+
}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
2152
|
+
}>>;
|
|
2153
|
+
type PromptDefinition = z.infer<typeof promptDefinitionSchema>;
|
|
2154
|
+
type PromptOpts<HasId extends boolean, HasVersion extends boolean, HasTools extends boolean = true, HasNoTrace extends boolean = true> = (Partial<Omit<BaseFnOpts, "name">> & {
|
|
2155
|
+
name: string;
|
|
2156
|
+
}) & (HasId extends true ? PromptId : Partial<PromptId>) & (HasVersion extends true ? PromptVersion : Partial<PromptVersion>) & (HasTools extends true ? Partial<PromptTools> : {}) & (HasNoTrace extends true ? Partial<PromptNoTrace> : {}) & PromptDefinition;
|
|
2157
|
+
declare class PromptBuilder {
|
|
2158
|
+
private readonly project;
|
|
2159
|
+
constructor(project: Project);
|
|
2160
|
+
create<HasId extends boolean = false, HasVersion extends boolean = false>(opts: PromptOpts<HasId, HasVersion>): Prompt<HasId, HasVersion>;
|
|
2161
|
+
}
|
|
2162
|
+
|
|
2163
|
+
declare const evalParametersSchema: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodObject<{
|
|
2164
|
+
type: z.ZodLiteral<"prompt">;
|
|
2165
|
+
default: z.ZodOptional<z.ZodIntersection<z.ZodIntersection<z.ZodUnion<[z.ZodObject<{
|
|
2166
|
+
prompt: z.ZodString;
|
|
2167
|
+
}, "strip", z.ZodTypeAny, {
|
|
2168
|
+
prompt: string;
|
|
2169
|
+
}, {
|
|
2170
|
+
prompt: string;
|
|
2171
|
+
}>, z.ZodObject<{
|
|
2172
|
+
messages: z.ZodArray<z.ZodUnion<[z.ZodUnion<[z.ZodObject<{
|
|
2173
|
+
content: z.ZodUnion<[z.ZodDefault<z.ZodString>, z.ZodArray<z.ZodObject<{
|
|
2174
|
+
text: z.ZodDefault<z.ZodString>;
|
|
2175
|
+
type: z.ZodLiteral<"text">;
|
|
2176
|
+
cache_control: z.ZodOptional<z.ZodObject<{
|
|
2177
|
+
type: z.ZodEnum<["ephemeral"]>;
|
|
2178
|
+
}, "strip", z.ZodTypeAny, {
|
|
2179
|
+
type: "ephemeral";
|
|
2180
|
+
}, {
|
|
2181
|
+
type: "ephemeral";
|
|
2182
|
+
}>>;
|
|
2183
|
+
}, "strip", z.ZodTypeAny, {
|
|
2184
|
+
type: "text";
|
|
2185
|
+
text: string;
|
|
2186
|
+
cache_control?: {
|
|
2187
|
+
type: "ephemeral";
|
|
2188
|
+
} | undefined;
|
|
2189
|
+
}, {
|
|
2190
|
+
type: "text";
|
|
2191
|
+
text?: string | undefined;
|
|
2192
|
+
cache_control?: {
|
|
2193
|
+
type: "ephemeral";
|
|
2194
|
+
} | undefined;
|
|
2195
|
+
}>, "many">]>;
|
|
2196
|
+
role: z.ZodLiteral<"system">;
|
|
2197
|
+
name: z.ZodOptional<z.ZodString>;
|
|
2198
|
+
}, "strip", z.ZodTypeAny, {
|
|
2199
|
+
content: (string | {
|
|
2200
|
+
type: "text";
|
|
2201
|
+
text: string;
|
|
2202
|
+
cache_control?: {
|
|
2203
|
+
type: "ephemeral";
|
|
2204
|
+
} | undefined;
|
|
2205
|
+
}[]) & (string | {
|
|
2206
|
+
type: "text";
|
|
2207
|
+
text: string;
|
|
2208
|
+
cache_control?: {
|
|
2209
|
+
type: "ephemeral";
|
|
2210
|
+
} | undefined;
|
|
2211
|
+
}[] | undefined);
|
|
2212
|
+
role: "system";
|
|
2213
|
+
name?: string | undefined;
|
|
2214
|
+
}, {
|
|
2215
|
+
role: "system";
|
|
2216
|
+
content?: string | {
|
|
2217
|
+
type: "text";
|
|
2218
|
+
text?: string | undefined;
|
|
2219
|
+
cache_control?: {
|
|
2220
|
+
type: "ephemeral";
|
|
2221
|
+
} | undefined;
|
|
2222
|
+
}[] | undefined;
|
|
2223
|
+
name?: string | undefined;
|
|
2224
|
+
}>, z.ZodObject<{
|
|
2225
|
+
content: z.ZodUnion<[z.ZodDefault<z.ZodString>, z.ZodArray<z.ZodUnion<[z.ZodObject<{
|
|
2226
|
+
text: z.ZodDefault<z.ZodString>;
|
|
2227
|
+
type: z.ZodLiteral<"text">;
|
|
2228
|
+
cache_control: z.ZodOptional<z.ZodObject<{
|
|
2229
|
+
type: z.ZodEnum<["ephemeral"]>;
|
|
2230
|
+
}, "strip", z.ZodTypeAny, {
|
|
2231
|
+
type: "ephemeral";
|
|
2232
|
+
}, {
|
|
2233
|
+
type: "ephemeral";
|
|
2234
|
+
}>>;
|
|
2235
|
+
}, "strip", z.ZodTypeAny, {
|
|
2236
|
+
type: "text";
|
|
2237
|
+
text: string;
|
|
2238
|
+
cache_control?: {
|
|
2239
|
+
type: "ephemeral";
|
|
2240
|
+
} | undefined;
|
|
2241
|
+
}, {
|
|
2242
|
+
type: "text";
|
|
2243
|
+
text?: string | undefined;
|
|
2244
|
+
cache_control?: {
|
|
2245
|
+
type: "ephemeral";
|
|
2246
|
+
} | undefined;
|
|
2247
|
+
}>, z.ZodObject<{
|
|
2248
|
+
image_url: z.ZodObject<{
|
|
2249
|
+
url: z.ZodString;
|
|
2250
|
+
detail: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"auto">, z.ZodLiteral<"low">, z.ZodLiteral<"high">]>>;
|
|
2251
|
+
}, "strip", z.ZodTypeAny, {
|
|
2252
|
+
url: string;
|
|
2253
|
+
detail?: "auto" | "low" | "high" | undefined;
|
|
2254
|
+
}, {
|
|
2255
|
+
url: string;
|
|
2256
|
+
detail?: "auto" | "low" | "high" | undefined;
|
|
2257
|
+
}>;
|
|
2258
|
+
type: z.ZodLiteral<"image_url">;
|
|
2259
|
+
}, "strip", z.ZodTypeAny, {
|
|
2260
|
+
type: "image_url";
|
|
2261
|
+
image_url: {
|
|
2262
|
+
url: string;
|
|
2263
|
+
detail?: "auto" | "low" | "high" | undefined;
|
|
2264
|
+
};
|
|
2265
|
+
}, {
|
|
2266
|
+
type: "image_url";
|
|
2267
|
+
image_url: {
|
|
2268
|
+
url: string;
|
|
2269
|
+
detail?: "auto" | "low" | "high" | undefined;
|
|
2270
|
+
};
|
|
2271
|
+
}>]>, "many">]>;
|
|
2272
|
+
role: z.ZodLiteral<"user">;
|
|
2273
|
+
name: z.ZodOptional<z.ZodString>;
|
|
2274
|
+
}, "strip", z.ZodTypeAny, {
|
|
2275
|
+
content: (string | ({
|
|
2276
|
+
type: "text";
|
|
2277
|
+
text: string;
|
|
2278
|
+
cache_control?: {
|
|
2279
|
+
type: "ephemeral";
|
|
2280
|
+
} | undefined;
|
|
2281
|
+
} | {
|
|
2282
|
+
type: "image_url";
|
|
2283
|
+
image_url: {
|
|
2284
|
+
url: string;
|
|
2285
|
+
detail?: "auto" | "low" | "high" | undefined;
|
|
2286
|
+
};
|
|
2287
|
+
})[]) & (string | ({
|
|
2288
|
+
type: "text";
|
|
2289
|
+
text: string;
|
|
2290
|
+
cache_control?: {
|
|
2291
|
+
type: "ephemeral";
|
|
2292
|
+
} | undefined;
|
|
2293
|
+
} | {
|
|
2294
|
+
type: "image_url";
|
|
2295
|
+
image_url: {
|
|
2296
|
+
url: string;
|
|
2297
|
+
detail?: "auto" | "low" | "high" | undefined;
|
|
2298
|
+
};
|
|
2299
|
+
})[] | undefined);
|
|
2300
|
+
role: "user";
|
|
2301
|
+
name?: string | undefined;
|
|
2302
|
+
}, {
|
|
2303
|
+
role: "user";
|
|
2304
|
+
content?: string | ({
|
|
2305
|
+
type: "text";
|
|
2306
|
+
text?: string | undefined;
|
|
2307
|
+
cache_control?: {
|
|
2308
|
+
type: "ephemeral";
|
|
2309
|
+
} | undefined;
|
|
2310
|
+
} | {
|
|
2311
|
+
type: "image_url";
|
|
2312
|
+
image_url: {
|
|
2313
|
+
url: string;
|
|
2314
|
+
detail?: "auto" | "low" | "high" | undefined;
|
|
2315
|
+
};
|
|
2316
|
+
})[] | undefined;
|
|
2317
|
+
name?: string | undefined;
|
|
2318
|
+
}>, z.ZodObject<{
|
|
2319
|
+
role: z.ZodLiteral<"assistant">;
|
|
2320
|
+
content: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodObject<{
|
|
2321
|
+
text: z.ZodDefault<z.ZodString>;
|
|
2322
|
+
type: z.ZodLiteral<"text">;
|
|
2323
|
+
cache_control: z.ZodOptional<z.ZodObject<{
|
|
2324
|
+
type: z.ZodEnum<["ephemeral"]>;
|
|
2325
|
+
}, "strip", z.ZodTypeAny, {
|
|
2326
|
+
type: "ephemeral";
|
|
2327
|
+
}, {
|
|
2328
|
+
type: "ephemeral";
|
|
2329
|
+
}>>;
|
|
2330
|
+
}, "strip", z.ZodTypeAny, {
|
|
2331
|
+
type: "text";
|
|
2332
|
+
text: string;
|
|
2333
|
+
cache_control?: {
|
|
2334
|
+
type: "ephemeral";
|
|
2335
|
+
} | undefined;
|
|
2336
|
+
}, {
|
|
2337
|
+
type: "text";
|
|
2338
|
+
text?: string | undefined;
|
|
2339
|
+
cache_control?: {
|
|
2340
|
+
type: "ephemeral";
|
|
2341
|
+
} | undefined;
|
|
2342
|
+
}>, "many">]>>>;
|
|
2343
|
+
function_call: z.ZodEffects<z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
2344
|
+
arguments: z.ZodString;
|
|
2345
|
+
name: z.ZodString;
|
|
2346
|
+
}, "strip", z.ZodTypeAny, {
|
|
2347
|
+
name: string;
|
|
2348
|
+
arguments: string;
|
|
2349
|
+
}, {
|
|
2350
|
+
name: string;
|
|
2351
|
+
arguments: string;
|
|
2352
|
+
}>>>, {
|
|
2353
|
+
name: string;
|
|
2354
|
+
arguments: string;
|
|
2355
|
+
} | undefined, {
|
|
2356
|
+
name: string;
|
|
2357
|
+
arguments: string;
|
|
2358
|
+
} | null | undefined>;
|
|
2359
|
+
name: z.ZodEffects<z.ZodOptional<z.ZodNullable<z.ZodString>>, string | undefined, string | null | undefined>;
|
|
2360
|
+
tool_calls: z.ZodEffects<z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
2361
|
+
id: z.ZodString;
|
|
2362
|
+
function: z.ZodObject<{
|
|
2363
|
+
arguments: z.ZodString;
|
|
2364
|
+
name: z.ZodString;
|
|
2365
|
+
}, "strip", z.ZodTypeAny, {
|
|
2366
|
+
name: string;
|
|
2367
|
+
arguments: string;
|
|
2368
|
+
}, {
|
|
2369
|
+
name: string;
|
|
2370
|
+
arguments: string;
|
|
2371
|
+
}>;
|
|
2372
|
+
type: z.ZodLiteral<"function">;
|
|
2373
|
+
}, "strip", z.ZodTypeAny, {
|
|
2374
|
+
function: {
|
|
2375
|
+
name: string;
|
|
2376
|
+
arguments: string;
|
|
2377
|
+
};
|
|
2378
|
+
type: "function";
|
|
2379
|
+
id: string;
|
|
2380
|
+
}, {
|
|
2381
|
+
function: {
|
|
2382
|
+
name: string;
|
|
2383
|
+
arguments: string;
|
|
2384
|
+
};
|
|
2385
|
+
type: "function";
|
|
2386
|
+
id: string;
|
|
2387
|
+
}>, "many">>>, {
|
|
2388
|
+
function: {
|
|
2389
|
+
name: string;
|
|
2390
|
+
arguments: string;
|
|
2391
|
+
};
|
|
2392
|
+
type: "function";
|
|
2393
|
+
id: string;
|
|
2394
|
+
}[] | undefined, {
|
|
2395
|
+
function: {
|
|
2396
|
+
name: string;
|
|
2397
|
+
arguments: string;
|
|
2398
|
+
};
|
|
2399
|
+
type: "function";
|
|
2400
|
+
id: string;
|
|
2401
|
+
}[] | null | undefined>;
|
|
2402
|
+
reasoning: z.ZodEffects<z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
2403
|
+
id: z.ZodEffects<z.ZodOptional<z.ZodNullable<z.ZodString>>, string | undefined, string | null | undefined>;
|
|
2404
|
+
content: z.ZodEffects<z.ZodOptional<z.ZodNullable<z.ZodString>>, string | undefined, string | null | undefined>;
|
|
2405
|
+
}, "strip", z.ZodTypeAny, {
|
|
2406
|
+
id?: string | undefined;
|
|
2407
|
+
content?: string | undefined;
|
|
2408
|
+
}, {
|
|
2409
|
+
id?: string | null | undefined;
|
|
2410
|
+
content?: string | null | undefined;
|
|
2411
|
+
}>, "many">>>, {
|
|
2412
|
+
id?: string | undefined;
|
|
2413
|
+
content?: string | undefined;
|
|
2414
|
+
}[] | undefined, {
|
|
2415
|
+
id?: string | null | undefined;
|
|
2416
|
+
content?: string | null | undefined;
|
|
2417
|
+
}[] | null | undefined>;
|
|
2418
|
+
}, "strip", z.ZodTypeAny, {
|
|
2419
|
+
role: "assistant";
|
|
2420
|
+
content?: string | {
|
|
2421
|
+
type: "text";
|
|
2422
|
+
text: string;
|
|
2423
|
+
cache_control?: {
|
|
2424
|
+
type: "ephemeral";
|
|
2425
|
+
} | undefined;
|
|
2426
|
+
}[] | null | undefined;
|
|
2427
|
+
function_call?: {
|
|
2428
|
+
name: string;
|
|
2429
|
+
arguments: string;
|
|
2430
|
+
} | undefined;
|
|
2431
|
+
name?: string | undefined;
|
|
2432
|
+
tool_calls?: {
|
|
2433
|
+
function: {
|
|
2434
|
+
name: string;
|
|
2435
|
+
arguments: string;
|
|
2436
|
+
};
|
|
2437
|
+
type: "function";
|
|
2438
|
+
id: string;
|
|
2439
|
+
}[] | undefined;
|
|
2440
|
+
reasoning?: {
|
|
2441
|
+
id?: string | undefined;
|
|
2442
|
+
content?: string | undefined;
|
|
2443
|
+
}[] | undefined;
|
|
2444
|
+
}, {
|
|
2445
|
+
role: "assistant";
|
|
2446
|
+
content?: string | {
|
|
2447
|
+
type: "text";
|
|
2448
|
+
text?: string | undefined;
|
|
2449
|
+
cache_control?: {
|
|
2450
|
+
type: "ephemeral";
|
|
2451
|
+
} | undefined;
|
|
2452
|
+
}[] | null | undefined;
|
|
2453
|
+
function_call?: {
|
|
2454
|
+
name: string;
|
|
2455
|
+
arguments: string;
|
|
2456
|
+
} | null | undefined;
|
|
2457
|
+
name?: string | null | undefined;
|
|
2458
|
+
tool_calls?: {
|
|
2459
|
+
function: {
|
|
2460
|
+
name: string;
|
|
2461
|
+
arguments: string;
|
|
2462
|
+
};
|
|
2463
|
+
type: "function";
|
|
2464
|
+
id: string;
|
|
2465
|
+
}[] | null | undefined;
|
|
2466
|
+
reasoning?: {
|
|
2467
|
+
id?: string | null | undefined;
|
|
2468
|
+
content?: string | null | undefined;
|
|
2469
|
+
}[] | null | undefined;
|
|
2470
|
+
}>, z.ZodObject<{
|
|
2471
|
+
content: z.ZodDefault<z.ZodString>;
|
|
2472
|
+
role: z.ZodLiteral<"tool">;
|
|
2473
|
+
tool_call_id: z.ZodDefault<z.ZodString>;
|
|
2474
|
+
}, "strip", z.ZodTypeAny, {
|
|
2475
|
+
content: string;
|
|
2476
|
+
role: "tool";
|
|
2477
|
+
tool_call_id: string;
|
|
2478
|
+
}, {
|
|
2479
|
+
role: "tool";
|
|
2480
|
+
content?: string | undefined;
|
|
2481
|
+
tool_call_id?: string | undefined;
|
|
2482
|
+
}>, z.ZodObject<{
|
|
2483
|
+
content: z.ZodNullable<z.ZodString>;
|
|
2484
|
+
name: z.ZodString;
|
|
2485
|
+
role: z.ZodLiteral<"function">;
|
|
2486
|
+
}, "strip", z.ZodTypeAny, {
|
|
2487
|
+
name: string;
|
|
2488
|
+
content: string | null;
|
|
2489
|
+
role: "function";
|
|
2490
|
+
}, {
|
|
2491
|
+
name: string;
|
|
2492
|
+
content: string | null;
|
|
2493
|
+
role: "function";
|
|
2494
|
+
}>]>, z.ZodObject<{
|
|
2495
|
+
role: z.ZodEnum<["model"]>;
|
|
2496
|
+
content: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
2497
|
+
}, "strip", z.ZodTypeAny, {
|
|
2498
|
+
role: "model";
|
|
2499
|
+
content?: string | null | undefined;
|
|
2500
|
+
}, {
|
|
2501
|
+
role: "model";
|
|
2502
|
+
content?: string | null | undefined;
|
|
2503
|
+
}>]>, "many">;
|
|
2504
|
+
}, "strip", z.ZodTypeAny, {
|
|
2505
|
+
messages: ({
|
|
2506
|
+
content: (string | {
|
|
2507
|
+
type: "text";
|
|
2508
|
+
text: string;
|
|
2509
|
+
cache_control?: {
|
|
2510
|
+
type: "ephemeral";
|
|
2511
|
+
} | undefined;
|
|
2512
|
+
}[]) & (string | {
|
|
2513
|
+
type: "text";
|
|
2514
|
+
text: string;
|
|
2515
|
+
cache_control?: {
|
|
2516
|
+
type: "ephemeral";
|
|
2517
|
+
} | undefined;
|
|
2518
|
+
}[] | undefined);
|
|
2519
|
+
role: "system";
|
|
2520
|
+
name?: string | undefined;
|
|
2521
|
+
} | {
|
|
2522
|
+
content: (string | ({
|
|
2523
|
+
type: "text";
|
|
2524
|
+
text: string;
|
|
2525
|
+
cache_control?: {
|
|
2526
|
+
type: "ephemeral";
|
|
2527
|
+
} | undefined;
|
|
2528
|
+
} | {
|
|
2529
|
+
type: "image_url";
|
|
2530
|
+
image_url: {
|
|
2531
|
+
url: string;
|
|
2532
|
+
detail?: "auto" | "low" | "high" | undefined;
|
|
2533
|
+
};
|
|
2534
|
+
})[]) & (string | ({
|
|
2535
|
+
type: "text";
|
|
2536
|
+
text: string;
|
|
2537
|
+
cache_control?: {
|
|
2538
|
+
type: "ephemeral";
|
|
2539
|
+
} | undefined;
|
|
2540
|
+
} | {
|
|
2541
|
+
type: "image_url";
|
|
2542
|
+
image_url: {
|
|
2543
|
+
url: string;
|
|
2544
|
+
detail?: "auto" | "low" | "high" | undefined;
|
|
2545
|
+
};
|
|
2546
|
+
})[] | undefined);
|
|
2547
|
+
role: "user";
|
|
2548
|
+
name?: string | undefined;
|
|
2549
|
+
} | {
|
|
2550
|
+
role: "assistant";
|
|
2551
|
+
content?: string | {
|
|
2552
|
+
type: "text";
|
|
2553
|
+
text: string;
|
|
2554
|
+
cache_control?: {
|
|
2555
|
+
type: "ephemeral";
|
|
2556
|
+
} | undefined;
|
|
2557
|
+
}[] | null | undefined;
|
|
2558
|
+
function_call?: {
|
|
2559
|
+
name: string;
|
|
2560
|
+
arguments: string;
|
|
2561
|
+
} | undefined;
|
|
2562
|
+
name?: string | undefined;
|
|
2563
|
+
tool_calls?: {
|
|
2564
|
+
function: {
|
|
2565
|
+
name: string;
|
|
2566
|
+
arguments: string;
|
|
2567
|
+
};
|
|
2568
|
+
type: "function";
|
|
2569
|
+
id: string;
|
|
2570
|
+
}[] | undefined;
|
|
2571
|
+
reasoning?: {
|
|
2572
|
+
id?: string | undefined;
|
|
2573
|
+
content?: string | undefined;
|
|
2574
|
+
}[] | undefined;
|
|
2575
|
+
} | {
|
|
2576
|
+
content: string;
|
|
2577
|
+
role: "tool";
|
|
2578
|
+
tool_call_id: string;
|
|
2579
|
+
} | {
|
|
2580
|
+
name: string;
|
|
2581
|
+
content: string | null;
|
|
2582
|
+
role: "function";
|
|
2583
|
+
} | {
|
|
2584
|
+
role: "model";
|
|
2585
|
+
content?: string | null | undefined;
|
|
2586
|
+
})[];
|
|
2587
|
+
}, {
|
|
2588
|
+
messages: ({
|
|
2589
|
+
role: "system";
|
|
2590
|
+
content?: string | {
|
|
2591
|
+
type: "text";
|
|
2592
|
+
text?: string | undefined;
|
|
2593
|
+
cache_control?: {
|
|
2594
|
+
type: "ephemeral";
|
|
2595
|
+
} | undefined;
|
|
2596
|
+
}[] | undefined;
|
|
2597
|
+
name?: string | undefined;
|
|
2598
|
+
} | {
|
|
2599
|
+
role: "user";
|
|
2600
|
+
content?: string | ({
|
|
2601
|
+
type: "text";
|
|
2602
|
+
text?: string | undefined;
|
|
2603
|
+
cache_control?: {
|
|
2604
|
+
type: "ephemeral";
|
|
2605
|
+
} | undefined;
|
|
2606
|
+
} | {
|
|
2607
|
+
type: "image_url";
|
|
2608
|
+
image_url: {
|
|
2609
|
+
url: string;
|
|
2610
|
+
detail?: "auto" | "low" | "high" | undefined;
|
|
2611
|
+
};
|
|
2612
|
+
})[] | undefined;
|
|
2613
|
+
name?: string | undefined;
|
|
2614
|
+
} | {
|
|
2615
|
+
role: "assistant";
|
|
2616
|
+
content?: string | {
|
|
2617
|
+
type: "text";
|
|
2618
|
+
text?: string | undefined;
|
|
2619
|
+
cache_control?: {
|
|
2620
|
+
type: "ephemeral";
|
|
2621
|
+
} | undefined;
|
|
2622
|
+
}[] | null | undefined;
|
|
2623
|
+
function_call?: {
|
|
2624
|
+
name: string;
|
|
2625
|
+
arguments: string;
|
|
2626
|
+
} | null | undefined;
|
|
2627
|
+
name?: string | null | undefined;
|
|
2628
|
+
tool_calls?: {
|
|
2629
|
+
function: {
|
|
2630
|
+
name: string;
|
|
2631
|
+
arguments: string;
|
|
2632
|
+
};
|
|
2633
|
+
type: "function";
|
|
2634
|
+
id: string;
|
|
2635
|
+
}[] | null | undefined;
|
|
2636
|
+
reasoning?: {
|
|
2637
|
+
id?: string | null | undefined;
|
|
2638
|
+
content?: string | null | undefined;
|
|
2639
|
+
}[] | null | undefined;
|
|
2640
|
+
} | {
|
|
2641
|
+
role: "tool";
|
|
2642
|
+
content?: string | undefined;
|
|
2643
|
+
tool_call_id?: string | undefined;
|
|
2644
|
+
} | {
|
|
2645
|
+
name: string;
|
|
2646
|
+
content: string | null;
|
|
2647
|
+
role: "function";
|
|
2648
|
+
} | {
|
|
2649
|
+
role: "model";
|
|
2650
|
+
content?: string | null | undefined;
|
|
2651
|
+
})[];
|
|
2652
|
+
}>]>, z.ZodObject<{
|
|
2653
|
+
model: z.ZodString;
|
|
2654
|
+
params: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
|
|
2655
|
+
use_cache: z.ZodOptional<z.ZodBoolean>;
|
|
2656
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
2657
|
+
top_p: z.ZodOptional<z.ZodNumber>;
|
|
2658
|
+
max_tokens: z.ZodOptional<z.ZodNumber>;
|
|
2659
|
+
max_completion_tokens: z.ZodOptional<z.ZodNumber>;
|
|
2660
|
+
frequency_penalty: z.ZodOptional<z.ZodNumber>;
|
|
2661
|
+
presence_penalty: z.ZodOptional<z.ZodNumber>;
|
|
2662
|
+
response_format: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodObject<{
|
|
2663
|
+
type: z.ZodLiteral<"json_object">;
|
|
2664
|
+
}, "strip", z.ZodTypeAny, {
|
|
2665
|
+
type: "json_object";
|
|
2666
|
+
}, {
|
|
2667
|
+
type: "json_object";
|
|
2668
|
+
}>, z.ZodObject<{
|
|
2669
|
+
type: z.ZodLiteral<"json_schema">;
|
|
2670
|
+
json_schema: z.ZodObject<{
|
|
2671
|
+
name: z.ZodString;
|
|
2672
|
+
description: z.ZodOptional<z.ZodString>;
|
|
2673
|
+
schema: z.ZodOptional<z.ZodUnion<[z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodString]>>;
|
|
2674
|
+
strict: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
2675
|
+
}, "strip", z.ZodTypeAny, {
|
|
2676
|
+
name: string;
|
|
2677
|
+
description?: string | undefined;
|
|
2678
|
+
schema?: string | Record<string, unknown> | undefined;
|
|
2679
|
+
strict?: boolean | null | undefined;
|
|
2680
|
+
}, {
|
|
2681
|
+
name: string;
|
|
2682
|
+
description?: string | undefined;
|
|
2683
|
+
schema?: string | Record<string, unknown> | undefined;
|
|
2684
|
+
strict?: boolean | null | undefined;
|
|
2685
|
+
}>;
|
|
2686
|
+
}, "strip", z.ZodTypeAny, {
|
|
2687
|
+
type: "json_schema";
|
|
2688
|
+
json_schema: {
|
|
2689
|
+
name: string;
|
|
2690
|
+
description?: string | undefined;
|
|
2691
|
+
schema?: string | Record<string, unknown> | undefined;
|
|
2692
|
+
strict?: boolean | null | undefined;
|
|
2693
|
+
};
|
|
2694
|
+
}, {
|
|
2695
|
+
type: "json_schema";
|
|
2696
|
+
json_schema: {
|
|
2697
|
+
name: string;
|
|
2698
|
+
description?: string | undefined;
|
|
2699
|
+
schema?: string | Record<string, unknown> | undefined;
|
|
2700
|
+
strict?: boolean | null | undefined;
|
|
2701
|
+
};
|
|
2702
|
+
}>, z.ZodObject<{
|
|
2703
|
+
type: z.ZodLiteral<"text">;
|
|
2704
|
+
}, "strip", z.ZodTypeAny, {
|
|
2705
|
+
type: "text";
|
|
2706
|
+
}, {
|
|
2707
|
+
type: "text";
|
|
2708
|
+
}>]>>>;
|
|
2709
|
+
tool_choice: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"auto">, z.ZodLiteral<"none">, z.ZodLiteral<"required">, z.ZodObject<{
|
|
2710
|
+
type: z.ZodLiteral<"function">;
|
|
2711
|
+
function: z.ZodObject<{
|
|
2712
|
+
name: z.ZodString;
|
|
2713
|
+
}, "strip", z.ZodTypeAny, {
|
|
2714
|
+
name: string;
|
|
2715
|
+
}, {
|
|
2716
|
+
name: string;
|
|
2717
|
+
}>;
|
|
2718
|
+
}, "strip", z.ZodTypeAny, {
|
|
2719
|
+
function: {
|
|
2720
|
+
name: string;
|
|
2721
|
+
};
|
|
2722
|
+
type: "function";
|
|
2723
|
+
}, {
|
|
2724
|
+
function: {
|
|
2725
|
+
name: string;
|
|
2726
|
+
};
|
|
2727
|
+
type: "function";
|
|
2728
|
+
}>]>>;
|
|
2729
|
+
function_call: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"auto">, z.ZodLiteral<"none">, z.ZodObject<{
|
|
2730
|
+
name: z.ZodString;
|
|
2731
|
+
}, "strip", z.ZodTypeAny, {
|
|
2732
|
+
name: string;
|
|
2733
|
+
}, {
|
|
2734
|
+
name: string;
|
|
2735
|
+
}>]>>;
|
|
2736
|
+
n: z.ZodOptional<z.ZodNumber>;
|
|
2737
|
+
stop: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
2738
|
+
reasoning_effort: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
|
|
2739
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
2740
|
+
use_cache: z.ZodOptional<z.ZodBoolean>;
|
|
2741
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
2742
|
+
top_p: z.ZodOptional<z.ZodNumber>;
|
|
2743
|
+
max_tokens: z.ZodOptional<z.ZodNumber>;
|
|
2744
|
+
max_completion_tokens: z.ZodOptional<z.ZodNumber>;
|
|
2745
|
+
frequency_penalty: z.ZodOptional<z.ZodNumber>;
|
|
2746
|
+
presence_penalty: z.ZodOptional<z.ZodNumber>;
|
|
2747
|
+
response_format: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodObject<{
|
|
2748
|
+
type: z.ZodLiteral<"json_object">;
|
|
2749
|
+
}, "strip", z.ZodTypeAny, {
|
|
2750
|
+
type: "json_object";
|
|
2751
|
+
}, {
|
|
2752
|
+
type: "json_object";
|
|
2753
|
+
}>, z.ZodObject<{
|
|
2754
|
+
type: z.ZodLiteral<"json_schema">;
|
|
2755
|
+
json_schema: z.ZodObject<{
|
|
2756
|
+
name: z.ZodString;
|
|
2757
|
+
description: z.ZodOptional<z.ZodString>;
|
|
2758
|
+
schema: z.ZodOptional<z.ZodUnion<[z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodString]>>;
|
|
2759
|
+
strict: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
2760
|
+
}, "strip", z.ZodTypeAny, {
|
|
2761
|
+
name: string;
|
|
2762
|
+
description?: string | undefined;
|
|
2763
|
+
schema?: string | Record<string, unknown> | undefined;
|
|
2764
|
+
strict?: boolean | null | undefined;
|
|
2765
|
+
}, {
|
|
2766
|
+
name: string;
|
|
2767
|
+
description?: string | undefined;
|
|
2768
|
+
schema?: string | Record<string, unknown> | undefined;
|
|
2769
|
+
strict?: boolean | null | undefined;
|
|
2770
|
+
}>;
|
|
2771
|
+
}, "strip", z.ZodTypeAny, {
|
|
2772
|
+
type: "json_schema";
|
|
2773
|
+
json_schema: {
|
|
2774
|
+
name: string;
|
|
2775
|
+
description?: string | undefined;
|
|
2776
|
+
schema?: string | Record<string, unknown> | undefined;
|
|
2777
|
+
strict?: boolean | null | undefined;
|
|
2778
|
+
};
|
|
2779
|
+
}, {
|
|
2780
|
+
type: "json_schema";
|
|
2781
|
+
json_schema: {
|
|
2782
|
+
name: string;
|
|
2783
|
+
description?: string | undefined;
|
|
2784
|
+
schema?: string | Record<string, unknown> | undefined;
|
|
2785
|
+
strict?: boolean | null | undefined;
|
|
2786
|
+
};
|
|
2787
|
+
}>, z.ZodObject<{
|
|
2788
|
+
type: z.ZodLiteral<"text">;
|
|
2789
|
+
}, "strip", z.ZodTypeAny, {
|
|
2790
|
+
type: "text";
|
|
2791
|
+
}, {
|
|
2792
|
+
type: "text";
|
|
2793
|
+
}>]>>>;
|
|
2794
|
+
tool_choice: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"auto">, z.ZodLiteral<"none">, z.ZodLiteral<"required">, z.ZodObject<{
|
|
2795
|
+
type: z.ZodLiteral<"function">;
|
|
2796
|
+
function: z.ZodObject<{
|
|
2797
|
+
name: z.ZodString;
|
|
2798
|
+
}, "strip", z.ZodTypeAny, {
|
|
2799
|
+
name: string;
|
|
2800
|
+
}, {
|
|
2801
|
+
name: string;
|
|
2802
|
+
}>;
|
|
2803
|
+
}, "strip", z.ZodTypeAny, {
|
|
2804
|
+
function: {
|
|
2805
|
+
name: string;
|
|
2806
|
+
};
|
|
2807
|
+
type: "function";
|
|
2808
|
+
}, {
|
|
2809
|
+
function: {
|
|
2810
|
+
name: string;
|
|
2811
|
+
};
|
|
2812
|
+
type: "function";
|
|
2813
|
+
}>]>>;
|
|
2814
|
+
function_call: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"auto">, z.ZodLiteral<"none">, z.ZodObject<{
|
|
2815
|
+
name: z.ZodString;
|
|
2816
|
+
}, "strip", z.ZodTypeAny, {
|
|
2817
|
+
name: string;
|
|
2818
|
+
}, {
|
|
2819
|
+
name: string;
|
|
2820
|
+
}>]>>;
|
|
2821
|
+
n: z.ZodOptional<z.ZodNumber>;
|
|
2822
|
+
stop: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
2823
|
+
reasoning_effort: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
|
|
2824
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
2825
|
+
use_cache: z.ZodOptional<z.ZodBoolean>;
|
|
2826
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
2827
|
+
top_p: z.ZodOptional<z.ZodNumber>;
|
|
2828
|
+
max_tokens: z.ZodOptional<z.ZodNumber>;
|
|
2829
|
+
max_completion_tokens: z.ZodOptional<z.ZodNumber>;
|
|
2830
|
+
frequency_penalty: z.ZodOptional<z.ZodNumber>;
|
|
2831
|
+
presence_penalty: z.ZodOptional<z.ZodNumber>;
|
|
2832
|
+
response_format: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodObject<{
|
|
2833
|
+
type: z.ZodLiteral<"json_object">;
|
|
2834
|
+
}, "strip", z.ZodTypeAny, {
|
|
2835
|
+
type: "json_object";
|
|
2836
|
+
}, {
|
|
2837
|
+
type: "json_object";
|
|
2838
|
+
}>, z.ZodObject<{
|
|
2839
|
+
type: z.ZodLiteral<"json_schema">;
|
|
2840
|
+
json_schema: z.ZodObject<{
|
|
2841
|
+
name: z.ZodString;
|
|
2842
|
+
description: z.ZodOptional<z.ZodString>;
|
|
2843
|
+
schema: z.ZodOptional<z.ZodUnion<[z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodString]>>;
|
|
2844
|
+
strict: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
2845
|
+
}, "strip", z.ZodTypeAny, {
|
|
2846
|
+
name: string;
|
|
2847
|
+
description?: string | undefined;
|
|
2848
|
+
schema?: string | Record<string, unknown> | undefined;
|
|
2849
|
+
strict?: boolean | null | undefined;
|
|
2850
|
+
}, {
|
|
2851
|
+
name: string;
|
|
2852
|
+
description?: string | undefined;
|
|
2853
|
+
schema?: string | Record<string, unknown> | undefined;
|
|
2854
|
+
strict?: boolean | null | undefined;
|
|
2855
|
+
}>;
|
|
2856
|
+
}, "strip", z.ZodTypeAny, {
|
|
2857
|
+
type: "json_schema";
|
|
2858
|
+
json_schema: {
|
|
2859
|
+
name: string;
|
|
2860
|
+
description?: string | undefined;
|
|
2861
|
+
schema?: string | Record<string, unknown> | undefined;
|
|
2862
|
+
strict?: boolean | null | undefined;
|
|
2863
|
+
};
|
|
2864
|
+
}, {
|
|
2865
|
+
type: "json_schema";
|
|
2866
|
+
json_schema: {
|
|
2867
|
+
name: string;
|
|
2868
|
+
description?: string | undefined;
|
|
2869
|
+
schema?: string | Record<string, unknown> | undefined;
|
|
2870
|
+
strict?: boolean | null | undefined;
|
|
2871
|
+
};
|
|
2872
|
+
}>, z.ZodObject<{
|
|
2873
|
+
type: z.ZodLiteral<"text">;
|
|
2874
|
+
}, "strip", z.ZodTypeAny, {
|
|
2875
|
+
type: "text";
|
|
2876
|
+
}, {
|
|
2877
|
+
type: "text";
|
|
2878
|
+
}>]>>>;
|
|
2879
|
+
tool_choice: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"auto">, z.ZodLiteral<"none">, z.ZodLiteral<"required">, z.ZodObject<{
|
|
2880
|
+
type: z.ZodLiteral<"function">;
|
|
2881
|
+
function: z.ZodObject<{
|
|
2882
|
+
name: z.ZodString;
|
|
2883
|
+
}, "strip", z.ZodTypeAny, {
|
|
2884
|
+
name: string;
|
|
2885
|
+
}, {
|
|
2886
|
+
name: string;
|
|
2887
|
+
}>;
|
|
2888
|
+
}, "strip", z.ZodTypeAny, {
|
|
2889
|
+
function: {
|
|
2890
|
+
name: string;
|
|
2891
|
+
};
|
|
2892
|
+
type: "function";
|
|
2893
|
+
}, {
|
|
2894
|
+
function: {
|
|
2895
|
+
name: string;
|
|
2896
|
+
};
|
|
2897
|
+
type: "function";
|
|
2898
|
+
}>]>>;
|
|
2899
|
+
function_call: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"auto">, z.ZodLiteral<"none">, z.ZodObject<{
|
|
2900
|
+
name: z.ZodString;
|
|
2901
|
+
}, "strip", z.ZodTypeAny, {
|
|
2902
|
+
name: string;
|
|
2903
|
+
}, {
|
|
2904
|
+
name: string;
|
|
2905
|
+
}>]>>;
|
|
2906
|
+
n: z.ZodOptional<z.ZodNumber>;
|
|
2907
|
+
stop: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
2908
|
+
reasoning_effort: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
|
|
2909
|
+
}, z.ZodTypeAny, "passthrough">>, z.ZodObject<{
|
|
2910
|
+
use_cache: z.ZodOptional<z.ZodBoolean>;
|
|
2911
|
+
max_tokens: z.ZodNumber;
|
|
2912
|
+
temperature: z.ZodNumber;
|
|
2913
|
+
top_p: z.ZodOptional<z.ZodNumber>;
|
|
2914
|
+
top_k: z.ZodOptional<z.ZodNumber>;
|
|
2915
|
+
stop_sequences: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
2916
|
+
max_tokens_to_sample: z.ZodOptional<z.ZodNumber>;
|
|
2917
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
2918
|
+
use_cache: z.ZodOptional<z.ZodBoolean>;
|
|
2919
|
+
max_tokens: z.ZodNumber;
|
|
2920
|
+
temperature: z.ZodNumber;
|
|
2921
|
+
top_p: z.ZodOptional<z.ZodNumber>;
|
|
2922
|
+
top_k: z.ZodOptional<z.ZodNumber>;
|
|
2923
|
+
stop_sequences: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
2924
|
+
max_tokens_to_sample: z.ZodOptional<z.ZodNumber>;
|
|
2925
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
2926
|
+
use_cache: z.ZodOptional<z.ZodBoolean>;
|
|
2927
|
+
max_tokens: z.ZodNumber;
|
|
2928
|
+
temperature: z.ZodNumber;
|
|
2929
|
+
top_p: z.ZodOptional<z.ZodNumber>;
|
|
2930
|
+
top_k: z.ZodOptional<z.ZodNumber>;
|
|
2931
|
+
stop_sequences: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
2932
|
+
max_tokens_to_sample: z.ZodOptional<z.ZodNumber>;
|
|
2933
|
+
}, z.ZodTypeAny, "passthrough">>, z.ZodObject<{
|
|
2934
|
+
use_cache: z.ZodOptional<z.ZodBoolean>;
|
|
2935
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
2936
|
+
maxOutputTokens: z.ZodOptional<z.ZodNumber>;
|
|
2937
|
+
topP: z.ZodOptional<z.ZodNumber>;
|
|
2938
|
+
topK: z.ZodOptional<z.ZodNumber>;
|
|
2939
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
2940
|
+
use_cache: z.ZodOptional<z.ZodBoolean>;
|
|
2941
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
2942
|
+
maxOutputTokens: z.ZodOptional<z.ZodNumber>;
|
|
2943
|
+
topP: z.ZodOptional<z.ZodNumber>;
|
|
2944
|
+
topK: z.ZodOptional<z.ZodNumber>;
|
|
2945
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
2946
|
+
use_cache: z.ZodOptional<z.ZodBoolean>;
|
|
2947
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
2948
|
+
maxOutputTokens: z.ZodOptional<z.ZodNumber>;
|
|
2949
|
+
topP: z.ZodOptional<z.ZodNumber>;
|
|
2950
|
+
topK: z.ZodOptional<z.ZodNumber>;
|
|
2951
|
+
}, z.ZodTypeAny, "passthrough">>, z.ZodObject<{
|
|
2952
|
+
use_cache: z.ZodOptional<z.ZodBoolean>;
|
|
2953
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
2954
|
+
topK: z.ZodOptional<z.ZodNumber>;
|
|
2955
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
2956
|
+
use_cache: z.ZodOptional<z.ZodBoolean>;
|
|
2957
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
2958
|
+
topK: z.ZodOptional<z.ZodNumber>;
|
|
2959
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
2960
|
+
use_cache: z.ZodOptional<z.ZodBoolean>;
|
|
2961
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
2962
|
+
topK: z.ZodOptional<z.ZodNumber>;
|
|
2963
|
+
}, z.ZodTypeAny, "passthrough">>, z.ZodObject<{
|
|
2964
|
+
use_cache: z.ZodOptional<z.ZodBoolean>;
|
|
2965
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
2966
|
+
use_cache: z.ZodOptional<z.ZodBoolean>;
|
|
2967
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
2968
|
+
use_cache: z.ZodOptional<z.ZodBoolean>;
|
|
2969
|
+
}, z.ZodTypeAny, "passthrough">>]>>;
|
|
2970
|
+
}, "strip", z.ZodTypeAny, {
|
|
2971
|
+
model: string;
|
|
2972
|
+
params?: z.objectOutputType<{
|
|
2973
|
+
use_cache: z.ZodOptional<z.ZodBoolean>;
|
|
2974
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
2975
|
+
top_p: z.ZodOptional<z.ZodNumber>;
|
|
2976
|
+
max_tokens: z.ZodOptional<z.ZodNumber>;
|
|
2977
|
+
max_completion_tokens: z.ZodOptional<z.ZodNumber>;
|
|
2978
|
+
frequency_penalty: z.ZodOptional<z.ZodNumber>;
|
|
2979
|
+
presence_penalty: z.ZodOptional<z.ZodNumber>;
|
|
2980
|
+
response_format: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodObject<{
|
|
2981
|
+
type: z.ZodLiteral<"json_object">;
|
|
2982
|
+
}, "strip", z.ZodTypeAny, {
|
|
2983
|
+
type: "json_object";
|
|
2984
|
+
}, {
|
|
2985
|
+
type: "json_object";
|
|
2986
|
+
}>, z.ZodObject<{
|
|
2987
|
+
type: z.ZodLiteral<"json_schema">;
|
|
2988
|
+
json_schema: z.ZodObject<{
|
|
2989
|
+
name: z.ZodString;
|
|
2990
|
+
description: z.ZodOptional<z.ZodString>;
|
|
2991
|
+
schema: z.ZodOptional<z.ZodUnion<[z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodString]>>;
|
|
2992
|
+
strict: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
2993
|
+
}, "strip", z.ZodTypeAny, {
|
|
2994
|
+
name: string;
|
|
2995
|
+
description?: string | undefined;
|
|
2996
|
+
schema?: string | Record<string, unknown> | undefined;
|
|
2997
|
+
strict?: boolean | null | undefined;
|
|
2998
|
+
}, {
|
|
2999
|
+
name: string;
|
|
3000
|
+
description?: string | undefined;
|
|
3001
|
+
schema?: string | Record<string, unknown> | undefined;
|
|
3002
|
+
strict?: boolean | null | undefined;
|
|
3003
|
+
}>;
|
|
3004
|
+
}, "strip", z.ZodTypeAny, {
|
|
3005
|
+
type: "json_schema";
|
|
3006
|
+
json_schema: {
|
|
3007
|
+
name: string;
|
|
3008
|
+
description?: string | undefined;
|
|
3009
|
+
schema?: string | Record<string, unknown> | undefined;
|
|
3010
|
+
strict?: boolean | null | undefined;
|
|
3011
|
+
};
|
|
3012
|
+
}, {
|
|
3013
|
+
type: "json_schema";
|
|
3014
|
+
json_schema: {
|
|
3015
|
+
name: string;
|
|
3016
|
+
description?: string | undefined;
|
|
3017
|
+
schema?: string | Record<string, unknown> | undefined;
|
|
3018
|
+
strict?: boolean | null | undefined;
|
|
3019
|
+
};
|
|
3020
|
+
}>, z.ZodObject<{
|
|
3021
|
+
type: z.ZodLiteral<"text">;
|
|
3022
|
+
}, "strip", z.ZodTypeAny, {
|
|
3023
|
+
type: "text";
|
|
3024
|
+
}, {
|
|
3025
|
+
type: "text";
|
|
3026
|
+
}>]>>>;
|
|
3027
|
+
tool_choice: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"auto">, z.ZodLiteral<"none">, z.ZodLiteral<"required">, z.ZodObject<{
|
|
3028
|
+
type: z.ZodLiteral<"function">;
|
|
3029
|
+
function: z.ZodObject<{
|
|
3030
|
+
name: z.ZodString;
|
|
3031
|
+
}, "strip", z.ZodTypeAny, {
|
|
3032
|
+
name: string;
|
|
3033
|
+
}, {
|
|
3034
|
+
name: string;
|
|
3035
|
+
}>;
|
|
3036
|
+
}, "strip", z.ZodTypeAny, {
|
|
3037
|
+
function: {
|
|
3038
|
+
name: string;
|
|
3039
|
+
};
|
|
3040
|
+
type: "function";
|
|
3041
|
+
}, {
|
|
3042
|
+
function: {
|
|
3043
|
+
name: string;
|
|
3044
|
+
};
|
|
3045
|
+
type: "function";
|
|
3046
|
+
}>]>>;
|
|
3047
|
+
function_call: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"auto">, z.ZodLiteral<"none">, z.ZodObject<{
|
|
3048
|
+
name: z.ZodString;
|
|
3049
|
+
}, "strip", z.ZodTypeAny, {
|
|
3050
|
+
name: string;
|
|
3051
|
+
}, {
|
|
3052
|
+
name: string;
|
|
3053
|
+
}>]>>;
|
|
3054
|
+
n: z.ZodOptional<z.ZodNumber>;
|
|
3055
|
+
stop: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
3056
|
+
reasoning_effort: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
|
|
3057
|
+
}, z.ZodTypeAny, "passthrough"> | z.objectOutputType<{
|
|
3058
|
+
use_cache: z.ZodOptional<z.ZodBoolean>;
|
|
3059
|
+
max_tokens: z.ZodNumber;
|
|
3060
|
+
temperature: z.ZodNumber;
|
|
3061
|
+
top_p: z.ZodOptional<z.ZodNumber>;
|
|
3062
|
+
top_k: z.ZodOptional<z.ZodNumber>;
|
|
3063
|
+
stop_sequences: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
3064
|
+
max_tokens_to_sample: z.ZodOptional<z.ZodNumber>;
|
|
3065
|
+
}, z.ZodTypeAny, "passthrough"> | z.objectOutputType<{
|
|
3066
|
+
use_cache: z.ZodOptional<z.ZodBoolean>;
|
|
3067
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
3068
|
+
maxOutputTokens: z.ZodOptional<z.ZodNumber>;
|
|
3069
|
+
topP: z.ZodOptional<z.ZodNumber>;
|
|
3070
|
+
topK: z.ZodOptional<z.ZodNumber>;
|
|
3071
|
+
}, z.ZodTypeAny, "passthrough"> | z.objectOutputType<{
|
|
3072
|
+
use_cache: z.ZodOptional<z.ZodBoolean>;
|
|
3073
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
3074
|
+
topK: z.ZodOptional<z.ZodNumber>;
|
|
3075
|
+
}, z.ZodTypeAny, "passthrough"> | z.objectOutputType<{
|
|
3076
|
+
use_cache: z.ZodOptional<z.ZodBoolean>;
|
|
3077
|
+
}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
3078
|
+
}, {
|
|
3079
|
+
model: string;
|
|
3080
|
+
params?: z.objectInputType<{
|
|
3081
|
+
use_cache: z.ZodOptional<z.ZodBoolean>;
|
|
3082
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
3083
|
+
top_p: z.ZodOptional<z.ZodNumber>;
|
|
3084
|
+
max_tokens: z.ZodOptional<z.ZodNumber>;
|
|
3085
|
+
max_completion_tokens: z.ZodOptional<z.ZodNumber>;
|
|
3086
|
+
frequency_penalty: z.ZodOptional<z.ZodNumber>;
|
|
3087
|
+
presence_penalty: z.ZodOptional<z.ZodNumber>;
|
|
3088
|
+
response_format: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodObject<{
|
|
3089
|
+
type: z.ZodLiteral<"json_object">;
|
|
3090
|
+
}, "strip", z.ZodTypeAny, {
|
|
3091
|
+
type: "json_object";
|
|
3092
|
+
}, {
|
|
3093
|
+
type: "json_object";
|
|
3094
|
+
}>, z.ZodObject<{
|
|
3095
|
+
type: z.ZodLiteral<"json_schema">;
|
|
3096
|
+
json_schema: z.ZodObject<{
|
|
3097
|
+
name: z.ZodString;
|
|
3098
|
+
description: z.ZodOptional<z.ZodString>;
|
|
3099
|
+
schema: z.ZodOptional<z.ZodUnion<[z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodString]>>;
|
|
3100
|
+
strict: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
3101
|
+
}, "strip", z.ZodTypeAny, {
|
|
3102
|
+
name: string;
|
|
3103
|
+
description?: string | undefined;
|
|
3104
|
+
schema?: string | Record<string, unknown> | undefined;
|
|
3105
|
+
strict?: boolean | null | undefined;
|
|
3106
|
+
}, {
|
|
3107
|
+
name: string;
|
|
3108
|
+
description?: string | undefined;
|
|
3109
|
+
schema?: string | Record<string, unknown> | undefined;
|
|
3110
|
+
strict?: boolean | null | undefined;
|
|
3111
|
+
}>;
|
|
3112
|
+
}, "strip", z.ZodTypeAny, {
|
|
3113
|
+
type: "json_schema";
|
|
3114
|
+
json_schema: {
|
|
3115
|
+
name: string;
|
|
3116
|
+
description?: string | undefined;
|
|
3117
|
+
schema?: string | Record<string, unknown> | undefined;
|
|
3118
|
+
strict?: boolean | null | undefined;
|
|
3119
|
+
};
|
|
3120
|
+
}, {
|
|
3121
|
+
type: "json_schema";
|
|
3122
|
+
json_schema: {
|
|
3123
|
+
name: string;
|
|
3124
|
+
description?: string | undefined;
|
|
3125
|
+
schema?: string | Record<string, unknown> | undefined;
|
|
3126
|
+
strict?: boolean | null | undefined;
|
|
3127
|
+
};
|
|
3128
|
+
}>, z.ZodObject<{
|
|
3129
|
+
type: z.ZodLiteral<"text">;
|
|
3130
|
+
}, "strip", z.ZodTypeAny, {
|
|
3131
|
+
type: "text";
|
|
3132
|
+
}, {
|
|
3133
|
+
type: "text";
|
|
3134
|
+
}>]>>>;
|
|
3135
|
+
tool_choice: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"auto">, z.ZodLiteral<"none">, z.ZodLiteral<"required">, z.ZodObject<{
|
|
3136
|
+
type: z.ZodLiteral<"function">;
|
|
3137
|
+
function: z.ZodObject<{
|
|
3138
|
+
name: z.ZodString;
|
|
3139
|
+
}, "strip", z.ZodTypeAny, {
|
|
3140
|
+
name: string;
|
|
3141
|
+
}, {
|
|
3142
|
+
name: string;
|
|
3143
|
+
}>;
|
|
3144
|
+
}, "strip", z.ZodTypeAny, {
|
|
3145
|
+
function: {
|
|
3146
|
+
name: string;
|
|
3147
|
+
};
|
|
3148
|
+
type: "function";
|
|
3149
|
+
}, {
|
|
3150
|
+
function: {
|
|
3151
|
+
name: string;
|
|
3152
|
+
};
|
|
3153
|
+
type: "function";
|
|
3154
|
+
}>]>>;
|
|
3155
|
+
function_call: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"auto">, z.ZodLiteral<"none">, z.ZodObject<{
|
|
3156
|
+
name: z.ZodString;
|
|
3157
|
+
}, "strip", z.ZodTypeAny, {
|
|
3158
|
+
name: string;
|
|
3159
|
+
}, {
|
|
3160
|
+
name: string;
|
|
3161
|
+
}>]>>;
|
|
3162
|
+
n: z.ZodOptional<z.ZodNumber>;
|
|
3163
|
+
stop: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
3164
|
+
reasoning_effort: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
|
|
3165
|
+
}, z.ZodTypeAny, "passthrough"> | z.objectInputType<{
|
|
3166
|
+
use_cache: z.ZodOptional<z.ZodBoolean>;
|
|
3167
|
+
max_tokens: z.ZodNumber;
|
|
3168
|
+
temperature: z.ZodNumber;
|
|
3169
|
+
top_p: z.ZodOptional<z.ZodNumber>;
|
|
3170
|
+
top_k: z.ZodOptional<z.ZodNumber>;
|
|
3171
|
+
stop_sequences: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
3172
|
+
max_tokens_to_sample: z.ZodOptional<z.ZodNumber>;
|
|
3173
|
+
}, z.ZodTypeAny, "passthrough"> | z.objectInputType<{
|
|
3174
|
+
use_cache: z.ZodOptional<z.ZodBoolean>;
|
|
3175
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
3176
|
+
maxOutputTokens: z.ZodOptional<z.ZodNumber>;
|
|
3177
|
+
topP: z.ZodOptional<z.ZodNumber>;
|
|
3178
|
+
topK: z.ZodOptional<z.ZodNumber>;
|
|
3179
|
+
}, z.ZodTypeAny, "passthrough"> | z.objectInputType<{
|
|
3180
|
+
use_cache: z.ZodOptional<z.ZodBoolean>;
|
|
3181
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
3182
|
+
topK: z.ZodOptional<z.ZodNumber>;
|
|
3183
|
+
}, z.ZodTypeAny, "passthrough"> | z.objectInputType<{
|
|
3184
|
+
use_cache: z.ZodOptional<z.ZodBoolean>;
|
|
3185
|
+
}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
3186
|
+
}>>, z.ZodObject<{
|
|
3187
|
+
tools: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
3188
|
+
type: z.ZodLiteral<"function">;
|
|
3189
|
+
function: z.ZodObject<{
|
|
3190
|
+
name: z.ZodString;
|
|
3191
|
+
description: z.ZodOptional<z.ZodString>;
|
|
3192
|
+
parameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
3193
|
+
strict: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
3194
|
+
}, "strip", z.ZodTypeAny, {
|
|
3195
|
+
name: string;
|
|
3196
|
+
description?: string | undefined;
|
|
3197
|
+
parameters?: Record<string, unknown> | undefined;
|
|
3198
|
+
strict?: boolean | null | undefined;
|
|
3199
|
+
}, {
|
|
3200
|
+
name: string;
|
|
3201
|
+
description?: string | undefined;
|
|
3202
|
+
parameters?: Record<string, unknown> | undefined;
|
|
3203
|
+
strict?: boolean | null | undefined;
|
|
3204
|
+
}>;
|
|
3205
|
+
}, "strip", z.ZodTypeAny, {
|
|
3206
|
+
function: {
|
|
3207
|
+
name: string;
|
|
3208
|
+
description?: string | undefined;
|
|
3209
|
+
parameters?: Record<string, unknown> | undefined;
|
|
3210
|
+
strict?: boolean | null | undefined;
|
|
3211
|
+
};
|
|
3212
|
+
type: "function";
|
|
3213
|
+
}, {
|
|
3214
|
+
function: {
|
|
3215
|
+
name: string;
|
|
3216
|
+
description?: string | undefined;
|
|
3217
|
+
parameters?: Record<string, unknown> | undefined;
|
|
3218
|
+
strict?: boolean | null | undefined;
|
|
3219
|
+
};
|
|
3220
|
+
type: "function";
|
|
3221
|
+
}>, "many">>;
|
|
3222
|
+
}, "strip", z.ZodTypeAny, {
|
|
3223
|
+
tools?: {
|
|
3224
|
+
function: {
|
|
3225
|
+
name: string;
|
|
3226
|
+
description?: string | undefined;
|
|
3227
|
+
parameters?: Record<string, unknown> | undefined;
|
|
3228
|
+
strict?: boolean | null | undefined;
|
|
3229
|
+
};
|
|
3230
|
+
type: "function";
|
|
3231
|
+
}[] | undefined;
|
|
3232
|
+
}, {
|
|
3233
|
+
tools?: {
|
|
3234
|
+
function: {
|
|
3235
|
+
name: string;
|
|
3236
|
+
description?: string | undefined;
|
|
3237
|
+
parameters?: Record<string, unknown> | undefined;
|
|
3238
|
+
strict?: boolean | null | undefined;
|
|
3239
|
+
};
|
|
3240
|
+
type: "function";
|
|
3241
|
+
}[] | undefined;
|
|
3242
|
+
}>>>;
|
|
3243
|
+
description: z.ZodOptional<z.ZodString>;
|
|
3244
|
+
}, "strip", z.ZodTypeAny, {
|
|
3245
|
+
type: "prompt";
|
|
3246
|
+
default?: ((({
|
|
3247
|
+
prompt: string;
|
|
3248
|
+
} | {
|
|
3249
|
+
messages: ({
|
|
3250
|
+
content: (string | {
|
|
3251
|
+
type: "text";
|
|
3252
|
+
text: string;
|
|
3253
|
+
cache_control?: {
|
|
3254
|
+
type: "ephemeral";
|
|
3255
|
+
} | undefined;
|
|
3256
|
+
}[]) & (string | {
|
|
3257
|
+
type: "text";
|
|
3258
|
+
text: string;
|
|
3259
|
+
cache_control?: {
|
|
3260
|
+
type: "ephemeral";
|
|
3261
|
+
} | undefined;
|
|
3262
|
+
}[] | undefined);
|
|
3263
|
+
role: "system";
|
|
3264
|
+
name?: string | undefined;
|
|
3265
|
+
} | {
|
|
3266
|
+
content: (string | ({
|
|
3267
|
+
type: "text";
|
|
3268
|
+
text: string;
|
|
3269
|
+
cache_control?: {
|
|
3270
|
+
type: "ephemeral";
|
|
3271
|
+
} | undefined;
|
|
3272
|
+
} | {
|
|
3273
|
+
type: "image_url";
|
|
3274
|
+
image_url: {
|
|
3275
|
+
url: string;
|
|
3276
|
+
detail?: "auto" | "low" | "high" | undefined;
|
|
3277
|
+
};
|
|
3278
|
+
})[]) & (string | ({
|
|
3279
|
+
type: "text";
|
|
3280
|
+
text: string;
|
|
3281
|
+
cache_control?: {
|
|
3282
|
+
type: "ephemeral";
|
|
3283
|
+
} | undefined;
|
|
3284
|
+
} | {
|
|
3285
|
+
type: "image_url";
|
|
3286
|
+
image_url: {
|
|
3287
|
+
url: string;
|
|
3288
|
+
detail?: "auto" | "low" | "high" | undefined;
|
|
3289
|
+
};
|
|
3290
|
+
})[] | undefined);
|
|
3291
|
+
role: "user";
|
|
3292
|
+
name?: string | undefined;
|
|
3293
|
+
} | {
|
|
3294
|
+
role: "assistant";
|
|
3295
|
+
content?: string | {
|
|
3296
|
+
type: "text";
|
|
3297
|
+
text: string;
|
|
3298
|
+
cache_control?: {
|
|
3299
|
+
type: "ephemeral";
|
|
3300
|
+
} | undefined;
|
|
3301
|
+
}[] | null | undefined;
|
|
3302
|
+
function_call?: {
|
|
3303
|
+
name: string;
|
|
3304
|
+
arguments: string;
|
|
3305
|
+
} | undefined;
|
|
3306
|
+
name?: string | undefined;
|
|
3307
|
+
tool_calls?: {
|
|
3308
|
+
function: {
|
|
3309
|
+
name: string;
|
|
3310
|
+
arguments: string;
|
|
3311
|
+
};
|
|
3312
|
+
type: "function";
|
|
3313
|
+
id: string;
|
|
3314
|
+
}[] | undefined;
|
|
3315
|
+
reasoning?: {
|
|
3316
|
+
id?: string | undefined;
|
|
3317
|
+
content?: string | undefined;
|
|
3318
|
+
}[] | undefined;
|
|
3319
|
+
} | {
|
|
3320
|
+
content: string;
|
|
3321
|
+
role: "tool";
|
|
3322
|
+
tool_call_id: string;
|
|
3323
|
+
} | {
|
|
3324
|
+
name: string;
|
|
3325
|
+
content: string | null;
|
|
3326
|
+
role: "function";
|
|
3327
|
+
} | {
|
|
3328
|
+
role: "model";
|
|
3329
|
+
content?: string | null | undefined;
|
|
3330
|
+
})[];
|
|
3331
|
+
}) & {
|
|
3332
|
+
model: string;
|
|
3333
|
+
params?: z.objectOutputType<{
|
|
3334
|
+
use_cache: z.ZodOptional<z.ZodBoolean>;
|
|
3335
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
3336
|
+
top_p: z.ZodOptional<z.ZodNumber>;
|
|
3337
|
+
max_tokens: z.ZodOptional<z.ZodNumber>;
|
|
3338
|
+
max_completion_tokens: z.ZodOptional<z.ZodNumber>;
|
|
3339
|
+
frequency_penalty: z.ZodOptional<z.ZodNumber>;
|
|
3340
|
+
presence_penalty: z.ZodOptional<z.ZodNumber>;
|
|
3341
|
+
response_format: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodObject<{
|
|
3342
|
+
type: z.ZodLiteral<"json_object">;
|
|
3343
|
+
}, "strip", z.ZodTypeAny, {
|
|
3344
|
+
type: "json_object";
|
|
3345
|
+
}, {
|
|
3346
|
+
type: "json_object";
|
|
3347
|
+
}>, z.ZodObject<{
|
|
3348
|
+
type: z.ZodLiteral<"json_schema">;
|
|
3349
|
+
json_schema: z.ZodObject<{
|
|
3350
|
+
name: z.ZodString;
|
|
3351
|
+
description: z.ZodOptional<z.ZodString>;
|
|
3352
|
+
schema: z.ZodOptional<z.ZodUnion<[z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodString]>>;
|
|
3353
|
+
strict: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
3354
|
+
}, "strip", z.ZodTypeAny, {
|
|
3355
|
+
name: string;
|
|
3356
|
+
description?: string | undefined;
|
|
3357
|
+
schema?: string | Record<string, unknown> | undefined;
|
|
3358
|
+
strict?: boolean | null | undefined;
|
|
3359
|
+
}, {
|
|
3360
|
+
name: string;
|
|
3361
|
+
description?: string | undefined;
|
|
3362
|
+
schema?: string | Record<string, unknown> | undefined;
|
|
3363
|
+
strict?: boolean | null | undefined;
|
|
3364
|
+
}>;
|
|
3365
|
+
}, "strip", z.ZodTypeAny, {
|
|
3366
|
+
type: "json_schema";
|
|
3367
|
+
json_schema: {
|
|
3368
|
+
name: string;
|
|
3369
|
+
description?: string | undefined;
|
|
3370
|
+
schema?: string | Record<string, unknown> | undefined;
|
|
3371
|
+
strict?: boolean | null | undefined;
|
|
3372
|
+
};
|
|
3373
|
+
}, {
|
|
3374
|
+
type: "json_schema";
|
|
3375
|
+
json_schema: {
|
|
3376
|
+
name: string;
|
|
3377
|
+
description?: string | undefined;
|
|
3378
|
+
schema?: string | Record<string, unknown> | undefined;
|
|
3379
|
+
strict?: boolean | null | undefined;
|
|
3380
|
+
};
|
|
3381
|
+
}>, z.ZodObject<{
|
|
3382
|
+
type: z.ZodLiteral<"text">;
|
|
3383
|
+
}, "strip", z.ZodTypeAny, {
|
|
3384
|
+
type: "text";
|
|
3385
|
+
}, {
|
|
3386
|
+
type: "text";
|
|
3387
|
+
}>]>>>;
|
|
3388
|
+
tool_choice: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"auto">, z.ZodLiteral<"none">, z.ZodLiteral<"required">, z.ZodObject<{
|
|
3389
|
+
type: z.ZodLiteral<"function">;
|
|
3390
|
+
function: z.ZodObject<{
|
|
3391
|
+
name: z.ZodString;
|
|
3392
|
+
}, "strip", z.ZodTypeAny, {
|
|
3393
|
+
name: string;
|
|
3394
|
+
}, {
|
|
3395
|
+
name: string;
|
|
3396
|
+
}>;
|
|
3397
|
+
}, "strip", z.ZodTypeAny, {
|
|
3398
|
+
function: {
|
|
3399
|
+
name: string;
|
|
3400
|
+
};
|
|
3401
|
+
type: "function";
|
|
3402
|
+
}, {
|
|
3403
|
+
function: {
|
|
3404
|
+
name: string;
|
|
3405
|
+
};
|
|
3406
|
+
type: "function";
|
|
3407
|
+
}>]>>;
|
|
3408
|
+
function_call: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"auto">, z.ZodLiteral<"none">, z.ZodObject<{
|
|
3409
|
+
name: z.ZodString;
|
|
3410
|
+
}, "strip", z.ZodTypeAny, {
|
|
3411
|
+
name: string;
|
|
3412
|
+
}, {
|
|
3413
|
+
name: string;
|
|
3414
|
+
}>]>>;
|
|
3415
|
+
n: z.ZodOptional<z.ZodNumber>;
|
|
3416
|
+
stop: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
3417
|
+
reasoning_effort: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
|
|
3418
|
+
}, z.ZodTypeAny, "passthrough"> | z.objectOutputType<{
|
|
3419
|
+
use_cache: z.ZodOptional<z.ZodBoolean>;
|
|
3420
|
+
max_tokens: z.ZodNumber;
|
|
3421
|
+
temperature: z.ZodNumber;
|
|
3422
|
+
top_p: z.ZodOptional<z.ZodNumber>;
|
|
3423
|
+
top_k: z.ZodOptional<z.ZodNumber>;
|
|
3424
|
+
stop_sequences: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
3425
|
+
max_tokens_to_sample: z.ZodOptional<z.ZodNumber>;
|
|
3426
|
+
}, z.ZodTypeAny, "passthrough"> | z.objectOutputType<{
|
|
3427
|
+
use_cache: z.ZodOptional<z.ZodBoolean>;
|
|
3428
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
3429
|
+
maxOutputTokens: z.ZodOptional<z.ZodNumber>;
|
|
3430
|
+
topP: z.ZodOptional<z.ZodNumber>;
|
|
3431
|
+
topK: z.ZodOptional<z.ZodNumber>;
|
|
3432
|
+
}, z.ZodTypeAny, "passthrough"> | z.objectOutputType<{
|
|
3433
|
+
use_cache: z.ZodOptional<z.ZodBoolean>;
|
|
3434
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
3435
|
+
topK: z.ZodOptional<z.ZodNumber>;
|
|
3436
|
+
}, z.ZodTypeAny, "passthrough"> | z.objectOutputType<{
|
|
3437
|
+
use_cache: z.ZodOptional<z.ZodBoolean>;
|
|
3438
|
+
}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
3439
|
+
}) & {
|
|
3440
|
+
tools?: {
|
|
3441
|
+
function: {
|
|
3442
|
+
name: string;
|
|
3443
|
+
description?: string | undefined;
|
|
3444
|
+
parameters?: Record<string, unknown> | undefined;
|
|
3445
|
+
strict?: boolean | null | undefined;
|
|
3446
|
+
};
|
|
3447
|
+
type: "function";
|
|
3448
|
+
}[] | undefined;
|
|
3449
|
+
}) | undefined;
|
|
3450
|
+
description?: string | undefined;
|
|
3451
|
+
}, {
|
|
3452
|
+
type: "prompt";
|
|
3453
|
+
default?: ((({
|
|
3454
|
+
prompt: string;
|
|
3455
|
+
} | {
|
|
3456
|
+
messages: ({
|
|
3457
|
+
role: "system";
|
|
3458
|
+
content?: string | {
|
|
3459
|
+
type: "text";
|
|
3460
|
+
text?: string | undefined;
|
|
3461
|
+
cache_control?: {
|
|
3462
|
+
type: "ephemeral";
|
|
3463
|
+
} | undefined;
|
|
3464
|
+
}[] | undefined;
|
|
3465
|
+
name?: string | undefined;
|
|
3466
|
+
} | {
|
|
3467
|
+
role: "user";
|
|
3468
|
+
content?: string | ({
|
|
3469
|
+
type: "text";
|
|
3470
|
+
text?: string | undefined;
|
|
3471
|
+
cache_control?: {
|
|
3472
|
+
type: "ephemeral";
|
|
3473
|
+
} | undefined;
|
|
3474
|
+
} | {
|
|
3475
|
+
type: "image_url";
|
|
3476
|
+
image_url: {
|
|
3477
|
+
url: string;
|
|
3478
|
+
detail?: "auto" | "low" | "high" | undefined;
|
|
3479
|
+
};
|
|
3480
|
+
})[] | undefined;
|
|
3481
|
+
name?: string | undefined;
|
|
3482
|
+
} | {
|
|
3483
|
+
role: "assistant";
|
|
3484
|
+
content?: string | {
|
|
3485
|
+
type: "text";
|
|
3486
|
+
text?: string | undefined;
|
|
3487
|
+
cache_control?: {
|
|
3488
|
+
type: "ephemeral";
|
|
3489
|
+
} | undefined;
|
|
3490
|
+
}[] | null | undefined;
|
|
3491
|
+
function_call?: {
|
|
3492
|
+
name: string;
|
|
3493
|
+
arguments: string;
|
|
3494
|
+
} | null | undefined;
|
|
3495
|
+
name?: string | null | undefined;
|
|
3496
|
+
tool_calls?: {
|
|
3497
|
+
function: {
|
|
3498
|
+
name: string;
|
|
3499
|
+
arguments: string;
|
|
3500
|
+
};
|
|
3501
|
+
type: "function";
|
|
3502
|
+
id: string;
|
|
3503
|
+
}[] | null | undefined;
|
|
3504
|
+
reasoning?: {
|
|
3505
|
+
id?: string | null | undefined;
|
|
3506
|
+
content?: string | null | undefined;
|
|
3507
|
+
}[] | null | undefined;
|
|
3508
|
+
} | {
|
|
3509
|
+
role: "tool";
|
|
3510
|
+
content?: string | undefined;
|
|
3511
|
+
tool_call_id?: string | undefined;
|
|
3512
|
+
} | {
|
|
3513
|
+
name: string;
|
|
3514
|
+
content: string | null;
|
|
3515
|
+
role: "function";
|
|
3516
|
+
} | {
|
|
3517
|
+
role: "model";
|
|
3518
|
+
content?: string | null | undefined;
|
|
3519
|
+
})[];
|
|
3520
|
+
}) & {
|
|
3521
|
+
model: string;
|
|
3522
|
+
params?: z.objectInputType<{
|
|
3523
|
+
use_cache: z.ZodOptional<z.ZodBoolean>;
|
|
3524
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
3525
|
+
top_p: z.ZodOptional<z.ZodNumber>;
|
|
3526
|
+
max_tokens: z.ZodOptional<z.ZodNumber>;
|
|
3527
|
+
max_completion_tokens: z.ZodOptional<z.ZodNumber>;
|
|
3528
|
+
frequency_penalty: z.ZodOptional<z.ZodNumber>;
|
|
3529
|
+
presence_penalty: z.ZodOptional<z.ZodNumber>;
|
|
3530
|
+
response_format: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodObject<{
|
|
3531
|
+
type: z.ZodLiteral<"json_object">;
|
|
3532
|
+
}, "strip", z.ZodTypeAny, {
|
|
3533
|
+
type: "json_object";
|
|
3534
|
+
}, {
|
|
3535
|
+
type: "json_object";
|
|
3536
|
+
}>, z.ZodObject<{
|
|
3537
|
+
type: z.ZodLiteral<"json_schema">;
|
|
3538
|
+
json_schema: z.ZodObject<{
|
|
3539
|
+
name: z.ZodString;
|
|
3540
|
+
description: z.ZodOptional<z.ZodString>;
|
|
3541
|
+
schema: z.ZodOptional<z.ZodUnion<[z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodString]>>;
|
|
3542
|
+
strict: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
3543
|
+
}, "strip", z.ZodTypeAny, {
|
|
3544
|
+
name: string;
|
|
3545
|
+
description?: string | undefined;
|
|
3546
|
+
schema?: string | Record<string, unknown> | undefined;
|
|
3547
|
+
strict?: boolean | null | undefined;
|
|
3548
|
+
}, {
|
|
3549
|
+
name: string;
|
|
3550
|
+
description?: string | undefined;
|
|
3551
|
+
schema?: string | Record<string, unknown> | undefined;
|
|
3552
|
+
strict?: boolean | null | undefined;
|
|
3553
|
+
}>;
|
|
3554
|
+
}, "strip", z.ZodTypeAny, {
|
|
3555
|
+
type: "json_schema";
|
|
3556
|
+
json_schema: {
|
|
3557
|
+
name: string;
|
|
3558
|
+
description?: string | undefined;
|
|
3559
|
+
schema?: string | Record<string, unknown> | undefined;
|
|
3560
|
+
strict?: boolean | null | undefined;
|
|
3561
|
+
};
|
|
3562
|
+
}, {
|
|
3563
|
+
type: "json_schema";
|
|
3564
|
+
json_schema: {
|
|
3565
|
+
name: string;
|
|
3566
|
+
description?: string | undefined;
|
|
3567
|
+
schema?: string | Record<string, unknown> | undefined;
|
|
3568
|
+
strict?: boolean | null | undefined;
|
|
3569
|
+
};
|
|
3570
|
+
}>, z.ZodObject<{
|
|
3571
|
+
type: z.ZodLiteral<"text">;
|
|
3572
|
+
}, "strip", z.ZodTypeAny, {
|
|
3573
|
+
type: "text";
|
|
3574
|
+
}, {
|
|
3575
|
+
type: "text";
|
|
3576
|
+
}>]>>>;
|
|
3577
|
+
tool_choice: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"auto">, z.ZodLiteral<"none">, z.ZodLiteral<"required">, z.ZodObject<{
|
|
3578
|
+
type: z.ZodLiteral<"function">;
|
|
3579
|
+
function: z.ZodObject<{
|
|
3580
|
+
name: z.ZodString;
|
|
3581
|
+
}, "strip", z.ZodTypeAny, {
|
|
3582
|
+
name: string;
|
|
3583
|
+
}, {
|
|
3584
|
+
name: string;
|
|
3585
|
+
}>;
|
|
3586
|
+
}, "strip", z.ZodTypeAny, {
|
|
3587
|
+
function: {
|
|
3588
|
+
name: string;
|
|
3589
|
+
};
|
|
3590
|
+
type: "function";
|
|
3591
|
+
}, {
|
|
3592
|
+
function: {
|
|
3593
|
+
name: string;
|
|
3594
|
+
};
|
|
3595
|
+
type: "function";
|
|
3596
|
+
}>]>>;
|
|
3597
|
+
function_call: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"auto">, z.ZodLiteral<"none">, z.ZodObject<{
|
|
3598
|
+
name: z.ZodString;
|
|
3599
|
+
}, "strip", z.ZodTypeAny, {
|
|
3600
|
+
name: string;
|
|
3601
|
+
}, {
|
|
3602
|
+
name: string;
|
|
3603
|
+
}>]>>;
|
|
3604
|
+
n: z.ZodOptional<z.ZodNumber>;
|
|
3605
|
+
stop: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
3606
|
+
reasoning_effort: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
|
|
3607
|
+
}, z.ZodTypeAny, "passthrough"> | z.objectInputType<{
|
|
3608
|
+
use_cache: z.ZodOptional<z.ZodBoolean>;
|
|
3609
|
+
max_tokens: z.ZodNumber;
|
|
3610
|
+
temperature: z.ZodNumber;
|
|
3611
|
+
top_p: z.ZodOptional<z.ZodNumber>;
|
|
3612
|
+
top_k: z.ZodOptional<z.ZodNumber>;
|
|
3613
|
+
stop_sequences: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
3614
|
+
max_tokens_to_sample: z.ZodOptional<z.ZodNumber>;
|
|
3615
|
+
}, z.ZodTypeAny, "passthrough"> | z.objectInputType<{
|
|
3616
|
+
use_cache: z.ZodOptional<z.ZodBoolean>;
|
|
3617
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
3618
|
+
maxOutputTokens: z.ZodOptional<z.ZodNumber>;
|
|
3619
|
+
topP: z.ZodOptional<z.ZodNumber>;
|
|
3620
|
+
topK: z.ZodOptional<z.ZodNumber>;
|
|
3621
|
+
}, z.ZodTypeAny, "passthrough"> | z.objectInputType<{
|
|
3622
|
+
use_cache: z.ZodOptional<z.ZodBoolean>;
|
|
3623
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
3624
|
+
topK: z.ZodOptional<z.ZodNumber>;
|
|
3625
|
+
}, z.ZodTypeAny, "passthrough"> | z.objectInputType<{
|
|
3626
|
+
use_cache: z.ZodOptional<z.ZodBoolean>;
|
|
3627
|
+
}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
3628
|
+
}) & {
|
|
3629
|
+
tools?: {
|
|
3630
|
+
function: {
|
|
3631
|
+
name: string;
|
|
3632
|
+
description?: string | undefined;
|
|
3633
|
+
parameters?: Record<string, unknown> | undefined;
|
|
3634
|
+
strict?: boolean | null | undefined;
|
|
3635
|
+
};
|
|
3636
|
+
type: "function";
|
|
3637
|
+
}[] | undefined;
|
|
3638
|
+
}) | undefined;
|
|
3639
|
+
description?: string | undefined;
|
|
3640
|
+
}>, z.ZodType<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeDef, z.ZodType<unknown, z.ZodTypeDef, unknown>>]>>;
|
|
3641
|
+
type EvalParameters = z.infer<typeof evalParametersSchema>;
|
|
3642
|
+
type InferParameterValue<T> = T extends {
|
|
3643
|
+
type: "prompt";
|
|
3644
|
+
} ? Prompt : T extends z.ZodType ? z.infer<T> : never;
|
|
3645
|
+
type InferParameters<T extends EvalParameters> = {
|
|
3646
|
+
[K in keyof T]: InferParameterValue<T[K]>;
|
|
3647
|
+
};
|
|
3648
|
+
|
|
3649
|
+
type BaseExperiment<Input, Expected, Metadata extends BaseMetadata = DefaultMetadataType> = {
|
|
3650
|
+
_type: "BaseExperiment";
|
|
3651
|
+
_phantom?: [Input, Expected, Metadata];
|
|
3652
|
+
name?: string;
|
|
3653
|
+
};
|
|
3654
|
+
/**
|
|
3655
|
+
* Use this to specify that the dataset should actually be the data from a previous (base) experiment.
|
|
3656
|
+
* If you do not specify a name, Braintrust will automatically figure out the best base experiment to
|
|
3657
|
+
* use based on your git history (or fall back to timestamps).
|
|
3658
|
+
*
|
|
3659
|
+
* @param options
|
|
3660
|
+
* @param options.name The name of the base experiment to use. If unspecified, Braintrust will automatically figure out the best base
|
|
3661
|
+
* using your git history (or fall back to timestamps).
|
|
3662
|
+
* @returns
|
|
3663
|
+
*/
|
|
3664
|
+
declare function BaseExperiment<Input = unknown, Expected = unknown, Metadata extends BaseMetadata = DefaultMetadataType>(options?: {
|
|
3665
|
+
name?: string;
|
|
3666
|
+
}): BaseExperiment<Input, Expected, Metadata>;
|
|
3667
|
+
type EvalData<Input, Expected, Metadata extends BaseMetadata = DefaultMetadataType> = EvalCase<Input, Expected, Metadata>[] | (() => EvalCase<Input, Expected, Metadata>[]) | Promise<EvalCase<Input, Expected, Metadata>[]> | (() => Promise<EvalCase<Input, Expected, Metadata>[]>) | AsyncGenerator<EvalCase<Input, Expected, Metadata>> | AsyncIterable<EvalCase<Input, Expected, Metadata>> | BaseExperiment<Input, Expected, Metadata> | (() => BaseExperiment<Input, Expected, Metadata>);
|
|
3668
|
+
type EvalTask<Input, Output, Expected, Metadata extends BaseMetadata, Parameters extends EvalParameters> = ((input: Input, hooks: EvalHooks<Expected, Metadata, Parameters>) => Promise<Output>) | ((input: Input, hooks: EvalHooks<Expected, Metadata, Parameters>) => Output);
|
|
3669
|
+
type TaskProgressEvent = Omit<SSEProgressEventData, "id" | "origin" | "object_type" | "name">;
|
|
3670
|
+
interface EvalHooks<Expected, Metadata extends BaseMetadata, Parameters extends EvalParameters> {
|
|
3671
|
+
/**
|
|
3672
|
+
* @deprecated Use `metadata` instead.
|
|
3673
|
+
*/
|
|
3674
|
+
meta: (info: Metadata) => void;
|
|
3675
|
+
/**
|
|
3676
|
+
* The metadata object for the current evaluation. You can mutate this object to add or remove metadata.
|
|
3677
|
+
*/
|
|
3678
|
+
metadata: Metadata extends void ? Record<string, unknown> : Metadata;
|
|
3679
|
+
/**
|
|
3680
|
+
* The expected output for the current evaluation.
|
|
3681
|
+
*/
|
|
3682
|
+
expected: Expected;
|
|
3683
|
+
/**
|
|
3684
|
+
* The task's span.
|
|
3685
|
+
*/
|
|
3686
|
+
span: Span;
|
|
3687
|
+
/**
|
|
3688
|
+
* The current parameters being used for this specific task execution.
|
|
3689
|
+
* Array parameters are converted to single values.
|
|
3690
|
+
*/
|
|
3691
|
+
parameters: InferParameters<Parameters>;
|
|
3692
|
+
/**
|
|
3693
|
+
* Report progress that will show up in the playground.
|
|
3694
|
+
*/
|
|
3695
|
+
reportProgress: (progress: TaskProgressEvent) => void;
|
|
3696
|
+
}
|
|
3697
|
+
type EvalScorerArgs<Input, Output, Expected, Metadata extends BaseMetadata = DefaultMetadataType> = EvalCase<Input, Expected, Metadata> & {
|
|
3698
|
+
output: Output;
|
|
3699
|
+
};
|
|
3700
|
+
type OneOrMoreScores = Score | number | null | Array<Score>;
|
|
3701
|
+
type EvalScorer<Input, Output, Expected, Metadata extends BaseMetadata = DefaultMetadataType> = (args: EvalScorerArgs<Input, Output, Expected, Metadata>) => OneOrMoreScores | Promise<OneOrMoreScores>;
|
|
3702
|
+
type EvalResult<Input, Output, Expected, Metadata extends BaseMetadata = DefaultMetadataType> = EvalCase<Input, Expected, Metadata> & {
|
|
3703
|
+
output: Output;
|
|
3704
|
+
scores: Record<string, number | null>;
|
|
3705
|
+
error: unknown;
|
|
3706
|
+
origin?: ObjectReference;
|
|
3707
|
+
};
|
|
3708
|
+
type ErrorScoreHandler = (args: {
|
|
3709
|
+
rootSpan: Span;
|
|
3710
|
+
data: EvalCase<any, any, any>;
|
|
3711
|
+
unhandledScores: string[];
|
|
3712
|
+
}) => Record<string, number> | undefined | void;
|
|
3713
|
+
interface Evaluator<Input, Output, Expected, Metadata extends BaseMetadata = DefaultMetadataType, Parameters extends EvalParameters = EvalParameters> {
|
|
3714
|
+
/**
|
|
3715
|
+
* A function that returns a list of inputs, expected outputs, and metadata.
|
|
3716
|
+
*/
|
|
3717
|
+
data: EvalData<Input, Expected, Metadata>;
|
|
3718
|
+
/**
|
|
3719
|
+
* A function that takes an input and returns an output.
|
|
3720
|
+
*/
|
|
3721
|
+
task: EvalTask<Input, Output, Expected, Metadata, Parameters>;
|
|
3722
|
+
/**
|
|
3723
|
+
* A set of functions that take an input, output, and expected value and return a score.
|
|
3724
|
+
*/
|
|
3725
|
+
scores: EvalScorer<Input, Output, Expected, Metadata>[];
|
|
3726
|
+
/**
|
|
3727
|
+
* A set of parameters that will be passed to the evaluator.
|
|
3728
|
+
* Can contain array values that will be converted to single values in the task.
|
|
3729
|
+
*/
|
|
3730
|
+
parameters?: Parameters;
|
|
3731
|
+
/**
|
|
3732
|
+
* An optional name for the experiment.
|
|
3733
|
+
*/
|
|
3734
|
+
experimentName?: string;
|
|
3735
|
+
/**
|
|
3736
|
+
* An optional description for the experiment.
|
|
3737
|
+
*/
|
|
3738
|
+
description?: string;
|
|
3739
|
+
/**
|
|
3740
|
+
* The number of times to run the evaluator per input. This is useful for evaluating applications that
|
|
3741
|
+
* have non-deterministic behavior and gives you both a stronger aggregate measure and a sense of the
|
|
3742
|
+
* variance in the results.
|
|
3743
|
+
*/
|
|
3744
|
+
trialCount?: number;
|
|
3745
|
+
/**
|
|
3746
|
+
* Optional additional metadata for the experiment.
|
|
3747
|
+
*/
|
|
3748
|
+
metadata?: Record<string, unknown>;
|
|
3749
|
+
/**
|
|
3750
|
+
* Whether the experiment should be public. Defaults to false.
|
|
3751
|
+
*/
|
|
3752
|
+
isPublic?: boolean;
|
|
3753
|
+
/**
|
|
3754
|
+
* Whether to update an existing experiment with `experiment_name` if one exists. Defaults to false.
|
|
3755
|
+
*/
|
|
3756
|
+
update?: boolean;
|
|
3757
|
+
/**
|
|
3758
|
+
* The duration, in milliseconds, after which to time out the evaluation.
|
|
3759
|
+
* Defaults to undefined, in which case there is no timeout.
|
|
3760
|
+
*/
|
|
3761
|
+
timeout?: number;
|
|
3762
|
+
/**
|
|
3763
|
+
* An abort signal that can be used to stop the evaluation.
|
|
3764
|
+
*/
|
|
3765
|
+
signal?: AbortSignal;
|
|
3766
|
+
/**
|
|
3767
|
+
* The maximum number of tasks/scorers that will be run concurrently.
|
|
3768
|
+
* Defaults to undefined, in which case there is no max concurrency.
|
|
3769
|
+
*/
|
|
3770
|
+
maxConcurrency?: number;
|
|
3771
|
+
/**
|
|
3772
|
+
* If specified, uses the given project ID instead of the evaluator's name to identify the project.
|
|
3773
|
+
*/
|
|
3774
|
+
projectId?: string;
|
|
3775
|
+
/**
|
|
3776
|
+
* If specified, uses the logger state to initialize Braintrust objects. If unspecified, falls back
|
|
3777
|
+
* to the global state (initialized using your API key).
|
|
3778
|
+
*/
|
|
3779
|
+
state?: BraintrustState;
|
|
3780
|
+
/**
|
|
3781
|
+
* An optional experiment name to use as a base. If specified, the new experiment will be summarized
|
|
3782
|
+
* and compared to this experiment.
|
|
3783
|
+
*/
|
|
3784
|
+
baseExperimentName?: string;
|
|
3785
|
+
/**
|
|
3786
|
+
* An optional experiment id to use as a base. If specified, the new experiment will be summarized
|
|
3787
|
+
* and compared to this experiment. This takes precedence over `baseExperimentName` if specified.
|
|
3788
|
+
*/
|
|
3789
|
+
baseExperimentId?: string;
|
|
3790
|
+
/**
|
|
3791
|
+
* Optional settings for collecting git metadata. By default, will collect all git metadata fields allowed in org-level settings.
|
|
3792
|
+
*/
|
|
3793
|
+
gitMetadataSettings?: GitMetadataSettings;
|
|
3794
|
+
/**
|
|
3795
|
+
* Optionally explicitly specify the git metadata for this experiment. This takes precedence over `gitMetadataSettings` if specified.
|
|
3796
|
+
*/
|
|
3797
|
+
repoInfo?: RepoInfo;
|
|
3798
|
+
/**
|
|
3799
|
+
* Optionally supply a custom function to specifically handle score values when tasks or scoring functions have errored.
|
|
3800
|
+
* A default implementation is exported as `defaultErrorScoreHandler` which will log a 0 score to the root span for any scorer that was not run.
|
|
3801
|
+
*/
|
|
3802
|
+
errorScoreHandler?: ErrorScoreHandler;
|
|
3803
|
+
/**
|
|
3804
|
+
* Whether to summarize the scores of the experiment after it has run.
|
|
3805
|
+
* Defaults to true.
|
|
3806
|
+
*/
|
|
3807
|
+
summarizeScores?: boolean;
|
|
3808
|
+
}
|
|
3809
|
+
declare class EvalResultWithSummary<Input, Output, Expected, Metadata extends BaseMetadata = DefaultMetadataType> {
|
|
3810
|
+
summary: ExperimentSummary;
|
|
3811
|
+
results: EvalResult<Input, Output, Expected, Metadata>[];
|
|
3812
|
+
constructor(summary: ExperimentSummary, results: EvalResult<Input, Output, Expected, Metadata>[]);
|
|
3813
|
+
toString(): string;
|
|
3814
|
+
toJSON(): {
|
|
3815
|
+
summary: ExperimentSummary;
|
|
3816
|
+
results: EvalResult<Input, Output, Expected, Metadata>[];
|
|
3817
|
+
};
|
|
3818
|
+
}
|
|
3819
|
+
interface ReporterOpts {
|
|
3820
|
+
verbose: boolean;
|
|
3821
|
+
jsonl: boolean;
|
|
3822
|
+
}
|
|
3823
|
+
interface ReporterBody<EvalReport> {
|
|
3824
|
+
/**
|
|
3825
|
+
* A function that takes an evaluator and its result and returns a report.
|
|
3826
|
+
*
|
|
3827
|
+
* @param evaluator
|
|
3828
|
+
* @param result
|
|
3829
|
+
* @param opts
|
|
3830
|
+
*/
|
|
3831
|
+
reportEval(evaluator: EvaluatorDef<any, any, any, any, any>, result: EvalResultWithSummary<any, any, any, any>, opts: ReporterOpts): Promise<EvalReport> | EvalReport;
|
|
3832
|
+
/**
|
|
3833
|
+
* A function that takes all evaluator results and returns a boolean indicating
|
|
3834
|
+
* whether the run was successful. If you return false, the `braintrust eval`
|
|
3835
|
+
* command will exit with a non-zero status code.
|
|
3836
|
+
*
|
|
3837
|
+
* @param reports
|
|
3838
|
+
*/
|
|
3839
|
+
reportRun(reports: EvalReport[]): boolean | Promise<boolean>;
|
|
3840
|
+
}
|
|
3841
|
+
type ReporterDef<EvalReport> = {
|
|
3842
|
+
name: string;
|
|
3843
|
+
} & ReporterBody<EvalReport>;
|
|
3844
|
+
type EvaluatorDef<Input, Output, Expected, Metadata extends BaseMetadata = DefaultMetadataType, Parameters extends EvalParameters = EvalParameters> = {
|
|
3845
|
+
projectName: string;
|
|
3846
|
+
evalName: string;
|
|
3847
|
+
} & Evaluator<Input, Output, Expected, Metadata, Parameters>;
|
|
3848
|
+
type EvaluatorFile = {
|
|
3849
|
+
functions: CodeFunction<unknown, unknown, GenericFunction<unknown, unknown>>[];
|
|
3850
|
+
prompts: CodePrompt[];
|
|
3851
|
+
evaluators: {
|
|
3852
|
+
[evalName: string]: {
|
|
3853
|
+
evaluator: EvaluatorDef<unknown, unknown, unknown, BaseMetadata, EvalParameters>;
|
|
3854
|
+
reporter?: ReporterDef<unknown> | string;
|
|
3855
|
+
};
|
|
3856
|
+
};
|
|
3857
|
+
reporters: {
|
|
3858
|
+
[reporterName: string]: ReporterDef<unknown>;
|
|
3859
|
+
};
|
|
3860
|
+
};
|
|
3861
|
+
type SpanContext = {
|
|
3862
|
+
currentSpan: typeof currentSpan;
|
|
3863
|
+
startSpan: typeof startSpan;
|
|
3864
|
+
withCurrent: typeof withCurrent;
|
|
3865
|
+
NOOP_SPAN: typeof NOOP_SPAN;
|
|
3866
|
+
};
|
|
3867
|
+
declare global {
|
|
3868
|
+
var _evals: EvaluatorFile;
|
|
3869
|
+
var _spanContext: SpanContext | undefined;
|
|
3870
|
+
var _lazy_load: boolean;
|
|
3871
|
+
}
|
|
3872
|
+
|
|
3873
|
+
interface DevServerOpts {
|
|
3874
|
+
host: string;
|
|
3875
|
+
port: number;
|
|
3876
|
+
}
|
|
3877
|
+
declare function runDevServer(evaluators: EvaluatorDef<any, any, any, any, any>[], opts: DevServerOpts): void;
|
|
3878
|
+
|
|
3879
|
+
export { runDevServer };
|