@ai-sdk/openai 2.0.1 → 2.0.2
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 +47 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +47 -9
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +47 -9
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +47 -9
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -708,7 +708,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
708
708
|
};
|
|
709
709
|
}
|
|
710
710
|
async doGenerate(options) {
|
|
711
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
711
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
712
712
|
const { args: body, warnings } = await this.getArgs(options);
|
|
713
713
|
const {
|
|
714
714
|
responseHeaders,
|
|
@@ -742,8 +742,17 @@ var OpenAIChatLanguageModel = class {
|
|
|
742
742
|
input: toolCall.function.arguments
|
|
743
743
|
});
|
|
744
744
|
}
|
|
745
|
-
const
|
|
746
|
-
|
|
745
|
+
for (const annotation of (_c = choice.message.annotations) != null ? _c : []) {
|
|
746
|
+
content.push({
|
|
747
|
+
type: "source",
|
|
748
|
+
sourceType: "url",
|
|
749
|
+
id: (0, import_provider_utils5.generateId)(),
|
|
750
|
+
url: annotation.url,
|
|
751
|
+
title: annotation.title
|
|
752
|
+
});
|
|
753
|
+
}
|
|
754
|
+
const completionTokenDetails = (_d = response.usage) == null ? void 0 : _d.completion_tokens_details;
|
|
755
|
+
const promptTokenDetails = (_e = response.usage) == null ? void 0 : _e.prompt_tokens_details;
|
|
747
756
|
const providerMetadata = { openai: {} };
|
|
748
757
|
if ((completionTokenDetails == null ? void 0 : completionTokenDetails.accepted_prediction_tokens) != null) {
|
|
749
758
|
providerMetadata.openai.acceptedPredictionTokens = completionTokenDetails == null ? void 0 : completionTokenDetails.accepted_prediction_tokens;
|
|
@@ -751,18 +760,18 @@ var OpenAIChatLanguageModel = class {
|
|
|
751
760
|
if ((completionTokenDetails == null ? void 0 : completionTokenDetails.rejected_prediction_tokens) != null) {
|
|
752
761
|
providerMetadata.openai.rejectedPredictionTokens = completionTokenDetails == null ? void 0 : completionTokenDetails.rejected_prediction_tokens;
|
|
753
762
|
}
|
|
754
|
-
if (((
|
|
763
|
+
if (((_f = choice.logprobs) == null ? void 0 : _f.content) != null) {
|
|
755
764
|
providerMetadata.openai.logprobs = choice.logprobs.content;
|
|
756
765
|
}
|
|
757
766
|
return {
|
|
758
767
|
content,
|
|
759
768
|
finishReason: mapOpenAIFinishReason(choice.finish_reason),
|
|
760
769
|
usage: {
|
|
761
|
-
inputTokens: (
|
|
762
|
-
outputTokens: (
|
|
763
|
-
totalTokens: (
|
|
764
|
-
reasoningTokens: (
|
|
765
|
-
cachedInputTokens: (
|
|
770
|
+
inputTokens: (_h = (_g = response.usage) == null ? void 0 : _g.prompt_tokens) != null ? _h : void 0,
|
|
771
|
+
outputTokens: (_j = (_i = response.usage) == null ? void 0 : _i.completion_tokens) != null ? _j : void 0,
|
|
772
|
+
totalTokens: (_l = (_k = response.usage) == null ? void 0 : _k.total_tokens) != null ? _l : void 0,
|
|
773
|
+
reasoningTokens: (_m = completionTokenDetails == null ? void 0 : completionTokenDetails.reasoning_tokens) != null ? _m : void 0,
|
|
774
|
+
cachedInputTokens: (_n = promptTokenDetails == null ? void 0 : promptTokenDetails.cached_tokens) != null ? _n : void 0
|
|
766
775
|
},
|
|
767
776
|
request: { body },
|
|
768
777
|
response: {
|
|
@@ -959,6 +968,17 @@ var OpenAIChatLanguageModel = class {
|
|
|
959
968
|
}
|
|
960
969
|
}
|
|
961
970
|
}
|
|
971
|
+
if (delta.annotations != null) {
|
|
972
|
+
for (const annotation of delta.annotations) {
|
|
973
|
+
controller.enqueue({
|
|
974
|
+
type: "source",
|
|
975
|
+
sourceType: "url",
|
|
976
|
+
id: (0, import_provider_utils5.generateId)(),
|
|
977
|
+
url: annotation.url,
|
|
978
|
+
title: annotation.title
|
|
979
|
+
});
|
|
980
|
+
}
|
|
981
|
+
}
|
|
962
982
|
},
|
|
963
983
|
flush(controller) {
|
|
964
984
|
if (isActiveText) {
|
|
@@ -1009,6 +1029,15 @@ var openaiChatResponseSchema = import_v45.z.object({
|
|
|
1009
1029
|
arguments: import_v45.z.string()
|
|
1010
1030
|
})
|
|
1011
1031
|
})
|
|
1032
|
+
).nullish(),
|
|
1033
|
+
annotations: import_v45.z.array(
|
|
1034
|
+
import_v45.z.object({
|
|
1035
|
+
type: import_v45.z.literal("url_citation"),
|
|
1036
|
+
start_index: import_v45.z.number(),
|
|
1037
|
+
end_index: import_v45.z.number(),
|
|
1038
|
+
url: import_v45.z.string(),
|
|
1039
|
+
title: import_v45.z.string()
|
|
1040
|
+
})
|
|
1012
1041
|
).nullish()
|
|
1013
1042
|
}),
|
|
1014
1043
|
index: import_v45.z.number(),
|
|
@@ -1051,6 +1080,15 @@ var openaiChatChunkSchema = import_v45.z.union([
|
|
|
1051
1080
|
arguments: import_v45.z.string().nullish()
|
|
1052
1081
|
})
|
|
1053
1082
|
})
|
|
1083
|
+
).nullish(),
|
|
1084
|
+
annotations: import_v45.z.array(
|
|
1085
|
+
import_v45.z.object({
|
|
1086
|
+
type: import_v45.z.literal("url_citation"),
|
|
1087
|
+
start_index: import_v45.z.number(),
|
|
1088
|
+
end_index: import_v45.z.number(),
|
|
1089
|
+
url: import_v45.z.string(),
|
|
1090
|
+
title: import_v45.z.string()
|
|
1091
|
+
})
|
|
1054
1092
|
).nullish()
|
|
1055
1093
|
}).nullish(),
|
|
1056
1094
|
logprobs: import_v45.z.object({
|