@ai-sdk/openai 2.0.133 → 2.0.134
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 +6 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +76 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +77 -9
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +570 -503
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +568 -500
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -298,7 +298,7 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazyValidator<{
|
|
|
298
298
|
call_id: string;
|
|
299
299
|
name: string;
|
|
300
300
|
arguments: string;
|
|
301
|
-
status: "
|
|
301
|
+
status: "completed" | "in_progress" | "incomplete";
|
|
302
302
|
async?: boolean | null | undefined;
|
|
303
303
|
} | {
|
|
304
304
|
type: "code_interpreter_call";
|
package/dist/index.d.ts
CHANGED
|
@@ -298,7 +298,7 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazyValidator<{
|
|
|
298
298
|
call_id: string;
|
|
299
299
|
name: string;
|
|
300
300
|
arguments: string;
|
|
301
|
-
status: "
|
|
301
|
+
status: "completed" | "in_progress" | "incomplete";
|
|
302
302
|
async?: boolean | null | undefined;
|
|
303
303
|
} | {
|
|
304
304
|
type: "code_interpreter_call";
|
package/dist/index.js
CHANGED
|
@@ -2485,6 +2485,56 @@ var openaiResponsesSystemMessageOptionsSchema = (0, import_provider_utils21.lazy
|
|
|
2485
2485
|
);
|
|
2486
2486
|
|
|
2487
2487
|
// src/responses/convert-to-openai-responses-input.ts
|
|
2488
|
+
async function convertWebSearchToolResultOutput({
|
|
2489
|
+
output,
|
|
2490
|
+
id
|
|
2491
|
+
}) {
|
|
2492
|
+
if (output.type !== "json") {
|
|
2493
|
+
return void 0;
|
|
2494
|
+
}
|
|
2495
|
+
const validation = await (0, import_provider_utils22.safeValidateTypes)({
|
|
2496
|
+
value: output.value,
|
|
2497
|
+
schema: webSearchOutputSchema
|
|
2498
|
+
});
|
|
2499
|
+
if (!validation.success || validation.value.action == null) {
|
|
2500
|
+
return void 0;
|
|
2501
|
+
}
|
|
2502
|
+
const { action, sources } = validation.value;
|
|
2503
|
+
switch (action.type) {
|
|
2504
|
+
case "search":
|
|
2505
|
+
return {
|
|
2506
|
+
type: "web_search_call",
|
|
2507
|
+
id,
|
|
2508
|
+
status: "completed",
|
|
2509
|
+
action: {
|
|
2510
|
+
type: "search",
|
|
2511
|
+
...action.query != null && { query: action.query },
|
|
2512
|
+
...sources != null && { sources }
|
|
2513
|
+
}
|
|
2514
|
+
};
|
|
2515
|
+
case "openPage":
|
|
2516
|
+
return {
|
|
2517
|
+
type: "web_search_call",
|
|
2518
|
+
id,
|
|
2519
|
+
status: "completed",
|
|
2520
|
+
action: {
|
|
2521
|
+
type: "open_page",
|
|
2522
|
+
url: action.url
|
|
2523
|
+
}
|
|
2524
|
+
};
|
|
2525
|
+
case "findInPage":
|
|
2526
|
+
return {
|
|
2527
|
+
type: "web_search_call",
|
|
2528
|
+
id,
|
|
2529
|
+
status: "completed",
|
|
2530
|
+
action: {
|
|
2531
|
+
type: "find_in_page",
|
|
2532
|
+
url: action.url,
|
|
2533
|
+
pattern: action.pattern
|
|
2534
|
+
}
|
|
2535
|
+
};
|
|
2536
|
+
}
|
|
2537
|
+
}
|
|
2488
2538
|
function getPromptCacheBreakpoint2(providerOptions) {
|
|
2489
2539
|
var _a2;
|
|
2490
2540
|
return (_a2 = providerOptions == null ? void 0 : providerOptions.openai) == null ? void 0 : _a2.promptCacheBreakpoint;
|
|
@@ -2501,9 +2551,10 @@ async function convertToOpenAIResponsesInput({
|
|
|
2501
2551
|
fileIdPrefixes,
|
|
2502
2552
|
store,
|
|
2503
2553
|
configurationUpdateUnsupportedReason,
|
|
2504
|
-
hasLocalShellTool = false
|
|
2554
|
+
hasLocalShellTool = false,
|
|
2555
|
+
webSearchToolName
|
|
2505
2556
|
}) {
|
|
2506
|
-
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
2557
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
2507
2558
|
let input = [];
|
|
2508
2559
|
const warnings = [];
|
|
2509
2560
|
for (const { role, content, providerOptions } of prompt) {
|
|
@@ -2713,6 +2764,21 @@ async function convertToOpenAIResponsesInput({
|
|
|
2713
2764
|
}
|
|
2714
2765
|
// assistant tool result parts are from provider-executed tools:
|
|
2715
2766
|
case "tool-result": {
|
|
2767
|
+
if (part.toolName === "web_search" || part.toolName === "web_search_preview" || part.toolName === webSearchToolName) {
|
|
2768
|
+
const itemId = (_k = (_j = (_i = part.providerOptions) == null ? void 0 : _i[providerOptionsName]) == null ? void 0 : _j.itemId) != null ? _k : part.toolCallId;
|
|
2769
|
+
if (store) {
|
|
2770
|
+
input.push({ type: "item_reference", id: itemId });
|
|
2771
|
+
break;
|
|
2772
|
+
}
|
|
2773
|
+
const webSearchCall = await convertWebSearchToolResultOutput({
|
|
2774
|
+
output: part.output,
|
|
2775
|
+
id: itemId
|
|
2776
|
+
});
|
|
2777
|
+
if (webSearchCall != null) {
|
|
2778
|
+
input.push(webSearchCall);
|
|
2779
|
+
break;
|
|
2780
|
+
}
|
|
2781
|
+
}
|
|
2716
2782
|
if (store) {
|
|
2717
2783
|
input.push({ type: "item_reference", id: part.toolCallId });
|
|
2718
2784
|
} else {
|
|
@@ -3643,6 +3709,9 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3643
3709
|
modelCapabilities,
|
|
3644
3710
|
options: openaiOptions
|
|
3645
3711
|
});
|
|
3712
|
+
const webSearchToolName = (_a2 = tools == null ? void 0 : tools.find(
|
|
3713
|
+
(tool) => tool.type === "provider-defined" && (tool.id === "openai.web_search" || tool.id === "openai.web_search_preview")
|
|
3714
|
+
)) == null ? void 0 : _a2.name;
|
|
3646
3715
|
const { input, warnings: inputWarnings } = await convertToOpenAIResponsesInput({
|
|
3647
3716
|
prompt,
|
|
3648
3717
|
configurationUpdateUnsupportedReason,
|
|
@@ -3650,8 +3719,9 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3650
3719
|
systemMessageMode: modelCapabilities.systemMessageMode,
|
|
3651
3720
|
explicitMessageItemType: this.config.explicitMessageItemType,
|
|
3652
3721
|
fileIdPrefixes: this.config.fileIdPrefixes,
|
|
3653
|
-
store: (
|
|
3654
|
-
hasLocalShellTool: hasOpenAITool("openai.local_shell")
|
|
3722
|
+
store: (_b = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _b : true,
|
|
3723
|
+
hasLocalShellTool: hasOpenAITool("openai.local_shell"),
|
|
3724
|
+
webSearchToolName
|
|
3655
3725
|
});
|
|
3656
3726
|
warnings.push(...inputWarnings);
|
|
3657
3727
|
let resolvedReasoningEffort = openaiOptions == null ? void 0 : openaiOptions.reasoningEffort;
|
|
@@ -3688,7 +3758,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3688
3758
|
});
|
|
3689
3759
|
}
|
|
3690
3760
|
}
|
|
3691
|
-
const strictJsonSchema = (
|
|
3761
|
+
const strictJsonSchema = (_c = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _c : false;
|
|
3692
3762
|
let include = openaiOptions == null ? void 0 : openaiOptions.include;
|
|
3693
3763
|
function addInclude(key) {
|
|
3694
3764
|
if (include == null) {
|
|
@@ -3706,9 +3776,6 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3706
3776
|
if (topLogprobs) {
|
|
3707
3777
|
addInclude("message.output_text.logprobs");
|
|
3708
3778
|
}
|
|
3709
|
-
const webSearchToolName = (_c = tools == null ? void 0 : tools.find(
|
|
3710
|
-
(tool) => tool.type === "provider-defined" && (tool.id === "openai.web_search" || tool.id === "openai.web_search_preview")
|
|
3711
|
-
)) == null ? void 0 : _c.name;
|
|
3712
3779
|
if (webSearchToolName) {
|
|
3713
3780
|
addInclude("web_search_call.action.sources");
|
|
3714
3781
|
}
|
|
@@ -5139,7 +5206,7 @@ var OpenAITranscriptionModel = class {
|
|
|
5139
5206
|
};
|
|
5140
5207
|
|
|
5141
5208
|
// src/version.ts
|
|
5142
|
-
var VERSION = true ? "2.0.
|
|
5209
|
+
var VERSION = true ? "2.0.134" : "0.0.0-test";
|
|
5143
5210
|
|
|
5144
5211
|
// src/openai-provider.ts
|
|
5145
5212
|
function createOpenAI(options = {}) {
|