@ai-sdk/provider 4.0.10 → 4.0.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 +7 -0
- package/dist/index.d.ts +1869 -1826
- package/package.json +1 -1
- package/src/batch/v4/batch-v4-request.ts +15 -0
- package/src/batch/v4/batch-v4.ts +78 -29
- package/src/batch/v4/index.ts +6 -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,9 @@ export type BatchV4StartResult = BatchV4Status & {
|
|
|
65
89
|
*/
|
|
66
90
|
export type BatchV4OperationOptions = {
|
|
67
91
|
readonly batchId: string;
|
|
68
|
-
|
|
69
|
-
readonly abortSignal?: AbortSignal;
|
|
70
|
-
readonly headers?: Record<string, string | undefined>;
|
|
71
|
-
};
|
|
92
|
+
} & BatchV4CallOptions;
|
|
72
93
|
|
|
73
|
-
|
|
74
|
-
* A complete terminal result for one request in a batch.
|
|
75
|
-
*/
|
|
76
|
-
export type BatchV4ItemResult<RESULT> =
|
|
94
|
+
type BatchV4ItemResultBase<RESULT> =
|
|
77
95
|
| {
|
|
78
96
|
readonly id: string;
|
|
79
97
|
readonly status: 'succeeded';
|
|
@@ -93,19 +111,50 @@ export type BatchV4ItemResult<RESULT> =
|
|
|
93
111
|
};
|
|
94
112
|
|
|
95
113
|
/**
|
|
96
|
-
*
|
|
97
|
-
|
|
114
|
+
* A complete terminal result for one request in a text batch.
|
|
115
|
+
*/
|
|
116
|
+
export type TextBatchV4ItemResult = {
|
|
117
|
+
readonly type: 'text';
|
|
118
|
+
} & BatchV4ItemResultBase<LanguageModelV4GenerateResult>;
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* A complete terminal result for one request in a batch, discriminated by
|
|
122
|
+
* modality.
|
|
123
|
+
*
|
|
124
|
+
* Additional modality-specific item results can be added to this union.
|
|
98
125
|
*/
|
|
99
|
-
export type
|
|
100
|
-
|
|
101
|
-
|
|
126
|
+
export type BatchV4ItemResult = TextBatchV4ItemResult;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Specification for a batch interface that implements batch interface version 4.
|
|
130
|
+
*/
|
|
131
|
+
export type BatchV4<ModelIds extends BatchV4ModelIds = BatchV4ModelIds> = {
|
|
132
|
+
/**
|
|
133
|
+
* The batch interface must specify which batch interface version it implements.
|
|
134
|
+
*/
|
|
135
|
+
readonly specificationVersion: 'v4';
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Provider ID.
|
|
139
|
+
*/
|
|
140
|
+
readonly provider: string;
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Supported URL patterns by media type for requests in this batch interface.
|
|
144
|
+
*/
|
|
145
|
+
readonly supportedUrls:
|
|
146
|
+
| PromiseLike<Record<string, RegExp[]>>
|
|
147
|
+
| Record<string, RegExp[]>;
|
|
148
|
+
|
|
149
|
+
doStartBatch(
|
|
150
|
+
options: BatchV4StartOptions<ModelIds>,
|
|
102
151
|
): PromiseLike<BatchV4StartResult>;
|
|
103
152
|
|
|
104
|
-
|
|
153
|
+
doGetBatchStatus(
|
|
105
154
|
options: BatchV4OperationOptions,
|
|
106
155
|
): PromiseLike<BatchV4Status>;
|
|
107
156
|
|
|
108
|
-
|
|
157
|
+
doGetBatchResults(
|
|
109
158
|
options: BatchV4OperationOptions,
|
|
110
|
-
): PromiseLike<ReadableStream<BatchV4ItemResult
|
|
159
|
+
): PromiseLike<ReadableStream<BatchV4ItemResult>>;
|
|
111
160
|
};
|
package/src/batch/v4/index.ts
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
export type {
|
|
2
|
-
|
|
2
|
+
BatchV4 as Experimental_BatchV4,
|
|
3
3
|
BatchV4Error as Experimental_BatchV4Error,
|
|
4
4
|
BatchV4ItemResult as Experimental_BatchV4ItemResult,
|
|
5
|
+
BatchV4ModelIds as Experimental_BatchV4ModelIds,
|
|
5
6
|
BatchV4OperationOptions as Experimental_BatchV4OperationOptions,
|
|
7
|
+
BatchV4Request as Experimental_BatchV4Request,
|
|
6
8
|
BatchV4StartOptions as Experimental_BatchV4StartOptions,
|
|
7
9
|
BatchV4StartResult as Experimental_BatchV4StartResult,
|
|
8
10
|
BatchV4Status as Experimental_BatchV4Status,
|
|
11
|
+
TextBatchV4ItemResult as Experimental_TextBatchV4ItemResult,
|
|
9
12
|
} from './batch-v4';
|
|
13
|
+
export type { BatchV4RequestBase as Experimental_BatchV4RequestBase } from './batch-v4-request';
|
|
14
|
+
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>;
|