@ai-sdk/openai 4.0.64 → 4.0.65
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 +9 -0
- package/dist/index.js +77 -24
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/openai-batch.ts +95 -29
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @ai-sdk/openai
|
|
2
2
|
|
|
3
|
+
## 4.0.65
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 9942196: feat(openai): add batch cancellation and listing
|
|
8
|
+
- Updated dependencies [9942196]
|
|
9
|
+
- @ai-sdk/provider@4.0.13
|
|
10
|
+
- @ai-sdk/provider-utils@5.0.39
|
|
11
|
+
|
|
3
12
|
## 4.0.64
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -9097,30 +9097,29 @@ var openaiBatchProviderOptionsSchema = lazySchema26(
|
|
|
9097
9097
|
})
|
|
9098
9098
|
)
|
|
9099
9099
|
);
|
|
9100
|
+
var openaiBatchResponseZodSchema = () => z28.object({
|
|
9101
|
+
id: z28.string(),
|
|
9102
|
+
status: z28.string(),
|
|
9103
|
+
output_file_id: z28.string().nullish(),
|
|
9104
|
+
error_file_id: z28.string().nullish(),
|
|
9105
|
+
created_at: z28.number().nullish(),
|
|
9106
|
+
expires_at: z28.number().nullish(),
|
|
9107
|
+
request_counts: z28.object({
|
|
9108
|
+
total: z28.number().nullish(),
|
|
9109
|
+
completed: z28.number().nullish(),
|
|
9110
|
+
failed: z28.number().nullish()
|
|
9111
|
+
}).nullish(),
|
|
9112
|
+
errors: z28.object({
|
|
9113
|
+
data: z28.array(
|
|
9114
|
+
z28.object({
|
|
9115
|
+
code: z28.string().nullish(),
|
|
9116
|
+
message: z28.string().nullish()
|
|
9117
|
+
})
|
|
9118
|
+
).nullish()
|
|
9119
|
+
}).nullish()
|
|
9120
|
+
});
|
|
9100
9121
|
var openaiBatchResponseSchema = lazySchema26(
|
|
9101
|
-
() => zodSchema26(
|
|
9102
|
-
z28.object({
|
|
9103
|
-
id: z28.string(),
|
|
9104
|
-
status: z28.string(),
|
|
9105
|
-
output_file_id: z28.string().nullish(),
|
|
9106
|
-
error_file_id: z28.string().nullish(),
|
|
9107
|
-
created_at: z28.number().nullish(),
|
|
9108
|
-
expires_at: z28.number().nullish(),
|
|
9109
|
-
request_counts: z28.object({
|
|
9110
|
-
total: z28.number().nullish(),
|
|
9111
|
-
completed: z28.number().nullish(),
|
|
9112
|
-
failed: z28.number().nullish()
|
|
9113
|
-
}).nullish(),
|
|
9114
|
-
errors: z28.object({
|
|
9115
|
-
data: z28.array(
|
|
9116
|
-
z28.object({
|
|
9117
|
-
code: z28.string().nullish(),
|
|
9118
|
-
message: z28.string().nullish()
|
|
9119
|
-
})
|
|
9120
|
-
).nullish()
|
|
9121
|
-
}).nullish()
|
|
9122
|
-
})
|
|
9123
|
-
)
|
|
9122
|
+
() => zodSchema26(openaiBatchResponseZodSchema())
|
|
9124
9123
|
);
|
|
9125
9124
|
var openaiBatchResultLineSchema = lazySchema26(
|
|
9126
9125
|
() => zodSchema26(
|
|
@@ -9138,6 +9137,15 @@ var openaiBatchResultLineSchema = lazySchema26(
|
|
|
9138
9137
|
})
|
|
9139
9138
|
)
|
|
9140
9139
|
);
|
|
9140
|
+
var openaiBatchListResponseSchema = lazySchema26(
|
|
9141
|
+
() => zodSchema26(
|
|
9142
|
+
z28.object({
|
|
9143
|
+
data: z28.array(openaiBatchResponseZodSchema()),
|
|
9144
|
+
has_more: z28.boolean(),
|
|
9145
|
+
last_id: z28.string().nullish()
|
|
9146
|
+
})
|
|
9147
|
+
)
|
|
9148
|
+
);
|
|
9141
9149
|
var OpenAIBatch = class {
|
|
9142
9150
|
constructor(options) {
|
|
9143
9151
|
this.options = options;
|
|
@@ -9273,6 +9281,51 @@ var OpenAIBatch = class {
|
|
|
9273
9281
|
const batch = await this.retrieveBatch(options);
|
|
9274
9282
|
return convertOpenAIBatchStatus(batch);
|
|
9275
9283
|
}
|
|
9284
|
+
async doCancelBatch(options) {
|
|
9285
|
+
var _a2, _b;
|
|
9286
|
+
await postJsonToApi6({
|
|
9287
|
+
url: this.getUrl(
|
|
9288
|
+
`/batches/${encodeURIComponent(options.batchId)}/cancel`
|
|
9289
|
+
),
|
|
9290
|
+
headers: combineHeaders7((_b = (_a2 = this.options.config).headers) == null ? void 0 : _b.call(_a2), options.headers),
|
|
9291
|
+
body: {},
|
|
9292
|
+
failedResponseHandler: openaiFailedResponseHandler,
|
|
9293
|
+
successfulResponseHandler: createJsonResponseHandler7(
|
|
9294
|
+
openaiBatchResponseSchema
|
|
9295
|
+
),
|
|
9296
|
+
abortSignal: options.abortSignal,
|
|
9297
|
+
fetch: this.options.config.fetch
|
|
9298
|
+
});
|
|
9299
|
+
return {};
|
|
9300
|
+
}
|
|
9301
|
+
async doListBatches(options) {
|
|
9302
|
+
var _a2, _b;
|
|
9303
|
+
const url = new URL(this.getUrl("/batches"));
|
|
9304
|
+
if (options.limit != null) {
|
|
9305
|
+
url.searchParams.set("limit", String(options.limit));
|
|
9306
|
+
}
|
|
9307
|
+
if (options.cursor != null) {
|
|
9308
|
+
url.searchParams.set("after", options.cursor);
|
|
9309
|
+
}
|
|
9310
|
+
const { value: page } = await getFromApi2({
|
|
9311
|
+
url: url.toString(),
|
|
9312
|
+
headers: combineHeaders7((_b = (_a2 = this.options.config).headers) == null ? void 0 : _b.call(_a2), options.headers),
|
|
9313
|
+
failedResponseHandler: openaiFailedResponseHandler,
|
|
9314
|
+
successfulResponseHandler: createJsonResponseHandler7(
|
|
9315
|
+
openaiBatchListResponseSchema
|
|
9316
|
+
),
|
|
9317
|
+
abortSignal: options.abortSignal,
|
|
9318
|
+
fetch: this.options.config.fetch,
|
|
9319
|
+
validateUrl: false
|
|
9320
|
+
});
|
|
9321
|
+
return {
|
|
9322
|
+
batches: page.data.map((batch) => ({
|
|
9323
|
+
batchId: batch.id,
|
|
9324
|
+
...convertOpenAIBatchStatus(batch)
|
|
9325
|
+
})),
|
|
9326
|
+
...page.has_more && page.last_id != null ? { nextCursor: page.last_id } : {}
|
|
9327
|
+
};
|
|
9328
|
+
}
|
|
9276
9329
|
async doGetBatchResults(options) {
|
|
9277
9330
|
const batch = await this.retrieveBatch(options);
|
|
9278
9331
|
const batchStatus = convertOpenAIBatchStatus(batch);
|
|
@@ -11217,7 +11270,7 @@ var OpenAISkills = class {
|
|
|
11217
11270
|
};
|
|
11218
11271
|
|
|
11219
11272
|
// src/version.ts
|
|
11220
|
-
var VERSION = true ? "4.0.
|
|
11273
|
+
var VERSION = true ? "4.0.65" : "0.0.0-test";
|
|
11221
11274
|
|
|
11222
11275
|
// src/openai-provider.ts
|
|
11223
11276
|
function createOpenAI(options = {}) {
|