@ai-sdk/openai 1.3.22 → 1.3.24
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 +12 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- 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/internal/dist/index.d.mts +2 -2
- package/internal/dist/index.d.ts +2 -2
- package/internal/dist/index.js +36 -6
- package/internal/dist/index.js.map +1 -1
- package/internal/dist/index.mjs +38 -6
- package/internal/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1043,7 +1043,7 @@ var openaiChatChunkSchema = z2.union([
|
|
|
1043
1043
|
openaiErrorDataSchema
|
|
1044
1044
|
]);
|
|
1045
1045
|
function isReasoningModel(modelId) {
|
|
1046
|
-
return modelId.startsWith("o");
|
|
1046
|
+
return modelId.startsWith("o") || modelId.startsWith("gpt-5");
|
|
1047
1047
|
}
|
|
1048
1048
|
function isAudioModel(modelId) {
|
|
1049
1049
|
return modelId.startsWith("gpt-4o-audio-preview");
|
|
@@ -1810,6 +1810,9 @@ var openaiTranscriptionResponseSchema = z6.object({
|
|
|
1810
1810
|
});
|
|
1811
1811
|
|
|
1812
1812
|
// src/responses/openai-responses-language-model.ts
|
|
1813
|
+
import {
|
|
1814
|
+
APICallError
|
|
1815
|
+
} from "@ai-sdk/provider";
|
|
1813
1816
|
import {
|
|
1814
1817
|
combineHeaders as combineHeaders6,
|
|
1815
1818
|
createEventSourceResponseHandler as createEventSourceResponseHandler3,
|
|
@@ -2233,15 +2236,16 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2233
2236
|
async doGenerate(options) {
|
|
2234
2237
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
2235
2238
|
const { args: body, warnings } = this.getArgs(options);
|
|
2239
|
+
const url = this.config.url({
|
|
2240
|
+
path: "/responses",
|
|
2241
|
+
modelId: this.modelId
|
|
2242
|
+
});
|
|
2236
2243
|
const {
|
|
2237
2244
|
responseHeaders,
|
|
2238
2245
|
value: response,
|
|
2239
2246
|
rawValue: rawResponse
|
|
2240
2247
|
} = await postJsonToApi5({
|
|
2241
|
-
url
|
|
2242
|
-
path: "/responses",
|
|
2243
|
-
modelId: this.modelId
|
|
2244
|
-
}),
|
|
2248
|
+
url,
|
|
2245
2249
|
headers: combineHeaders6(this.config.headers(), options.headers),
|
|
2246
2250
|
body,
|
|
2247
2251
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
@@ -2249,6 +2253,10 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2249
2253
|
z7.object({
|
|
2250
2254
|
id: z7.string(),
|
|
2251
2255
|
created_at: z7.number(),
|
|
2256
|
+
error: z7.object({
|
|
2257
|
+
message: z7.string(),
|
|
2258
|
+
code: z7.string()
|
|
2259
|
+
}).nullish(),
|
|
2252
2260
|
model: z7.string(),
|
|
2253
2261
|
output: z7.array(
|
|
2254
2262
|
z7.discriminatedUnion("type", [
|
|
@@ -2301,6 +2309,17 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2301
2309
|
abortSignal: options.abortSignal,
|
|
2302
2310
|
fetch: this.config.fetch
|
|
2303
2311
|
});
|
|
2312
|
+
if (response.error) {
|
|
2313
|
+
throw new APICallError({
|
|
2314
|
+
message: response.error.message,
|
|
2315
|
+
url,
|
|
2316
|
+
requestBodyValues: body,
|
|
2317
|
+
statusCode: 400,
|
|
2318
|
+
responseHeaders,
|
|
2319
|
+
responseBody: rawResponse,
|
|
2320
|
+
isRetryable: false
|
|
2321
|
+
});
|
|
2322
|
+
}
|
|
2304
2323
|
const outputTextElements = response.output.filter((output) => output.type === "message").flatMap((output) => output.content).filter((content) => content.type === "output_text");
|
|
2305
2324
|
const toolCalls = response.output.filter((output) => output.type === "function_call").map((output) => ({
|
|
2306
2325
|
toolCallType: "function",
|
|
@@ -2472,6 +2491,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2472
2491
|
title: value.annotation.title
|
|
2473
2492
|
}
|
|
2474
2493
|
});
|
|
2494
|
+
} else if (isErrorChunk(value)) {
|
|
2495
|
+
controller.enqueue({ type: "error", error: value });
|
|
2475
2496
|
}
|
|
2476
2497
|
},
|
|
2477
2498
|
flush(controller) {
|
|
@@ -2581,6 +2602,13 @@ var responseReasoningSummaryTextDeltaSchema = z7.object({
|
|
|
2581
2602
|
summary_index: z7.number(),
|
|
2582
2603
|
delta: z7.string()
|
|
2583
2604
|
});
|
|
2605
|
+
var errorChunkSchema = z7.object({
|
|
2606
|
+
type: z7.literal("error"),
|
|
2607
|
+
code: z7.string(),
|
|
2608
|
+
message: z7.string(),
|
|
2609
|
+
param: z7.string().nullish(),
|
|
2610
|
+
sequence_number: z7.number()
|
|
2611
|
+
});
|
|
2584
2612
|
var openaiResponsesChunkSchema = z7.union([
|
|
2585
2613
|
textDeltaChunkSchema,
|
|
2586
2614
|
responseFinishedChunkSchema,
|
|
@@ -2590,6 +2618,7 @@ var openaiResponsesChunkSchema = z7.union([
|
|
|
2590
2618
|
responseOutputItemAddedSchema,
|
|
2591
2619
|
responseAnnotationAddedSchema,
|
|
2592
2620
|
responseReasoningSummaryTextDeltaSchema,
|
|
2621
|
+
errorChunkSchema,
|
|
2593
2622
|
z7.object({ type: z7.string() }).passthrough()
|
|
2594
2623
|
// fallback for unknown chunks
|
|
2595
2624
|
]);
|
|
@@ -2617,8 +2646,11 @@ function isResponseAnnotationAddedChunk(chunk) {
|
|
|
2617
2646
|
function isResponseReasoningSummaryTextDeltaChunk(chunk) {
|
|
2618
2647
|
return chunk.type === "response.reasoning_summary_text.delta";
|
|
2619
2648
|
}
|
|
2649
|
+
function isErrorChunk(chunk) {
|
|
2650
|
+
return chunk.type === "error";
|
|
2651
|
+
}
|
|
2620
2652
|
function getResponsesModelConfig(modelId) {
|
|
2621
|
-
if (modelId.startsWith("o")) {
|
|
2653
|
+
if (modelId.startsWith("o") || modelId.startsWith("gpt-5")) {
|
|
2622
2654
|
if (modelId.startsWith("o1-mini") || modelId.startsWith("o1-preview")) {
|
|
2623
2655
|
return {
|
|
2624
2656
|
isReasoningModel: true,
|