@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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @ai-sdk/openai
|
|
2
2
|
|
|
3
|
+
## 2.0.39
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 5428a0d: The built in Code Interpreter tool input code is streamed in `tool-input-<start/delta/end>` chunks.
|
|
8
|
+
|
|
9
|
+
## 2.0.38
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 0bda600: enables code_interpreter and file_search capabilities in the Azure provider through the Responses API
|
|
14
|
+
|
|
3
15
|
## 2.0.37
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -2068,6 +2068,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2068
2068
|
});
|
|
2069
2069
|
break;
|
|
2070
2070
|
}
|
|
2071
|
+
// assistant tool result parts are from provider-executed tools:
|
|
2071
2072
|
case "tool-result": {
|
|
2072
2073
|
if (store) {
|
|
2073
2074
|
input.push({ type: "item_reference", id: part.toolCallId });
|
|
@@ -2989,6 +2990,24 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2989
2990
|
id: value.item.id,
|
|
2990
2991
|
toolName: "computer_use"
|
|
2991
2992
|
});
|
|
2993
|
+
} else if (value.item.type === "code_interpreter_call") {
|
|
2994
|
+
ongoingToolCalls[value.output_index] = {
|
|
2995
|
+
toolName: "code_interpreter",
|
|
2996
|
+
toolCallId: value.item.id,
|
|
2997
|
+
codeInterpreter: {
|
|
2998
|
+
containerId: value.item.container_id
|
|
2999
|
+
}
|
|
3000
|
+
};
|
|
3001
|
+
controller.enqueue({
|
|
3002
|
+
type: "tool-input-start",
|
|
3003
|
+
id: value.item.id,
|
|
3004
|
+
toolName: "code_interpreter"
|
|
3005
|
+
});
|
|
3006
|
+
controller.enqueue({
|
|
3007
|
+
type: "tool-input-delta",
|
|
3008
|
+
id: value.item.id,
|
|
3009
|
+
delta: `{"containerId":"${value.item.container_id}","code":"`
|
|
3010
|
+
});
|
|
2992
3011
|
} else if (value.item.type === "file_search_call") {
|
|
2993
3012
|
controller.enqueue({
|
|
2994
3013
|
type: "tool-call",
|
|
@@ -3112,16 +3131,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3112
3131
|
providerExecuted: true
|
|
3113
3132
|
});
|
|
3114
3133
|
} else if (value.item.type === "code_interpreter_call") {
|
|
3115
|
-
|
|
3116
|
-
type: "tool-call",
|
|
3117
|
-
toolCallId: value.item.id,
|
|
3118
|
-
toolName: "code_interpreter",
|
|
3119
|
-
input: JSON.stringify({
|
|
3120
|
-
code: value.item.code,
|
|
3121
|
-
containerId: value.item.container_id
|
|
3122
|
-
}),
|
|
3123
|
-
providerExecuted: true
|
|
3124
|
-
});
|
|
3134
|
+
ongoingToolCalls[value.output_index] = void 0;
|
|
3125
3135
|
controller.enqueue({
|
|
3126
3136
|
type: "tool-result",
|
|
3127
3137
|
toolCallId: value.item.id,
|
|
@@ -3171,6 +3181,40 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3171
3181
|
delta: value.delta
|
|
3172
3182
|
});
|
|
3173
3183
|
}
|
|
3184
|
+
} else if (isResponseCodeInterpreterCallCodeDeltaChunk(value)) {
|
|
3185
|
+
const toolCall = ongoingToolCalls[value.output_index];
|
|
3186
|
+
if (toolCall != null) {
|
|
3187
|
+
controller.enqueue({
|
|
3188
|
+
type: "tool-input-delta",
|
|
3189
|
+
id: toolCall.toolCallId,
|
|
3190
|
+
// The delta is code, which is embedding in a JSON string.
|
|
3191
|
+
// To escape it, we use JSON.stringify and slice to remove the outer quotes.
|
|
3192
|
+
delta: JSON.stringify(value.delta).slice(1, -1)
|
|
3193
|
+
});
|
|
3194
|
+
}
|
|
3195
|
+
} else if (isResponseCodeInterpreterCallCodeDoneChunk(value)) {
|
|
3196
|
+
const toolCall = ongoingToolCalls[value.output_index];
|
|
3197
|
+
if (toolCall != null) {
|
|
3198
|
+
controller.enqueue({
|
|
3199
|
+
type: "tool-input-delta",
|
|
3200
|
+
id: toolCall.toolCallId,
|
|
3201
|
+
delta: '"}'
|
|
3202
|
+
});
|
|
3203
|
+
controller.enqueue({
|
|
3204
|
+
type: "tool-input-end",
|
|
3205
|
+
id: toolCall.toolCallId
|
|
3206
|
+
});
|
|
3207
|
+
controller.enqueue({
|
|
3208
|
+
type: "tool-call",
|
|
3209
|
+
toolCallId: toolCall.toolCallId,
|
|
3210
|
+
toolName: "code_interpreter",
|
|
3211
|
+
input: JSON.stringify({
|
|
3212
|
+
code: value.code,
|
|
3213
|
+
containerId: toolCall.codeInterpreter.containerId
|
|
3214
|
+
}),
|
|
3215
|
+
providerExecuted: true
|
|
3216
|
+
});
|
|
3217
|
+
}
|
|
3174
3218
|
} else if (isResponseCreatedChunk(value)) {
|
|
3175
3219
|
responseId = value.response.id;
|
|
3176
3220
|
controller.enqueue({
|
|
@@ -3354,6 +3398,19 @@ var responseOutputItemAddedSchema = import_v415.z.object({
|
|
|
3354
3398
|
import_v415.z.object({
|
|
3355
3399
|
type: import_v415.z.literal("image_generation_call"),
|
|
3356
3400
|
id: import_v415.z.string()
|
|
3401
|
+
}),
|
|
3402
|
+
import_v415.z.object({
|
|
3403
|
+
type: import_v415.z.literal("code_interpreter_call"),
|
|
3404
|
+
id: import_v415.z.string(),
|
|
3405
|
+
container_id: import_v415.z.string(),
|
|
3406
|
+
code: import_v415.z.string().nullable(),
|
|
3407
|
+
outputs: import_v415.z.array(
|
|
3408
|
+
import_v415.z.discriminatedUnion("type", [
|
|
3409
|
+
import_v415.z.object({ type: import_v415.z.literal("logs"), logs: import_v415.z.string() }),
|
|
3410
|
+
import_v415.z.object({ type: import_v415.z.literal("image"), url: import_v415.z.string() })
|
|
3411
|
+
])
|
|
3412
|
+
).nullable(),
|
|
3413
|
+
status: import_v415.z.string()
|
|
3357
3414
|
})
|
|
3358
3415
|
])
|
|
3359
3416
|
});
|
|
@@ -3395,6 +3452,18 @@ var responseFunctionCallArgumentsDeltaSchema = import_v415.z.object({
|
|
|
3395
3452
|
output_index: import_v415.z.number(),
|
|
3396
3453
|
delta: import_v415.z.string()
|
|
3397
3454
|
});
|
|
3455
|
+
var responseCodeInterpreterCallCodeDeltaSchema = import_v415.z.object({
|
|
3456
|
+
type: import_v415.z.literal("response.code_interpreter_call_code.delta"),
|
|
3457
|
+
item_id: import_v415.z.string(),
|
|
3458
|
+
output_index: import_v415.z.number(),
|
|
3459
|
+
delta: import_v415.z.string()
|
|
3460
|
+
});
|
|
3461
|
+
var responseCodeInterpreterCallCodeDoneSchema = import_v415.z.object({
|
|
3462
|
+
type: import_v415.z.literal("response.code_interpreter_call_code.done"),
|
|
3463
|
+
item_id: import_v415.z.string(),
|
|
3464
|
+
output_index: import_v415.z.number(),
|
|
3465
|
+
code: import_v415.z.string()
|
|
3466
|
+
});
|
|
3398
3467
|
var responseAnnotationAddedSchema = import_v415.z.object({
|
|
3399
3468
|
type: import_v415.z.literal("response.output_text.annotation.added"),
|
|
3400
3469
|
annotation: import_v415.z.discriminatedUnion("type", [
|
|
@@ -3432,6 +3501,8 @@ var openaiResponsesChunkSchema = import_v415.z.union([
|
|
|
3432
3501
|
responseOutputItemAddedSchema,
|
|
3433
3502
|
responseOutputItemDoneSchema,
|
|
3434
3503
|
responseFunctionCallArgumentsDeltaSchema,
|
|
3504
|
+
responseCodeInterpreterCallCodeDeltaSchema,
|
|
3505
|
+
responseCodeInterpreterCallCodeDoneSchema,
|
|
3435
3506
|
responseAnnotationAddedSchema,
|
|
3436
3507
|
responseReasoningSummaryPartAddedSchema,
|
|
3437
3508
|
responseReasoningSummaryTextDeltaSchema,
|
|
@@ -3457,6 +3528,12 @@ function isResponseCreatedChunk(chunk) {
|
|
|
3457
3528
|
function isResponseFunctionCallArgumentsDeltaChunk(chunk) {
|
|
3458
3529
|
return chunk.type === "response.function_call_arguments.delta";
|
|
3459
3530
|
}
|
|
3531
|
+
function isResponseCodeInterpreterCallCodeDeltaChunk(chunk) {
|
|
3532
|
+
return chunk.type === "response.code_interpreter_call_code.delta";
|
|
3533
|
+
}
|
|
3534
|
+
function isResponseCodeInterpreterCallCodeDoneChunk(chunk) {
|
|
3535
|
+
return chunk.type === "response.code_interpreter_call_code.done";
|
|
3536
|
+
}
|
|
3460
3537
|
function isResponseOutputItemAddedChunk(chunk) {
|
|
3461
3538
|
return chunk.type === "response.output_item.added";
|
|
3462
3539
|
}
|
|
@@ -3883,7 +3960,7 @@ var openaiTranscriptionResponseSchema = import_v418.z.object({
|
|
|
3883
3960
|
});
|
|
3884
3961
|
|
|
3885
3962
|
// src/version.ts
|
|
3886
|
-
var VERSION = true ? "2.0.
|
|
3963
|
+
var VERSION = true ? "2.0.39" : "0.0.0-test";
|
|
3887
3964
|
|
|
3888
3965
|
// src/openai-provider.ts
|
|
3889
3966
|
function createOpenAI(options = {}) {
|