@zenning/openai 3.0.21 → 3.0.23
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 +14 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +24 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +24 -14
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +23 -13
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +23 -13
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @ai-sdk/openai
|
|
2
2
|
|
|
3
|
+
## 3.0.23
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- ferr
|
|
8
|
+
|
|
9
|
+
## 3.0.22
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Fix duplicate item_reference for approval responses. Skip creating item_reference for all tool-calls when approval responses are detected in the prompt, preventing duplicate item errors with previousResponseId.
|
|
14
|
+
- Fix tool approval with previousResponseId. Skip creating item_reference for tool-calls that have approval responses, preventing duplicate item errors when continuing from a previous response.
|
|
15
|
+
- ll
|
|
16
|
+
|
|
3
17
|
## 3.0.21
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -462,6 +462,7 @@ declare const openaiResponsesProviderOptionsSchema: _zenning_provider_utils.Lazy
|
|
|
462
462
|
encrypted_content: string;
|
|
463
463
|
}[] | undefined;
|
|
464
464
|
containsApprovalResponses?: boolean | undefined;
|
|
465
|
+
approvalToolCallIds?: string[] | undefined;
|
|
465
466
|
}>;
|
|
466
467
|
type OpenAIResponsesProviderOptions = InferSchema<typeof openaiResponsesProviderOptionsSchema>;
|
|
467
468
|
|
package/dist/index.d.ts
CHANGED
|
@@ -462,6 +462,7 @@ declare const openaiResponsesProviderOptionsSchema: _zenning_provider_utils.Lazy
|
|
|
462
462
|
encrypted_content: string;
|
|
463
463
|
}[] | undefined;
|
|
464
464
|
containsApprovalResponses?: boolean | undefined;
|
|
465
|
+
approvalToolCallIds?: string[] | undefined;
|
|
465
466
|
}>;
|
|
466
467
|
type OpenAIResponsesProviderOptions = InferSchema<typeof openaiResponsesProviderOptionsSchema>;
|
|
467
468
|
|
package/dist/index.js
CHANGED
|
@@ -2480,12 +2480,14 @@ async function convertToOpenAIResponsesInput({
|
|
|
2480
2480
|
hasApplyPatchTool = false,
|
|
2481
2481
|
compactionInput,
|
|
2482
2482
|
previousResponseId,
|
|
2483
|
-
containsApprovalResponses
|
|
2483
|
+
containsApprovalResponses,
|
|
2484
|
+
approvalToolCallIds: approvalToolCallIdsArray
|
|
2484
2485
|
}) {
|
|
2485
2486
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
2486
2487
|
const input = [];
|
|
2487
2488
|
const warnings = [];
|
|
2488
2489
|
const processedApprovalIds = /* @__PURE__ */ new Set();
|
|
2490
|
+
const approvalToolCallIds = new Set(approvalToolCallIdsArray || []);
|
|
2489
2491
|
if (compactionInput && compactionInput.length > 0) {
|
|
2490
2492
|
input.push(...compactionInput);
|
|
2491
2493
|
}
|
|
@@ -2580,17 +2582,18 @@ async function convertToOpenAIResponsesInput({
|
|
|
2580
2582
|
}
|
|
2581
2583
|
case "tool-call": {
|
|
2582
2584
|
const id = (_g = (_d = (_c = part.providerOptions) == null ? void 0 : _c[providerOptionsName]) == null ? void 0 : _d.itemId) != null ? _g : (_f = (_e = part.providerMetadata) == null ? void 0 : _e[providerOptionsName]) == null ? void 0 : _f.itemId;
|
|
2585
|
+
const toolHadApproval = containsApprovalResponses && approvalToolCallIds.has(part.toolCallId);
|
|
2583
2586
|
if (part.providerExecuted) {
|
|
2584
|
-
if (store && id != null && !
|
|
2587
|
+
if (store && id != null && !toolHadApproval) {
|
|
2585
2588
|
input.push({ type: "item_reference", id });
|
|
2586
2589
|
}
|
|
2587
2590
|
break;
|
|
2588
2591
|
}
|
|
2589
|
-
if (store && id != null && !
|
|
2592
|
+
if (store && id != null && !toolHadApproval) {
|
|
2590
2593
|
input.push({ type: "item_reference", id });
|
|
2591
2594
|
break;
|
|
2592
2595
|
}
|
|
2593
|
-
if (store && id != null &&
|
|
2596
|
+
if (store && id != null && toolHadApproval) {
|
|
2594
2597
|
break;
|
|
2595
2598
|
}
|
|
2596
2599
|
const resolvedToolName = toolNameMapping.toProviderToolName(
|
|
@@ -2648,10 +2651,11 @@ async function convertToOpenAIResponsesInput({
|
|
|
2648
2651
|
if (part.output.type === "execution-denied" || part.output.type === "json" && typeof part.output.value === "object" && part.output.value != null && "type" in part.output.value && part.output.value.type === "execution-denied") {
|
|
2649
2652
|
break;
|
|
2650
2653
|
}
|
|
2651
|
-
|
|
2654
|
+
const toolResultHadApproval = containsApprovalResponses && approvalToolCallIds.has(part.toolCallId);
|
|
2655
|
+
if (store && !toolResultHadApproval) {
|
|
2652
2656
|
const itemId = (_j = (_i = (_h = part.providerMetadata) == null ? void 0 : _h[providerOptionsName]) == null ? void 0 : _i.itemId) != null ? _j : part.toolCallId;
|
|
2653
2657
|
input.push({ type: "item_reference", id: itemId });
|
|
2654
|
-
} else {
|
|
2658
|
+
} else if (!store) {
|
|
2655
2659
|
warnings.push({
|
|
2656
2660
|
type: "other",
|
|
2657
2661
|
message: `Results for OpenAI tool ${part.toolName} are not sent to the API when store is false`
|
|
@@ -3801,7 +3805,12 @@ var openaiResponsesProviderOptionsSchema = (0, import_provider_utils25.lazySchem
|
|
|
3801
3805
|
* Whether the request contains tool approval responses.
|
|
3802
3806
|
* Defaults to `false`.
|
|
3803
3807
|
*/
|
|
3804
|
-
containsApprovalResponses: import_v420.z.boolean().optional()
|
|
3808
|
+
containsApprovalResponses: import_v420.z.boolean().optional(),
|
|
3809
|
+
/**
|
|
3810
|
+
* Array of tool call IDs that have approval responses (approved or denied).
|
|
3811
|
+
* Used to skip item_reference for tools that had user approval flow.
|
|
3812
|
+
*/
|
|
3813
|
+
approvalToolCallIds: import_v420.z.array(import_v420.z.string()).optional()
|
|
3805
3814
|
})
|
|
3806
3815
|
)
|
|
3807
3816
|
);
|
|
@@ -4032,7 +4041,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4032
4041
|
toolChoice,
|
|
4033
4042
|
responseFormat
|
|
4034
4043
|
}) {
|
|
4035
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
4044
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
4036
4045
|
const warnings = [];
|
|
4037
4046
|
const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
|
|
4038
4047
|
if (topK != null) {
|
|
@@ -4097,10 +4106,11 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4097
4106
|
hasApplyPatchTool: hasOpenAITool("openai.apply_patch"),
|
|
4098
4107
|
compactionInput: openaiOptions == null ? void 0 : openaiOptions.compactionInput,
|
|
4099
4108
|
previousResponseId: (_d = openaiOptions == null ? void 0 : openaiOptions.previousResponseId) != null ? _d : void 0,
|
|
4100
|
-
containsApprovalResponses: (_e = openaiOptions == null ? void 0 : openaiOptions.containsApprovalResponses) != null ? _e : false
|
|
4109
|
+
containsApprovalResponses: (_e = openaiOptions == null ? void 0 : openaiOptions.containsApprovalResponses) != null ? _e : false,
|
|
4110
|
+
approvalToolCallIds: (_f = openaiOptions == null ? void 0 : openaiOptions.approvalToolCallIds) != null ? _f : void 0
|
|
4101
4111
|
});
|
|
4102
4112
|
warnings.push(...inputWarnings);
|
|
4103
|
-
const strictJsonSchema = (
|
|
4113
|
+
const strictJsonSchema = (_g = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _g : true;
|
|
4104
4114
|
let include = openaiOptions == null ? void 0 : openaiOptions.include;
|
|
4105
4115
|
function addInclude(key) {
|
|
4106
4116
|
if (include == null) {
|
|
@@ -4116,9 +4126,9 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4116
4126
|
if (topLogprobs) {
|
|
4117
4127
|
addInclude("message.output_text.logprobs");
|
|
4118
4128
|
}
|
|
4119
|
-
const webSearchToolName = (
|
|
4129
|
+
const webSearchToolName = (_h = tools == null ? void 0 : tools.find(
|
|
4120
4130
|
(tool) => tool.type === "provider" && (tool.id === "openai.web_search" || tool.id === "openai.web_search_preview")
|
|
4121
|
-
)) == null ? void 0 :
|
|
4131
|
+
)) == null ? void 0 : _h.name;
|
|
4122
4132
|
if (webSearchToolName) {
|
|
4123
4133
|
addInclude("web_search_call.action.sources");
|
|
4124
4134
|
}
|
|
@@ -4141,7 +4151,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4141
4151
|
format: responseFormat.schema != null ? {
|
|
4142
4152
|
type: "json_schema",
|
|
4143
4153
|
strict: strictJsonSchema,
|
|
4144
|
-
name: (
|
|
4154
|
+
name: (_i = responseFormat.name) != null ? _i : "response",
|
|
4145
4155
|
description: responseFormat.description,
|
|
4146
4156
|
schema: responseFormat.schema
|
|
4147
4157
|
} : { type: "json_object" }
|
|
@@ -5783,7 +5793,7 @@ var OpenAITranscriptionModel = class {
|
|
|
5783
5793
|
};
|
|
5784
5794
|
|
|
5785
5795
|
// src/version.ts
|
|
5786
|
-
var VERSION = true ? "3.0.
|
|
5796
|
+
var VERSION = true ? "3.0.23" : "0.0.0-test";
|
|
5787
5797
|
|
|
5788
5798
|
// src/openai-provider.ts
|
|
5789
5799
|
function createOpenAI(options = {}) {
|