@ai-sdk/openai 3.0.0-beta.50 → 3.0.0-beta.51
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 +103 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +103 -12
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +102 -11
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +102 -11
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/internal/index.js
CHANGED
|
@@ -2702,6 +2702,20 @@ var openaiResponsesChunkSchema = (0, import_provider_utils21.lazySchema)(
|
|
|
2702
2702
|
start_index: import_v414.z.number().nullish(),
|
|
2703
2703
|
end_index: import_v414.z.number().nullish(),
|
|
2704
2704
|
quote: import_v414.z.string().nullish()
|
|
2705
|
+
}),
|
|
2706
|
+
import_v414.z.object({
|
|
2707
|
+
type: import_v414.z.literal("container_file_citation"),
|
|
2708
|
+
container_id: import_v414.z.string(),
|
|
2709
|
+
file_id: import_v414.z.string(),
|
|
2710
|
+
filename: import_v414.z.string().nullish(),
|
|
2711
|
+
start_index: import_v414.z.number().nullish(),
|
|
2712
|
+
end_index: import_v414.z.number().nullish(),
|
|
2713
|
+
index: import_v414.z.number().nullish()
|
|
2714
|
+
}),
|
|
2715
|
+
import_v414.z.object({
|
|
2716
|
+
type: import_v414.z.literal("file_path"),
|
|
2717
|
+
file_id: import_v414.z.string(),
|
|
2718
|
+
index: import_v414.z.number().nullish()
|
|
2705
2719
|
})
|
|
2706
2720
|
])
|
|
2707
2721
|
}),
|
|
@@ -2787,7 +2801,18 @@ var openaiResponsesResponseSchema = (0, import_provider_utils21.lazySchema)(
|
|
|
2787
2801
|
quote: import_v414.z.string().nullish()
|
|
2788
2802
|
}),
|
|
2789
2803
|
import_v414.z.object({
|
|
2790
|
-
type: import_v414.z.literal("container_file_citation")
|
|
2804
|
+
type: import_v414.z.literal("container_file_citation"),
|
|
2805
|
+
container_id: import_v414.z.string(),
|
|
2806
|
+
file_id: import_v414.z.string(),
|
|
2807
|
+
filename: import_v414.z.string().nullish(),
|
|
2808
|
+
start_index: import_v414.z.number().nullish(),
|
|
2809
|
+
end_index: import_v414.z.number().nullish(),
|
|
2810
|
+
index: import_v414.z.number().nullish()
|
|
2811
|
+
}),
|
|
2812
|
+
import_v414.z.object({
|
|
2813
|
+
type: import_v414.z.literal("file_path"),
|
|
2814
|
+
file_id: import_v414.z.string(),
|
|
2815
|
+
index: import_v414.z.number().nullish()
|
|
2791
2816
|
})
|
|
2792
2817
|
])
|
|
2793
2818
|
)
|
|
@@ -3603,7 +3628,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3603
3628
|
};
|
|
3604
3629
|
}
|
|
3605
3630
|
async doGenerate(options) {
|
|
3606
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
|
|
3631
|
+
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;
|
|
3607
3632
|
const {
|
|
3608
3633
|
args: body,
|
|
3609
3634
|
warnings,
|
|
@@ -3701,13 +3726,17 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3701
3726
|
if (((_c = (_b = options.providerOptions) == null ? void 0 : _b.openai) == null ? void 0 : _c.logprobs) && contentPart.logprobs) {
|
|
3702
3727
|
logprobs.push(contentPart.logprobs);
|
|
3703
3728
|
}
|
|
3729
|
+
const providerMetadata2 = {
|
|
3730
|
+
itemId: part.id,
|
|
3731
|
+
...contentPart.annotations.length > 0 && {
|
|
3732
|
+
annotations: contentPart.annotations
|
|
3733
|
+
}
|
|
3734
|
+
};
|
|
3704
3735
|
content.push({
|
|
3705
3736
|
type: "text",
|
|
3706
3737
|
text: contentPart.text,
|
|
3707
3738
|
providerMetadata: {
|
|
3708
|
-
openai:
|
|
3709
|
-
itemId: part.id
|
|
3710
|
-
}
|
|
3739
|
+
openai: providerMetadata2
|
|
3711
3740
|
}
|
|
3712
3741
|
});
|
|
3713
3742
|
for (const annotation of contentPart.annotations) {
|
|
@@ -3735,6 +3764,37 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3735
3764
|
}
|
|
3736
3765
|
} : {}
|
|
3737
3766
|
});
|
|
3767
|
+
} else if (annotation.type === "container_file_citation") {
|
|
3768
|
+
content.push({
|
|
3769
|
+
type: "source",
|
|
3770
|
+
sourceType: "document",
|
|
3771
|
+
id: (_o = (_n = (_m = this.config).generateId) == null ? void 0 : _n.call(_m)) != null ? _o : (0, import_provider_utils29.generateId)(),
|
|
3772
|
+
mediaType: "text/plain",
|
|
3773
|
+
title: (_q = (_p = annotation.filename) != null ? _p : annotation.file_id) != null ? _q : "Document",
|
|
3774
|
+
filename: (_r = annotation.filename) != null ? _r : annotation.file_id,
|
|
3775
|
+
providerMetadata: {
|
|
3776
|
+
openai: {
|
|
3777
|
+
fileId: annotation.file_id,
|
|
3778
|
+
containerId: annotation.container_id,
|
|
3779
|
+
...annotation.index != null ? { index: annotation.index } : {}
|
|
3780
|
+
}
|
|
3781
|
+
}
|
|
3782
|
+
});
|
|
3783
|
+
} else if (annotation.type === "file_path") {
|
|
3784
|
+
content.push({
|
|
3785
|
+
type: "source",
|
|
3786
|
+
sourceType: "document",
|
|
3787
|
+
id: (_u = (_t = (_s = this.config).generateId) == null ? void 0 : _t.call(_s)) != null ? _u : (0, import_provider_utils29.generateId)(),
|
|
3788
|
+
mediaType: "application/octet-stream",
|
|
3789
|
+
title: annotation.file_id,
|
|
3790
|
+
filename: annotation.file_id,
|
|
3791
|
+
providerMetadata: {
|
|
3792
|
+
openai: {
|
|
3793
|
+
fileId: annotation.file_id,
|
|
3794
|
+
...annotation.index != null ? { index: annotation.index } : {}
|
|
3795
|
+
}
|
|
3796
|
+
}
|
|
3797
|
+
});
|
|
3738
3798
|
}
|
|
3739
3799
|
}
|
|
3740
3800
|
}
|
|
@@ -3804,13 +3864,13 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3804
3864
|
toolName: "file_search",
|
|
3805
3865
|
result: {
|
|
3806
3866
|
queries: part.queries,
|
|
3807
|
-
results: (
|
|
3867
|
+
results: (_w = (_v = part.results) == null ? void 0 : _v.map((result) => ({
|
|
3808
3868
|
attributes: result.attributes,
|
|
3809
3869
|
fileId: result.file_id,
|
|
3810
3870
|
filename: result.filename,
|
|
3811
3871
|
score: result.score,
|
|
3812
3872
|
text: result.text
|
|
3813
|
-
}))) != null ?
|
|
3873
|
+
}))) != null ? _w : null
|
|
3814
3874
|
}
|
|
3815
3875
|
});
|
|
3816
3876
|
break;
|
|
@@ -3850,15 +3910,15 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3850
3910
|
return {
|
|
3851
3911
|
content,
|
|
3852
3912
|
finishReason: mapOpenAIResponseFinishReason({
|
|
3853
|
-
finishReason: (
|
|
3913
|
+
finishReason: (_x = response.incomplete_details) == null ? void 0 : _x.reason,
|
|
3854
3914
|
hasFunctionCall
|
|
3855
3915
|
}),
|
|
3856
3916
|
usage: {
|
|
3857
3917
|
inputTokens: response.usage.input_tokens,
|
|
3858
3918
|
outputTokens: response.usage.output_tokens,
|
|
3859
3919
|
totalTokens: response.usage.input_tokens + response.usage.output_tokens,
|
|
3860
|
-
reasoningTokens: (
|
|
3861
|
-
cachedInputTokens: (
|
|
3920
|
+
reasoningTokens: (_z = (_y = response.usage.output_tokens_details) == null ? void 0 : _y.reasoning_tokens) != null ? _z : void 0,
|
|
3921
|
+
cachedInputTokens: (_B = (_A = response.usage.input_tokens_details) == null ? void 0 : _A.cached_tokens) != null ? _B : void 0
|
|
3862
3922
|
},
|
|
3863
3923
|
request: { body },
|
|
3864
3924
|
response: {
|
|
@@ -3916,7 +3976,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3916
3976
|
controller.enqueue({ type: "stream-start", warnings });
|
|
3917
3977
|
},
|
|
3918
3978
|
transform(chunk, controller) {
|
|
3919
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
3979
|
+
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, _C, _D, _E;
|
|
3920
3980
|
if (options.includeRawChunks) {
|
|
3921
3981
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
3922
3982
|
}
|
|
@@ -4321,6 +4381,37 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4321
4381
|
}
|
|
4322
4382
|
} : {}
|
|
4323
4383
|
});
|
|
4384
|
+
} else if (value.annotation.type === "container_file_citation") {
|
|
4385
|
+
controller.enqueue({
|
|
4386
|
+
type: "source",
|
|
4387
|
+
sourceType: "document",
|
|
4388
|
+
id: (_y = (_x = (_w = self.config).generateId) == null ? void 0 : _x.call(_w)) != null ? _y : (0, import_provider_utils29.generateId)(),
|
|
4389
|
+
mediaType: "text/plain",
|
|
4390
|
+
title: (_A = (_z = value.annotation.filename) != null ? _z : value.annotation.file_id) != null ? _A : "Document",
|
|
4391
|
+
filename: (_B = value.annotation.filename) != null ? _B : value.annotation.file_id,
|
|
4392
|
+
providerMetadata: {
|
|
4393
|
+
openai: {
|
|
4394
|
+
fileId: value.annotation.file_id,
|
|
4395
|
+
containerId: value.annotation.container_id,
|
|
4396
|
+
...value.annotation.index != null ? { index: value.annotation.index } : {}
|
|
4397
|
+
}
|
|
4398
|
+
}
|
|
4399
|
+
});
|
|
4400
|
+
} else if (value.annotation.type === "file_path") {
|
|
4401
|
+
controller.enqueue({
|
|
4402
|
+
type: "source",
|
|
4403
|
+
sourceType: "document",
|
|
4404
|
+
id: (_E = (_D = (_C = self.config).generateId) == null ? void 0 : _D.call(_C)) != null ? _E : (0, import_provider_utils29.generateId)(),
|
|
4405
|
+
mediaType: "application/octet-stream",
|
|
4406
|
+
title: value.annotation.file_id,
|
|
4407
|
+
filename: value.annotation.file_id,
|
|
4408
|
+
providerMetadata: {
|
|
4409
|
+
openai: {
|
|
4410
|
+
fileId: value.annotation.file_id,
|
|
4411
|
+
...value.annotation.index != null ? { index: value.annotation.index } : {}
|
|
4412
|
+
}
|
|
4413
|
+
}
|
|
4414
|
+
});
|
|
4324
4415
|
}
|
|
4325
4416
|
} else if (isErrorChunk(value)) {
|
|
4326
4417
|
controller.enqueue({ type: "error", error: value });
|