ai 3.1.0-canary.4 → 3.1.0

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.
Files changed (69) hide show
  1. package/dist/index.d.mts +982 -24
  2. package/dist/index.d.ts +982 -24
  3. package/dist/index.js +1748 -175
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +1723 -174
  6. package/dist/index.mjs.map +1 -1
  7. package/package.json +11 -28
  8. package/prompts/dist/index.d.mts +13 -1
  9. package/prompts/dist/index.d.ts +13 -1
  10. package/prompts/dist/index.js +13 -0
  11. package/prompts/dist/index.js.map +1 -1
  12. package/prompts/dist/index.mjs +12 -0
  13. package/prompts/dist/index.mjs.map +1 -1
  14. package/react/dist/index.d.mts +23 -6
  15. package/react/dist/index.d.ts +27 -8
  16. package/react/dist/index.js +154 -141
  17. package/react/dist/index.js.map +1 -1
  18. package/react/dist/index.mjs +153 -141
  19. package/react/dist/index.mjs.map +1 -1
  20. package/react/dist/index.server.d.mts +4 -2
  21. package/react/dist/index.server.d.ts +4 -2
  22. package/react/dist/index.server.js.map +1 -1
  23. package/react/dist/index.server.mjs.map +1 -1
  24. package/rsc/dist/index.d.ts +385 -20
  25. package/rsc/dist/rsc-client.d.mts +1 -1
  26. package/rsc/dist/rsc-client.mjs +2 -0
  27. package/rsc/dist/rsc-client.mjs.map +1 -1
  28. package/rsc/dist/rsc-server.d.mts +367 -20
  29. package/rsc/dist/rsc-server.mjs +676 -35
  30. package/rsc/dist/rsc-server.mjs.map +1 -1
  31. package/rsc/dist/rsc-shared.d.mts +24 -9
  32. package/rsc/dist/rsc-shared.mjs +98 -4
  33. package/rsc/dist/rsc-shared.mjs.map +1 -1
  34. package/solid/dist/index.d.mts +7 -3
  35. package/solid/dist/index.d.ts +7 -3
  36. package/solid/dist/index.js +106 -107
  37. package/solid/dist/index.js.map +1 -1
  38. package/solid/dist/index.mjs +106 -107
  39. package/solid/dist/index.mjs.map +1 -1
  40. package/svelte/dist/index.d.mts +7 -3
  41. package/svelte/dist/index.d.ts +7 -3
  42. package/svelte/dist/index.js +109 -109
  43. package/svelte/dist/index.js.map +1 -1
  44. package/svelte/dist/index.mjs +109 -109
  45. package/svelte/dist/index.mjs.map +1 -1
  46. package/vue/dist/index.d.mts +7 -3
  47. package/vue/dist/index.d.ts +7 -3
  48. package/vue/dist/index.js +106 -107
  49. package/vue/dist/index.js.map +1 -1
  50. package/vue/dist/index.mjs +106 -107
  51. package/vue/dist/index.mjs.map +1 -1
  52. package/ai-model-specification/dist/index.d.mts +0 -665
  53. package/ai-model-specification/dist/index.d.ts +0 -665
  54. package/ai-model-specification/dist/index.js +0 -716
  55. package/ai-model-specification/dist/index.js.map +0 -1
  56. package/ai-model-specification/dist/index.mjs +0 -656
  57. package/ai-model-specification/dist/index.mjs.map +0 -1
  58. package/core/dist/index.d.mts +0 -626
  59. package/core/dist/index.d.ts +0 -626
  60. package/core/dist/index.js +0 -1918
  61. package/core/dist/index.js.map +0 -1
  62. package/core/dist/index.mjs +0 -1873
  63. package/core/dist/index.mjs.map +0 -1
  64. package/openai/dist/index.d.mts +0 -429
  65. package/openai/dist/index.d.ts +0 -429
  66. package/openai/dist/index.js +0 -1231
  67. package/openai/dist/index.js.map +0 -1
  68. package/openai/dist/index.mjs +0 -1195
  69. package/openai/dist/index.mjs.map +0 -1
