@ai-sdk/openai 2.0.74 → 2.0.75
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 +64 -29
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +64 -29
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +63 -28
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +63 -28
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -3340,7 +3340,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3340
3340
|
};
|
|
3341
3341
|
}
|
|
3342
3342
|
async doGenerate(options) {
|
|
3343
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
|
|
3343
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B;
|
|
3344
3344
|
const {
|
|
3345
3345
|
args: body,
|
|
3346
3346
|
warnings,
|
|
@@ -3350,6 +3350,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3350
3350
|
path: "/responses",
|
|
3351
3351
|
modelId: this.modelId
|
|
3352
3352
|
});
|
|
3353
|
+
const providerKey = this.config.provider.replace(".responses", "");
|
|
3353
3354
|
const {
|
|
3354
3355
|
responseHeaders,
|
|
3355
3356
|
value: response,
|
|
@@ -3390,7 +3391,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3390
3391
|
type: "reasoning",
|
|
3391
3392
|
text: summary.text,
|
|
3392
3393
|
providerMetadata: {
|
|
3393
|
-
|
|
3394
|
+
[providerKey]: {
|
|
3394
3395
|
itemId: part.id,
|
|
3395
3396
|
reasoningEncryptedContent: (_a = part.encrypted_content) != null ? _a : null
|
|
3396
3397
|
}
|
|
@@ -3427,7 +3428,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3427
3428
|
action: part.action
|
|
3428
3429
|
}),
|
|
3429
3430
|
providerMetadata: {
|
|
3430
|
-
|
|
3431
|
+
[providerKey]: {
|
|
3431
3432
|
itemId: part.id
|
|
3432
3433
|
}
|
|
3433
3434
|
}
|
|
@@ -3443,7 +3444,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3443
3444
|
type: "text",
|
|
3444
3445
|
text: contentPart.text,
|
|
3445
3446
|
providerMetadata: {
|
|
3446
|
-
|
|
3447
|
+
[providerKey]: {
|
|
3447
3448
|
itemId: part.id
|
|
3448
3449
|
}
|
|
3449
3450
|
}
|
|
@@ -3467,12 +3468,43 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3467
3468
|
filename: (_l = annotation.filename) != null ? _l : annotation.file_id,
|
|
3468
3469
|
...annotation.file_id ? {
|
|
3469
3470
|
providerMetadata: {
|
|
3470
|
-
|
|
3471
|
+
[providerKey]: {
|
|
3471
3472
|
fileId: annotation.file_id
|
|
3472
3473
|
}
|
|
3473
3474
|
}
|
|
3474
3475
|
} : {}
|
|
3475
3476
|
});
|
|
3477
|
+
} else if (annotation.type === "container_file_citation") {
|
|
3478
|
+
content.push({
|
|
3479
|
+
type: "source",
|
|
3480
|
+
sourceType: "document",
|
|
3481
|
+
id: (_o = (_n = (_m = this.config).generateId) == null ? void 0 : _n.call(_m)) != null ? _o : (0, import_provider_utils24.generateId)(),
|
|
3482
|
+
mediaType: "text/plain",
|
|
3483
|
+
title: (_q = (_p = annotation.filename) != null ? _p : annotation.file_id) != null ? _q : "Document",
|
|
3484
|
+
filename: (_r = annotation.filename) != null ? _r : annotation.file_id,
|
|
3485
|
+
providerMetadata: {
|
|
3486
|
+
[providerKey]: {
|
|
3487
|
+
fileId: annotation.file_id,
|
|
3488
|
+
containerId: annotation.container_id,
|
|
3489
|
+
...annotation.index != null ? { index: annotation.index } : {}
|
|
3490
|
+
}
|
|
3491
|
+
}
|
|
3492
|
+
});
|
|
3493
|
+
} else if (annotation.type === "file_path") {
|
|
3494
|
+
content.push({
|
|
3495
|
+
type: "source",
|
|
3496
|
+
sourceType: "document",
|
|
3497
|
+
id: (_u = (_t = (_s = this.config).generateId) == null ? void 0 : _t.call(_s)) != null ? _u : (0, import_provider_utils24.generateId)(),
|
|
3498
|
+
mediaType: "application/octet-stream",
|
|
3499
|
+
title: annotation.file_id,
|
|
3500
|
+
filename: annotation.file_id,
|
|
3501
|
+
providerMetadata: {
|
|
3502
|
+
[providerKey]: {
|
|
3503
|
+
fileId: annotation.file_id,
|
|
3504
|
+
...annotation.index != null ? { index: annotation.index } : {}
|
|
3505
|
+
}
|
|
3506
|
+
}
|
|
3507
|
+
});
|
|
3476
3508
|
}
|
|
3477
3509
|
}
|
|
3478
3510
|
}
|
|
@@ -3486,7 +3518,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3486
3518
|
toolName: part.name,
|
|
3487
3519
|
input: part.arguments,
|
|
3488
3520
|
providerMetadata: {
|
|
3489
|
-
|
|
3521
|
+
[providerKey]: {
|
|
3490
3522
|
itemId: part.id
|
|
3491
3523
|
}
|
|
3492
3524
|
}
|
|
@@ -3544,13 +3576,13 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3544
3576
|
toolName: "file_search",
|
|
3545
3577
|
result: {
|
|
3546
3578
|
queries: part.queries,
|
|
3547
|
-
results: (
|
|
3579
|
+
results: (_w = (_v = part.results) == null ? void 0 : _v.map((result) => ({
|
|
3548
3580
|
attributes: result.attributes,
|
|
3549
3581
|
fileId: result.file_id,
|
|
3550
3582
|
filename: result.filename,
|
|
3551
3583
|
score: result.score,
|
|
3552
3584
|
text: result.text
|
|
3553
|
-
}))) != null ?
|
|
3585
|
+
}))) != null ? _w : null
|
|
3554
3586
|
},
|
|
3555
3587
|
providerExecuted: true
|
|
3556
3588
|
});
|
|
@@ -3581,29 +3613,29 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3581
3613
|
}
|
|
3582
3614
|
}
|
|
3583
3615
|
const providerMetadata = {
|
|
3584
|
-
|
|
3616
|
+
[providerKey]: {
|
|
3585
3617
|
...response.id != null ? { responseId: response.id } : {}
|
|
3586
3618
|
}
|
|
3587
3619
|
};
|
|
3588
3620
|
if (logprobs.length > 0) {
|
|
3589
|
-
providerMetadata.
|
|
3621
|
+
providerMetadata[providerKey].logprobs = logprobs;
|
|
3590
3622
|
}
|
|
3591
3623
|
if (typeof response.service_tier === "string") {
|
|
3592
|
-
providerMetadata.
|
|
3624
|
+
providerMetadata[providerKey].serviceTier = response.service_tier;
|
|
3593
3625
|
}
|
|
3594
3626
|
const usage = response.usage;
|
|
3595
3627
|
return {
|
|
3596
3628
|
content,
|
|
3597
3629
|
finishReason: mapOpenAIResponseFinishReason({
|
|
3598
|
-
finishReason: (
|
|
3630
|
+
finishReason: (_x = response.incomplete_details) == null ? void 0 : _x.reason,
|
|
3599
3631
|
hasFunctionCall
|
|
3600
3632
|
}),
|
|
3601
3633
|
usage: {
|
|
3602
3634
|
inputTokens: usage.input_tokens,
|
|
3603
3635
|
outputTokens: usage.output_tokens,
|
|
3604
3636
|
totalTokens: usage.input_tokens + usage.output_tokens,
|
|
3605
|
-
reasoningTokens: (
|
|
3606
|
-
cachedInputTokens: (
|
|
3637
|
+
reasoningTokens: (_z = (_y = usage.output_tokens_details) == null ? void 0 : _y.reasoning_tokens) != null ? _z : void 0,
|
|
3638
|
+
cachedInputTokens: (_B = (_A = usage.input_tokens_details) == null ? void 0 : _A.cached_tokens) != null ? _B : void 0
|
|
3607
3639
|
},
|
|
3608
3640
|
request: { body },
|
|
3609
3641
|
response: {
|
|
@@ -3642,6 +3674,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3642
3674
|
fetch: this.config.fetch
|
|
3643
3675
|
});
|
|
3644
3676
|
const self = this;
|
|
3677
|
+
const providerKey = this.config.provider.replace(".responses", "");
|
|
3645
3678
|
let finishReason = "unknown";
|
|
3646
3679
|
const usage = {
|
|
3647
3680
|
inputTokens: void 0,
|
|
@@ -3757,7 +3790,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3757
3790
|
type: "text-start",
|
|
3758
3791
|
id: value.item.id,
|
|
3759
3792
|
providerMetadata: {
|
|
3760
|
-
|
|
3793
|
+
[providerKey]: {
|
|
3761
3794
|
itemId: value.item.id
|
|
3762
3795
|
}
|
|
3763
3796
|
}
|
|
@@ -3771,7 +3804,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3771
3804
|
type: "reasoning-start",
|
|
3772
3805
|
id: `${value.item.id}:0`,
|
|
3773
3806
|
providerMetadata: {
|
|
3774
|
-
|
|
3807
|
+
[providerKey]: {
|
|
3775
3808
|
itemId: value.item.id,
|
|
3776
3809
|
reasoningEncryptedContent: (_a = value.item.encrypted_content) != null ? _a : null
|
|
3777
3810
|
}
|
|
@@ -3784,7 +3817,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3784
3817
|
type: "text-end",
|
|
3785
3818
|
id: value.item.id,
|
|
3786
3819
|
providerMetadata: {
|
|
3787
|
-
|
|
3820
|
+
[providerKey]: {
|
|
3788
3821
|
itemId: value.item.id,
|
|
3789
3822
|
...ongoingAnnotations.length > 0 && {
|
|
3790
3823
|
annotations: ongoingAnnotations
|
|
@@ -3805,7 +3838,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3805
3838
|
toolName: value.item.name,
|
|
3806
3839
|
input: value.item.arguments,
|
|
3807
3840
|
providerMetadata: {
|
|
3808
|
-
|
|
3841
|
+
[providerKey]: {
|
|
3809
3842
|
itemId: value.item.id
|
|
3810
3843
|
}
|
|
3811
3844
|
}
|
|
@@ -3898,7 +3931,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3898
3931
|
}
|
|
3899
3932
|
}),
|
|
3900
3933
|
providerMetadata: {
|
|
3901
|
-
|
|
3934
|
+
[providerKey]: { itemId: value.item.id }
|
|
3902
3935
|
}
|
|
3903
3936
|
});
|
|
3904
3937
|
} else if (value.item.type === "reasoning") {
|
|
@@ -3913,7 +3946,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3913
3946
|
type: "reasoning-end",
|
|
3914
3947
|
id: `${value.item.id}:${summaryIndex}`,
|
|
3915
3948
|
providerMetadata: {
|
|
3916
|
-
|
|
3949
|
+
[providerKey]: {
|
|
3917
3950
|
itemId: value.item.id,
|
|
3918
3951
|
reasoningEncryptedContent: (_d = value.item.encrypted_content) != null ? _d : null
|
|
3919
3952
|
}
|
|
@@ -3993,7 +4026,9 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3993
4026
|
controller.enqueue({
|
|
3994
4027
|
type: "reasoning-end",
|
|
3995
4028
|
id: `${value.item_id}:${summaryIndex}`,
|
|
3996
|
-
providerMetadata: {
|
|
4029
|
+
providerMetadata: {
|
|
4030
|
+
[providerKey]: { itemId: value.item_id }
|
|
4031
|
+
}
|
|
3997
4032
|
});
|
|
3998
4033
|
activeReasoningPart.summaryParts[summaryIndex] = "concluded";
|
|
3999
4034
|
}
|
|
@@ -4002,7 +4037,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4002
4037
|
type: "reasoning-start",
|
|
4003
4038
|
id: `${value.item_id}:${value.summary_index}`,
|
|
4004
4039
|
providerMetadata: {
|
|
4005
|
-
|
|
4040
|
+
[providerKey]: {
|
|
4006
4041
|
itemId: value.item_id,
|
|
4007
4042
|
reasoningEncryptedContent: (_h = (_g = activeReasoning[value.item_id]) == null ? void 0 : _g.encryptedContent) != null ? _h : null
|
|
4008
4043
|
}
|
|
@@ -4015,7 +4050,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4015
4050
|
id: `${value.item_id}:${value.summary_index}`,
|
|
4016
4051
|
delta: value.delta,
|
|
4017
4052
|
providerMetadata: {
|
|
4018
|
-
|
|
4053
|
+
[providerKey]: {
|
|
4019
4054
|
itemId: value.item_id
|
|
4020
4055
|
}
|
|
4021
4056
|
}
|
|
@@ -4026,7 +4061,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4026
4061
|
type: "reasoning-end",
|
|
4027
4062
|
id: `${value.item_id}:${value.summary_index}`,
|
|
4028
4063
|
providerMetadata: {
|
|
4029
|
-
|
|
4064
|
+
[providerKey]: { itemId: value.item_id }
|
|
4030
4065
|
}
|
|
4031
4066
|
});
|
|
4032
4067
|
activeReasoning[value.item_id].summaryParts[value.summary_index] = "concluded";
|
|
@@ -4066,7 +4101,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4066
4101
|
filename: (_v = value.annotation.filename) != null ? _v : value.annotation.file_id,
|
|
4067
4102
|
...value.annotation.file_id ? {
|
|
4068
4103
|
providerMetadata: {
|
|
4069
|
-
|
|
4104
|
+
[providerKey]: {
|
|
4070
4105
|
fileId: value.annotation.file_id
|
|
4071
4106
|
}
|
|
4072
4107
|
}
|
|
@@ -4079,15 +4114,15 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4079
4114
|
},
|
|
4080
4115
|
flush(controller) {
|
|
4081
4116
|
const providerMetadata = {
|
|
4082
|
-
|
|
4117
|
+
[providerKey]: {
|
|
4083
4118
|
responseId
|
|
4084
4119
|
}
|
|
4085
4120
|
};
|
|
4086
4121
|
if (logprobs.length > 0) {
|
|
4087
|
-
providerMetadata.
|
|
4122
|
+
providerMetadata[providerKey].logprobs = logprobs;
|
|
4088
4123
|
}
|
|
4089
4124
|
if (serviceTier !== void 0) {
|
|
4090
|
-
providerMetadata.
|
|
4125
|
+
providerMetadata[providerKey].serviceTier = serviceTier;
|
|
4091
4126
|
}
|
|
4092
4127
|
controller.enqueue({
|
|
4093
4128
|
type: "finish",
|
|
@@ -4530,7 +4565,7 @@ var OpenAITranscriptionModel = class {
|
|
|
4530
4565
|
};
|
|
4531
4566
|
|
|
4532
4567
|
// src/version.ts
|
|
4533
|
-
var VERSION = true ? "2.0.
|
|
4568
|
+
var VERSION = true ? "2.0.75" : "0.0.0-test";
|
|
4534
4569
|
|
|
4535
4570
|
// src/openai-provider.ts
|
|
4536
4571
|
function createOpenAI(options = {}) {
|