@ai-sdk/provider 4.0.10 → 4.0.12
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 +13 -0
- package/dist/index.d.ts +1905 -1833
- package/package.json +1 -1
- package/src/batch/v4/batch-v4-request.ts +15 -0
- package/src/batch/v4/batch-v4.ts +112 -26
- package/src/batch/v4/index.ts +10 -1
- package/src/batch/v4/text-batch-v4-request.ts +27 -0
- package/src/image-model/v4/image-model-v4-result.ts +6 -0
- package/src/language-model/v4/index.ts +0 -4
- package/src/language-model/v4/language-model-v4-batch.ts +0 -42
package/package.json
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fields shared by every request in a batch.
|
|
3
|
+
*/
|
|
4
|
+
export type BatchV4RequestBase<ModelId extends string = string> = {
|
|
5
|
+
/**
|
|
6
|
+
* Application-provided identifier used to correlate the request with its
|
|
7
|
+
* result.
|
|
8
|
+
*/
|
|
9
|
+
readonly id: string;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Provider-specific model ID for this request.
|
|
13
|
+
*/
|
|
14
|
+
readonly modelId: ModelId;
|
|
15
|
+
};
|
package/src/batch/v4/batch-v4.ts
CHANGED
|
@@ -3,6 +3,32 @@ import type {
|
|
|
3
3
|
SharedV4ProviderOptions,
|
|
4
4
|
SharedV4Warning,
|
|
5
5
|
} from '../../shared';
|
|
6
|
+
import type { LanguageModelV4GenerateResult } from '../../language-model/v4/language-model-v4-generate-result';
|
|
7
|
+
import type { TextBatchV4Request } from './text-batch-v4-request';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Model IDs accepted by each batch modality.
|
|
11
|
+
*
|
|
12
|
+
* Additional modality-specific model ID types can be added to this mapping.
|
|
13
|
+
*/
|
|
14
|
+
export type BatchV4ModelIds = {
|
|
15
|
+
readonly text: string;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
type BatchV4CallOptions = {
|
|
19
|
+
readonly providerOptions?: SharedV4ProviderOptions;
|
|
20
|
+
readonly abortSignal?: AbortSignal;
|
|
21
|
+
readonly headers?: Record<string, string | undefined>;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
type BatchV4StartCallOptions = BatchV4CallOptions & {
|
|
25
|
+
/**
|
|
26
|
+
* URL the provider notifies when the batch reaches a terminal state.
|
|
27
|
+
* Providers that do not support completion webhooks should return an
|
|
28
|
+
* unsupported warning.
|
|
29
|
+
*/
|
|
30
|
+
readonly webhookUrl?: string;
|
|
31
|
+
};
|
|
6
32
|
|
|
7
33
|
/**
|
|
8
34
|
* Serializable error information for a batch or batch item.
|
|
@@ -32,21 +58,19 @@ export type BatchV4Status = {
|
|
|
32
58
|
readonly providerMetadata?: SharedV4ProviderMetadata;
|
|
33
59
|
};
|
|
34
60
|
|
|
61
|
+
export type BatchV4Request<ModelIds extends BatchV4ModelIds = BatchV4ModelIds> =
|
|
62
|
+
TextBatchV4Request<ModelIds['text']>;
|
|
63
|
+
|
|
35
64
|
/**
|
|
36
|
-
* Options for starting a batch.
|
|
65
|
+
* Options for starting a batch of requests discriminated by modality.
|
|
66
|
+
*
|
|
67
|
+
* Additional modality-specific request variants can be added to
|
|
68
|
+
* `BatchV4Request`.
|
|
37
69
|
*/
|
|
38
|
-
export type BatchV4StartOptions<
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
readonly
|
|
42
|
-
readonly headers?: Record<string, string | undefined>;
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* URL the provider notifies when the batch reaches a terminal state.
|
|
46
|
-
* Providers that do not support completion webhooks should return an
|
|
47
|
-
* unsupported warning.
|
|
48
|
-
*/
|
|
49
|
-
readonly webhookUrl?: string;
|
|
70
|
+
export type BatchV4StartOptions<
|
|
71
|
+
ModelIds extends BatchV4ModelIds = BatchV4ModelIds,
|
|
72
|
+
> = BatchV4StartCallOptions & {
|
|
73
|
+
readonly requests: ReadonlyArray<BatchV4Request<ModelIds>>;
|
|
50
74
|
};
|
|
51
75
|
|
|
52
76
|
/**
|
|
@@ -65,15 +89,40 @@ export type BatchV4StartResult = BatchV4Status & {
|
|
|
65
89
|
*/
|
|
66
90
|
export type BatchV4OperationOptions = {
|
|
67
91
|
readonly batchId: string;
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
92
|
+
} & BatchV4CallOptions;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Result of requesting cancellation of a batch.
|
|
96
|
+
*/
|
|
97
|
+
export type BatchV4CancelResult = {
|
|
98
|
+
readonly providerMetadata?: SharedV4ProviderMetadata;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Options for listing batches.
|
|
103
|
+
*/
|
|
104
|
+
export type BatchV4ListOptions = BatchV4CallOptions & {
|
|
105
|
+
readonly limit?: number;
|
|
106
|
+
readonly cursor?: string;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* A batch returned by a list operation.
|
|
111
|
+
*/
|
|
112
|
+
export type BatchV4ListItem = BatchV4Status & {
|
|
113
|
+
readonly batchId: string;
|
|
71
114
|
};
|
|
72
115
|
|
|
73
116
|
/**
|
|
74
|
-
*
|
|
117
|
+
* Result of listing batches.
|
|
75
118
|
*/
|
|
76
|
-
export type
|
|
119
|
+
export type BatchV4ListResult = {
|
|
120
|
+
readonly batches: Array<BatchV4ListItem>;
|
|
121
|
+
readonly nextCursor?: string;
|
|
122
|
+
readonly providerMetadata?: SharedV4ProviderMetadata;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
type BatchV4ItemResultBase<RESULT> =
|
|
77
126
|
| {
|
|
78
127
|
readonly id: string;
|
|
79
128
|
readonly status: 'succeeded';
|
|
@@ -93,19 +142,56 @@ export type BatchV4ItemResult<RESULT> =
|
|
|
93
142
|
};
|
|
94
143
|
|
|
95
144
|
/**
|
|
96
|
-
*
|
|
97
|
-
|
|
145
|
+
* A complete terminal result for one request in a text batch.
|
|
146
|
+
*/
|
|
147
|
+
export type TextBatchV4ItemResult = {
|
|
148
|
+
readonly type: 'text';
|
|
149
|
+
} & BatchV4ItemResultBase<LanguageModelV4GenerateResult>;
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* A complete terminal result for one request in a batch, discriminated by
|
|
153
|
+
* modality.
|
|
154
|
+
*
|
|
155
|
+
* Additional modality-specific item results can be added to this union.
|
|
156
|
+
*/
|
|
157
|
+
export type BatchV4ItemResult = TextBatchV4ItemResult;
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Specification for a batch interface that implements batch interface version 4.
|
|
98
161
|
*/
|
|
99
|
-
export type
|
|
100
|
-
|
|
101
|
-
|
|
162
|
+
export type BatchV4<ModelIds extends BatchV4ModelIds = BatchV4ModelIds> = {
|
|
163
|
+
/**
|
|
164
|
+
* The batch interface must specify which batch interface version it implements.
|
|
165
|
+
*/
|
|
166
|
+
readonly specificationVersion: 'v4';
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Provider ID.
|
|
170
|
+
*/
|
|
171
|
+
readonly provider: string;
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Supported URL patterns by media type for requests in this batch interface.
|
|
175
|
+
*/
|
|
176
|
+
readonly supportedUrls:
|
|
177
|
+
| PromiseLike<Record<string, RegExp[]>>
|
|
178
|
+
| Record<string, RegExp[]>;
|
|
179
|
+
|
|
180
|
+
doStartBatch(
|
|
181
|
+
options: BatchV4StartOptions<ModelIds>,
|
|
102
182
|
): PromiseLike<BatchV4StartResult>;
|
|
103
183
|
|
|
104
|
-
|
|
184
|
+
doGetBatchStatus(
|
|
105
185
|
options: BatchV4OperationOptions,
|
|
106
186
|
): PromiseLike<BatchV4Status>;
|
|
107
187
|
|
|
108
|
-
|
|
188
|
+
doGetBatchResults(
|
|
189
|
+
options: BatchV4OperationOptions,
|
|
190
|
+
): PromiseLike<ReadableStream<BatchV4ItemResult>>;
|
|
191
|
+
|
|
192
|
+
doCancelBatch?(
|
|
109
193
|
options: BatchV4OperationOptions,
|
|
110
|
-
): PromiseLike<
|
|
194
|
+
): PromiseLike<BatchV4CancelResult>;
|
|
195
|
+
|
|
196
|
+
doListBatches?(options: BatchV4ListOptions): PromiseLike<BatchV4ListResult>;
|
|
111
197
|
};
|
package/src/batch/v4/index.ts
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
export type {
|
|
2
|
-
|
|
2
|
+
BatchV4 as Experimental_BatchV4,
|
|
3
|
+
BatchV4CancelResult as Experimental_BatchV4CancelResult,
|
|
3
4
|
BatchV4Error as Experimental_BatchV4Error,
|
|
4
5
|
BatchV4ItemResult as Experimental_BatchV4ItemResult,
|
|
6
|
+
BatchV4ListItem as Experimental_BatchV4ListItem,
|
|
7
|
+
BatchV4ListOptions as Experimental_BatchV4ListOptions,
|
|
8
|
+
BatchV4ListResult as Experimental_BatchV4ListResult,
|
|
9
|
+
BatchV4ModelIds as Experimental_BatchV4ModelIds,
|
|
5
10
|
BatchV4OperationOptions as Experimental_BatchV4OperationOptions,
|
|
11
|
+
BatchV4Request as Experimental_BatchV4Request,
|
|
6
12
|
BatchV4StartOptions as Experimental_BatchV4StartOptions,
|
|
7
13
|
BatchV4StartResult as Experimental_BatchV4StartResult,
|
|
8
14
|
BatchV4Status as Experimental_BatchV4Status,
|
|
15
|
+
TextBatchV4ItemResult as Experimental_TextBatchV4ItemResult,
|
|
9
16
|
} from './batch-v4';
|
|
17
|
+
export type { BatchV4RequestBase as Experimental_BatchV4RequestBase } from './batch-v4-request';
|
|
18
|
+
export type { TextBatchV4Request as Experimental_TextBatchV4Request } from './text-batch-v4-request';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { LanguageModelV4CallOptions } from '../../language-model/v4/language-model-v4-call-options';
|
|
2
|
+
import type { BatchV4RequestBase } from './batch-v4-request';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A normalized text generation request within a batch.
|
|
6
|
+
*/
|
|
7
|
+
export type TextBatchV4Request<ModelId extends string = string> =
|
|
8
|
+
BatchV4RequestBase<ModelId> & {
|
|
9
|
+
readonly type: 'text';
|
|
10
|
+
readonly options: Pick<
|
|
11
|
+
LanguageModelV4CallOptions,
|
|
12
|
+
| 'prompt'
|
|
13
|
+
| 'maxOutputTokens'
|
|
14
|
+
| 'temperature'
|
|
15
|
+
| 'stopSequences'
|
|
16
|
+
| 'topP'
|
|
17
|
+
| 'topK'
|
|
18
|
+
| 'presencePenalty'
|
|
19
|
+
| 'frequencyPenalty'
|
|
20
|
+
| 'seed'
|
|
21
|
+
| 'reasoning'
|
|
22
|
+
| 'responseFormat'
|
|
23
|
+
| 'toolChoice'
|
|
24
|
+
| 'tools'
|
|
25
|
+
| 'providerOptions'
|
|
26
|
+
>;
|
|
27
|
+
};
|
|
@@ -22,6 +22,12 @@ export type ImageModelV4Result = {
|
|
|
22
22
|
*/
|
|
23
23
|
images: Array<string> | Array<Uint8Array>;
|
|
24
24
|
|
|
25
|
+
/**
|
|
26
|
+
* Whether an unsuccessful result, such as an empty image result, can be
|
|
27
|
+
* retried. When omitted, the result is unclassified.
|
|
28
|
+
*/
|
|
29
|
+
isRetryable?: boolean;
|
|
30
|
+
|
|
25
31
|
/**
|
|
26
32
|
* Warnings for the call, e.g. unsupported features.
|
|
27
33
|
*/
|
|
@@ -20,7 +20,3 @@ export * from './language-model-v4-tool-call';
|
|
|
20
20
|
export * from './language-model-v4-tool-choice';
|
|
21
21
|
export * from './language-model-v4-tool-result';
|
|
22
22
|
export * from './language-model-v4-usage';
|
|
23
|
-
export type {
|
|
24
|
-
BatchLanguageModelV4 as Experimental_BatchLanguageModelV4,
|
|
25
|
-
LanguageModelV4BatchRequest as Experimental_LanguageModelV4BatchRequest,
|
|
26
|
-
} from './language-model-v4-batch';
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import type { BatchModelV4 } from '../../batch/v4/batch-v4';
|
|
2
|
-
import type { LanguageModelV4 } from './language-model-v4';
|
|
3
|
-
import type { LanguageModelV4CallOptions } from './language-model-v4-call-options';
|
|
4
|
-
import type { LanguageModelV4GenerateResult } from './language-model-v4-generate-result';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* A normalized language model call within a batch.
|
|
8
|
-
*/
|
|
9
|
-
export type LanguageModelV4BatchRequest = {
|
|
10
|
-
/**
|
|
11
|
-
* Application-provided identifier used to correlate the request with its
|
|
12
|
-
* result.
|
|
13
|
-
*/
|
|
14
|
-
readonly id: string;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Normalized text-generation options for the request.
|
|
18
|
-
*/
|
|
19
|
-
readonly options: Pick<
|
|
20
|
-
LanguageModelV4CallOptions,
|
|
21
|
-
| 'prompt'
|
|
22
|
-
| 'maxOutputTokens'
|
|
23
|
-
| 'temperature'
|
|
24
|
-
| 'stopSequences'
|
|
25
|
-
| 'topP'
|
|
26
|
-
| 'topK'
|
|
27
|
-
| 'presencePenalty'
|
|
28
|
-
| 'frequencyPenalty'
|
|
29
|
-
| 'seed'
|
|
30
|
-
| 'reasoning'
|
|
31
|
-
| 'responseFormat'
|
|
32
|
-
| 'toolChoice'
|
|
33
|
-
| 'tools'
|
|
34
|
-
| 'providerOptions'
|
|
35
|
-
>;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Language model V4 with durable batch-processing support.
|
|
40
|
-
*/
|
|
41
|
-
export type BatchLanguageModelV4 = LanguageModelV4 &
|
|
42
|
-
BatchModelV4<LanguageModelV4BatchRequest, LanguageModelV4GenerateResult>;
|