@ai-sdk/openai 2.0.37 → 2.0.39
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.js +88 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +88 -11
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +212 -1
- package/dist/internal/index.d.ts +212 -1
- package/dist/internal/index.js +106 -10
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +98 -10
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/internal/index.mjs
CHANGED
|
@@ -2156,6 +2156,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2156
2156
|
});
|
|
2157
2157
|
break;
|
|
2158
2158
|
}
|
|
2159
|
+
// assistant tool result parts are from provider-executed tools:
|
|
2159
2160
|
case "tool-result": {
|
|
2160
2161
|
if (store) {
|
|
2161
2162
|
input.push({ type: "item_reference", id: part.toolCallId });
|
|
@@ -2310,6 +2311,9 @@ var codeInterpreterToolFactory = createProviderDefinedToolFactoryWithOutputSchem
|
|
|
2310
2311
|
inputSchema: codeInterpreterInputSchema,
|
|
2311
2312
|
outputSchema: codeInterpreterOutputSchema
|
|
2312
2313
|
});
|
|
2314
|
+
var codeInterpreter = (args = {}) => {
|
|
2315
|
+
return codeInterpreterToolFactory(args);
|
|
2316
|
+
};
|
|
2313
2317
|
|
|
2314
2318
|
// src/tool/file-search.ts
|
|
2315
2319
|
import { createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema2 } from "@ai-sdk/provider-utils";
|
|
@@ -3277,6 +3281,24 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3277
3281
|
id: value.item.id,
|
|
3278
3282
|
toolName: "computer_use"
|
|
3279
3283
|
});
|
|
3284
|
+
} else if (value.item.type === "code_interpreter_call") {
|
|
3285
|
+
ongoingToolCalls[value.output_index] = {
|
|
3286
|
+
toolName: "code_interpreter",
|
|
3287
|
+
toolCallId: value.item.id,
|
|
3288
|
+
codeInterpreter: {
|
|
3289
|
+
containerId: value.item.container_id
|
|
3290
|
+
}
|
|
3291
|
+
};
|
|
3292
|
+
controller.enqueue({
|
|
3293
|
+
type: "tool-input-start",
|
|
3294
|
+
id: value.item.id,
|
|
3295
|
+
toolName: "code_interpreter"
|
|
3296
|
+
});
|
|
3297
|
+
controller.enqueue({
|
|
3298
|
+
type: "tool-input-delta",
|
|
3299
|
+
id: value.item.id,
|
|
3300
|
+
delta: `{"containerId":"${value.item.container_id}","code":"`
|
|
3301
|
+
});
|
|
3280
3302
|
} else if (value.item.type === "file_search_call") {
|
|
3281
3303
|
controller.enqueue({
|
|
3282
3304
|
type: "tool-call",
|
|
@@ -3400,16 +3422,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3400
3422
|
providerExecuted: true
|
|
3401
3423
|
});
|
|
3402
3424
|
} else if (value.item.type === "code_interpreter_call") {
|
|
3403
|
-
|
|
3404
|
-
type: "tool-call",
|
|
3405
|
-
toolCallId: value.item.id,
|
|
3406
|
-
toolName: "code_interpreter",
|
|
3407
|
-
input: JSON.stringify({
|
|
3408
|
-
code: value.item.code,
|
|
3409
|
-
containerId: value.item.container_id
|
|
3410
|
-
}),
|
|
3411
|
-
providerExecuted: true
|
|
3412
|
-
});
|
|
3425
|
+
ongoingToolCalls[value.output_index] = void 0;
|
|
3413
3426
|
controller.enqueue({
|
|
3414
3427
|
type: "tool-result",
|
|
3415
3428
|
toolCallId: value.item.id,
|
|
@@ -3459,6 +3472,40 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3459
3472
|
delta: value.delta
|
|
3460
3473
|
});
|
|
3461
3474
|
}
|
|
3475
|
+
} else if (isResponseCodeInterpreterCallCodeDeltaChunk(value)) {
|
|
3476
|
+
const toolCall = ongoingToolCalls[value.output_index];
|
|
3477
|
+
if (toolCall != null) {
|
|
3478
|
+
controller.enqueue({
|
|
3479
|
+
type: "tool-input-delta",
|
|
3480
|
+
id: toolCall.toolCallId,
|
|
3481
|
+
// The delta is code, which is embedding in a JSON string.
|
|
3482
|
+
// To escape it, we use JSON.stringify and slice to remove the outer quotes.
|
|
3483
|
+
delta: JSON.stringify(value.delta).slice(1, -1)
|
|
3484
|
+
});
|
|
3485
|
+
}
|
|
3486
|
+
} else if (isResponseCodeInterpreterCallCodeDoneChunk(value)) {
|
|
3487
|
+
const toolCall = ongoingToolCalls[value.output_index];
|
|
3488
|
+
if (toolCall != null) {
|
|
3489
|
+
controller.enqueue({
|
|
3490
|
+
type: "tool-input-delta",
|
|
3491
|
+
id: toolCall.toolCallId,
|
|
3492
|
+
delta: '"}'
|
|
3493
|
+
});
|
|
3494
|
+
controller.enqueue({
|
|
3495
|
+
type: "tool-input-end",
|
|
3496
|
+
id: toolCall.toolCallId
|
|
3497
|
+
});
|
|
3498
|
+
controller.enqueue({
|
|
3499
|
+
type: "tool-call",
|
|
3500
|
+
toolCallId: toolCall.toolCallId,
|
|
3501
|
+
toolName: "code_interpreter",
|
|
3502
|
+
input: JSON.stringify({
|
|
3503
|
+
code: value.code,
|
|
3504
|
+
containerId: toolCall.codeInterpreter.containerId
|
|
3505
|
+
}),
|
|
3506
|
+
providerExecuted: true
|
|
3507
|
+
});
|
|
3508
|
+
}
|
|
3462
3509
|
} else if (isResponseCreatedChunk(value)) {
|
|
3463
3510
|
responseId = value.response.id;
|
|
3464
3511
|
controller.enqueue({
|
|
@@ -3642,6 +3689,19 @@ var responseOutputItemAddedSchema = z18.object({
|
|
|
3642
3689
|
z18.object({
|
|
3643
3690
|
type: z18.literal("image_generation_call"),
|
|
3644
3691
|
id: z18.string()
|
|
3692
|
+
}),
|
|
3693
|
+
z18.object({
|
|
3694
|
+
type: z18.literal("code_interpreter_call"),
|
|
3695
|
+
id: z18.string(),
|
|
3696
|
+
container_id: z18.string(),
|
|
3697
|
+
code: z18.string().nullable(),
|
|
3698
|
+
outputs: z18.array(
|
|
3699
|
+
z18.discriminatedUnion("type", [
|
|
3700
|
+
z18.object({ type: z18.literal("logs"), logs: z18.string() }),
|
|
3701
|
+
z18.object({ type: z18.literal("image"), url: z18.string() })
|
|
3702
|
+
])
|
|
3703
|
+
).nullable(),
|
|
3704
|
+
status: z18.string()
|
|
3645
3705
|
})
|
|
3646
3706
|
])
|
|
3647
3707
|
});
|
|
@@ -3683,6 +3743,18 @@ var responseFunctionCallArgumentsDeltaSchema = z18.object({
|
|
|
3683
3743
|
output_index: z18.number(),
|
|
3684
3744
|
delta: z18.string()
|
|
3685
3745
|
});
|
|
3746
|
+
var responseCodeInterpreterCallCodeDeltaSchema = z18.object({
|
|
3747
|
+
type: z18.literal("response.code_interpreter_call_code.delta"),
|
|
3748
|
+
item_id: z18.string(),
|
|
3749
|
+
output_index: z18.number(),
|
|
3750
|
+
delta: z18.string()
|
|
3751
|
+
});
|
|
3752
|
+
var responseCodeInterpreterCallCodeDoneSchema = z18.object({
|
|
3753
|
+
type: z18.literal("response.code_interpreter_call_code.done"),
|
|
3754
|
+
item_id: z18.string(),
|
|
3755
|
+
output_index: z18.number(),
|
|
3756
|
+
code: z18.string()
|
|
3757
|
+
});
|
|
3686
3758
|
var responseAnnotationAddedSchema = z18.object({
|
|
3687
3759
|
type: z18.literal("response.output_text.annotation.added"),
|
|
3688
3760
|
annotation: z18.discriminatedUnion("type", [
|
|
@@ -3720,6 +3792,8 @@ var openaiResponsesChunkSchema = z18.union([
|
|
|
3720
3792
|
responseOutputItemAddedSchema,
|
|
3721
3793
|
responseOutputItemDoneSchema,
|
|
3722
3794
|
responseFunctionCallArgumentsDeltaSchema,
|
|
3795
|
+
responseCodeInterpreterCallCodeDeltaSchema,
|
|
3796
|
+
responseCodeInterpreterCallCodeDoneSchema,
|
|
3723
3797
|
responseAnnotationAddedSchema,
|
|
3724
3798
|
responseReasoningSummaryPartAddedSchema,
|
|
3725
3799
|
responseReasoningSummaryTextDeltaSchema,
|
|
@@ -3745,6 +3819,12 @@ function isResponseCreatedChunk(chunk) {
|
|
|
3745
3819
|
function isResponseFunctionCallArgumentsDeltaChunk(chunk) {
|
|
3746
3820
|
return chunk.type === "response.function_call_arguments.delta";
|
|
3747
3821
|
}
|
|
3822
|
+
function isResponseCodeInterpreterCallCodeDeltaChunk(chunk) {
|
|
3823
|
+
return chunk.type === "response.code_interpreter_call_code.delta";
|
|
3824
|
+
}
|
|
3825
|
+
function isResponseCodeInterpreterCallCodeDoneChunk(chunk) {
|
|
3826
|
+
return chunk.type === "response.code_interpreter_call_code.done";
|
|
3827
|
+
}
|
|
3748
3828
|
function isResponseOutputItemAddedChunk(chunk) {
|
|
3749
3829
|
return chunk.type === "response.output_item.added";
|
|
3750
3830
|
}
|
|
@@ -3846,6 +3926,14 @@ export {
|
|
|
3846
3926
|
OpenAIResponsesLanguageModel,
|
|
3847
3927
|
OpenAISpeechModel,
|
|
3848
3928
|
OpenAITranscriptionModel,
|
|
3929
|
+
codeInterpreter,
|
|
3930
|
+
codeInterpreterArgsSchema,
|
|
3931
|
+
codeInterpreterInputSchema,
|
|
3932
|
+
codeInterpreterOutputSchema,
|
|
3933
|
+
codeInterpreterToolFactory,
|
|
3934
|
+
fileSearch,
|
|
3935
|
+
fileSearchArgsSchema,
|
|
3936
|
+
fileSearchOutputSchema,
|
|
3849
3937
|
hasDefaultResponseFormat,
|
|
3850
3938
|
modelMaxImagesPerCall,
|
|
3851
3939
|
openAITranscriptionProviderOptions,
|