ai 7.0.98 → 7.0.99
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 +8 -0
- package/dist/index.d.ts +7 -2
- package/dist/index.js +16 -4
- package/dist/index.js.map +1 -1
- package/dist/internal/index.js +1 -1
- package/docs/02-foundations/02-providers-and-models.mdx +1 -0
- package/docs/07-reference/01-ai-sdk-core/06-embed-many.mdx +1 -1
- package/docs/07-reference/05-ai-sdk-errors/ai-invalid-argument-error.mdx +6 -1
- package/package.json +4 -4
- package/src/embed/embed-many.ts +5 -2
- package/src/util/data-url.ts +14 -2
- package/src/util/split-array.ts +8 -1
package/dist/internal/index.js
CHANGED
|
@@ -97,6 +97,7 @@ The open-source community has created the following providers:
|
|
|
97
97
|
- [Crusoe Provider](/providers/community-providers/crusoe) (`crusoe-ai-provider`)
|
|
98
98
|
- [Neon AI Gateway Provider](/providers/community-providers/neon-ai-gateway) (`@neon/ai-sdk-provider`)
|
|
99
99
|
- [Interfaze Provider](/providers/community-providers/interfaze) (`@interfaze-ai/ai-sdk`)
|
|
100
|
+
- [Telnyx Provider](/providers/community-providers/telnyx) (`@telnyx/ai-sdk-provider`)
|
|
100
101
|
|
|
101
102
|
## Self-Hosted Models
|
|
102
103
|
|
|
@@ -81,7 +81,7 @@ const { embeddings } = await embedMany({
|
|
|
81
81
|
type: 'number',
|
|
82
82
|
isOptional: true,
|
|
83
83
|
description:
|
|
84
|
-
'Maximum number of concurrent requests
|
|
84
|
+
'Maximum number of concurrent requests when a request is split into multiple model calls. Must be greater than 0 when chunking is active and the model supports parallel calls; invalid values throw AI_InvalidArgumentError. Default: Infinity.',
|
|
85
85
|
},
|
|
86
86
|
{
|
|
87
87
|
name: 'runtimeContext',
|
|
@@ -7,6 +7,11 @@ description: Learn how to fix AI_InvalidArgumentError
|
|
|
7
7
|
|
|
8
8
|
This error occurs when an invalid argument was provided.
|
|
9
9
|
|
|
10
|
+
For example, `getTextFromDataUrl` throws this error when its `dataUrl` argument
|
|
11
|
+
is malformed or cannot be decoded. Utility validation that is used by higher
|
|
12
|
+
level APIs also uses this error, so you can handle invalid arguments with one
|
|
13
|
+
stable error guard.
|
|
14
|
+
|
|
10
15
|
## Properties
|
|
11
16
|
|
|
12
17
|
- `parameter`: The name of the parameter that is invalid
|
|
@@ -21,6 +26,6 @@ You can check if an error is an instance of `AI_InvalidArgumentError` using:
|
|
|
21
26
|
import { InvalidArgumentError } from 'ai';
|
|
22
27
|
|
|
23
28
|
if (InvalidArgumentError.isInstance(error)) {
|
|
24
|
-
|
|
29
|
+
console.error(`Invalid ${error.parameter}:`, error.message);
|
|
25
30
|
}
|
|
26
31
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ai",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.99",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "AI SDK by Vercel - build apps like ChatGPT, Claude, Gemini, and more with a single interface for any model using the Vercel AI Gateway or go direct to OpenAI, Anthropic, Google, or any other model provider.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -42,14 +42,14 @@
|
|
|
42
42
|
}
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@ai-sdk/gateway": "4.0.
|
|
45
|
+
"@ai-sdk/gateway": "4.0.80",
|
|
46
46
|
"@ai-sdk/provider": "4.0.14",
|
|
47
47
|
"@ai-sdk/provider-utils": "5.0.40"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@ai-sdk/amazon-bedrock": "5.0.82",
|
|
51
|
-
"@ai-sdk/deepseek": "3.0.
|
|
52
|
-
"@ai-sdk/google": "4.0.
|
|
51
|
+
"@ai-sdk/deepseek": "3.0.44",
|
|
52
|
+
"@ai-sdk/google": "4.0.69",
|
|
53
53
|
"@ai-sdk/groq": "4.0.41",
|
|
54
54
|
"@ai-sdk/huggingface": "2.0.48",
|
|
55
55
|
"@ai-sdk/moonshotai": "3.0.49",
|
package/src/embed/embed-many.ts
CHANGED
|
@@ -40,7 +40,9 @@ const originalGenerateCallId = createIdGenerator({
|
|
|
40
40
|
* @param abortSignal - An optional abort signal that can be used to cancel the call.
|
|
41
41
|
* @param headers - Additional HTTP headers to be sent with the request. Only applicable for HTTP-based providers.
|
|
42
42
|
*
|
|
43
|
-
* @param maxParallelCalls - Maximum number of concurrent requests
|
|
43
|
+
* @param maxParallelCalls - Maximum number of concurrent requests when a request is split into
|
|
44
|
+
* multiple model calls. Must be greater than 0 when the model supports parallel calls.
|
|
45
|
+
* Default: Infinity.
|
|
44
46
|
*
|
|
45
47
|
* @param telemetry - Optional telemetry configuration.
|
|
46
48
|
* @param runtimeContext - User-defined runtime context passed to callbacks and, when explicitly included, telemetry.
|
|
@@ -121,7 +123,8 @@ export async function embedMany<RUNTIME_CONTEXT extends Context = Context>({
|
|
|
121
123
|
providerOptions?: ProviderOptions;
|
|
122
124
|
|
|
123
125
|
/**
|
|
124
|
-
* Maximum number of concurrent requests.
|
|
126
|
+
* Maximum number of concurrent requests when a request is split into multiple model calls.
|
|
127
|
+
* Must be greater than 0 when the model supports parallel calls.
|
|
125
128
|
*
|
|
126
129
|
* @default Infinity
|
|
127
130
|
*/
|
package/src/util/data-url.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { InvalidArgumentError } from '../error/invalid-argument-error';
|
|
2
|
+
|
|
1
3
|
// atob needs to be invoked as a function call, not as a method call.
|
|
2
4
|
// Otherwise Cloudflare will throw a
|
|
3
5
|
// "TypeError: Illegal invocation: function called with incorrect this reference"
|
|
@@ -5,18 +7,28 @@ const { atob } = globalThis;
|
|
|
5
7
|
|
|
6
8
|
/**
|
|
7
9
|
* Converts a data URL of type text/* to a text string.
|
|
10
|
+
*
|
|
11
|
+
* @throws {InvalidArgumentError} If the data URL is malformed or cannot be decoded.
|
|
8
12
|
*/
|
|
9
13
|
export function getTextFromDataUrl(dataUrl: string): string {
|
|
10
14
|
const [header, base64Content] = dataUrl.split(',');
|
|
11
15
|
const mediaType = header.split(';')[0].split(':')[1];
|
|
12
16
|
|
|
13
17
|
if (mediaType == null || base64Content == null) {
|
|
14
|
-
throw new
|
|
18
|
+
throw new InvalidArgumentError({
|
|
19
|
+
parameter: 'dataUrl',
|
|
20
|
+
value: dataUrl,
|
|
21
|
+
message: 'Invalid data URL format',
|
|
22
|
+
});
|
|
15
23
|
}
|
|
16
24
|
|
|
17
25
|
try {
|
|
18
26
|
return atob(base64Content);
|
|
19
27
|
} catch {
|
|
20
|
-
throw new
|
|
28
|
+
throw new InvalidArgumentError({
|
|
29
|
+
parameter: 'dataUrl',
|
|
30
|
+
value: dataUrl,
|
|
31
|
+
message: 'Error decoding data URL',
|
|
32
|
+
});
|
|
21
33
|
}
|
|
22
34
|
}
|
package/src/util/split-array.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { InvalidArgumentError } from '../error/invalid-argument-error';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Splits an array into chunks of a specified size.
|
|
3
5
|
*
|
|
@@ -5,10 +7,15 @@
|
|
|
5
7
|
* @param {T[]} array - The array to split.
|
|
6
8
|
* @param {number} chunkSize - The size of each chunk.
|
|
7
9
|
* @returns {T[][]} - A new array containing the chunks.
|
|
10
|
+
* @throws {InvalidArgumentError} If the chunk size is not greater than 0.
|
|
8
11
|
*/
|
|
9
12
|
export function splitArray<T>(array: T[], chunkSize: number): T[][] {
|
|
10
13
|
if (chunkSize <= 0) {
|
|
11
|
-
throw new
|
|
14
|
+
throw new InvalidArgumentError({
|
|
15
|
+
parameter: 'chunkSize',
|
|
16
|
+
value: chunkSize,
|
|
17
|
+
message: 'chunkSize must be greater than 0',
|
|
18
|
+
});
|
|
12
19
|
}
|
|
13
20
|
|
|
14
21
|
const result = [];
|