@ai-sdk/provider 4.0.0-beta.1 → 4.0.0-beta.10
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 +68 -13
- package/dist/index.d.mts +681 -366
- package/dist/index.d.ts +681 -366
- package/dist/index.js +54 -31
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +51 -29
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -4
- package/src/errors/get-error-message.ts +1 -1
- package/src/errors/index.ts +1 -0
- package/src/errors/no-such-provider-reference-error.ts +35 -0
- package/src/files/index.ts +1 -0
- package/src/files/v4/files-v4-upload-file-call-options.ts +28 -0
- package/src/files/v4/files-v4-upload-file-result.ts +35 -0
- package/src/files/v4/files-v4.ts +25 -0
- package/src/files/v4/index.ts +3 -0
- package/src/image-model/v4/image-model-v4-result.ts +73 -0
- package/src/image-model/v4/image-model-v4.ts +2 -69
- package/src/image-model/v4/index.ts +4 -3
- package/src/index.ts +2 -0
- package/src/language-model/v4/index.ts +2 -0
- package/src/language-model/v4/language-model-v4-call-options.ts +13 -0
- package/src/language-model/v4/language-model-v4-content.ts +4 -0
- package/src/language-model/v4/language-model-v4-custom-content.ts +21 -0
- package/src/language-model/v4/language-model-v4-prompt.ts +61 -19
- package/src/language-model/v4/language-model-v4-reasoning-file.ts +32 -0
- package/src/language-model/v4/language-model-v4-stream-part.ts +4 -0
- package/src/provider/v4/provider-v4.ts +16 -0
- package/src/reranking-model/v4/index.ts +1 -0
- package/src/reranking-model/v4/reranking-model-v4-result.ts +68 -0
- package/src/reranking-model/v4/reranking-model-v4.ts +4 -64
- package/src/shared/v4/index.ts +1 -0
- package/src/shared/v4/shared-v4-provider-reference.ts +15 -0
- package/src/shared/v4/shared-v4-warning.ts +16 -0
- package/src/skills/index.ts +1 -0
- package/src/skills/v4/index.ts +6 -0
- package/src/skills/v4/skills-v4-upload-skill-call-options.ts +30 -0
- package/src/skills/v4/skills-v4-upload-skill-result.ts +40 -0
- package/src/skills/v4/skills-v4.ts +28 -0
- package/src/speech-model/v4/index.ts +1 -0
- package/src/speech-model/v4/speech-model-v4-result.ts +64 -0
- package/src/speech-model/v4/speech-model-v4.ts +4 -60
- package/src/transcription-model/v4/index.ts +1 -0
- package/src/transcription-model/v4/transcription-model-v4-result.ts +92 -0
- package/src/transcription-model/v4/transcription-model-v4.ts +4 -88
- package/src/video-model/v4/index.ts +4 -3
- package/src/video-model/v4/video-model-v4-result.ts +92 -0
- package/src/video-model/v4/video-model-v4.ts +2 -88
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/provider",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.10",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -56,8 +56,6 @@
|
|
|
56
56
|
"build": "pnpm clean && tsup --tsconfig tsconfig.build.json",
|
|
57
57
|
"build:watch": "pnpm clean && tsup --watch",
|
|
58
58
|
"clean": "del-cli dist *.tsbuildinfo",
|
|
59
|
-
"
|
|
60
|
-
"type-check": "tsc --build",
|
|
61
|
-
"prettier-check": "prettier --check \"./**/*.ts*\""
|
|
59
|
+
"type-check": "tsc --build"
|
|
62
60
|
}
|
|
63
61
|
}
|
package/src/errors/index.ts
CHANGED
|
@@ -10,6 +10,7 @@ export { LoadAPIKeyError } from './load-api-key-error';
|
|
|
10
10
|
export { LoadSettingError } from './load-setting-error';
|
|
11
11
|
export { NoContentGeneratedError } from './no-content-generated-error';
|
|
12
12
|
export { NoSuchModelError } from './no-such-model-error';
|
|
13
|
+
export { NoSuchProviderReferenceError } from './no-such-provider-reference-error';
|
|
13
14
|
export { TooManyEmbeddingValuesForCallError } from './too-many-embedding-values-for-call-error';
|
|
14
15
|
export type { TypeValidationContext } from './type-validation-error';
|
|
15
16
|
export { TypeValidationError } from './type-validation-error';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { SharedV4ProviderReference } from '../shared/v4/shared-v4-provider-reference';
|
|
2
|
+
import { AISDKError } from './ai-sdk-error';
|
|
3
|
+
|
|
4
|
+
const name = 'AI_NoSuchProviderReferenceError';
|
|
5
|
+
const marker = `vercel.ai.error.${name}`;
|
|
6
|
+
const symbol = Symbol.for(marker);
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Thrown when a provider reference cannot be resolved because the specified
|
|
10
|
+
* provider is not found in the provider reference mapping.
|
|
11
|
+
*/
|
|
12
|
+
export class NoSuchProviderReferenceError extends AISDKError {
|
|
13
|
+
private readonly [symbol] = true; // used in isInstance
|
|
14
|
+
|
|
15
|
+
readonly provider: string;
|
|
16
|
+
readonly reference: SharedV4ProviderReference;
|
|
17
|
+
|
|
18
|
+
constructor({
|
|
19
|
+
provider,
|
|
20
|
+
reference,
|
|
21
|
+
message = `No provider reference found for provider '${provider}'. Available providers: ${Object.keys(reference).join(', ')}`,
|
|
22
|
+
}: {
|
|
23
|
+
provider: string;
|
|
24
|
+
reference: SharedV4ProviderReference;
|
|
25
|
+
message?: string;
|
|
26
|
+
}) {
|
|
27
|
+
super({ name, message });
|
|
28
|
+
this.provider = provider;
|
|
29
|
+
this.reference = reference;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
static isInstance(error: unknown): error is NoSuchProviderReferenceError {
|
|
33
|
+
return AISDKError.hasMarker(error, marker);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './v4/index';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { SharedV4ProviderOptions } from '../../shared/v4/shared-v4-provider-options';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Options for uploading a file via the files interface.
|
|
5
|
+
*/
|
|
6
|
+
export type FilesV4UploadFileCallOptions = {
|
|
7
|
+
/**
|
|
8
|
+
* The file data as raw bytes or a base64-encoded string.
|
|
9
|
+
*/
|
|
10
|
+
data: Uint8Array | string;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The IANA media type of the file (e.g. `'application/pdf'`).
|
|
14
|
+
*/
|
|
15
|
+
mediaType: string;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The filename of the file.
|
|
19
|
+
*/
|
|
20
|
+
filename?: string;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Additional provider-specific options. They are passed through
|
|
24
|
+
* to the provider from the AI SDK and enable provider-specific
|
|
25
|
+
* functionality that can be fully encapsulated in the provider.
|
|
26
|
+
*/
|
|
27
|
+
providerOptions?: SharedV4ProviderOptions;
|
|
28
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { SharedV4ProviderMetadata } from '../../shared/v4/shared-v4-provider-metadata';
|
|
2
|
+
import { SharedV4ProviderReference } from '../../shared/v4/shared-v4-provider-reference';
|
|
3
|
+
import { SharedV4Warning } from '../../shared/v4/shared-v4-warning';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Result of uploading a file via the files interface.
|
|
7
|
+
*/
|
|
8
|
+
export type FilesV4UploadFileResult = {
|
|
9
|
+
/**
|
|
10
|
+
* A provider reference mapping provider names to provider-specific file identifiers.
|
|
11
|
+
*/
|
|
12
|
+
providerReference: SharedV4ProviderReference;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The IANA media type of the uploaded file, if available from the provider.
|
|
16
|
+
*/
|
|
17
|
+
mediaType?: string;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The filename of the uploaded file, if available from the provider.
|
|
21
|
+
*/
|
|
22
|
+
filename?: string;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Additional provider-specific metadata. They are passed through
|
|
26
|
+
* to the provider from the AI SDK and enable provider-specific
|
|
27
|
+
* functionality that can be fully encapsulated in the provider.
|
|
28
|
+
*/
|
|
29
|
+
providerMetadata?: SharedV4ProviderMetadata;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Warnings from the provider.
|
|
33
|
+
*/
|
|
34
|
+
warnings: Array<SharedV4Warning>;
|
|
35
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { FilesV4UploadFileCallOptions } from './files-v4-upload-file-call-options';
|
|
2
|
+
import { FilesV4UploadFileResult } from './files-v4-upload-file-result';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Specification for a file management interface that implements the files interface version 4.
|
|
6
|
+
*/
|
|
7
|
+
export type FilesV4 = {
|
|
8
|
+
/**
|
|
9
|
+
* The files interface must specify which files interface version it implements.
|
|
10
|
+
*/
|
|
11
|
+
readonly specificationVersion: 'v4';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Provider ID.
|
|
15
|
+
*/
|
|
16
|
+
readonly provider: string;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Uploads a file to the provider and returns a provider reference
|
|
20
|
+
* that can be used in subsequent API calls.
|
|
21
|
+
*/
|
|
22
|
+
uploadFile(
|
|
23
|
+
options: FilesV4UploadFileCallOptions,
|
|
24
|
+
): PromiseLike<FilesV4UploadFileResult>;
|
|
25
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { JSONArray, JSONValue } from '../../json-value';
|
|
2
|
+
import { SharedV4Warning } from '../../shared/v4/shared-v4-warning';
|
|
3
|
+
import { ImageModelV4Usage } from './image-model-v4-usage';
|
|
4
|
+
|
|
5
|
+
export type ImageModelV4ProviderMetadata = Record<
|
|
6
|
+
string,
|
|
7
|
+
{
|
|
8
|
+
images: JSONArray;
|
|
9
|
+
} & JSONValue
|
|
10
|
+
>;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The result of an image model doGenerate call.
|
|
14
|
+
*/
|
|
15
|
+
export type ImageModelV4Result = {
|
|
16
|
+
/**
|
|
17
|
+
* Generated images as base64 encoded strings or binary data.
|
|
18
|
+
* The images should be returned without any unnecessary conversion.
|
|
19
|
+
* If the API returns base64 encoded strings, the images should be returned
|
|
20
|
+
* as base64 encoded strings. If the API returns binary data, the images should
|
|
21
|
+
* be returned as binary data.
|
|
22
|
+
*/
|
|
23
|
+
images: Array<string> | Array<Uint8Array>;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Warnings for the call, e.g. unsupported features.
|
|
27
|
+
*/
|
|
28
|
+
warnings: Array<SharedV4Warning>;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Additional provider-specific metadata. They are passed through
|
|
32
|
+
* from the provider to the AI SDK and enable provider-specific
|
|
33
|
+
* results that can be fully encapsulated in the provider.
|
|
34
|
+
*
|
|
35
|
+
* The outer record is keyed by the provider name, and the inner
|
|
36
|
+
* record is provider-specific metadata. It always includes an
|
|
37
|
+
* `images` key with image-specific metadata
|
|
38
|
+
*
|
|
39
|
+
* ```ts
|
|
40
|
+
* {
|
|
41
|
+
* "openai": {
|
|
42
|
+
* "images": ["revisedPrompt": "Revised prompt here."]
|
|
43
|
+
* }
|
|
44
|
+
* }
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
providerMetadata?: ImageModelV4ProviderMetadata;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Response information for telemetry and debugging purposes.
|
|
51
|
+
*/
|
|
52
|
+
response: {
|
|
53
|
+
/**
|
|
54
|
+
* Timestamp for the start of the generated response.
|
|
55
|
+
*/
|
|
56
|
+
timestamp: Date;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The ID of the response model that was used to generate the response.
|
|
60
|
+
*/
|
|
61
|
+
modelId: string;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Response headers.
|
|
65
|
+
*/
|
|
66
|
+
headers: Record<string, string> | undefined;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Optional token usage for the image generation call (if the provider reports it).
|
|
71
|
+
*/
|
|
72
|
+
usage?: ImageModelV4Usage;
|
|
73
|
+
};
|
|
@@ -1,14 +1,5 @@
|
|
|
1
|
-
import { JSONArray, JSONValue } from '../../json-value';
|
|
2
|
-
import { ImageModelV4Usage } from './image-model-v4-usage';
|
|
3
1
|
import { ImageModelV4CallOptions } from './image-model-v4-call-options';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
export type ImageModelV4ProviderMetadata = Record<
|
|
7
|
-
string,
|
|
8
|
-
{
|
|
9
|
-
images: JSONArray;
|
|
10
|
-
} & JSONValue
|
|
11
|
-
>;
|
|
2
|
+
import { ImageModelV4Result } from './image-model-v4-result';
|
|
12
3
|
|
|
13
4
|
type GetMaxImagesPerCallFunction = (options: {
|
|
14
5
|
modelId: string;
|
|
@@ -48,63 +39,5 @@ export type ImageModelV4 = {
|
|
|
48
39
|
/**
|
|
49
40
|
* Generates an array of images.
|
|
50
41
|
*/
|
|
51
|
-
doGenerate(options: ImageModelV4CallOptions): PromiseLike<
|
|
52
|
-
/**
|
|
53
|
-
* Generated images as base64 encoded strings or binary data.
|
|
54
|
-
* The images should be returned without any unnecessary conversion.
|
|
55
|
-
* If the API returns base64 encoded strings, the images should be returned
|
|
56
|
-
* as base64 encoded strings. If the API returns binary data, the images should
|
|
57
|
-
* be returned as binary data.
|
|
58
|
-
*/
|
|
59
|
-
images: Array<string> | Array<Uint8Array>;
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Warnings for the call, e.g. unsupported features.
|
|
63
|
-
*/
|
|
64
|
-
warnings: Array<SharedV4Warning>;
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Additional provider-specific metadata. They are passed through
|
|
68
|
-
* from the provider to the AI SDK and enable provider-specific
|
|
69
|
-
* results that can be fully encapsulated in the provider.
|
|
70
|
-
*
|
|
71
|
-
* The outer record is keyed by the provider name, and the inner
|
|
72
|
-
* record is provider-specific metadata. It always includes an
|
|
73
|
-
* `images` key with image-specific metadata
|
|
74
|
-
*
|
|
75
|
-
* ```ts
|
|
76
|
-
* {
|
|
77
|
-
* "openai": {
|
|
78
|
-
* "images": ["revisedPrompt": "Revised prompt here."]
|
|
79
|
-
* }
|
|
80
|
-
* }
|
|
81
|
-
* ```
|
|
82
|
-
*/
|
|
83
|
-
providerMetadata?: ImageModelV4ProviderMetadata;
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Response information for telemetry and debugging purposes.
|
|
87
|
-
*/
|
|
88
|
-
response: {
|
|
89
|
-
/**
|
|
90
|
-
* Timestamp for the start of the generated response.
|
|
91
|
-
*/
|
|
92
|
-
timestamp: Date;
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* The ID of the response model that was used to generate the response.
|
|
96
|
-
*/
|
|
97
|
-
modelId: string;
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Response headers.
|
|
101
|
-
*/
|
|
102
|
-
headers: Record<string, string> | undefined;
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Optional token usage for the image generation call (if the provider reports it).
|
|
107
|
-
*/
|
|
108
|
-
usage?: ImageModelV4Usage;
|
|
109
|
-
}>;
|
|
42
|
+
doGenerate(options: ImageModelV4CallOptions): PromiseLike<ImageModelV4Result>;
|
|
110
43
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
export type { ImageModelV4 } from './image-model-v4';
|
|
2
|
+
export type { ImageModelV4CallOptions } from './image-model-v4-call-options';
|
|
1
3
|
export type {
|
|
2
|
-
ImageModelV4,
|
|
3
4
|
ImageModelV4ProviderMetadata,
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
ImageModelV4Result,
|
|
6
|
+
} from './image-model-v4-result';
|
|
6
7
|
export type { ImageModelV4Usage } from './image-model-v4-usage';
|
|
7
8
|
export type { ImageModelV4File } from './image-model-v4-file';
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from './embedding-model/index';
|
|
2
2
|
export * from './errors/index';
|
|
3
|
+
export * from './files/index';
|
|
3
4
|
export * from './image-model/index';
|
|
4
5
|
export * from './image-model-middleware/index';
|
|
5
6
|
export * from './json-value/index';
|
|
@@ -9,6 +10,7 @@ export * from './language-model/index';
|
|
|
9
10
|
export * from './provider/index';
|
|
10
11
|
export * from './reranking-model/index';
|
|
11
12
|
export * from './shared/index';
|
|
13
|
+
export * from './skills/index';
|
|
12
14
|
export * from './speech-model/index';
|
|
13
15
|
export * from './transcription-model/index';
|
|
14
16
|
export * from './video-model/index';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './language-model-v4';
|
|
2
2
|
export * from './language-model-v4-call-options';
|
|
3
3
|
export * from './language-model-v4-content';
|
|
4
|
+
export * from './language-model-v4-custom-content';
|
|
4
5
|
export * from './language-model-v4-data-content';
|
|
5
6
|
export * from './language-model-v4-file';
|
|
6
7
|
export * from './language-model-v4-finish-reason';
|
|
@@ -9,6 +10,7 @@ export * from './language-model-v4-generate-result';
|
|
|
9
10
|
export * from './language-model-v4-prompt';
|
|
10
11
|
export * from './language-model-v4-provider-tool';
|
|
11
12
|
export * from './language-model-v4-reasoning';
|
|
13
|
+
export * from './language-model-v4-reasoning-file';
|
|
12
14
|
export * from './language-model-v4-response-metadata';
|
|
13
15
|
export * from './language-model-v4-source';
|
|
14
16
|
export * from './language-model-v4-stream-part';
|
|
@@ -116,6 +116,19 @@ export type LanguageModelV4CallOptions = {
|
|
|
116
116
|
*/
|
|
117
117
|
headers?: Record<string, string | undefined>;
|
|
118
118
|
|
|
119
|
+
/**
|
|
120
|
+
* Reasoning effort level for the model. Controls how much reasoning
|
|
121
|
+
* the model performs before generating a response. Defaults to 'provider-default'.
|
|
122
|
+
*/
|
|
123
|
+
reasoning?:
|
|
124
|
+
| 'provider-default'
|
|
125
|
+
| 'none'
|
|
126
|
+
| 'minimal'
|
|
127
|
+
| 'low'
|
|
128
|
+
| 'medium'
|
|
129
|
+
| 'high'
|
|
130
|
+
| 'xhigh';
|
|
131
|
+
|
|
119
132
|
/**
|
|
120
133
|
* Additional provider-specific options. They are passed through
|
|
121
134
|
* to the provider from the AI SDK and enable provider-specific
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { LanguageModelV4CustomContent } from './language-model-v4-custom-content';
|
|
1
2
|
import { LanguageModelV4File } from './language-model-v4-file';
|
|
2
3
|
import { LanguageModelV4Reasoning } from './language-model-v4-reasoning';
|
|
4
|
+
import { LanguageModelV4ReasoningFile } from './language-model-v4-reasoning-file';
|
|
3
5
|
import { LanguageModelV4Source } from './language-model-v4-source';
|
|
4
6
|
import { LanguageModelV4Text } from './language-model-v4-text';
|
|
5
7
|
import { LanguageModelV4ToolApprovalRequest } from './language-model-v4-tool-approval-request';
|
|
@@ -9,6 +11,8 @@ import { LanguageModelV4ToolResult } from './language-model-v4-tool-result';
|
|
|
9
11
|
export type LanguageModelV4Content =
|
|
10
12
|
| LanguageModelV4Text
|
|
11
13
|
| LanguageModelV4Reasoning
|
|
14
|
+
| LanguageModelV4CustomContent
|
|
15
|
+
| LanguageModelV4ReasoningFile
|
|
12
16
|
| LanguageModelV4File
|
|
13
17
|
| LanguageModelV4ToolApprovalRequest
|
|
14
18
|
| LanguageModelV4Source
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { SharedV4ProviderMetadata } from '../../shared/v4/shared-v4-provider-metadata';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A provider-specific content block that does not map to another standardized
|
|
5
|
+
* content part type.
|
|
6
|
+
*/
|
|
7
|
+
export type LanguageModelV4CustomContent = {
|
|
8
|
+
type: 'custom';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The kind of custom content, in the format `{provider}.{provider-type}`.
|
|
12
|
+
*/
|
|
13
|
+
kind: `${string}.${string}`;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Additional provider-specific options. They are passed through
|
|
17
|
+
* to the provider from the AI SDK and enable provider-specific
|
|
18
|
+
* functionality that can be fully encapsulated in the provider.
|
|
19
|
+
*/
|
|
20
|
+
providerMetadata?: SharedV4ProviderMetadata;
|
|
21
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { JSONValue } from '../../json-value/json-value';
|
|
2
2
|
import { SharedV4ProviderOptions } from '../../shared/v4/shared-v4-provider-options';
|
|
3
|
+
import { SharedV4ProviderReference } from '../../shared/v4/shared-v4-provider-reference';
|
|
3
4
|
import { LanguageModelV4DataContent } from './language-model-v4-data-content';
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -31,7 +32,9 @@ export type LanguageModelV4Message =
|
|
|
31
32
|
content: Array<
|
|
32
33
|
| LanguageModelV4TextPart
|
|
33
34
|
| LanguageModelV4FilePart
|
|
35
|
+
| LanguageModelV4CustomPart
|
|
34
36
|
| LanguageModelV4ReasoningPart
|
|
37
|
+
| LanguageModelV4ReasoningFilePart
|
|
35
38
|
| LanguageModelV4ToolCallPart
|
|
36
39
|
| LanguageModelV4ToolResultPart
|
|
37
40
|
>;
|
|
@@ -90,6 +93,52 @@ export interface LanguageModelV4ReasoningPart {
|
|
|
90
93
|
providerOptions?: SharedV4ProviderOptions;
|
|
91
94
|
}
|
|
92
95
|
|
|
96
|
+
/**
|
|
97
|
+
* Reasoning file content part of a prompt. It contains a file generated as part of reasoning.
|
|
98
|
+
*/
|
|
99
|
+
export interface LanguageModelV4ReasoningFilePart {
|
|
100
|
+
type: 'reasoning-file';
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* File data. Can be a Uint8Array or base64 encoded data as a string.
|
|
104
|
+
*/
|
|
105
|
+
data: LanguageModelV4DataContent;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* IANA media type of the file.
|
|
109
|
+
*
|
|
110
|
+
* @see https://www.iana.org/assignments/media-types/media-types.xhtml
|
|
111
|
+
*/
|
|
112
|
+
mediaType: string;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Additional provider-specific options. They are passed through
|
|
116
|
+
* to the provider from the AI SDK and enable provider-specific
|
|
117
|
+
* functionality that can be fully encapsulated in the provider.
|
|
118
|
+
*/
|
|
119
|
+
providerOptions?: SharedV4ProviderOptions;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Provider-specific content part of a prompt. It contains no standardized
|
|
124
|
+
* payload beyond provider-specific options.
|
|
125
|
+
*/
|
|
126
|
+
export interface LanguageModelV4CustomPart {
|
|
127
|
+
type: 'custom';
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* The kind of custom content, in the format `{provider}.{provider-type}`.
|
|
131
|
+
*/
|
|
132
|
+
kind: `${string}.${string}`;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Additional provider-specific options. They are passed through
|
|
136
|
+
* to the provider from the AI SDK and enable provider-specific
|
|
137
|
+
* functionality that can be fully encapsulated in the provider.
|
|
138
|
+
*/
|
|
139
|
+
providerOptions?: SharedV4ProviderOptions;
|
|
140
|
+
}
|
|
141
|
+
|
|
93
142
|
/**
|
|
94
143
|
* File content part of a prompt. It contains a file.
|
|
95
144
|
*/
|
|
@@ -102,9 +151,10 @@ export interface LanguageModelV4FilePart {
|
|
|
102
151
|
filename?: string;
|
|
103
152
|
|
|
104
153
|
/**
|
|
105
|
-
* File data. Can be a Uint8Array, base64 encoded data as a string
|
|
154
|
+
* File data. Can be a Uint8Array, base64 encoded data as a string, a URL,
|
|
155
|
+
* or a provider reference mapping provider names to provider-specific file IDs.
|
|
106
156
|
*/
|
|
107
|
-
data: LanguageModelV4DataContent;
|
|
157
|
+
data: LanguageModelV4DataContent | SharedV4ProviderReference;
|
|
108
158
|
|
|
109
159
|
/**
|
|
110
160
|
* IANA media type of the file.
|
|
@@ -330,17 +380,13 @@ export type LanguageModelV4ToolResultOutput =
|
|
|
330
380
|
providerOptions?: SharedV4ProviderOptions;
|
|
331
381
|
}
|
|
332
382
|
| {
|
|
333
|
-
type: 'file-
|
|
383
|
+
type: 'file-reference';
|
|
334
384
|
|
|
335
385
|
/**
|
|
336
|
-
*
|
|
337
|
-
*
|
|
338
|
-
* If you use multiple providers, you need to
|
|
339
|
-
* specify the provider specific ids using
|
|
340
|
-
* the Record option. The key is the provider
|
|
341
|
-
* name, e.g. 'openai' or 'anthropic'.
|
|
386
|
+
* Provider-specific references for the file.
|
|
387
|
+
* The key is the provider name, e.g. 'openai' or 'anthropic'.
|
|
342
388
|
*/
|
|
343
|
-
|
|
389
|
+
providerReference: SharedV4ProviderReference;
|
|
344
390
|
|
|
345
391
|
/**
|
|
346
392
|
* Provider-specific options.
|
|
@@ -387,19 +433,15 @@ export type LanguageModelV4ToolResultOutput =
|
|
|
387
433
|
}
|
|
388
434
|
| {
|
|
389
435
|
/**
|
|
390
|
-
* Images that are referenced using a provider
|
|
436
|
+
* Images that are referenced using a provider reference.
|
|
391
437
|
*/
|
|
392
|
-
type: 'image-file-
|
|
438
|
+
type: 'image-file-reference';
|
|
393
439
|
|
|
394
440
|
/**
|
|
395
|
-
*
|
|
396
|
-
*
|
|
397
|
-
* If you use multiple providers, you need to
|
|
398
|
-
* specify the provider specific ids using
|
|
399
|
-
* the Record option. The key is the provider
|
|
400
|
-
* name, e.g. 'openai' or 'anthropic'.
|
|
441
|
+
* Provider-specific references for the image file.
|
|
442
|
+
* The key is the provider name, e.g. 'openai' or 'anthropic'.
|
|
401
443
|
*/
|
|
402
|
-
|
|
444
|
+
providerReference: SharedV4ProviderReference;
|
|
403
445
|
|
|
404
446
|
/**
|
|
405
447
|
* Provider-specific options.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { SharedV4ProviderMetadata } from '../../shared';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A file that has been generated by the model as part of reasoning.
|
|
5
|
+
* Generated files as base64 encoded strings or binary data.
|
|
6
|
+
* The files should be returned without any unnecessary conversion.
|
|
7
|
+
*/
|
|
8
|
+
export type LanguageModelV4ReasoningFile = {
|
|
9
|
+
type: 'reasoning-file';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The IANA media type of the file, e.g. `image/png` or `audio/mp3`.
|
|
13
|
+
*
|
|
14
|
+
* @see https://www.iana.org/assignments/media-types/media-types.xhtml
|
|
15
|
+
*/
|
|
16
|
+
mediaType: string;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Generated file data as base64 encoded strings or binary data.
|
|
20
|
+
*
|
|
21
|
+
* The file data should be returned without any unnecessary conversion.
|
|
22
|
+
* If the API returns base64 encoded strings, the file data should be returned
|
|
23
|
+
* as base64 encoded strings. If the API returns binary data, the file data should
|
|
24
|
+
* be returned as binary data.
|
|
25
|
+
*/
|
|
26
|
+
data: string | Uint8Array;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Optional provider-specific metadata for the reasoning file part.
|
|
30
|
+
*/
|
|
31
|
+
providerMetadata?: SharedV4ProviderMetadata;
|
|
32
|
+
};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { SharedV4ProviderMetadata } from '../../shared/v4/shared-v4-provider-metadata';
|
|
2
2
|
import { SharedV4Warning } from '../../shared/v4/shared-v4-warning';
|
|
3
|
+
import { LanguageModelV4CustomContent } from './language-model-v4-custom-content';
|
|
3
4
|
import { LanguageModelV4File } from './language-model-v4-file';
|
|
4
5
|
import { LanguageModelV4FinishReason } from './language-model-v4-finish-reason';
|
|
6
|
+
import { LanguageModelV4ReasoningFile } from './language-model-v4-reasoning-file';
|
|
5
7
|
import { LanguageModelV4ResponseMetadata } from './language-model-v4-response-metadata';
|
|
6
8
|
import { LanguageModelV4Source } from './language-model-v4-source';
|
|
7
9
|
import { LanguageModelV4ToolApprovalRequest } from './language-model-v4-tool-approval-request';
|
|
@@ -70,9 +72,11 @@ export type LanguageModelV4StreamPart =
|
|
|
70
72
|
| LanguageModelV4ToolApprovalRequest
|
|
71
73
|
| LanguageModelV4ToolCall
|
|
72
74
|
| LanguageModelV4ToolResult
|
|
75
|
+
| LanguageModelV4CustomContent
|
|
73
76
|
|
|
74
77
|
// Files and sources:
|
|
75
78
|
| LanguageModelV4File
|
|
79
|
+
| LanguageModelV4ReasoningFile
|
|
76
80
|
| LanguageModelV4Source
|
|
77
81
|
|
|
78
82
|
// stream start event with warnings for the call, e.g. unsupported settings:
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { EmbeddingModelV4 } from '../../embedding-model/v4/embedding-model-v4';
|
|
2
|
+
import { FilesV4 } from '../../files/v4/files-v4';
|
|
2
3
|
import { ImageModelV4 } from '../../image-model/v4/image-model-v4';
|
|
3
4
|
import { LanguageModelV4 } from '../../language-model/v4/language-model-v4';
|
|
4
5
|
import { RerankingModelV4 } from '../../reranking-model/v4/reranking-model-v4';
|
|
5
6
|
import { SpeechModelV4 } from '../../speech-model/v4/speech-model-v4';
|
|
6
7
|
import { TranscriptionModelV4 } from '../../transcription-model/v4/transcription-model-v4';
|
|
8
|
+
import { SkillsV4 } from '../../skills/v4/skills-v4';
|
|
7
9
|
|
|
8
10
|
/**
|
|
9
11
|
* Provider for language, text embedding, and image generation models.
|
|
@@ -76,4 +78,18 @@ export interface ProviderV4 {
|
|
|
76
78
|
* @throws {NoSuchModelError} If no such model exists.
|
|
77
79
|
*/
|
|
78
80
|
rerankingModel?(modelId: string): RerankingModelV4;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Returns the files interface for uploading files to the provider.
|
|
84
|
+
* The returned interface can be passed to the `uploadFile` function.
|
|
85
|
+
*
|
|
86
|
+
* @returns {FilesV4} The files interface for this provider.
|
|
87
|
+
*/
|
|
88
|
+
files?(): FilesV4;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Returns the skills interface for uploading skills to the provider.
|
|
92
|
+
* The returned interface can be passed to the `uploadSkill` function.
|
|
93
|
+
*/
|
|
94
|
+
skills?(): SkillsV4;
|
|
79
95
|
}
|