@ai-sdk/provider 0.0.24 → 1.0.0-canary.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.
- package/CHANGELOG.md +23 -0
- package/dist/index.d.mts +103 -161
- package/dist/index.d.ts +103 -161
- package/dist/index.js +99 -271
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +96 -269
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
import { JSONSchema7 } from 'json-schema';
|
2
|
+
export { JSONSchema7, JSONSchema7Definition } from 'json-schema';
|
2
3
|
|
3
4
|
/**
|
4
5
|
An embedding is a vector, i.e. an array of numbers.
|
@@ -82,13 +83,13 @@ type EmbeddingModelV1<VALUE> = {
|
|
82
83
|
}>;
|
83
84
|
};
|
84
85
|
|
85
|
-
declare const symbol$
|
86
|
+
declare const symbol$d: unique symbol;
|
86
87
|
/**
|
87
88
|
* Custom error class for AI SDK related errors.
|
88
89
|
* @extends Error
|
89
90
|
*/
|
90
91
|
declare class AISDKError extends Error {
|
91
|
-
private readonly [symbol$
|
92
|
+
private readonly [symbol$d];
|
92
93
|
/**
|
93
94
|
* The underlying cause of the error, if any.
|
94
95
|
*/
|
@@ -113,21 +114,11 @@ declare class AISDKError extends Error {
|
|
113
114
|
*/
|
114
115
|
static isInstance(error: unknown): error is AISDKError;
|
115
116
|
protected static hasMarker(error: unknown, marker: string): boolean;
|
116
|
-
/**
|
117
|
-
* Returns a JSON representation of the error.
|
118
|
-
* @returns {Object} An object containing the error's name, message, and cause.
|
119
|
-
*
|
120
|
-
* @deprecated Do not use this method. It will be removed in the next major version.
|
121
|
-
*/
|
122
|
-
toJSON(): {
|
123
|
-
name: string;
|
124
|
-
message: string;
|
125
|
-
};
|
126
117
|
}
|
127
118
|
|
128
|
-
declare const symbol$
|
119
|
+
declare const symbol$c: unique symbol;
|
129
120
|
declare class APICallError extends AISDKError {
|
130
|
-
private readonly [symbol$
|
121
|
+
private readonly [symbol$c];
|
131
122
|
readonly url: string;
|
132
123
|
readonly requestBodyValues: unknown;
|
133
124
|
readonly statusCode?: number;
|
@@ -148,42 +139,34 @@ declare class APICallError extends AISDKError {
|
|
148
139
|
data?: unknown;
|
149
140
|
});
|
150
141
|
static isInstance(error: unknown): error is APICallError;
|
151
|
-
/**
|
152
|
-
* @deprecated Use isInstance instead.
|
153
|
-
*/
|
154
|
-
static isAPICallError(error: unknown): error is APICallError;
|
155
|
-
/**
|
156
|
-
* @deprecated Do not use this method. It will be removed in the next major version.
|
157
|
-
*/
|
158
|
-
toJSON(): {
|
159
|
-
name: string;
|
160
|
-
message: string;
|
161
|
-
url: string;
|
162
|
-
requestBodyValues: unknown;
|
163
|
-
statusCode: number | undefined;
|
164
|
-
responseHeaders: Record<string, string> | undefined;
|
165
|
-
responseBody: string | undefined;
|
166
|
-
cause: unknown;
|
167
|
-
isRetryable: boolean;
|
168
|
-
data: unknown;
|
169
|
-
};
|
170
142
|
}
|
171
143
|
|
172
|
-
declare const symbol$
|
144
|
+
declare const symbol$b: unique symbol;
|
173
145
|
declare class EmptyResponseBodyError extends AISDKError {
|
174
|
-
private readonly [symbol$
|
146
|
+
private readonly [symbol$b];
|
175
147
|
constructor({ message }?: {
|
176
148
|
message?: string;
|
177
149
|
});
|
178
150
|
static isInstance(error: unknown): error is EmptyResponseBodyError;
|
179
|
-
/**
|
180
|
-
* @deprecated use `isInstance` instead
|
181
|
-
*/
|
182
|
-
static isEmptyResponseBodyError(error: unknown): error is EmptyResponseBodyError;
|
183
151
|
}
|
184
152
|
|
185
153
|
declare function getErrorMessage(error: unknown | undefined): string;
|
186
154
|
|
155
|
+
declare const symbol$a: unique symbol;
|
156
|
+
/**
|
157
|
+
* A function argument is invalid.
|
158
|
+
*/
|
159
|
+
declare class InvalidArgumentError extends AISDKError {
|
160
|
+
private readonly [symbol$a];
|
161
|
+
readonly argument: string;
|
162
|
+
constructor({ message, cause, argument, }: {
|
163
|
+
argument: string;
|
164
|
+
message: string;
|
165
|
+
cause?: unknown;
|
166
|
+
});
|
167
|
+
static isInstance(error: unknown): error is InvalidArgumentError;
|
168
|
+
}
|
169
|
+
|
187
170
|
declare const symbol$9: unique symbol;
|
188
171
|
/**
|
189
172
|
* A prompt is invalid. This error should be thrown by providers when they cannot
|
@@ -198,19 +181,6 @@ declare class InvalidPromptError extends AISDKError {
|
|
198
181
|
cause?: unknown;
|
199
182
|
});
|
200
183
|
static isInstance(error: unknown): error is InvalidPromptError;
|
201
|
-
/**
|
202
|
-
* @deprecated use `isInstance` instead
|
203
|
-
*/
|
204
|
-
static isInvalidPromptError(error: unknown): error is InvalidPromptError;
|
205
|
-
/**
|
206
|
-
* @deprecated Do not use this method. It will be removed in the next major version.
|
207
|
-
*/
|
208
|
-
toJSON(): {
|
209
|
-
name: string;
|
210
|
-
message: string;
|
211
|
-
stack: string | undefined;
|
212
|
-
prompt: unknown;
|
213
|
-
};
|
214
184
|
}
|
215
185
|
|
216
186
|
declare const symbol$8: unique symbol;
|
@@ -226,19 +196,6 @@ declare class InvalidResponseDataError extends AISDKError {
|
|
226
196
|
message?: string;
|
227
197
|
});
|
228
198
|
static isInstance(error: unknown): error is InvalidResponseDataError;
|
229
|
-
/**
|
230
|
-
* @deprecated use `isInstance` instead
|
231
|
-
*/
|
232
|
-
static isInvalidResponseDataError(error: unknown): error is InvalidResponseDataError;
|
233
|
-
/**
|
234
|
-
* @deprecated Do not use this method. It will be removed in the next major version.
|
235
|
-
*/
|
236
|
-
toJSON(): {
|
237
|
-
name: string;
|
238
|
-
message: string;
|
239
|
-
stack: string | undefined;
|
240
|
-
data: unknown;
|
241
|
-
};
|
242
199
|
}
|
243
200
|
|
244
201
|
declare const symbol$7: unique symbol;
|
@@ -250,20 +207,6 @@ declare class JSONParseError extends AISDKError {
|
|
250
207
|
cause: unknown;
|
251
208
|
});
|
252
209
|
static isInstance(error: unknown): error is JSONParseError;
|
253
|
-
/**
|
254
|
-
* @deprecated use `isInstance` instead
|
255
|
-
*/
|
256
|
-
static isJSONParseError(error: unknown): error is JSONParseError;
|
257
|
-
/**
|
258
|
-
* @deprecated Do not use this method. It will be removed in the next major version.
|
259
|
-
*/
|
260
|
-
toJSON(): {
|
261
|
-
name: string;
|
262
|
-
message: string;
|
263
|
-
cause: unknown;
|
264
|
-
stack: string | undefined;
|
265
|
-
valueText: string;
|
266
|
-
};
|
267
210
|
}
|
268
211
|
|
269
212
|
declare const symbol$6: unique symbol;
|
@@ -273,10 +216,6 @@ declare class LoadAPIKeyError extends AISDKError {
|
|
273
216
|
message: string;
|
274
217
|
});
|
275
218
|
static isInstance(error: unknown): error is LoadAPIKeyError;
|
276
|
-
/**
|
277
|
-
* @deprecated Use isInstance instead.
|
278
|
-
*/
|
279
|
-
static isLoadAPIKeyError(error: unknown): error is LoadAPIKeyError;
|
280
219
|
}
|
281
220
|
|
282
221
|
declare const symbol$5: unique symbol;
|
@@ -286,10 +225,6 @@ declare class LoadSettingError extends AISDKError {
|
|
286
225
|
message: string;
|
287
226
|
});
|
288
227
|
static isInstance(error: unknown): error is LoadSettingError;
|
289
|
-
/**
|
290
|
-
* @deprecated Use isInstance instead.
|
291
|
-
*/
|
292
|
-
static isLoadSettingError(error: unknown): error is LoadSettingError;
|
293
228
|
}
|
294
229
|
|
295
230
|
declare const symbol$4: unique symbol;
|
@@ -302,19 +237,6 @@ declare class NoContentGeneratedError extends AISDKError {
|
|
302
237
|
message?: string;
|
303
238
|
});
|
304
239
|
static isInstance(error: unknown): error is NoContentGeneratedError;
|
305
|
-
/**
|
306
|
-
* @deprecated Use isInstance instead.
|
307
|
-
*/
|
308
|
-
static isNoContentGeneratedError(error: unknown): error is NoContentGeneratedError;
|
309
|
-
/**
|
310
|
-
* @deprecated Do not use this method. It will be removed in the next major version.
|
311
|
-
*/
|
312
|
-
toJSON(): {
|
313
|
-
name: string;
|
314
|
-
cause: unknown;
|
315
|
-
message: string;
|
316
|
-
stack: string | undefined;
|
317
|
-
};
|
318
240
|
}
|
319
241
|
|
320
242
|
declare const symbol$3: unique symbol;
|
@@ -329,20 +251,6 @@ declare class NoSuchModelError extends AISDKError {
|
|
329
251
|
message?: string;
|
330
252
|
});
|
331
253
|
static isInstance(error: unknown): error is NoSuchModelError;
|
332
|
-
/**
|
333
|
-
* @deprecated use `isInstance` instead
|
334
|
-
*/
|
335
|
-
static isNoSuchModelError(error: unknown): error is NoSuchModelError;
|
336
|
-
/**
|
337
|
-
* @deprecated Do not use this method. It will be removed in the next major version.
|
338
|
-
*/
|
339
|
-
toJSON(): {
|
340
|
-
name: string;
|
341
|
-
message: string;
|
342
|
-
stack: string | undefined;
|
343
|
-
modelId: string;
|
344
|
-
modelType: "languageModel" | "textEmbeddingModel";
|
345
|
-
};
|
346
254
|
}
|
347
255
|
|
348
256
|
declare const symbol$2: unique symbol;
|
@@ -359,22 +267,6 @@ declare class TooManyEmbeddingValuesForCallError extends AISDKError {
|
|
359
267
|
values: Array<unknown>;
|
360
268
|
});
|
361
269
|
static isInstance(error: unknown): error is TooManyEmbeddingValuesForCallError;
|
362
|
-
/**
|
363
|
-
* @deprecated use `isInstance` instead
|
364
|
-
*/
|
365
|
-
static isTooManyEmbeddingValuesForCallError(error: unknown): error is TooManyEmbeddingValuesForCallError;
|
366
|
-
/**
|
367
|
-
* @deprecated Do not use this method. It will be removed in the next major version.
|
368
|
-
*/
|
369
|
-
toJSON(): {
|
370
|
-
name: string;
|
371
|
-
message: string;
|
372
|
-
stack: string | undefined;
|
373
|
-
provider: string;
|
374
|
-
modelId: string;
|
375
|
-
maxEmbeddingsPerCall: number;
|
376
|
-
values: unknown[];
|
377
|
-
};
|
378
270
|
}
|
379
271
|
|
380
272
|
declare const symbol$1: unique symbol;
|
@@ -400,20 +292,6 @@ declare class TypeValidationError extends AISDKError {
|
|
400
292
|
value: unknown;
|
401
293
|
cause: unknown;
|
402
294
|
}): TypeValidationError;
|
403
|
-
/**
|
404
|
-
* @deprecated use `isInstance` instead
|
405
|
-
*/
|
406
|
-
static isTypeValidationError(error: unknown): error is TypeValidationError;
|
407
|
-
/**
|
408
|
-
* @deprecated Do not use this method. It will be removed in the next major version.
|
409
|
-
*/
|
410
|
-
toJSON(): {
|
411
|
-
name: string;
|
412
|
-
message: string;
|
413
|
-
cause: unknown;
|
414
|
-
stack: string | undefined;
|
415
|
-
value: unknown;
|
416
|
-
};
|
417
295
|
}
|
418
296
|
|
419
297
|
declare const symbol: unique symbol;
|
@@ -424,19 +302,6 @@ declare class UnsupportedFunctionalityError extends AISDKError {
|
|
424
302
|
functionality: string;
|
425
303
|
});
|
426
304
|
static isInstance(error: unknown): error is UnsupportedFunctionalityError;
|
427
|
-
/**
|
428
|
-
* @deprecated Use isInstance instead.
|
429
|
-
*/
|
430
|
-
static isUnsupportedFunctionalityError(error: unknown): error is UnsupportedFunctionalityError;
|
431
|
-
/**
|
432
|
-
* @deprecated Do not use this method. It will be removed in the next major version.
|
433
|
-
*/
|
434
|
-
toJSON(): {
|
435
|
-
name: string;
|
436
|
-
message: string;
|
437
|
-
stack: string | undefined;
|
438
|
-
functionality: string;
|
439
|
-
};
|
440
305
|
}
|
441
306
|
|
442
307
|
type JSONValue = null | string | number | boolean | JSONObject | JSONArray;
|
@@ -535,8 +400,7 @@ map the user-facing tool definitions to this format.
|
|
535
400
|
*/
|
536
401
|
type LanguageModelV1FunctionTool = {
|
537
402
|
/**
|
538
|
-
The type of the tool
|
539
|
-
add more specific tool types in the future and use a discriminated union.
|
403
|
+
The type of the tool (always 'function').
|
540
404
|
*/
|
541
405
|
type: 'function';
|
542
406
|
/**
|
@@ -708,6 +572,27 @@ interface LanguageModelV1ToolResultPart {
|
|
708
572
|
*/
|
709
573
|
isError?: boolean;
|
710
574
|
/**
|
575
|
+
Tool results as an array of parts. This enables advanced tool results including images.
|
576
|
+
When this is used, the `result` field should be ignored (if the provider supports content).
|
577
|
+
*/
|
578
|
+
content?: Array<{
|
579
|
+
type: 'text';
|
580
|
+
/**
|
581
|
+
Text content.
|
582
|
+
*/
|
583
|
+
text: string;
|
584
|
+
} | {
|
585
|
+
type: 'image';
|
586
|
+
/**
|
587
|
+
base-64 encoded image data
|
588
|
+
*/
|
589
|
+
data: string;
|
590
|
+
/**
|
591
|
+
Mime type of the image.
|
592
|
+
*/
|
593
|
+
mimeType?: string;
|
594
|
+
}>;
|
595
|
+
/**
|
711
596
|
* Additional provider-specific metadata. They are passed through
|
712
597
|
* to the provider from the AI SDK and enable provider-specific
|
713
598
|
* functionality that can be fully encapsulated in the provider.
|
@@ -715,6 +600,28 @@ interface LanguageModelV1ToolResultPart {
|
|
715
600
|
providerMetadata?: LanguageModelV1ProviderMetadata;
|
716
601
|
}
|
717
602
|
|
603
|
+
/**
|
604
|
+
The configuration of a tool that is defined by the provider.
|
605
|
+
*/
|
606
|
+
type LanguageModelV1ProviderDefinedTool = {
|
607
|
+
/**
|
608
|
+
The type of the tool (always 'provider-defined').
|
609
|
+
*/
|
610
|
+
type: 'provider-defined';
|
611
|
+
/**
|
612
|
+
The ID of the tool. Should follow the format `<provider-name>.<tool-name>`.
|
613
|
+
*/
|
614
|
+
id: `${string}.${string}`;
|
615
|
+
/**
|
616
|
+
The name of the tool. Unique within this model call.
|
617
|
+
*/
|
618
|
+
name: string;
|
619
|
+
/**
|
620
|
+
The arguments for configuring the tool. Must match the expected arguments defined by the provider for this tool.
|
621
|
+
*/
|
622
|
+
args: Record<string, unknown>;
|
623
|
+
};
|
624
|
+
|
718
625
|
type LanguageModelV1ToolChoice = {
|
719
626
|
type: 'auto';
|
720
627
|
} | {
|
@@ -751,7 +658,7 @@ type LanguageModelV1CallOptions = LanguageModelV1CallSettings & {
|
|
751
658
|
/**
|
752
659
|
The tools that are available for the model.
|
753
660
|
*/
|
754
|
-
tools?: Array<LanguageModelV1FunctionTool>;
|
661
|
+
tools?: Array<LanguageModelV1FunctionTool | LanguageModelV1ProviderDefinedTool>;
|
755
662
|
/**
|
756
663
|
Specifies how the tool should be selected. Defaults to 'auto'.
|
757
664
|
*/
|
@@ -799,6 +706,10 @@ type LanguageModelV1CallWarning = {
|
|
799
706
|
type: 'unsupported-setting';
|
800
707
|
setting: keyof LanguageModelV1CallSettings;
|
801
708
|
details?: string;
|
709
|
+
} | {
|
710
|
+
type: 'unsupported-tool';
|
711
|
+
tool: LanguageModelV1FunctionTool | LanguageModelV1ProviderDefinedTool;
|
712
|
+
details?: string;
|
802
713
|
} | {
|
803
714
|
type: 'other';
|
804
715
|
message: string;
|
@@ -895,6 +806,14 @@ type LanguageModelV1 = {
|
|
895
806
|
*/
|
896
807
|
readonly supportsStructuredOutputs?: boolean;
|
897
808
|
/**
|
809
|
+
Checks if the model supports the given URL for file parts natively.
|
810
|
+
If the model does not support the URL,
|
811
|
+
the AI SDK will download the file and pass the file data to the model.
|
812
|
+
|
813
|
+
When undefined, the AI SDK will download the file.
|
814
|
+
*/
|
815
|
+
supportsUrl?(url: URL): boolean;
|
816
|
+
/**
|
898
817
|
Generates a language model output (non-streaming).
|
899
818
|
|
900
819
|
Naming: "do" prefix to prevent accidental direct usage of the method
|
@@ -946,6 +865,19 @@ type LanguageModelV1 = {
|
|
946
865
|
*/
|
947
866
|
headers?: Record<string, string>;
|
948
867
|
};
|
868
|
+
/**
|
869
|
+
Optional request information for telemetry and debugging purposes.
|
870
|
+
*/
|
871
|
+
request?: {
|
872
|
+
/**
|
873
|
+
Raw request HTTP body that was sent to the provider API as a string (JSON should be stringified).
|
874
|
+
Non-HTTP(s) providers should not set this.
|
875
|
+
*/
|
876
|
+
body?: string;
|
877
|
+
};
|
878
|
+
/**
|
879
|
+
Optional response information for telemetry and debugging purposes.
|
880
|
+
*/
|
949
881
|
response?: {
|
950
882
|
/**
|
951
883
|
ID for the generated response, if the provider sends one.
|
@@ -1009,6 +941,16 @@ type LanguageModelV1 = {
|
|
1009
941
|
*/
|
1010
942
|
headers?: Record<string, string>;
|
1011
943
|
};
|
944
|
+
/**
|
945
|
+
Optional request information for telemetry and debugging purposes.
|
946
|
+
*/
|
947
|
+
request?: {
|
948
|
+
/**
|
949
|
+
Raw request HTTP body that was sent to the provider API as a string (JSON should be stringified).
|
950
|
+
Non-HTTP(s) providers should not set this.
|
951
|
+
*/
|
952
|
+
body?: string;
|
953
|
+
};
|
1012
954
|
warnings?: LanguageModelV1CallWarning[];
|
1013
955
|
}>;
|
1014
956
|
};
|
@@ -1070,4 +1012,4 @@ interface ProviderV1 {
|
|
1070
1012
|
textEmbeddingModel(modelId: string): EmbeddingModelV1<string>;
|
1071
1013
|
}
|
1072
1014
|
|
1073
|
-
export { AISDKError, APICallError, type EmbeddingModelV1, type EmbeddingModelV1Embedding, EmptyResponseBodyError, InvalidPromptError, InvalidResponseDataError, type JSONArray, type JSONObject, JSONParseError, type JSONValue, type LanguageModelV1, type LanguageModelV1CallOptions, type LanguageModelV1CallWarning, type LanguageModelV1FilePart, type LanguageModelV1FinishReason, type LanguageModelV1FunctionTool, type LanguageModelV1FunctionToolCall, type LanguageModelV1ImagePart, type LanguageModelV1LogProbs, type LanguageModelV1Message, type LanguageModelV1Prompt, type LanguageModelV1ProviderMetadata, type LanguageModelV1StreamPart, type LanguageModelV1TextPart, type LanguageModelV1ToolCallPart, type LanguageModelV1ToolChoice, type LanguageModelV1ToolResultPart, LoadAPIKeyError, LoadSettingError, NoContentGeneratedError, NoSuchModelError, type ProviderV1, TooManyEmbeddingValuesForCallError, TypeValidationError, UnsupportedFunctionalityError, getErrorMessage, isJSONArray, isJSONObject, isJSONValue };
|
1015
|
+
export { AISDKError, APICallError, type EmbeddingModelV1, type EmbeddingModelV1Embedding, EmptyResponseBodyError, InvalidArgumentError, InvalidPromptError, InvalidResponseDataError, type JSONArray, type JSONObject, JSONParseError, type JSONValue, type LanguageModelV1, type LanguageModelV1CallOptions, type LanguageModelV1CallWarning, type LanguageModelV1FilePart, type LanguageModelV1FinishReason, type LanguageModelV1FunctionTool, type LanguageModelV1FunctionToolCall, type LanguageModelV1ImagePart, type LanguageModelV1LogProbs, type LanguageModelV1Message, type LanguageModelV1Prompt, type LanguageModelV1ProviderDefinedTool, type LanguageModelV1ProviderMetadata, type LanguageModelV1StreamPart, type LanguageModelV1TextPart, type LanguageModelV1ToolCallPart, type LanguageModelV1ToolChoice, type LanguageModelV1ToolResultPart, LoadAPIKeyError, LoadSettingError, NoContentGeneratedError, NoSuchModelError, type ProviderV1, TooManyEmbeddingValuesForCallError, TypeValidationError, UnsupportedFunctionalityError, getErrorMessage, isJSONArray, isJSONObject, isJSONValue };
|