@ai-sdk/openai 2.0.0-beta.4 → 2.0.0-beta.5
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.js +36 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +38 -6
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +36 -6
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +38 -6
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -1867,6 +1867,7 @@ var openaiTranscriptionResponseSchema = import_v412.z.object({
|
|
|
1867
1867
|
});
|
|
1868
1868
|
|
|
1869
1869
|
// src/responses/openai-responses-language-model.ts
|
|
1870
|
+
var import_provider8 = require("@ai-sdk/provider");
|
|
1870
1871
|
var import_provider_utils11 = require("@ai-sdk/provider-utils");
|
|
1871
1872
|
var import_v414 = require("zod/v4");
|
|
1872
1873
|
|
|
@@ -1991,7 +1992,7 @@ async function convertToOpenAIResponsesMessages({
|
|
|
1991
1992
|
const summaryParts = [];
|
|
1992
1993
|
if (part.text.length > 0) {
|
|
1993
1994
|
summaryParts.push({ type: "summary_text", text: part.text });
|
|
1994
|
-
} else {
|
|
1995
|
+
} else if (existingReasoningMessage !== void 0) {
|
|
1995
1996
|
warnings.push({
|
|
1996
1997
|
type: "other",
|
|
1997
1998
|
message: `Cannot append empty reasoning part to existing reasoning sequence. Skipping reasoning part: ${JSON.stringify(part)}.`
|
|
@@ -2309,15 +2310,16 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2309
2310
|
async doGenerate(options) {
|
|
2310
2311
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
2311
2312
|
const { args: body, warnings } = await this.getArgs(options);
|
|
2313
|
+
const url = this.config.url({
|
|
2314
|
+
path: "/responses",
|
|
2315
|
+
modelId: this.modelId
|
|
2316
|
+
});
|
|
2312
2317
|
const {
|
|
2313
2318
|
responseHeaders,
|
|
2314
2319
|
value: response,
|
|
2315
2320
|
rawValue: rawResponse
|
|
2316
2321
|
} = await (0, import_provider_utils11.postJsonToApi)({
|
|
2317
|
-
url
|
|
2318
|
-
path: "/responses",
|
|
2319
|
-
modelId: this.modelId
|
|
2320
|
-
}),
|
|
2322
|
+
url,
|
|
2321
2323
|
headers: (0, import_provider_utils11.combineHeaders)(this.config.headers(), options.headers),
|
|
2322
2324
|
body,
|
|
2323
2325
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
@@ -2325,6 +2327,10 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2325
2327
|
import_v414.z.object({
|
|
2326
2328
|
id: import_v414.z.string(),
|
|
2327
2329
|
created_at: import_v414.z.number(),
|
|
2330
|
+
error: import_v414.z.object({
|
|
2331
|
+
code: import_v414.z.string(),
|
|
2332
|
+
message: import_v414.z.string()
|
|
2333
|
+
}).nullish(),
|
|
2328
2334
|
model: import_v414.z.string(),
|
|
2329
2335
|
output: import_v414.z.array(
|
|
2330
2336
|
import_v414.z.discriminatedUnion("type", [
|
|
@@ -2383,6 +2389,17 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2383
2389
|
abortSignal: options.abortSignal,
|
|
2384
2390
|
fetch: this.config.fetch
|
|
2385
2391
|
});
|
|
2392
|
+
if (response.error) {
|
|
2393
|
+
throw new import_provider8.APICallError({
|
|
2394
|
+
message: response.error.message,
|
|
2395
|
+
url,
|
|
2396
|
+
requestBodyValues: body,
|
|
2397
|
+
statusCode: 400,
|
|
2398
|
+
responseHeaders,
|
|
2399
|
+
responseBody: rawResponse,
|
|
2400
|
+
isRetryable: false
|
|
2401
|
+
});
|
|
2402
|
+
}
|
|
2386
2403
|
const content = [];
|
|
2387
2404
|
for (const part of response.output) {
|
|
2388
2405
|
switch (part.type) {
|
|
@@ -2725,6 +2742,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2725
2742
|
url: value.annotation.url,
|
|
2726
2743
|
title: value.annotation.title
|
|
2727
2744
|
});
|
|
2745
|
+
} else if (isErrorChunk(value)) {
|
|
2746
|
+
controller.enqueue({ type: "error", error: value });
|
|
2728
2747
|
}
|
|
2729
2748
|
},
|
|
2730
2749
|
flush(controller) {
|
|
@@ -2757,6 +2776,13 @@ var textDeltaChunkSchema = import_v414.z.object({
|
|
|
2757
2776
|
item_id: import_v414.z.string(),
|
|
2758
2777
|
delta: import_v414.z.string()
|
|
2759
2778
|
});
|
|
2779
|
+
var errorChunkSchema = import_v414.z.object({
|
|
2780
|
+
type: import_v414.z.literal("error"),
|
|
2781
|
+
code: import_v414.z.string(),
|
|
2782
|
+
message: import_v414.z.string(),
|
|
2783
|
+
param: import_v414.z.string().nullish(),
|
|
2784
|
+
sequence_number: import_v414.z.number()
|
|
2785
|
+
});
|
|
2760
2786
|
var responseFinishedChunkSchema = import_v414.z.object({
|
|
2761
2787
|
type: import_v414.z.enum(["response.completed", "response.incomplete"]),
|
|
2762
2788
|
response: import_v414.z.object({
|
|
@@ -2877,7 +2903,8 @@ var openaiResponsesChunkSchema = import_v414.z.union([
|
|
|
2877
2903
|
responseFunctionCallArgumentsDeltaSchema,
|
|
2878
2904
|
responseAnnotationAddedSchema,
|
|
2879
2905
|
responseReasoningSummaryTextDeltaSchema,
|
|
2880
|
-
|
|
2906
|
+
errorChunkSchema,
|
|
2907
|
+
import_v414.z.object({ type: import_v414.z.string() }).loose()
|
|
2881
2908
|
// fallback for unknown chunks
|
|
2882
2909
|
]);
|
|
2883
2910
|
function isTextDeltaChunk(chunk) {
|
|
@@ -2904,6 +2931,9 @@ function isResponseAnnotationAddedChunk(chunk) {
|
|
|
2904
2931
|
function isResponseReasoningSummaryTextDeltaChunk(chunk) {
|
|
2905
2932
|
return chunk.type === "response.reasoning_summary_text.delta";
|
|
2906
2933
|
}
|
|
2934
|
+
function isErrorChunk(chunk) {
|
|
2935
|
+
return chunk.type === "error";
|
|
2936
|
+
}
|
|
2907
2937
|
function getResponsesModelConfig(modelId) {
|
|
2908
2938
|
if (modelId.startsWith("o") || modelId.startsWith("codex-") || modelId.startsWith("computer-use")) {
|
|
2909
2939
|
if (modelId.startsWith("o1-mini") || modelId.startsWith("o1-preview")) {
|