@ai-sdk/provider 0.0.13 → 0.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +188 -233
- package/dist/index.d.ts +188 -233
- package/dist/index.js +280 -346
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +276 -335
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
@@ -1,5 +1,60 @@
|
|
1
|
+
// src/errors/ai-sdk-error.ts
|
2
|
+
var marker = "vercel.ai.error";
|
3
|
+
var symbol = Symbol.for(marker);
|
4
|
+
var _a;
|
5
|
+
var _AISDKError = class _AISDKError extends Error {
|
6
|
+
/**
|
7
|
+
* Creates an AI SDK Error.
|
8
|
+
*
|
9
|
+
* @param {Object} params - The parameters for creating the error.
|
10
|
+
* @param {string} params.name - The name of the error.
|
11
|
+
* @param {string} params.message - The error message.
|
12
|
+
* @param {unknown} [params.cause] - The underlying cause of the error.
|
13
|
+
*/
|
14
|
+
constructor({
|
15
|
+
name: name12,
|
16
|
+
message,
|
17
|
+
cause
|
18
|
+
}) {
|
19
|
+
super(message);
|
20
|
+
this[_a] = true;
|
21
|
+
this.name = name12;
|
22
|
+
this.cause = cause;
|
23
|
+
}
|
24
|
+
/**
|
25
|
+
* Checks if the given error is an AI SDK Error.
|
26
|
+
* @param {unknown} error - The error to check.
|
27
|
+
* @returns {boolean} True if the error is an AI SDK Error, false otherwise.
|
28
|
+
*/
|
29
|
+
static isInstance(error) {
|
30
|
+
return _AISDKError.hasMarker(error, marker);
|
31
|
+
}
|
32
|
+
static hasMarker(error, marker13) {
|
33
|
+
const markerSymbol = Symbol.for(marker13);
|
34
|
+
return error != null && typeof error === "object" && markerSymbol in error && typeof error[markerSymbol] === "boolean" && error[markerSymbol] === true;
|
35
|
+
}
|
36
|
+
/**
|
37
|
+
* Returns a JSON representation of the error.
|
38
|
+
* @returns {Object} An object containing the error's name, message, and cause.
|
39
|
+
*
|
40
|
+
* @deprecated Do not use this method. It will be removed in the next major version.
|
41
|
+
*/
|
42
|
+
toJSON() {
|
43
|
+
return {
|
44
|
+
name: this.name,
|
45
|
+
message: this.message
|
46
|
+
};
|
47
|
+
}
|
48
|
+
};
|
49
|
+
_a = symbol;
|
50
|
+
var AISDKError = _AISDKError;
|
51
|
+
|
1
52
|
// src/errors/api-call-error.ts
|
2
|
-
var
|
53
|
+
var name = "AI_APICallError";
|
54
|
+
var marker2 = `vercel.ai.error.${name}`;
|
55
|
+
var symbol2 = Symbol.for(marker2);
|
56
|
+
var _a2;
|
57
|
+
var APICallError = class extends AISDKError {
|
3
58
|
constructor({
|
4
59
|
message,
|
5
60
|
url,
|
@@ -15,20 +70,28 @@ var APICallError = class extends Error {
|
|
15
70
|
// server error
|
16
71
|
data
|
17
72
|
}) {
|
18
|
-
super(message);
|
19
|
-
this
|
73
|
+
super({ name, message, cause });
|
74
|
+
this[_a2] = true;
|
20
75
|
this.url = url;
|
21
76
|
this.requestBodyValues = requestBodyValues;
|
22
77
|
this.statusCode = statusCode;
|
23
78
|
this.responseHeaders = responseHeaders;
|
24
79
|
this.responseBody = responseBody;
|
25
|
-
this.cause = cause;
|
26
80
|
this.isRetryable = isRetryable;
|
27
81
|
this.data = data;
|
28
82
|
}
|
83
|
+
static isInstance(error) {
|
84
|
+
return AISDKError.hasMarker(error, marker2);
|
85
|
+
}
|
86
|
+
/**
|
87
|
+
* @deprecated Use isInstance instead.
|
88
|
+
*/
|
29
89
|
static isAPICallError(error) {
|
30
|
-
return error instanceof Error && error.name ===
|
90
|
+
return error instanceof Error && error.name === name && typeof error.url === "string" && typeof error.requestBodyValues === "object" && (error.statusCode == null || typeof error.statusCode === "number") && (error.responseHeaders == null || typeof error.responseHeaders === "object") && (error.responseBody == null || typeof error.responseBody === "string") && (error.cause == null || typeof error.cause === "object") && typeof error.isRetryable === "boolean" && (error.data == null || typeof error.data === "object");
|
31
91
|
}
|
92
|
+
/**
|
93
|
+
* @deprecated Do not use this method. It will be removed in the next major version.
|
94
|
+
*/
|
32
95
|
toJSON() {
|
33
96
|
return {
|
34
97
|
name: this.name,
|
@@ -44,118 +107,71 @@ var APICallError = class extends Error {
|
|
44
107
|
};
|
45
108
|
}
|
46
109
|
};
|
47
|
-
|
48
|
-
// src/errors/download-error.ts
|
49
|
-
var DownloadError = class extends Error {
|
50
|
-
constructor({
|
51
|
-
url,
|
52
|
-
statusCode,
|
53
|
-
statusText,
|
54
|
-
cause,
|
55
|
-
message = cause == null ? `Failed to download ${url}: ${statusCode} ${statusText}` : `Failed to download ${url}: ${cause}`
|
56
|
-
}) {
|
57
|
-
super(message);
|
58
|
-
this.name = "AI_DownloadError";
|
59
|
-
this.url = url;
|
60
|
-
this.statusCode = statusCode;
|
61
|
-
this.statusText = statusText;
|
62
|
-
this.cause = cause;
|
63
|
-
}
|
64
|
-
static isDownloadError(error) {
|
65
|
-
return error instanceof Error && error.name === "AI_DownloadError" && typeof error.url === "string" && (error.statusCode == null || typeof error.statusCode === "number") && (error.statusText == null || typeof error.statusText === "string");
|
66
|
-
}
|
67
|
-
toJSON() {
|
68
|
-
return {
|
69
|
-
name: this.name,
|
70
|
-
message: this.message,
|
71
|
-
url: this.url,
|
72
|
-
statusCode: this.statusCode,
|
73
|
-
statusText: this.statusText,
|
74
|
-
cause: this.cause
|
75
|
-
};
|
76
|
-
}
|
77
|
-
};
|
110
|
+
_a2 = symbol2;
|
78
111
|
|
79
112
|
// src/errors/empty-response-body-error.ts
|
80
|
-
var
|
113
|
+
var name2 = "AI_EmptyResponseBodyError";
|
114
|
+
var marker3 = `vercel.ai.error.${name2}`;
|
115
|
+
var symbol3 = Symbol.for(marker3);
|
116
|
+
var _a3;
|
117
|
+
var EmptyResponseBodyError = class extends AISDKError {
|
118
|
+
// used in isInstance
|
81
119
|
constructor({ message = "Empty response body" } = {}) {
|
82
|
-
super(message);
|
83
|
-
this
|
120
|
+
super({ name: name2, message });
|
121
|
+
this[_a3] = true;
|
84
122
|
}
|
85
|
-
static
|
86
|
-
return error
|
123
|
+
static isInstance(error) {
|
124
|
+
return AISDKError.hasMarker(error, marker3);
|
87
125
|
}
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
};
|
94
|
-
}
|
95
|
-
};
|
96
|
-
|
97
|
-
// src/errors/invalid-argument-error.ts
|
98
|
-
var InvalidArgumentError = class extends Error {
|
99
|
-
constructor({
|
100
|
-
parameter,
|
101
|
-
value,
|
102
|
-
message
|
103
|
-
}) {
|
104
|
-
super(`Invalid argument for parameter ${parameter}: ${message}`);
|
105
|
-
this.name = "AI_InvalidArgumentError";
|
106
|
-
this.parameter = parameter;
|
107
|
-
this.value = value;
|
108
|
-
}
|
109
|
-
static isInvalidArgumentError(error) {
|
110
|
-
return error instanceof Error && error.name === "AI_InvalidArgumentError" && typeof error.parameter === "string" && typeof error.value === "string";
|
111
|
-
}
|
112
|
-
toJSON() {
|
113
|
-
return {
|
114
|
-
name: this.name,
|
115
|
-
message: this.message,
|
116
|
-
stack: this.stack,
|
117
|
-
parameter: this.parameter,
|
118
|
-
value: this.value
|
119
|
-
};
|
126
|
+
/**
|
127
|
+
* @deprecated use `isInstance` instead
|
128
|
+
*/
|
129
|
+
static isEmptyResponseBodyError(error) {
|
130
|
+
return error instanceof Error && error.name === name2;
|
120
131
|
}
|
121
132
|
};
|
133
|
+
_a3 = symbol3;
|
122
134
|
|
123
|
-
// src/errors/
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
cause,
|
128
|
-
message = `Invalid data content. Expected a base64 string, Uint8Array, ArrayBuffer, or Buffer, but got ${typeof content}.`
|
129
|
-
}) {
|
130
|
-
super(message);
|
131
|
-
this.name = "AI_InvalidDataContentError";
|
132
|
-
this.cause = cause;
|
133
|
-
this.content = content;
|
135
|
+
// src/errors/get-error-message.ts
|
136
|
+
function getErrorMessage(error) {
|
137
|
+
if (error == null) {
|
138
|
+
return "unknown error";
|
134
139
|
}
|
135
|
-
|
136
|
-
return error
|
140
|
+
if (typeof error === "string") {
|
141
|
+
return error;
|
137
142
|
}
|
138
|
-
|
139
|
-
return
|
140
|
-
name: this.name,
|
141
|
-
message: this.message,
|
142
|
-
stack: this.stack,
|
143
|
-
cause: this.cause,
|
144
|
-
content: this.content
|
145
|
-
};
|
143
|
+
if (error instanceof Error) {
|
144
|
+
return error.message;
|
146
145
|
}
|
147
|
-
|
146
|
+
return JSON.stringify(error);
|
147
|
+
}
|
148
148
|
|
149
149
|
// src/errors/invalid-prompt-error.ts
|
150
|
-
var
|
150
|
+
var name3 = "AI_InvalidPromptError";
|
151
|
+
var marker4 = `vercel.ai.error.${name3}`;
|
152
|
+
var symbol4 = Symbol.for(marker4);
|
153
|
+
var _a4;
|
154
|
+
var InvalidPromptError = class extends AISDKError {
|
151
155
|
constructor({ prompt: prompt2, message }) {
|
152
|
-
super(
|
153
|
-
|
156
|
+
super({
|
157
|
+
name: name3,
|
158
|
+
message: `Invalid prompt: ${message}`
|
159
|
+
});
|
160
|
+
this[_a4] = true;
|
154
161
|
this.prompt = prompt2;
|
155
162
|
}
|
163
|
+
static isInstance(error) {
|
164
|
+
return AISDKError.hasMarker(error, marker4);
|
165
|
+
}
|
166
|
+
/**
|
167
|
+
* @deprecated use `isInstance` instead
|
168
|
+
*/
|
156
169
|
static isInvalidPromptError(error) {
|
157
|
-
return error instanceof Error && error.name ===
|
170
|
+
return error instanceof Error && error.name === name3 && prompt != null;
|
158
171
|
}
|
172
|
+
/**
|
173
|
+
* @deprecated Do not use this method. It will be removed in the next major version.
|
174
|
+
*/
|
159
175
|
toJSON() {
|
160
176
|
return {
|
161
177
|
name: this.name,
|
@@ -165,20 +181,34 @@ var InvalidPromptError = class extends Error {
|
|
165
181
|
};
|
166
182
|
}
|
167
183
|
};
|
184
|
+
_a4 = symbol4;
|
168
185
|
|
169
186
|
// src/errors/invalid-response-data-error.ts
|
170
|
-
var
|
187
|
+
var name4 = "AI_InvalidResponseDataError";
|
188
|
+
var marker5 = `vercel.ai.error.${name4}`;
|
189
|
+
var symbol5 = Symbol.for(marker5);
|
190
|
+
var _a5;
|
191
|
+
var InvalidResponseDataError = class extends AISDKError {
|
171
192
|
constructor({
|
172
193
|
data,
|
173
194
|
message = `Invalid response data: ${JSON.stringify(data)}.`
|
174
195
|
}) {
|
175
|
-
super(message);
|
176
|
-
this
|
196
|
+
super({ name: name4, message });
|
197
|
+
this[_a5] = true;
|
177
198
|
this.data = data;
|
178
199
|
}
|
200
|
+
static isInstance(error) {
|
201
|
+
return AISDKError.hasMarker(error, marker5);
|
202
|
+
}
|
203
|
+
/**
|
204
|
+
* @deprecated use `isInstance` instead
|
205
|
+
*/
|
179
206
|
static isInvalidResponseDataError(error) {
|
180
|
-
return error instanceof Error && error.name ===
|
207
|
+
return error instanceof Error && error.name === name4 && error.data != null;
|
181
208
|
}
|
209
|
+
/**
|
210
|
+
* @deprecated Do not use this method. It will be removed in the next major version.
|
211
|
+
*/
|
182
212
|
toJSON() {
|
183
213
|
return {
|
184
214
|
name: this.name,
|
@@ -188,66 +218,36 @@ var InvalidResponseDataError = class extends Error {
|
|
188
218
|
};
|
189
219
|
}
|
190
220
|
};
|
191
|
-
|
192
|
-
// src/errors/get-error-message.ts
|
193
|
-
function getErrorMessage(error) {
|
194
|
-
if (error == null) {
|
195
|
-
return "unknown error";
|
196
|
-
}
|
197
|
-
if (typeof error === "string") {
|
198
|
-
return error;
|
199
|
-
}
|
200
|
-
if (error instanceof Error) {
|
201
|
-
return error.message;
|
202
|
-
}
|
203
|
-
return JSON.stringify(error);
|
204
|
-
}
|
205
|
-
|
206
|
-
// src/errors/invalid-tool-arguments-error.ts
|
207
|
-
var InvalidToolArgumentsError = class extends Error {
|
208
|
-
constructor({
|
209
|
-
toolArgs,
|
210
|
-
toolName,
|
211
|
-
cause,
|
212
|
-
message = `Invalid arguments for tool ${toolName}: ${getErrorMessage(
|
213
|
-
cause
|
214
|
-
)}`
|
215
|
-
}) {
|
216
|
-
super(message);
|
217
|
-
this.name = "AI_InvalidToolArgumentsError";
|
218
|
-
this.toolArgs = toolArgs;
|
219
|
-
this.toolName = toolName;
|
220
|
-
this.cause = cause;
|
221
|
-
}
|
222
|
-
static isInvalidToolArgumentsError(error) {
|
223
|
-
return error instanceof Error && error.name === "AI_InvalidToolArgumentsError" && typeof error.toolName === "string" && typeof error.toolArgs === "string";
|
224
|
-
}
|
225
|
-
toJSON() {
|
226
|
-
return {
|
227
|
-
name: this.name,
|
228
|
-
message: this.message,
|
229
|
-
cause: this.cause,
|
230
|
-
stack: this.stack,
|
231
|
-
toolName: this.toolName,
|
232
|
-
toolArgs: this.toolArgs
|
233
|
-
};
|
234
|
-
}
|
235
|
-
};
|
221
|
+
_a5 = symbol5;
|
236
222
|
|
237
223
|
// src/errors/json-parse-error.ts
|
238
|
-
var
|
224
|
+
var name5 = "AI_JSONParseError";
|
225
|
+
var marker6 = `vercel.ai.error.${name5}`;
|
226
|
+
var symbol6 = Symbol.for(marker6);
|
227
|
+
var _a6;
|
228
|
+
var JSONParseError = class extends AISDKError {
|
239
229
|
constructor({ text, cause }) {
|
240
|
-
super(
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
230
|
+
super({
|
231
|
+
name: name5,
|
232
|
+
message: `JSON parsing failed: Text: ${text}.
|
233
|
+
Error message: ${getErrorMessage(cause)}`,
|
234
|
+
cause
|
235
|
+
});
|
236
|
+
this[_a6] = true;
|
246
237
|
this.text = text;
|
247
238
|
}
|
239
|
+
static isInstance(error) {
|
240
|
+
return AISDKError.hasMarker(error, marker6);
|
241
|
+
}
|
242
|
+
/**
|
243
|
+
* @deprecated use `isInstance` instead
|
244
|
+
*/
|
248
245
|
static isJSONParseError(error) {
|
249
|
-
return error instanceof Error && error.name ===
|
246
|
+
return error instanceof Error && error.name === name5 && typeof error.text === "string" && typeof error.cause === "string";
|
250
247
|
}
|
248
|
+
/**
|
249
|
+
* @deprecated Do not use this method. It will be removed in the next major version.
|
250
|
+
*/
|
251
251
|
toJSON() {
|
252
252
|
return {
|
253
253
|
name: this.name,
|
@@ -258,71 +258,79 @@ Error message: ${getErrorMessage(cause)}`
|
|
258
258
|
};
|
259
259
|
}
|
260
260
|
};
|
261
|
+
_a6 = symbol6;
|
261
262
|
|
262
263
|
// src/errors/load-api-key-error.ts
|
263
|
-
var
|
264
|
+
var name6 = "AI_LoadAPIKeyError";
|
265
|
+
var marker7 = `vercel.ai.error.${name6}`;
|
266
|
+
var symbol7 = Symbol.for(marker7);
|
267
|
+
var _a7;
|
268
|
+
var LoadAPIKeyError = class extends AISDKError {
|
269
|
+
// used in isInstance
|
264
270
|
constructor({ message }) {
|
265
|
-
super(message);
|
266
|
-
this
|
271
|
+
super({ name: name6, message });
|
272
|
+
this[_a7] = true;
|
267
273
|
}
|
268
|
-
static
|
269
|
-
return error
|
274
|
+
static isInstance(error) {
|
275
|
+
return AISDKError.hasMarker(error, marker7);
|
270
276
|
}
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
277
|
+
/**
|
278
|
+
* @deprecated Use isInstance instead.
|
279
|
+
*/
|
280
|
+
static isLoadAPIKeyError(error) {
|
281
|
+
return error instanceof Error && error.name === name6;
|
276
282
|
}
|
277
283
|
};
|
284
|
+
_a7 = symbol7;
|
278
285
|
|
279
286
|
// src/errors/load-setting-error.ts
|
280
|
-
var
|
287
|
+
var name7 = "AI_LoadSettingError";
|
288
|
+
var marker8 = `vercel.ai.error.${name7}`;
|
289
|
+
var symbol8 = Symbol.for(marker8);
|
290
|
+
var _a8;
|
291
|
+
var LoadSettingError = class extends AISDKError {
|
292
|
+
// used in isInstance
|
281
293
|
constructor({ message }) {
|
282
|
-
super(message);
|
283
|
-
this
|
294
|
+
super({ name: name7, message });
|
295
|
+
this[_a8] = true;
|
284
296
|
}
|
285
|
-
static
|
286
|
-
return error
|
297
|
+
static isInstance(error) {
|
298
|
+
return AISDKError.hasMarker(error, marker8);
|
287
299
|
}
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
300
|
+
/**
|
301
|
+
* @deprecated Use isInstance instead.
|
302
|
+
*/
|
303
|
+
static isLoadSettingError(error) {
|
304
|
+
return error instanceof Error && error.name === name7;
|
293
305
|
}
|
294
306
|
};
|
307
|
+
_a8 = symbol8;
|
295
308
|
|
296
309
|
// src/errors/no-content-generated-error.ts
|
297
|
-
var
|
310
|
+
var name8 = "AI_NoContentGeneratedError";
|
311
|
+
var marker9 = `vercel.ai.error.${name8}`;
|
312
|
+
var symbol9 = Symbol.for(marker9);
|
313
|
+
var _a9;
|
314
|
+
var NoContentGeneratedError = class extends AISDKError {
|
315
|
+
// used in isInstance
|
298
316
|
constructor({
|
299
317
|
message = "No content generated."
|
300
318
|
} = {}) {
|
301
|
-
super(message);
|
302
|
-
this
|
303
|
-
}
|
304
|
-
static isNoContentGeneratedError(error) {
|
305
|
-
return error instanceof Error && error.name === "AI_NoContentGeneratedError";
|
319
|
+
super({ name: name8, message });
|
320
|
+
this[_a9] = true;
|
306
321
|
}
|
307
|
-
|
308
|
-
return
|
309
|
-
name: this.name,
|
310
|
-
cause: this.cause,
|
311
|
-
message: this.message,
|
312
|
-
stack: this.stack
|
313
|
-
};
|
322
|
+
static isInstance(error) {
|
323
|
+
return AISDKError.hasMarker(error, marker9);
|
314
324
|
}
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
super(message);
|
321
|
-
this.name = "AI_NoObjectGeneratedError";
|
322
|
-
}
|
323
|
-
static isNoObjectGeneratedError(error) {
|
324
|
-
return error instanceof Error && error.name === "AI_NoObjectGeneratedError";
|
325
|
+
/**
|
326
|
+
* @deprecated Use isInstance instead.
|
327
|
+
*/
|
328
|
+
static isNoContentGeneratedError(error) {
|
329
|
+
return error instanceof Error && error.name === name8;
|
325
330
|
}
|
331
|
+
/**
|
332
|
+
* @deprecated Do not use this method. It will be removed in the next major version.
|
333
|
+
*/
|
326
334
|
toJSON() {
|
327
335
|
return {
|
328
336
|
name: this.name,
|
@@ -332,75 +340,37 @@ var NoObjectGeneratedError = class extends Error {
|
|
332
340
|
};
|
333
341
|
}
|
334
342
|
};
|
335
|
-
|
336
|
-
// src/errors/no-such-tool-error.ts
|
337
|
-
var NoSuchToolError = class extends Error {
|
338
|
-
constructor({
|
339
|
-
toolName,
|
340
|
-
availableTools = void 0,
|
341
|
-
message = `Model tried to call unavailable tool '${toolName}'. ${availableTools === void 0 ? "No tools are available." : `Available tools: ${availableTools.join(", ")}.`}`
|
342
|
-
}) {
|
343
|
-
super(message);
|
344
|
-
this.name = "AI_NoSuchToolError";
|
345
|
-
this.toolName = toolName;
|
346
|
-
this.availableTools = availableTools;
|
347
|
-
}
|
348
|
-
static isNoSuchToolError(error) {
|
349
|
-
return error instanceof Error && error.name === "AI_NoSuchToolError" && "toolName" in error && error.toolName != void 0 && typeof error.name === "string";
|
350
|
-
}
|
351
|
-
toJSON() {
|
352
|
-
return {
|
353
|
-
name: this.name,
|
354
|
-
message: this.message,
|
355
|
-
stack: this.stack,
|
356
|
-
toolName: this.toolName,
|
357
|
-
availableTools: this.availableTools
|
358
|
-
};
|
359
|
-
}
|
360
|
-
};
|
361
|
-
|
362
|
-
// src/errors/retry-error.ts
|
363
|
-
var RetryError = class extends Error {
|
364
|
-
constructor({
|
365
|
-
message,
|
366
|
-
reason,
|
367
|
-
errors
|
368
|
-
}) {
|
369
|
-
super(message);
|
370
|
-
this.name = "AI_RetryError";
|
371
|
-
this.reason = reason;
|
372
|
-
this.errors = errors;
|
373
|
-
this.lastError = errors[errors.length - 1];
|
374
|
-
}
|
375
|
-
static isRetryError(error) {
|
376
|
-
return error instanceof Error && error.name === "AI_RetryError" && typeof error.reason === "string" && Array.isArray(error.errors);
|
377
|
-
}
|
378
|
-
toJSON() {
|
379
|
-
return {
|
380
|
-
name: this.name,
|
381
|
-
message: this.message,
|
382
|
-
reason: this.reason,
|
383
|
-
lastError: this.lastError,
|
384
|
-
errors: this.errors
|
385
|
-
};
|
386
|
-
}
|
387
|
-
};
|
343
|
+
_a9 = symbol9;
|
388
344
|
|
389
345
|
// src/errors/too-many-embedding-values-for-call-error.ts
|
390
|
-
var
|
346
|
+
var name9 = "AI_TooManyEmbeddingValuesForCallError";
|
347
|
+
var marker10 = `vercel.ai.error.${name9}`;
|
348
|
+
var symbol10 = Symbol.for(marker10);
|
349
|
+
var _a10;
|
350
|
+
var TooManyEmbeddingValuesForCallError = class extends AISDKError {
|
391
351
|
constructor(options) {
|
392
|
-
super(
|
393
|
-
|
394
|
-
|
395
|
-
|
352
|
+
super({
|
353
|
+
name: name9,
|
354
|
+
message: `Too many values for a single embedding call. The ${options.provider} model "${options.modelId}" can only embed up to ${options.maxEmbeddingsPerCall} values per call, but ${options.values.length} values were provided.`
|
355
|
+
});
|
356
|
+
this[_a10] = true;
|
396
357
|
this.provider = options.provider;
|
397
358
|
this.modelId = options.modelId;
|
398
359
|
this.maxEmbeddingsPerCall = options.maxEmbeddingsPerCall;
|
399
360
|
this.values = options.values;
|
400
361
|
}
|
401
|
-
static
|
402
|
-
return
|
362
|
+
static isInstance(error) {
|
363
|
+
return AISDKError.hasMarker(error, marker10);
|
403
364
|
}
|
365
|
+
/**
|
366
|
+
* @deprecated use `isInstance` instead
|
367
|
+
*/
|
368
|
+
static isTooManyEmbeddingValuesForCallError(error) {
|
369
|
+
return error instanceof Error && error.name === name9 && "provider" in error && typeof error.provider === "string" && "modelId" in error && typeof error.modelId === "string" && "maxEmbeddingsPerCall" in error && typeof error.maxEmbeddingsPerCall === "number" && "values" in error && Array.isArray(error.values);
|
370
|
+
}
|
371
|
+
/**
|
372
|
+
* @deprecated Do not use this method. It will be removed in the next major version.
|
373
|
+
*/
|
404
374
|
toJSON() {
|
405
375
|
return {
|
406
376
|
name: this.name,
|
@@ -413,50 +383,36 @@ var TooManyEmbeddingValuesForCallError = class extends Error {
|
|
413
383
|
};
|
414
384
|
}
|
415
385
|
};
|
416
|
-
|
417
|
-
// src/errors/tool-call-parse-error.ts
|
418
|
-
var ToolCallParseError = class extends Error {
|
419
|
-
constructor({
|
420
|
-
cause,
|
421
|
-
text,
|
422
|
-
tools,
|
423
|
-
message = `Failed to parse tool calls: ${getErrorMessage(cause)}`
|
424
|
-
}) {
|
425
|
-
super(message);
|
426
|
-
this.name = "AI_ToolCallParseError";
|
427
|
-
this.cause = cause;
|
428
|
-
this.text = text;
|
429
|
-
this.tools = tools;
|
430
|
-
}
|
431
|
-
static isToolCallParseError(error) {
|
432
|
-
return error instanceof Error && error.name === "AI_ToolCallParseError" && "cause" in error && error.cause != void 0 && "text" in error && error.text != void 0 && typeof error.text === "string" && "tools" in error && error.tools != void 0;
|
433
|
-
}
|
434
|
-
toJSON() {
|
435
|
-
return {
|
436
|
-
name: this.name,
|
437
|
-
message: this.message,
|
438
|
-
stack: this.stack,
|
439
|
-
cause: this.cause,
|
440
|
-
text: this.text,
|
441
|
-
tools: this.tools
|
442
|
-
};
|
443
|
-
}
|
444
|
-
};
|
386
|
+
_a10 = symbol10;
|
445
387
|
|
446
388
|
// src/errors/type-validation-error.ts
|
447
|
-
var
|
389
|
+
var name10 = "AI_TypeValidationError";
|
390
|
+
var marker11 = `vercel.ai.error.${name10}`;
|
391
|
+
var symbol11 = Symbol.for(marker11);
|
392
|
+
var _a11;
|
393
|
+
var TypeValidationError = class extends AISDKError {
|
448
394
|
constructor({ value, cause }) {
|
449
|
-
super(
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
395
|
+
super({
|
396
|
+
name: name10,
|
397
|
+
message: `Type validation failed: Value: ${JSON.stringify(value)}.
|
398
|
+
Error message: ${getErrorMessage(cause)}`,
|
399
|
+
cause
|
400
|
+
});
|
401
|
+
this[_a11] = true;
|
455
402
|
this.value = value;
|
456
403
|
}
|
404
|
+
static isInstance(error) {
|
405
|
+
return AISDKError.hasMarker(error, marker11);
|
406
|
+
}
|
407
|
+
/**
|
408
|
+
* @deprecated use `isInstance` instead
|
409
|
+
*/
|
457
410
|
static isTypeValidationError(error) {
|
458
|
-
return error instanceof Error && error.name ===
|
411
|
+
return error instanceof Error && error.name === name10;
|
459
412
|
}
|
413
|
+
/**
|
414
|
+
* @deprecated Do not use this method. It will be removed in the next major version.
|
415
|
+
*/
|
460
416
|
toJSON() {
|
461
417
|
return {
|
462
418
|
name: this.name,
|
@@ -467,17 +423,34 @@ Error message: ${getErrorMessage(cause)}`
|
|
467
423
|
};
|
468
424
|
}
|
469
425
|
};
|
426
|
+
_a11 = symbol11;
|
470
427
|
|
471
428
|
// src/errors/unsupported-functionality-error.ts
|
472
|
-
var
|
429
|
+
var name11 = "AI_UnsupportedFunctionalityError";
|
430
|
+
var marker12 = `vercel.ai.error.${name11}`;
|
431
|
+
var symbol12 = Symbol.for(marker12);
|
432
|
+
var _a12;
|
433
|
+
var UnsupportedFunctionalityError = class extends AISDKError {
|
473
434
|
constructor({ functionality }) {
|
474
|
-
super(
|
475
|
-
|
435
|
+
super({
|
436
|
+
name: name11,
|
437
|
+
message: `'${functionality}' functionality not supported.`
|
438
|
+
});
|
439
|
+
this[_a12] = true;
|
476
440
|
this.functionality = functionality;
|
477
441
|
}
|
442
|
+
static isInstance(error) {
|
443
|
+
return AISDKError.hasMarker(error, marker12);
|
444
|
+
}
|
445
|
+
/**
|
446
|
+
* @deprecated Use isInstance instead.
|
447
|
+
*/
|
478
448
|
static isUnsupportedFunctionalityError(error) {
|
479
|
-
return error instanceof Error && error.name ===
|
449
|
+
return error instanceof Error && error.name === name11 && typeof error.functionality === "string";
|
480
450
|
}
|
451
|
+
/**
|
452
|
+
* @deprecated Do not use this method. It will be removed in the next major version.
|
453
|
+
*/
|
481
454
|
toJSON() {
|
482
455
|
return {
|
483
456
|
name: this.name,
|
@@ -487,52 +460,20 @@ var UnsupportedFunctionalityError = class extends Error {
|
|
487
460
|
};
|
488
461
|
}
|
489
462
|
};
|
490
|
-
|
491
|
-
// src/errors/unsupported-json-schema-error.ts
|
492
|
-
var UnsupportedJSONSchemaError = class extends Error {
|
493
|
-
constructor({
|
494
|
-
schema,
|
495
|
-
reason,
|
496
|
-
message = `Unsupported JSON schema: ${reason}`
|
497
|
-
}) {
|
498
|
-
super(message);
|
499
|
-
this.name = "AI_UnsupportedJSONSchemaError";
|
500
|
-
this.reason = reason;
|
501
|
-
this.schema = schema;
|
502
|
-
}
|
503
|
-
static isUnsupportedJSONSchemaError(error) {
|
504
|
-
return error instanceof Error && error.name === "AI_UnsupportedJSONSchemaError" && "reason" in error && error.reason != void 0 && "schema" in error && error.schema !== void 0;
|
505
|
-
}
|
506
|
-
toJSON() {
|
507
|
-
return {
|
508
|
-
name: this.name,
|
509
|
-
message: this.message,
|
510
|
-
stack: this.stack,
|
511
|
-
reason: this.reason,
|
512
|
-
schema: this.schema
|
513
|
-
};
|
514
|
-
}
|
515
|
-
};
|
463
|
+
_a12 = symbol12;
|
516
464
|
export {
|
465
|
+
AISDKError,
|
517
466
|
APICallError,
|
518
|
-
DownloadError,
|
519
467
|
EmptyResponseBodyError,
|
520
|
-
InvalidArgumentError,
|
521
|
-
InvalidDataContentError,
|
522
468
|
InvalidPromptError,
|
523
469
|
InvalidResponseDataError,
|
524
|
-
InvalidToolArgumentsError,
|
525
470
|
JSONParseError,
|
526
471
|
LoadAPIKeyError,
|
527
472
|
LoadSettingError,
|
528
473
|
NoContentGeneratedError,
|
529
|
-
NoObjectGeneratedError,
|
530
|
-
NoSuchToolError,
|
531
|
-
RetryError,
|
532
474
|
TooManyEmbeddingValuesForCallError,
|
533
|
-
ToolCallParseError,
|
534
475
|
TypeValidationError,
|
535
476
|
UnsupportedFunctionalityError,
|
536
|
-
|
477
|
+
getErrorMessage
|
537
478
|
};
|
538
479
|
//# sourceMappingURL=index.mjs.map
|