@ai-sdk/openai 1.3.16 → 1.3.18
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 +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +47 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +47 -10
- package/dist/index.mjs.map +1 -1
- package/internal/dist/index.d.mts +5 -1
- package/internal/dist/index.d.ts +5 -1
- package/internal/dist/index.js +49 -10
- package/internal/dist/index.js.map +1 -1
- package/internal/dist/index.mjs +48 -10
- package/internal/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/internal/dist/index.mjs
CHANGED
|
@@ -1537,8 +1537,10 @@ import { z as z5 } from "zod";
|
|
|
1537
1537
|
// src/openai-image-settings.ts
|
|
1538
1538
|
var modelMaxImagesPerCall = {
|
|
1539
1539
|
"dall-e-3": 1,
|
|
1540
|
-
"dall-e-2": 10
|
|
1540
|
+
"dall-e-2": 10,
|
|
1541
|
+
"gpt-image-1": 10
|
|
1541
1542
|
};
|
|
1543
|
+
var hasDefaultResponseFormat = /* @__PURE__ */ new Set(["gpt-image-1"]);
|
|
1542
1544
|
|
|
1543
1545
|
// src/openai-image-model.ts
|
|
1544
1546
|
var OpenAIImageModel = class {
|
|
@@ -1590,7 +1592,7 @@ var OpenAIImageModel = class {
|
|
|
1590
1592
|
n,
|
|
1591
1593
|
size,
|
|
1592
1594
|
...(_d = providerOptions.openai) != null ? _d : {},
|
|
1593
|
-
response_format: "b64_json"
|
|
1595
|
+
...!hasDefaultResponseFormat.has(this.modelId) ? { response_format: "b64_json" } : {}
|
|
1594
1596
|
},
|
|
1595
1597
|
failedResponseHandler: openaiFailedResponseHandler,
|
|
1596
1598
|
successfulResponseHandler: createJsonResponseHandler4(
|
|
@@ -2225,8 +2227,15 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2225
2227
|
user: openaiOptions == null ? void 0 : openaiOptions.user,
|
|
2226
2228
|
instructions: openaiOptions == null ? void 0 : openaiOptions.instructions,
|
|
2227
2229
|
// model-specific settings:
|
|
2228
|
-
...modelConfig.isReasoningModel && (openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null && {
|
|
2229
|
-
reasoning: {
|
|
2230
|
+
...modelConfig.isReasoningModel && ((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null || (openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null) && {
|
|
2231
|
+
reasoning: {
|
|
2232
|
+
...(openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null && {
|
|
2233
|
+
effort: openaiOptions.reasoningEffort
|
|
2234
|
+
},
|
|
2235
|
+
...(openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) != null && {
|
|
2236
|
+
summary: openaiOptions.reasoningSummary
|
|
2237
|
+
}
|
|
2238
|
+
}
|
|
2230
2239
|
},
|
|
2231
2240
|
...modelConfig.requiredAutoTruncation && {
|
|
2232
2241
|
truncation: "auto"
|
|
@@ -2308,7 +2317,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2308
2317
|
}
|
|
2309
2318
|
}
|
|
2310
2319
|
async doGenerate(options) {
|
|
2311
|
-
var _a, _b, _c, _d, _e;
|
|
2320
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
2312
2321
|
const { args: body, warnings } = this.getArgs(options);
|
|
2313
2322
|
const {
|
|
2314
2323
|
responseHeaders,
|
|
@@ -2361,7 +2370,13 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2361
2370
|
type: z8.literal("computer_call")
|
|
2362
2371
|
}),
|
|
2363
2372
|
z8.object({
|
|
2364
|
-
type: z8.literal("reasoning")
|
|
2373
|
+
type: z8.literal("reasoning"),
|
|
2374
|
+
summary: z8.array(
|
|
2375
|
+
z8.object({
|
|
2376
|
+
type: z8.literal("summary_text"),
|
|
2377
|
+
text: z8.string()
|
|
2378
|
+
})
|
|
2379
|
+
)
|
|
2365
2380
|
})
|
|
2366
2381
|
])
|
|
2367
2382
|
),
|
|
@@ -2379,6 +2394,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2379
2394
|
toolName: output.name,
|
|
2380
2395
|
args: output.arguments
|
|
2381
2396
|
}));
|
|
2397
|
+
const reasoningSummary = (_b = (_a = response.output.find((item) => item.type === "reasoning")) == null ? void 0 : _a.summary) != null ? _b : null;
|
|
2382
2398
|
return {
|
|
2383
2399
|
text: outputTextElements.map((content) => content.text).join("\n"),
|
|
2384
2400
|
sources: outputTextElements.flatMap(
|
|
@@ -2393,10 +2409,14 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2393
2409
|
})
|
|
2394
2410
|
),
|
|
2395
2411
|
finishReason: mapOpenAIResponseFinishReason({
|
|
2396
|
-
finishReason: (
|
|
2412
|
+
finishReason: (_c = response.incomplete_details) == null ? void 0 : _c.reason,
|
|
2397
2413
|
hasToolCalls: toolCalls.length > 0
|
|
2398
2414
|
}),
|
|
2399
2415
|
toolCalls: toolCalls.length > 0 ? toolCalls : void 0,
|
|
2416
|
+
reasoning: reasoningSummary ? reasoningSummary.map((summary) => ({
|
|
2417
|
+
type: "text",
|
|
2418
|
+
text: summary.text
|
|
2419
|
+
})) : void 0,
|
|
2400
2420
|
usage: {
|
|
2401
2421
|
promptTokens: response.usage.input_tokens,
|
|
2402
2422
|
completionTokens: response.usage.output_tokens
|
|
@@ -2420,8 +2440,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2420
2440
|
providerMetadata: {
|
|
2421
2441
|
openai: {
|
|
2422
2442
|
responseId: response.id,
|
|
2423
|
-
cachedPromptTokens: (
|
|
2424
|
-
reasoningTokens: (
|
|
2443
|
+
cachedPromptTokens: (_e = (_d = response.usage.input_tokens_details) == null ? void 0 : _d.cached_tokens) != null ? _e : null,
|
|
2444
|
+
reasoningTokens: (_g = (_f = response.usage.output_tokens_details) == null ? void 0 : _f.reasoning_tokens) != null ? _g : null
|
|
2425
2445
|
}
|
|
2426
2446
|
},
|
|
2427
2447
|
warnings
|
|
@@ -2504,6 +2524,11 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2504
2524
|
type: "text-delta",
|
|
2505
2525
|
textDelta: value.delta
|
|
2506
2526
|
});
|
|
2527
|
+
} else if (isResponseReasoningSummaryTextDeltaChunk(value)) {
|
|
2528
|
+
controller.enqueue({
|
|
2529
|
+
type: "reasoning",
|
|
2530
|
+
textDelta: value.delta
|
|
2531
|
+
});
|
|
2507
2532
|
} else if (isResponseOutputItemDoneChunk(value) && value.item.type === "function_call") {
|
|
2508
2533
|
ongoingToolCalls[value.output_index] = void 0;
|
|
2509
2534
|
hasToolCalls = true;
|
|
@@ -2635,6 +2660,13 @@ var responseAnnotationAddedSchema = z8.object({
|
|
|
2635
2660
|
title: z8.string()
|
|
2636
2661
|
})
|
|
2637
2662
|
});
|
|
2663
|
+
var responseReasoningSummaryTextDeltaSchema = z8.object({
|
|
2664
|
+
type: z8.literal("response.reasoning_summary_text.delta"),
|
|
2665
|
+
item_id: z8.string(),
|
|
2666
|
+
output_index: z8.number(),
|
|
2667
|
+
summary_index: z8.number(),
|
|
2668
|
+
delta: z8.string()
|
|
2669
|
+
});
|
|
2638
2670
|
var openaiResponsesChunkSchema = z8.union([
|
|
2639
2671
|
textDeltaChunkSchema,
|
|
2640
2672
|
responseFinishedChunkSchema,
|
|
@@ -2643,6 +2675,7 @@ var openaiResponsesChunkSchema = z8.union([
|
|
|
2643
2675
|
responseFunctionCallArgumentsDeltaSchema,
|
|
2644
2676
|
responseOutputItemAddedSchema,
|
|
2645
2677
|
responseAnnotationAddedSchema,
|
|
2678
|
+
responseReasoningSummaryTextDeltaSchema,
|
|
2646
2679
|
z8.object({ type: z8.string() }).passthrough()
|
|
2647
2680
|
// fallback for unknown chunks
|
|
2648
2681
|
]);
|
|
@@ -2667,6 +2700,9 @@ function isResponseOutputItemAddedChunk(chunk) {
|
|
|
2667
2700
|
function isResponseAnnotationAddedChunk(chunk) {
|
|
2668
2701
|
return chunk.type === "response.output_text.annotation.added";
|
|
2669
2702
|
}
|
|
2703
|
+
function isResponseReasoningSummaryTextDeltaChunk(chunk) {
|
|
2704
|
+
return chunk.type === "response.reasoning_summary_text.delta";
|
|
2705
|
+
}
|
|
2670
2706
|
function getResponsesModelConfig(modelId) {
|
|
2671
2707
|
if (modelId.startsWith("o")) {
|
|
2672
2708
|
if (modelId.startsWith("o1-mini") || modelId.startsWith("o1-preview")) {
|
|
@@ -2696,7 +2732,8 @@ var openaiResponsesProviderOptionsSchema = z8.object({
|
|
|
2696
2732
|
user: z8.string().nullish(),
|
|
2697
2733
|
reasoningEffort: z8.string().nullish(),
|
|
2698
2734
|
strictSchemas: z8.boolean().nullish(),
|
|
2699
|
-
instructions: z8.string().nullish()
|
|
2735
|
+
instructions: z8.string().nullish(),
|
|
2736
|
+
reasoningSummary: z8.string().nullish()
|
|
2700
2737
|
});
|
|
2701
2738
|
export {
|
|
2702
2739
|
OpenAIChatLanguageModel,
|
|
@@ -2706,6 +2743,7 @@ export {
|
|
|
2706
2743
|
OpenAIResponsesLanguageModel,
|
|
2707
2744
|
OpenAISpeechModel,
|
|
2708
2745
|
OpenAITranscriptionModel,
|
|
2746
|
+
hasDefaultResponseFormat,
|
|
2709
2747
|
modelMaxImagesPerCall
|
|
2710
2748
|
};
|
|
2711
2749
|
//# sourceMappingURL=index.mjs.map
|