@ai-sdk/provider-utils 4.0.53 → 4.0.55
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 +19 -0
- package/dist/index.d.mts +38 -12
- package/dist/index.d.ts +38 -12
- package/dist/index.js +13 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +12 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/combine-headers.ts +1 -1
- package/src/delay.ts +1 -1
- package/src/embedding-model-capabilities.ts +23 -0
- package/src/index.ts +5 -1
- package/src/is-url-supported.ts +7 -3
- package/src/resolve.ts +1 -1
- package/src/to-json-schema/zod3-to-json-schema/parsers/string.ts +1 -1
- package/src/types/content-part.ts +6 -0
- package/src/types/tool-approval-request.ts +8 -0
- package/src/validate-download-url.ts +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/provider-utils",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.55",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@standard-schema/spec": "^1.1.0",
|
|
37
37
|
"eventsource-parser": "^3.0.8",
|
|
38
38
|
"undici": "^6.28.0",
|
|
39
|
-
"@ai-sdk/provider": "3.0.
|
|
39
|
+
"@ai-sdk/provider": "3.0.18"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/node": "20.17.24",
|
package/src/combine-headers.ts
CHANGED
package/src/delay.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { SharedV3ProviderOptions } from '@ai-sdk/provider';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Symbol for exposing the UTF-8 input byte budget of an embedding model.
|
|
3
5
|
*
|
|
@@ -7,3 +9,24 @@
|
|
|
7
9
|
export const EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL = Symbol.for(
|
|
8
10
|
'vercel.ai.embeddingModel.maxInputBytesPerCall',
|
|
9
11
|
);
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Symbol for transforming provider options for an automatically batched
|
|
15
|
+
* embedding model call.
|
|
16
|
+
*
|
|
17
|
+
* This capability is experimental and intentionally lives outside the versioned
|
|
18
|
+
* embedding model specification.
|
|
19
|
+
*/
|
|
20
|
+
export const EMBEDDING_MODEL_PROVIDER_OPTIONS_TRANSFORMER = Symbol.for(
|
|
21
|
+
'vercel.ai.embeddingModel.providerOptionsTransformer',
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
export type EmbeddingModelProviderOptionsTransformer = (options: {
|
|
25
|
+
providerOptions: SharedV3ProviderOptions | undefined;
|
|
26
|
+
values: Array<string>;
|
|
27
|
+
startIndex: number;
|
|
28
|
+
endIndex: number;
|
|
29
|
+
}) =>
|
|
30
|
+
| SharedV3ProviderOptions
|
|
31
|
+
| undefined
|
|
32
|
+
| PromiseLike<SharedV3ProviderOptions | undefined>;
|
package/src/index.ts
CHANGED
|
@@ -11,11 +11,15 @@ export { convertImageModelFileToDataUri } from './convert-image-model-file-to-da
|
|
|
11
11
|
export { convertToFormData } from './convert-to-form-data';
|
|
12
12
|
export { downloadBlob } from './download-blob';
|
|
13
13
|
export { DownloadError } from './download-error';
|
|
14
|
+
export {
|
|
15
|
+
EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL as EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL,
|
|
16
|
+
EMBEDDING_MODEL_PROVIDER_OPTIONS_TRANSFORMER as EXPERIMENTAL_EMBEDDING_MODEL_PROVIDER_OPTIONS_TRANSFORMER,
|
|
17
|
+
type EmbeddingModelProviderOptionsTransformer,
|
|
18
|
+
} from './embedding-model-capabilities';
|
|
14
19
|
export {
|
|
15
20
|
readResponseWithSizeLimit,
|
|
16
21
|
DEFAULT_MAX_DOWNLOAD_SIZE,
|
|
17
22
|
} from './read-response-with-size-limit';
|
|
18
|
-
export { EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL as EXPERIMENTAL_EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL } from './embedding-model-capabilities';
|
|
19
23
|
export { fetchWithValidatedRedirects } from './fetch-with-validated-redirects';
|
|
20
24
|
export * from './fetch-function';
|
|
21
25
|
export { createIdGenerator, generateId, type IdGenerator } from './generate-id';
|
package/src/is-url-supported.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Checks if the given URL is supported natively by the model.
|
|
3
3
|
*
|
|
4
|
-
* @param mediaType - The media type of the URL. Case-
|
|
4
|
+
* @param mediaType - The media type of the URL. Case-insensitive.
|
|
5
5
|
* @param url - The URL to check.
|
|
6
|
-
* @param supportedUrls - A record where keys are case-
|
|
6
|
+
* @param supportedUrls - A record where keys are case-insensitive media types (or '*')
|
|
7
7
|
* and values are arrays of RegExp patterns for URLs.
|
|
8
8
|
*
|
|
9
9
|
* @returns `true` if the URL matches a pattern under the specific media type
|
|
@@ -32,7 +32,11 @@ export function isUrlSupported({
|
|
|
32
32
|
: { mediaTypePrefix: mediaType.replace(/\*/, ''), regexes: value };
|
|
33
33
|
})
|
|
34
34
|
// gather all regexp pattern from matched media type prefixes:
|
|
35
|
-
.filter(({ mediaTypePrefix }) =>
|
|
35
|
+
.filter(({ mediaTypePrefix }) =>
|
|
36
|
+
mediaTypePrefix === '' || mediaTypePrefix.endsWith('/')
|
|
37
|
+
? mediaType.startsWith(mediaTypePrefix)
|
|
38
|
+
: mediaType === mediaTypePrefix,
|
|
39
|
+
)
|
|
36
40
|
.flatMap(({ regexes }) => regexes)
|
|
37
41
|
// check if any pattern matches the url:
|
|
38
42
|
.some(pattern => pattern.test(url))
|
package/src/resolve.ts
CHANGED
|
@@ -20,7 +20,7 @@ export const zodPatterns = {
|
|
|
20
20
|
* `a-z` was added to replicate /i flag
|
|
21
21
|
*/
|
|
22
22
|
email:
|
|
23
|
-
/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'
|
|
23
|
+
/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9-]*\.)+[a-zA-Z]{2,}$/,
|
|
24
24
|
/**
|
|
25
25
|
* Constructed a valid Unicode RegExp
|
|
26
26
|
*
|
|
@@ -281,6 +281,12 @@ export type ToolResultOutput =
|
|
|
281
281
|
*/
|
|
282
282
|
url: string;
|
|
283
283
|
|
|
284
|
+
/**
|
|
285
|
+
* IANA media type.
|
|
286
|
+
* @see https://www.iana.org/assignments/media-types/media-types.xhtml
|
|
287
|
+
*/
|
|
288
|
+
mediaType?: string;
|
|
289
|
+
|
|
284
290
|
/**
|
|
285
291
|
* Provider-specific options.
|
|
286
292
|
*/
|
|
@@ -19,4 +19,12 @@ export type ToolApprovalRequest = {
|
|
|
19
19
|
* Present only when `experimental_toolApprovalSecret` is configured.
|
|
20
20
|
*/
|
|
21
21
|
signature?: string;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Tool input before input schema validation and transformation.
|
|
25
|
+
*
|
|
26
|
+
* This is included when it differs from the validated tool input so that
|
|
27
|
+
* approved tool calls can be safely revalidated before execution.
|
|
28
|
+
*/
|
|
29
|
+
inputSchemaInput?: unknown;
|
|
22
30
|
};
|