@ai-sdk/openai 2.0.38 → 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 +6 -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.js +87 -10
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +87 -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 });
|
|
@@ -3280,6 +3281,24 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3280
3281
|
id: value.item.id,
|
|
3281
3282
|
toolName: "computer_use"
|
|
3282
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
|
+
});
|
|
3283
3302
|
} else if (value.item.type === "file_search_call") {
|
|
3284
3303
|
controller.enqueue({
|
|
3285
3304
|
type: "tool-call",
|
|
@@ -3403,16 +3422,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3403
3422
|
providerExecuted: true
|
|
3404
3423
|
});
|
|
3405
3424
|
} else if (value.item.type === "code_interpreter_call") {
|
|
3406
|
-
|
|
3407
|
-
type: "tool-call",
|
|
3408
|
-
toolCallId: value.item.id,
|
|
3409
|
-
toolName: "code_interpreter",
|
|
3410
|
-
input: JSON.stringify({
|
|
3411
|
-
code: value.item.code,
|
|
3412
|
-
containerId: value.item.container_id
|
|
3413
|
-
}),
|
|
3414
|
-
providerExecuted: true
|
|
3415
|
-
});
|
|
3425
|
+
ongoingToolCalls[value.output_index] = void 0;
|
|
3416
3426
|
controller.enqueue({
|
|
3417
3427
|
type: "tool-result",
|
|
3418
3428
|
toolCallId: value.item.id,
|
|
@@ -3462,6 +3472,40 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3462
3472
|
delta: value.delta
|
|
3463
3473
|
});
|
|
3464
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
|
+
}
|
|
3465
3509
|
} else if (isResponseCreatedChunk(value)) {
|
|
3466
3510
|
responseId = value.response.id;
|
|
3467
3511
|
controller.enqueue({
|
|
@@ -3645,6 +3689,19 @@ var responseOutputItemAddedSchema = z18.object({
|
|
|
3645
3689
|
z18.object({
|
|
3646
3690
|
type: z18.literal("image_generation_call"),
|
|
3647
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()
|
|
3648
3705
|
})
|
|
3649
3706
|
])
|
|
3650
3707
|
});
|
|
@@ -3686,6 +3743,18 @@ var responseFunctionCallArgumentsDeltaSchema = z18.object({
|
|
|
3686
3743
|
output_index: z18.number(),
|
|
3687
3744
|
delta: z18.string()
|
|
3688
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
|
+
});
|
|
3689
3758
|
var responseAnnotationAddedSchema = z18.object({
|
|
3690
3759
|
type: z18.literal("response.output_text.annotation.added"),
|
|
3691
3760
|
annotation: z18.discriminatedUnion("type", [
|
|
@@ -3723,6 +3792,8 @@ var openaiResponsesChunkSchema = z18.union([
|
|
|
3723
3792
|
responseOutputItemAddedSchema,
|
|
3724
3793
|
responseOutputItemDoneSchema,
|
|
3725
3794
|
responseFunctionCallArgumentsDeltaSchema,
|
|
3795
|
+
responseCodeInterpreterCallCodeDeltaSchema,
|
|
3796
|
+
responseCodeInterpreterCallCodeDoneSchema,
|
|
3726
3797
|
responseAnnotationAddedSchema,
|
|
3727
3798
|
responseReasoningSummaryPartAddedSchema,
|
|
3728
3799
|
responseReasoningSummaryTextDeltaSchema,
|
|
@@ -3748,6 +3819,12 @@ function isResponseCreatedChunk(chunk) {
|
|
|
3748
3819
|
function isResponseFunctionCallArgumentsDeltaChunk(chunk) {
|
|
3749
3820
|
return chunk.type === "response.function_call_arguments.delta";
|
|
3750
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
|
+
}
|
|
3751
3828
|
function isResponseOutputItemAddedChunk(chunk) {
|
|
3752
3829
|
return chunk.type === "response.output_item.added";
|
|
3753
3830
|
}
|