@@ -1,665 +0,0 @@
1
- import * as zod from 'zod';
2
- import { ZodSchema } from 'zod';
3
-
4
- declare class APICallError extends Error {
5
- readonly url: string;
6
- readonly requestBodyValues: unknown;
7
- readonly statusCode?: number;
8
- readonly responseBody?: string;
9
- readonly cause?: unknown;
10
- readonly isRetryable: boolean;
11
- readonly data?: unknown;
12
- constructor({ message, url, requestBodyValues, statusCode, responseBody, cause, isRetryable, // server error
13
- data, }: {
14
- message: string;
15
- url: string;
16
- requestBodyValues: unknown;
17
- statusCode?: number;
18
- responseBody?: string;
19
- cause?: unknown;
20
- isRetryable?: boolean;
21
- data?: unknown;
22
- });
23
- static isAPICallError(error: unknown): error is APICallError;
24
- toJSON(): {
25
- name: string;
26
- message: string;
27
- url: string;
28
- requestBodyValues: unknown;
29
- statusCode: number | undefined;
30
- responseBody: string | undefined;
31
- cause: unknown;
32
- isRetryable: boolean;
33
- data: unknown;
34
- };
35
- }
36
-
37
- declare class InvalidArgumentError extends Error {
38
- readonly parameter: string;
39
- readonly value: unknown;
40
- constructor({ parameter, value, message, }: {
41
- parameter: string;
42
- value: unknown;
43
- message: string;
44
- });
45
- static isInvalidArgumentError(error: unknown): error is InvalidArgumentError;
46
- toJSON(): {
47
- name: string;
48
- message: string;
49
- stack: string | undefined;
50
- parameter: string;
51
- value: unknown;
52
- };
53
- }
54
-
55
- declare class InvalidPromptError extends Error {
56
- readonly prompt: unknown;
57
- constructor({ prompt, message }: {
58
- prompt: unknown;
59
- message: string;
60
- });
61
- static isInvalidPromptError(error: unknown): error is InvalidPromptError;
62
- toJSON(): {
63
- name: string;
64
- message: string;
65
- stack: string | undefined;
66
- prompt: unknown;
67
- };
68
- }
69
-
70
- declare class InvalidToolArgumentsError extends Error {
71
- readonly toolName: string;
72
- readonly toolArgs: string;
73
- readonly cause: unknown;
74
- constructor({ toolArgs, toolName, cause, message, }: {
75
- message?: string;
76
- toolArgs: string;
77
- toolName: string;
78
- cause: unknown;
79
- });
80
- static isInvalidToolArgumentsError(error: unknown): error is InvalidToolArgumentsError;
81
- toJSON(): {
82
- name: string;
83
- message: string;
84
- cause: unknown;
85
- stack: string | undefined;
86
- toolName: string;
87
- toolArgs: string;
88
- };
89
- }
90
-
91
- declare class JSONParseError extends Error {
92
- readonly text: string;
93
- readonly cause: unknown;
94
- constructor({ text, cause }: {
95
- text: string;
96
- cause: unknown;
97
- });
98
- static isJSONParseError(error: unknown): error is JSONParseError;
99
- toJSON(): {
100
- name: string;
101
- message: string;
102
- cause: unknown;
103
- stack: string | undefined;
104
- valueText: string;
105
- };
106
- }
107
-
108
- declare class LoadAPIKeyError extends Error {
109
- constructor({ message }: {
110
- message: string;
111
- });
112
- static isLoadAPIKeyError(error: unknown): error is LoadAPIKeyError;
113
- toJSON(): {
114
- name: string;
115
- message: string;
116
- };
117
- }
118
-
119
- declare class NoTextGeneratedError extends Error {
120
- readonly cause: unknown;
121
- constructor();
122
- static isNoTextGeneratedError(error: unknown): error is NoTextGeneratedError;
123
- toJSON(): {
124
- name: string;
125
- cause: unknown;
126
- message: string;
127
- stack: string | undefined;
128
- };
129
- }
130
-
131
- declare class NoSuchToolError extends Error {
132
- readonly toolName: string;
133
- constructor({ message, toolName }: {
134
- message: string;
135
- toolName: string;
136
- });
137
- static isNoSuchToolError(error: unknown): error is NoSuchToolError;
138
- toJSON(): {
139
- name: string;
140
- message: string;
141
- stack: string | undefined;
142
- toolName: string;
143
- };
144
- }
145
-
146
- type RetryErrorReason = 'maxRetriesExceeded' | 'errorNotRetryable' | 'abort';
147
- declare class RetryError extends Error {
148
- readonly reason: RetryErrorReason;
149
- readonly lastError: unknown;
150
- readonly errors: Array<unknown>;
151
- constructor({ message, reason, errors, }: {
152
- message: string;
153
- reason: RetryErrorReason;
154
- errors: Array<unknown>;
155
- });
156
- static isRetryError(error: unknown): error is RetryError;
157
- toJSON(): {
158
- name: string;
159
- message: string;
160
- reason: RetryErrorReason;
161
- lastError: unknown;
162
- errors: unknown[];
163
- };
164
- }
165
-
166
- declare class TypeValidationError extends Error {
167
- readonly value: unknown;
168
- readonly cause: unknown;
169
- constructor({ value, cause }: {
170
- value: unknown;
171
- cause: unknown;
172
- });
173
- static isTypeValidationError(error: unknown): error is TypeValidationError;
174
- toJSON(): {
175
- name: string;
176
- message: string;
177
- cause: unknown;
178
- stack: string | undefined;
179
- value: unknown;
180
- };
181
- }
182
-
183
- declare class UnsupportedFunctionalityError extends Error {
184
- readonly functionality: string;
185
- readonly provider: string;
186
- constructor({ provider, functionality, }: {
187
- provider: string;
188
- functionality: string;
189
- });
190
- static isUnsupportedFunctionalityError(error: unknown): error is UnsupportedFunctionalityError;
191
- toJSON(): {
192
- name: string;
193
- message: string;
194
- stack: string | undefined;
195
- provider: string;
196
- functionality: string;
197
- };
198
- }
199
-
200
- type JsonSchema = Record<string, unknown>;
201
-
202
- type LanguageModelV1CallSettings = {
203
- /**
204
- * Maximum number of tokens to generate.
205
- */
206
- maxTokens?: number;
207
- /**
208
- * Temperature setting. This is a number between 0 (almost no randomness) and
209
- * 1 (very random).
210
- *
211
- * Different LLM providers have different temperature
212
- * scales, so they'd need to map it (without mapping, the same temperature has
213
- * different effects on different models). The provider can also chose to map
214
- * this to topP, potentially even using a custom setting on their model.
215
- *
216
- * Note: This is an example of a setting that requires a clear specification of
217
- * the semantics.
218
- */
219
- temperature?: number;
220
- /**
221
- * Nucleus sampling. This is a number between 0 and 1.
222
- *
223
- * E.g. 0.1 would mean that only tokens with the top 10% probability mass
224
- * are considered.
225
- *
226
- * It is recommended to set either `temperature` or `topP`, but not both.
227
- */
228
- topP?: number;
229
- /**
230
- * Presence penalty setting. It affects the likelihood of the model to
231
- * repeat information that is already in the prompt.
232
- *
233
- * The presence penalty is a number between -1 (increase repetition)
234
- * and 1 (maximum penalty, decrease repetition). 0 means no penalty.
235
- */
236
- presencePenalty?: number;
237
- /**
238
- * Frequency penalty setting. It affects the likelihood of the model
239
- * to repeatedly use the same words or phrases.
240
- *
241
- * The frequency penalty is a number between -1 (increase repetition)
242
- * and 1 (maximum penalty, decrease repetition). 0 means no penalty.
243
- */
244
- frequencyPenalty?: number;
245
- /**
246
- * The seed (integer) to use for random sampling. If set and supported
247
- * by the model, calls will generate deterministic results.
248
- */
249
- seed?: number;
250
- /**
251
- * Abort signal for cancelling the operation.
252
- */
253
- abortSignal?: AbortSignal;
254
- };
255
-
256
- /**
257
- * A tool has a name, a description, and a set of parameters.
258
- *
259
- * Note: this is **not** the user-facing tool definition. The AI SDK methods will
260
- * map the user-facing tool definitions to this format.
261
- */
262
- type LanguageModelV1FunctionTool = {
263
- /**
264
- * The type of the tool. Only functions for now, but this gives us room to
265
- * add more specific tool types in the future and use a discriminated union.
266
- */
267
- type: 'function';
268
- /**
269
- * The name of the tool. Unique within this model call.
270
- */
271
- name: string;
272
- description?: string;
273
- parameters: JsonSchema;
274
- };
275
-
276
- /**
277
- * A prompt is a list of messages.
278
- *
279
- * Note: Not all models and prompt formats support multi-modal inputs and
280
- * tool calls. The validation happens at runtime.
281
- *
282
- * Note: This is not a user-facing prompt. The AI SDK methods will map the
283
- * user-facing prompt types such as chat or instruction prompts to this format.
284
- */
285
- type LanguageModelV1Prompt = Array<LanguageModelV1Message>;
286
- type LanguageModelV1Message = {
287
- role: 'system';
288
- content: string;
289
- } | {
290
- role: 'user';
291
- content: Array<LanguageModelV1TextPart | LanguageModelV1ImagePart>;
292
- } | {
293
- role: 'assistant';
294
- content: Array<LanguageModelV1TextPart | LanguageModelV1ToolCallPart>;
295
- } | {
296
- role: 'tool';
297
- content: Array<LanguageModelV1ToolResultPart>;
298
- };
299
- interface LanguageModelV1TextPart {
300
- type: 'text';
301
- /**
302
- * The text content.
303
- */
304
- text: string;
305
- }
306
- interface LanguageModelV1ImagePart {
307
- type: 'image';
308
- /**
309
- * Image data as a Uint8Array (e.g. from a Blob or Buffer) or a URL.
310
- */
311
- image: Uint8Array | URL;
312
- /**
313
- * Optional mime type of the image.
314
- */
315
- mimeType?: string;
316
- }
317
- interface LanguageModelV1ToolCallPart {
318
- type: 'tool-call';
319
- toolCallId: string;
320
- toolName: string;
321
- args: unknown;
322
- }
323
- interface LanguageModelV1ToolResultPart {
324
- type: 'tool-result';
325
- toolCallId: string;
326
- toolName: string;
327
- result: unknown;
328
- }
329
-
330
- type LanguageModelV1CallOptions = LanguageModelV1CallSettings & {
331
- /**
332
- * Whether the user provided the input as messages or as
333
- * a prompt. This can help guide non-chat models in the
334
- * expansion, bc different expansions can be needed for
335
- * chat/non-chat use cases.
336
- */
337
- inputFormat: 'messages' | 'prompt';
338
- /**
339
- * The mode affects the behavior of the language model. It is required to
340
- * support provider-independent streaming and generation of structured objects.
341
- * The model can take this information and e.g. configure json mode, the correct
342
- * low level grammar, etc. It can also be used to optimize the efficiency of the
343
- * streaming, e.g. tool-delta stream parts are only needed in the
344
- * object-tool mode.
345
- */
346
- mode: {
347
- type: 'regular';
348
- tools?: Array<LanguageModelV1FunctionTool>;
349
- } | {
350
- type: 'object-json';
351
- } | {
352
- type: 'object-grammar';
353
- schema: JsonSchema;
354
- } | {
355
- type: 'object-tool';
356
- tool: LanguageModelV1FunctionTool;
357
- };
358
- /**
359
- * A language mode prompt is a standardized prompt type.
360
- *
361
- * Note: This is **not** the user-facing prompt. The AI SDK methods will map the
362
- * user-facing prompt types such as chat or instruction prompts to this format.
363
- * That approach allows us to evolve the user facing prompts without breaking
364
- * the language model interface.
365
- */
366
- prompt: LanguageModelV1Prompt;
367
- };
368
-
369
- /**
370
- * Warning from the model provider for this call. The call will proceed, but e.g.
371
- * some settings might not be supported, which can lead to suboptimal results.
372
- */
373
- type LanguageModelV1CallWarning = {
374
- type: 'unsupported-setting';
375
- setting: keyof LanguageModelV1CallSettings;
376
- } | {
377
- type: 'other';
378
- message: string;
379
- };
380
-
381
- type LanguageModelV1FinishReason = 'stop' | 'length' | 'content-filter' | 'tool-calls' | 'error' | 'other';
382
-
383
- type LanguageModelV1FunctionToolCall = {
384
- toolCallType: 'function';
385
- toolCallId: string;
386
- toolName: string;
387
- /**
388
- * Stringified JSON object with the tool call arguments. Must match the
389
- * parameters schema of the tool.
390
- */
391
- args: string;
392
- };
393
-
394
- type LanguageModelV1 = {
395
- /**
396
- * The language model must specify which language model interface
397
- * version it implements. This will allow us to evolve the language
398
- * model interface and retain backwards compatibility. The different
399
- * implementation versions can be handled as a discriminated union
400
- * on our side.
401
- */
402
- readonly specificationVersion: 'v1';
403
- /**
404
- * Name of the provider for logging purposes.
405
- */
406
- readonly provider: string;
407
- /**
408
- * Provider-specific model ID for logging purposes.
409
- */
410
- readonly modelId: string;
411
- /**
412
- * Default object generation mode that should be used with this model when
413
- * no mode is specified. Should be the mode with the best results for this
414
- * model. `undefined` can be returned if object generation is not supported.
415
- *
416
- * This is needed to generate the best objects possible w/o requiring the
417
- * user to explicitly specify the object generation mode.
418
- */
419
- readonly defaultObjectGenerationMode: 'json' | 'tool' | 'grammar' | undefined;
420
- /**
421
- * Generates a language model output (non-streaming).
422
- *
423
- * Naming: "do" prefix to prevent accidental direct usage of the method
424
- * by the user.
425
- */
426
- doGenerate(options: LanguageModelV1CallOptions): PromiseLike<{
427
- /**
428
- * Text that the model has generated. Can be undefined if the model
429
- * has only generated tool calls.
430
- */
431
- text?: string;
432
- /**
433
- * Tool calls that the model has generated. Can be undefined if the
434
- * model has only generated text.
435
- */
436
- toolCalls?: Array<LanguageModelV1FunctionToolCall>;
437
- /**
438
- * Finish reason.
439
- */
440
- finishReason: LanguageModelV1FinishReason;
441
- /**
442
- * Usage information.
443
- */
444
- usage: {
445
- promptTokens: number;
446
- completionTokens: number;
447
- };
448
- /**
449
- * Raw prompt and setting information for observability provider integration.
450
- */
451
- rawCall: {
452
- /**
453
- * Raw prompt after expansion and conversion to the format that the
454
- * provider uses to send the information to their API.
455
- */
456
- rawPrompt: unknown;
457
- /**
458
- * Raw settings that are used for the API call. Includes provider-specific
459
- * settings.
460
- */
461
- rawSettings: Record<string, unknown>;
462
- };
463
- warnings?: LanguageModelV1CallWarning[];
464
- }>;
465
- /**
466
- * Generates a language model output (streaming).
467
- *
468
- * Naming: "do" prefix to prevent accidental direct usage of the method
469
- * by the user.
470
- *
471
- * @return A stream of higher-level language model output parts.
472
- */
473
- doStream(options: LanguageModelV1CallOptions): PromiseLike<{
474
- stream: ReadableStream<LanguageModelV1StreamPart>;
475
- /**
476
- * Raw prompt and setting information for observability provider integration.
477
- */
478
- rawCall: {
479
- /**
480
- * Raw prompt after expansion and conversion to the format that the
481
- * provider uses to send the information to their API.
482
- */
483
- rawPrompt: unknown;
484
- /**
485
- * Raw settings that are used for the API call. Includes provider-specific
486
- * settings.
487
- */
488
- rawSettings: Record<string, unknown>;
489
- };
490
- warnings?: LanguageModelV1CallWarning[];
491
- }>;
492
- };
493
- type LanguageModelV1StreamPart = {
494
- type: 'text-delta';
495
- textDelta: string;
496
- } | ({
497
- type: 'tool-call';
498
- } & LanguageModelV1FunctionToolCall) | {
499
- type: 'tool-call-delta';
500
- toolCallId: string;
501
- toolName: string;
502
- argsTextDelta: string;
503
- } | {
504
- type: 'finish-metadata';
505
- finishReason: LanguageModelV1FinishReason;
506
- usage: {
507
- promptTokens: number;
508
- completionTokens: number;
509
- };
510
- } | {
511
- type: 'error';
512
- error: unknown;
513
- };
514
-
515
- declare function getErrorMessage(error: unknown | undefined): string;
516
-
517
- declare function loadApiKey({ apiKey, environmentVariableName, apiKeyParameterName, description, }: {
518
- apiKey: string | undefined;
519
- environmentVariableName: string;
520
- apiKeyParameterName?: string;
521
- description: string;
522
- }): string;
523
-
524
- /**
525
- * Parses a JSON string into an unknown object.
526
- *
527
- * @param text - The JSON string to parse.
528
- * @returns {unknown} - The parsed JSON object.
529
- */
530
- declare function parseJSON({ text }: {
531
- text: string;
532
- }): unknown;
533
- /**
534
- * Parses a JSON string into a strongly-typed object using the provided schema.
535
- *
536
- * @template T - The type of the object to parse the JSON into.
537
- * @param {string} text - The JSON string to parse.
538
- * @param {Schema<T>} schema - The schema to use for parsing the JSON.
539
- * @returns {T} - The parsed object.
540
- */
541
- declare function parseJSON<T>({ text, schema, }: {
542
- text: string;
543
- schema: ZodSchema<T>;
544
- }): T;
545
- /**
546
- * Safely parses a JSON string and returns the result as an object of type `unknown`.
547
- *
548
- * @param text - The JSON string to parse.
549
- * @returns {object} Either an object with `success: true` and the parsed data, or an object with `success: false` and the error that occurred.
550
- */
551
- declare function safeParseJSON({ text, }: {
552
- text: string;
553
- }): {
554
- success: true;
555
- value: unknown;
556
- } | {
557
- success: false;
558
- error: JSONParseError | TypeValidationError;
559
- };
560
- /**
561
- * Safely parses a JSON string into a strongly-typed object, using a provided schema to validate the object.
562
- *
563
- * @template T - The type of the object to parse the JSON into.
564
- * @param {string} text - The JSON string to parse.
565
- * @param {Schema<T>} schema - The schema to use for parsing the JSON.
566
- * @returns An object with either a `success` flag and the parsed and typed data, or a `success` flag and an error object.
567
- */
568
- declare function safeParseJSON<T>({ text, schema, }: {
569
- text: string;
570
- schema: ZodSchema<T>;
571
- }): {
572
- success: true;
573
- value: T;
574
- } | {
575
- success: false;
576
- error: JSONParseError | TypeValidationError;
577
- };
578
- declare function isParseableJson(input: string): boolean;
579
-
580
- type ParsedChunk<T> = {
581
- type: 'value';
582
- value: T;
583
- } | {
584
- type: 'error';
585
- error: unknown;
586
- };
587
-
588
- type ResponseHandler<RETURN_TYPE> = (options: {
589
- url: string;
590
- requestBodyValues: unknown;
591
- response: Response;
592
- }) => PromiseLike<RETURN_TYPE>;
593
- declare const createJsonErrorResponseHandler: <T>({ errorSchema, errorToMessage, isRetryable, }: {
594
- errorSchema: ZodSchema<T, zod.ZodTypeDef, T>;
595
- errorToMessage: (error: T) => string;
596
- isRetryable?: ((response: Response, error?: T | undefined) => boolean) | undefined;
597
- }) => ResponseHandler<APICallError>;
598
- declare const createEventSourceResponseHandler: <T>(chunkSchema: ZodSchema<T, zod.ZodTypeDef, T>) => ResponseHandler<ReadableStream<ParsedChunk<T>>>;
599
- declare const createJsonResponseHandler: <T>(responseSchema: ZodSchema<T, zod.ZodTypeDef, T>) => ResponseHandler<T>;
600
-
601
- declare const postJsonToApi: <T>({ url, headers, body, failedResponseHandler, successfulResponseHandler, abortSignal, }: {
602
- url: string;
603
- headers?: Record<string, string | undefined> | undefined;
604
- body: unknown;
605
- failedResponseHandler: ResponseHandler<APICallError>;
606
- successfulResponseHandler: ResponseHandler<T>;
607
- abortSignal?: AbortSignal | undefined;
608
- }) => Promise<T>;
609
- declare const postToApi: <T>({ url, headers, body, successfulResponseHandler, failedResponseHandler, abortSignal, }: {
610
- url: string;
611
- headers?: Record<string, string | undefined> | undefined;
612
- body: {
613
- content: string | FormData | Uint8Array;
614
- values: unknown;
615
- };
616
- failedResponseHandler: ResponseHandler<Error>;
617
- successfulResponseHandler: ResponseHandler<T>;
618
- abortSignal?: AbortSignal | undefined;
619
- }) => Promise<T>;
620
-
621
- declare function scale({ inputMin, inputMax, outputMin, outputMax, value, }: {
622
- inputMin?: number;
623
- inputMax?: number;
624
- outputMin: number;
625
- outputMax: number;
626
- value: number | undefined;
627
- }): number | undefined;
628
-
629
- declare function convertBase64ToUint8Array(base64String: string): Uint8Array;
630
- declare function convertUint8ArrayToBase64(array: Uint8Array): string;
631
-
632
- /**
633
- * Validates the types of an unknown object using a schema and
634
- * return a strongly-typed object.
635
- *
636
- * @template T - The type of the object to validate.
637
- * @param {string} options.value - The object to validate.
638
- * @param {Schema<T>} options.schema - The schema to use for validating the JSON.
639
- * @returns {T} - The typed object.
640
- */
641
- declare function validateTypes<T>({ value, schema, }: {
642
- value: unknown;
643
- schema: ZodSchema<T>;
644
- }): T;
645
- /**
646
- * Safely validates the types of an unknown object using a schema and
647
- * return a strongly-typed object.
648
- *
649
- * @template T - The type of the object to validate.
650
- * @param {string} options.value - The JSON object to validate.
651
- * @param {Schema<T>} options.schema - The schema to use for validating the JSON.
652
- * @returns An object with either a `success` flag and the parsed and typed data, or a `success` flag and an error object.
653
- */
654
- declare function safeValidateTypes<T>({ value, schema, }: {
655
- value: unknown;
656
- schema: ZodSchema<T>;
657
- }): {
658
- success: true;
659
- value: T;
660
- } | {
661
- success: false;
662
- error: TypeValidationError;
663
- };
664
-
665
- export { APICallError, InvalidArgumentError, InvalidPromptError, InvalidToolArgumentsError, JSONParseError, LanguageModelV1, LanguageModelV1CallOptions, LanguageModelV1CallWarning, LanguageModelV1FinishReason, LanguageModelV1FunctionTool, LanguageModelV1FunctionToolCall, LanguageModelV1ImagePart, LanguageModelV1Message, LanguageModelV1Prompt, LanguageModelV1StreamPart, LanguageModelV1TextPart, LanguageModelV1ToolCallPart, LanguageModelV1ToolResultPart, LoadAPIKeyError, NoSuchToolError, NoTextGeneratedError, ParsedChunk, ResponseHandler, RetryError, RetryErrorReason, TypeValidationError, UnsupportedFunctionalityError, convertBase64ToUint8Array, convertUint8ArrayToBase64, createEventSourceResponseHandler, createJsonErrorResponseHandler, createJsonResponseHandler, getErrorMessage, isParseableJson, loadApiKey, parseJSON, postJsonToApi, postToApi, safeParseJSON, safeValidateTypes, scale, validateTypes };