@ai-sdk/openai 2.0.28 → 2.0.29
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 +16 -12
- package/dist/index.d.ts +16 -12
- package/dist/index.js +77 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +80 -10
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +77 -7
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +80 -10
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/internal/index.mjs
CHANGED
|
@@ -2381,8 +2381,20 @@ import {
|
|
|
2381
2381
|
} from "@ai-sdk/provider";
|
|
2382
2382
|
|
|
2383
2383
|
// src/tool/code-interpreter.ts
|
|
2384
|
-
import {
|
|
2384
|
+
import { createProviderDefinedToolFactoryWithOutputSchema } from "@ai-sdk/provider-utils";
|
|
2385
2385
|
import { z as z15 } from "zod/v4";
|
|
2386
|
+
var codeInterpreterInputSchema = z15.object({
|
|
2387
|
+
code: z15.string().nullish(),
|
|
2388
|
+
containerId: z15.string()
|
|
2389
|
+
});
|
|
2390
|
+
var codeInterpreterOutputSchema = z15.object({
|
|
2391
|
+
outputs: z15.array(
|
|
2392
|
+
z15.discriminatedUnion("type", [
|
|
2393
|
+
z15.object({ type: z15.literal("logs"), logs: z15.string() }),
|
|
2394
|
+
z15.object({ type: z15.literal("image"), url: z15.string() })
|
|
2395
|
+
])
|
|
2396
|
+
).nullish()
|
|
2397
|
+
});
|
|
2386
2398
|
var codeInterpreterArgsSchema = z15.object({
|
|
2387
2399
|
container: z15.union([
|
|
2388
2400
|
z15.string(),
|
|
@@ -2391,14 +2403,15 @@ var codeInterpreterArgsSchema = z15.object({
|
|
|
2391
2403
|
})
|
|
2392
2404
|
]).optional()
|
|
2393
2405
|
});
|
|
2394
|
-
var codeInterpreterToolFactory =
|
|
2406
|
+
var codeInterpreterToolFactory = createProviderDefinedToolFactoryWithOutputSchema({
|
|
2395
2407
|
id: "openai.code_interpreter",
|
|
2396
2408
|
name: "code_interpreter",
|
|
2397
|
-
inputSchema:
|
|
2409
|
+
inputSchema: codeInterpreterInputSchema,
|
|
2410
|
+
outputSchema: codeInterpreterOutputSchema
|
|
2398
2411
|
});
|
|
2399
2412
|
|
|
2400
2413
|
// src/tool/web-search.ts
|
|
2401
|
-
import { createProviderDefinedToolFactory as
|
|
2414
|
+
import { createProviderDefinedToolFactory as createProviderDefinedToolFactory3 } from "@ai-sdk/provider-utils";
|
|
2402
2415
|
import { z as z16 } from "zod/v4";
|
|
2403
2416
|
var webSearchArgsSchema = z16.object({
|
|
2404
2417
|
filters: z16.object({
|
|
@@ -2413,7 +2426,7 @@ var webSearchArgsSchema = z16.object({
|
|
|
2413
2426
|
timezone: z16.string().optional()
|
|
2414
2427
|
}).optional()
|
|
2415
2428
|
});
|
|
2416
|
-
var webSearchToolFactory =
|
|
2429
|
+
var webSearchToolFactory = createProviderDefinedToolFactory3({
|
|
2417
2430
|
id: "openai.web_search",
|
|
2418
2431
|
name: "web_search",
|
|
2419
2432
|
inputSchema: z16.object({
|
|
@@ -2555,6 +2568,18 @@ var webSearchCallItem = z17.object({
|
|
|
2555
2568
|
})
|
|
2556
2569
|
]).nullish()
|
|
2557
2570
|
});
|
|
2571
|
+
var codeInterpreterCallItem = z17.object({
|
|
2572
|
+
type: z17.literal("code_interpreter_call"),
|
|
2573
|
+
id: z17.string(),
|
|
2574
|
+
code: z17.string().nullable(),
|
|
2575
|
+
container_id: z17.string(),
|
|
2576
|
+
outputs: z17.array(
|
|
2577
|
+
z17.discriminatedUnion("type", [
|
|
2578
|
+
z17.object({ type: z17.literal("logs"), logs: z17.string() }),
|
|
2579
|
+
z17.object({ type: z17.literal("image"), url: z17.string() })
|
|
2580
|
+
])
|
|
2581
|
+
).nullable()
|
|
2582
|
+
});
|
|
2558
2583
|
var TOP_LOGPROBS_MAX = 20;
|
|
2559
2584
|
var LOGPROBS_SCHEMA = z17.array(
|
|
2560
2585
|
z17.object({
|
|
@@ -2596,7 +2621,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2596
2621
|
toolChoice,
|
|
2597
2622
|
responseFormat
|
|
2598
2623
|
}) {
|
|
2599
|
-
var _a, _b, _c;
|
|
2624
|
+
var _a, _b, _c, _d;
|
|
2600
2625
|
const warnings = [];
|
|
2601
2626
|
const modelConfig = getResponsesModelConfig(this.modelId);
|
|
2602
2627
|
if (topK != null) {
|
|
@@ -2639,6 +2664,10 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2639
2664
|
(tool) => tool.type === "provider-defined" && (tool.id === "openai.web_search" || tool.id === "openai.web_search_preview")
|
|
2640
2665
|
)) == null ? void 0 : _b.name;
|
|
2641
2666
|
include = webSearchToolName ? Array.isArray(include) ? [...include, "web_search_call.action.sources"] : ["web_search_call.action.sources"] : include;
|
|
2667
|
+
const codeInterpreterToolName = (_c = tools == null ? void 0 : tools.find(
|
|
2668
|
+
(tool) => tool.type === "provider-defined" && tool.id === "openai.code_interpreter"
|
|
2669
|
+
)) == null ? void 0 : _c.name;
|
|
2670
|
+
include = codeInterpreterToolName ? Array.isArray(include) ? [...include, "code_interpreter_call.outputs"] : ["code_interpreter_call.outputs"] : include;
|
|
2642
2671
|
const baseArgs = {
|
|
2643
2672
|
model: this.modelId,
|
|
2644
2673
|
input: messages,
|
|
@@ -2651,7 +2680,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2651
2680
|
format: responseFormat.schema != null ? {
|
|
2652
2681
|
type: "json_schema",
|
|
2653
2682
|
strict: strictJsonSchema,
|
|
2654
|
-
name: (
|
|
2683
|
+
name: (_d = responseFormat.name) != null ? _d : "response",
|
|
2655
2684
|
description: responseFormat.description,
|
|
2656
2685
|
schema: responseFormat.schema
|
|
2657
2686
|
} : { type: "json_object" }
|
|
@@ -2822,9 +2851,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2822
2851
|
})
|
|
2823
2852
|
)
|
|
2824
2853
|
}),
|
|
2825
|
-
|
|
2826
|
-
type: z17.literal("code_interpreter_call")
|
|
2827
|
-
}),
|
|
2854
|
+
codeInterpreterCallItem,
|
|
2828
2855
|
z17.object({
|
|
2829
2856
|
type: z17.literal("function_call"),
|
|
2830
2857
|
call_id: z17.string(),
|
|
@@ -3020,6 +3047,28 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3020
3047
|
});
|
|
3021
3048
|
break;
|
|
3022
3049
|
}
|
|
3050
|
+
case "code_interpreter_call": {
|
|
3051
|
+
content.push({
|
|
3052
|
+
type: "tool-call",
|
|
3053
|
+
toolCallId: part.id,
|
|
3054
|
+
toolName: "code_interpreter",
|
|
3055
|
+
input: JSON.stringify({
|
|
3056
|
+
code: part.code,
|
|
3057
|
+
containerId: part.container_id
|
|
3058
|
+
}),
|
|
3059
|
+
providerExecuted: true
|
|
3060
|
+
});
|
|
3061
|
+
content.push({
|
|
3062
|
+
type: "tool-result",
|
|
3063
|
+
toolCallId: part.id,
|
|
3064
|
+
toolName: "code_interpreter",
|
|
3065
|
+
result: {
|
|
3066
|
+
outputs: part.outputs
|
|
3067
|
+
},
|
|
3068
|
+
providerExecuted: true
|
|
3069
|
+
});
|
|
3070
|
+
break;
|
|
3071
|
+
}
|
|
3023
3072
|
}
|
|
3024
3073
|
}
|
|
3025
3074
|
const providerMetadata = {
|
|
@@ -3263,6 +3312,26 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3263
3312
|
},
|
|
3264
3313
|
providerExecuted: true
|
|
3265
3314
|
});
|
|
3315
|
+
} else if (value.item.type === "code_interpreter_call") {
|
|
3316
|
+
controller.enqueue({
|
|
3317
|
+
type: "tool-call",
|
|
3318
|
+
toolCallId: value.item.id,
|
|
3319
|
+
toolName: "code_interpreter",
|
|
3320
|
+
input: JSON.stringify({
|
|
3321
|
+
code: value.item.code,
|
|
3322
|
+
containerId: value.item.container_id
|
|
3323
|
+
}),
|
|
3324
|
+
providerExecuted: true
|
|
3325
|
+
});
|
|
3326
|
+
controller.enqueue({
|
|
3327
|
+
type: "tool-result",
|
|
3328
|
+
toolCallId: value.item.id,
|
|
3329
|
+
toolName: "code_interpreter",
|
|
3330
|
+
result: {
|
|
3331
|
+
outputs: value.item.outputs
|
|
3332
|
+
},
|
|
3333
|
+
providerExecuted: true
|
|
3334
|
+
});
|
|
3266
3335
|
} else if (value.item.type === "message") {
|
|
3267
3336
|
controller.enqueue({
|
|
3268
3337
|
type: "text-end",
|
|
@@ -3508,6 +3577,7 @@ var responseOutputItemDoneSchema = z17.object({
|
|
|
3508
3577
|
arguments: z17.string(),
|
|
3509
3578
|
status: z17.literal("completed")
|
|
3510
3579
|
}),
|
|
3580
|
+
codeInterpreterCallItem,
|
|
3511
3581
|
webSearchCallItem,
|
|
3512
3582
|
z17.object({
|
|
3513
3583
|
type: z17.literal("computer_call"),
|