@ai-sdk/provider 4.0.0-beta.1 → 4.0.0-beta.11
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 +74 -13
- package/dist/index.d.ts +681 -366
- package/dist/index.js +53 -75
- package/dist/index.js.map +1 -1
- package/package.json +5 -7
- 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/dist/index.d.mts +0 -6304
- package/dist/index.mjs +0 -404
- package/dist/index.mjs.map +0 -1
|
@@ -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
|
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SharedV4Headers,
|
|
3
|
+
SharedV4ProviderMetadata,
|
|
4
|
+
SharedV4Warning,
|
|
5
|
+
} from '../../shared/v4/';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The result of a reranking model doRerank call.
|
|
9
|
+
*/
|
|
10
|
+
export type RerankingModelV4Result = {
|
|
11
|
+
/**
|
|
12
|
+
* Ordered list of reranked documents (via index before reranking).
|
|
13
|
+
* The documents are sorted by the descending order of relevance scores.
|
|
14
|
+
*/
|
|
15
|
+
ranking: Array<{
|
|
16
|
+
/**
|
|
17
|
+
* The index of the document in the original list of documents before reranking.
|
|
18
|
+
*/
|
|
19
|
+
index: number;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The relevance score of the document after reranking.
|
|
23
|
+
*/
|
|
24
|
+
relevanceScore: number;
|
|
25
|
+
}>;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Additional provider-specific metadata. They are passed through
|
|
29
|
+
* to the provider from the AI SDK and enable provider-specific
|
|
30
|
+
* functionality that can be fully encapsulated in the provider.
|
|
31
|
+
*/
|
|
32
|
+
providerMetadata?: SharedV4ProviderMetadata;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Warnings for the call, e.g. unsupported settings.
|
|
36
|
+
*/
|
|
37
|
+
warnings?: Array<SharedV4Warning>;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Optional response information for debugging purposes.
|
|
41
|
+
*/
|
|
42
|
+
response?: {
|
|
43
|
+
/**
|
|
44
|
+
* ID for the generated response, if the provider sends one.
|
|
45
|
+
*/
|
|
46
|
+
id?: string;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Timestamp for the start of the generated response, if the provider sends one.
|
|
50
|
+
*/
|
|
51
|
+
timestamp?: Date;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* The ID of the response model that was used to generate the response, if the provider sends one.
|
|
55
|
+
*/
|
|
56
|
+
modelId?: string;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Response headers.
|
|
60
|
+
*/
|
|
61
|
+
headers?: SharedV4Headers;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Response body.
|
|
65
|
+
*/
|
|
66
|
+
body?: unknown;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
SharedV4Headers,
|
|
3
|
-
SharedV4ProviderMetadata,
|
|
4
|
-
SharedV4Warning,
|
|
5
|
-
} from '../../shared/v4/';
|
|
6
1
|
import { RerankingModelV4CallOptions } from './reranking-model-v4-call-options';
|
|
2
|
+
import { RerankingModelV4Result } from './reranking-model-v4-result';
|
|
7
3
|
|
|
8
4
|
/**
|
|
9
5
|
* Specification for a reranking model that implements the reranking model interface version 3.
|
|
@@ -28,63 +24,7 @@ export type RerankingModelV4 = {
|
|
|
28
24
|
* Reranking a list of documents using the query.
|
|
29
25
|
*/
|
|
30
26
|
// Naming: "do" prefix to prevent accidental direct usage of the method by the user.
|
|
31
|
-
doRerank(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
* The documents are sorted by the descending order of relevance scores.
|
|
35
|
-
*/
|
|
36
|
-
ranking: Array<{
|
|
37
|
-
/**
|
|
38
|
-
* The index of the document in the original list of documents before reranking.
|
|
39
|
-
*/
|
|
40
|
-
index: number;
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* The relevance score of the document after reranking.
|
|
44
|
-
*/
|
|
45
|
-
relevanceScore: number;
|
|
46
|
-
}>;
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Additional provider-specific metadata. They are passed through
|
|
50
|
-
* to the provider from the AI SDK and enable provider-specific
|
|
51
|
-
* functionality that can be fully encapsulated in the provider.
|
|
52
|
-
*/
|
|
53
|
-
providerMetadata?: SharedV4ProviderMetadata;
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Warnings for the call, e.g. unsupported settings.
|
|
57
|
-
*/
|
|
58
|
-
warnings?: Array<SharedV4Warning>;
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Optional response information for debugging purposes.
|
|
62
|
-
*/
|
|
63
|
-
response?: {
|
|
64
|
-
/**
|
|
65
|
-
* ID for the generated response, if the provider sends one.
|
|
66
|
-
*/
|
|
67
|
-
id?: string;
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Timestamp for the start of the generated response, if the provider sends one.
|
|
71
|
-
*/
|
|
72
|
-
timestamp?: Date;
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* The ID of the response model that was used to generate the response, if the provider sends one.
|
|
76
|
-
*/
|
|
77
|
-
modelId?: string;
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Response headers.
|
|
81
|
-
*/
|
|
82
|
-
headers?: SharedV4Headers;
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Response body.
|
|
86
|
-
*/
|
|
87
|
-
body?: unknown;
|
|
88
|
-
};
|
|
89
|
-
}>;
|
|
27
|
+
doRerank(
|
|
28
|
+
options: RerankingModelV4CallOptions,
|
|
29
|
+
): PromiseLike<RerankingModelV4Result>;
|
|
90
30
|
};
|
package/src/shared/v4/index.ts
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A mapping of provider names to provider-specific file identifiers.
|
|
3
|
+
*
|
|
4
|
+
* Provider references allow files to be identified across different
|
|
5
|
+
* providers without re-uploading, by storing each provider's own
|
|
6
|
+
* identifier for the same logical file.
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* {
|
|
10
|
+
* "openai": "file-abc123",
|
|
11
|
+
* "anthropic": "file-xyz789"
|
|
12
|
+
* }
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export type SharedV4ProviderReference = Record<string, string>;
|
|
@@ -37,6 +37,22 @@ export type SharedV4Warning =
|
|
|
37
37
|
*/
|
|
38
38
|
details?: string;
|
|
39
39
|
}
|
|
40
|
+
| {
|
|
41
|
+
/**
|
|
42
|
+
* A deprecated feature or option is being used.
|
|
43
|
+
*/
|
|
44
|
+
type: 'deprecated';
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The deprecated setting or feature name.
|
|
48
|
+
*/
|
|
49
|
+
setting: string;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* A human-readable message explaining what to use instead.
|
|
53
|
+
*/
|
|
54
|
+
message: string;
|
|
55
|
+
}
|
|
40
56
|
| {
|
|
41
57
|
/**
|
|
42
58
|
* Other warning.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './v4/index';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { SharedV4ProviderOptions } from '../../shared/v4/shared-v4-provider-options';
|
|
2
|
+
|
|
3
|
+
export interface SkillsV4File {
|
|
4
|
+
/**
|
|
5
|
+
* The path of the file relative to the skill root.
|
|
6
|
+
*/
|
|
7
|
+
path: string;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The content of the file, either as a base64 string or binary data.
|
|
11
|
+
*/
|
|
12
|
+
content: string | Uint8Array;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface SkillsV4UploadSkillCallOptions {
|
|
16
|
+
/**
|
|
17
|
+
* The files that make up the skill.
|
|
18
|
+
*/
|
|
19
|
+
files: SkillsV4File[];
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Optional human-readable title for the skill.
|
|
23
|
+
*/
|
|
24
|
+
displayTitle?: string;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Additional provider-specific options.
|
|
28
|
+
*/
|
|
29
|
+
providerOptions?: SharedV4ProviderOptions;
|
|
30
|
+
}
|