@ai-sdk/openai 2.0.0 → 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 +12 -0
- package/dist/index.js +82 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +82 -9
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +82 -9
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +82 -9
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -698,7 +698,7 @@ var OpenAIChatLanguageModel = class {
|
|
|
698
698
|
};
|
|
699
699
|
}
|
|
700
700
|
async doGenerate(options) {
|
|
701
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
701
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
702
702
|
const { args: body, warnings } = await this.getArgs(options);
|
|
703
703
|
const {
|
|
704
704
|
responseHeaders,
|
|
@@ -732,8 +732,17 @@ var OpenAIChatLanguageModel = class {
|
|
|
732
732
|
input: toolCall.function.arguments
|
|
733
733
|
});
|
|
734
734
|
}
|
|
735
|
-
const
|
|
736
|
-
|
|
735
|
+
for (const annotation of (_c = choice.message.annotations) != null ? _c : []) {
|
|
736
|
+
content.push({
|
|
737
|
+
type: "source",
|
|
738
|
+
sourceType: "url",
|
|
739
|
+
id: generateId(),
|
|
740
|
+
url: annotation.url,
|
|
741
|
+
title: annotation.title
|
|
742
|
+
});
|
|
743
|
+
}
|
|
744
|
+
const completionTokenDetails = (_d = response.usage) == null ? void 0 : _d.completion_tokens_details;
|
|
745
|
+
const promptTokenDetails = (_e = response.usage) == null ? void 0 : _e.prompt_tokens_details;
|
|
737
746
|
const providerMetadata = { openai: {} };
|
|
738
747
|
if ((completionTokenDetails == null ? void 0 : completionTokenDetails.accepted_prediction_tokens) != null) {
|
|
739
748
|
providerMetadata.openai.acceptedPredictionTokens = completionTokenDetails == null ? void 0 : completionTokenDetails.accepted_prediction_tokens;
|
|
@@ -741,18 +750,18 @@ var OpenAIChatLanguageModel = class {
|
|
|
741
750
|
if ((completionTokenDetails == null ? void 0 : completionTokenDetails.rejected_prediction_tokens) != null) {
|
|
742
751
|
providerMetadata.openai.rejectedPredictionTokens = completionTokenDetails == null ? void 0 : completionTokenDetails.rejected_prediction_tokens;
|
|
743
752
|
}
|
|
744
|
-
if (((
|
|
753
|
+
if (((_f = choice.logprobs) == null ? void 0 : _f.content) != null) {
|
|
745
754
|
providerMetadata.openai.logprobs = choice.logprobs.content;
|
|
746
755
|
}
|
|
747
756
|
return {
|
|
748
757
|
content,
|
|
749
758
|
finishReason: mapOpenAIFinishReason(choice.finish_reason),
|
|
750
759
|
usage: {
|
|
751
|
-
inputTokens: (
|
|
752
|
-
outputTokens: (
|
|
753
|
-
totalTokens: (
|
|
754
|
-
reasoningTokens: (
|
|
755
|
-
cachedInputTokens: (
|
|
760
|
+
inputTokens: (_h = (_g = response.usage) == null ? void 0 : _g.prompt_tokens) != null ? _h : void 0,
|
|
761
|
+
outputTokens: (_j = (_i = response.usage) == null ? void 0 : _i.completion_tokens) != null ? _j : void 0,
|
|
762
|
+
totalTokens: (_l = (_k = response.usage) == null ? void 0 : _k.total_tokens) != null ? _l : void 0,
|
|
763
|
+
reasoningTokens: (_m = completionTokenDetails == null ? void 0 : completionTokenDetails.reasoning_tokens) != null ? _m : void 0,
|
|
764
|
+
cachedInputTokens: (_n = promptTokenDetails == null ? void 0 : promptTokenDetails.cached_tokens) != null ? _n : void 0
|
|
756
765
|
},
|
|
757
766
|
request: { body },
|
|
758
767
|
response: {
|
|
@@ -949,6 +958,17 @@ var OpenAIChatLanguageModel = class {
|
|
|
949
958
|
}
|
|
950
959
|
}
|
|
951
960
|
}
|
|
961
|
+
if (delta.annotations != null) {
|
|
962
|
+
for (const annotation of delta.annotations) {
|
|
963
|
+
controller.enqueue({
|
|
964
|
+
type: "source",
|
|
965
|
+
sourceType: "url",
|
|
966
|
+
id: generateId(),
|
|
967
|
+
url: annotation.url,
|
|
968
|
+
title: annotation.title
|
|
969
|
+
});
|
|
970
|
+
}
|
|
971
|
+
}
|
|
952
972
|
},
|
|
953
973
|
flush(controller) {
|
|
954
974
|
if (isActiveText) {
|
|
@@ -999,6 +1019,15 @@ var openaiChatResponseSchema = z5.object({
|
|
|
999
1019
|
arguments: z5.string()
|
|
1000
1020
|
})
|
|
1001
1021
|
})
|
|
1022
|
+
).nullish(),
|
|
1023
|
+
annotations: z5.array(
|
|
1024
|
+
z5.object({
|
|
1025
|
+
type: z5.literal("url_citation"),
|
|
1026
|
+
start_index: z5.number(),
|
|
1027
|
+
end_index: z5.number(),
|
|
1028
|
+
url: z5.string(),
|
|
1029
|
+
title: z5.string()
|
|
1030
|
+
})
|
|
1002
1031
|
).nullish()
|
|
1003
1032
|
}),
|
|
1004
1033
|
index: z5.number(),
|
|
@@ -1041,6 +1070,15 @@ var openaiChatChunkSchema = z5.union([
|
|
|
1041
1070
|
arguments: z5.string().nullish()
|
|
1042
1071
|
})
|
|
1043
1072
|
})
|
|
1073
|
+
).nullish(),
|
|
1074
|
+
annotations: z5.array(
|
|
1075
|
+
z5.object({
|
|
1076
|
+
type: z5.literal("url_citation"),
|
|
1077
|
+
start_index: z5.number(),
|
|
1078
|
+
end_index: z5.number(),
|
|
1079
|
+
url: z5.string(),
|
|
1080
|
+
title: z5.string()
|
|
1081
|
+
})
|
|
1044
1082
|
).nullish()
|
|
1045
1083
|
}).nullish(),
|
|
1046
1084
|
logprobs: z5.object({
|
|
@@ -2451,6 +2489,11 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2451
2489
|
id: z14.string(),
|
|
2452
2490
|
status: z14.string().optional()
|
|
2453
2491
|
}),
|
|
2492
|
+
z14.object({
|
|
2493
|
+
type: z14.literal("file_search_call"),
|
|
2494
|
+
id: z14.string(),
|
|
2495
|
+
status: z14.string().optional()
|
|
2496
|
+
}),
|
|
2454
2497
|
z14.object({
|
|
2455
2498
|
type: z14.literal("reasoning"),
|
|
2456
2499
|
id: z14.string(),
|
|
@@ -2577,6 +2620,26 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2577
2620
|
});
|
|
2578
2621
|
break;
|
|
2579
2622
|
}
|
|
2623
|
+
case "file_search_call": {
|
|
2624
|
+
content.push({
|
|
2625
|
+
type: "tool-call",
|
|
2626
|
+
toolCallId: part.id,
|
|
2627
|
+
toolName: "file_search",
|
|
2628
|
+
input: "",
|
|
2629
|
+
providerExecuted: true
|
|
2630
|
+
});
|
|
2631
|
+
content.push({
|
|
2632
|
+
type: "tool-result",
|
|
2633
|
+
toolCallId: part.id,
|
|
2634
|
+
toolName: "file_search",
|
|
2635
|
+
result: {
|
|
2636
|
+
type: "file_search_tool_result",
|
|
2637
|
+
status: part.status || "completed"
|
|
2638
|
+
},
|
|
2639
|
+
providerExecuted: true
|
|
2640
|
+
});
|
|
2641
|
+
break;
|
|
2642
|
+
}
|
|
2580
2643
|
}
|
|
2581
2644
|
}
|
|
2582
2645
|
return {
|
|
@@ -2953,6 +3016,11 @@ var responseOutputItemAddedSchema = z14.object({
|
|
|
2953
3016
|
type: z14.literal("computer_call"),
|
|
2954
3017
|
id: z14.string(),
|
|
2955
3018
|
status: z14.string()
|
|
3019
|
+
}),
|
|
3020
|
+
z14.object({
|
|
3021
|
+
type: z14.literal("file_search_call"),
|
|
3022
|
+
id: z14.string(),
|
|
3023
|
+
status: z14.string()
|
|
2956
3024
|
})
|
|
2957
3025
|
])
|
|
2958
3026
|
});
|
|
@@ -2986,6 +3054,11 @@ var responseOutputItemDoneSchema = z14.object({
|
|
|
2986
3054
|
type: z14.literal("computer_call"),
|
|
2987
3055
|
id: z14.string(),
|
|
2988
3056
|
status: z14.literal("completed")
|
|
3057
|
+
}),
|
|
3058
|
+
z14.object({
|
|
3059
|
+
type: z14.literal("file_search_call"),
|
|
3060
|
+
id: z14.string(),
|
|
3061
|
+
status: z14.literal("completed")
|
|
2989
3062
|
})
|
|
2990
3063
|
])
|
|
2991
3064
|
});
|