@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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @ai-sdk/openai
|
|
2
2
|
|
|
3
|
+
## 2.0.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 63e2016: fix(openai): missing url citations from web search tools
|
|
8
|
+
|
|
9
|
+
## 2.0.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- bc45e29: feat(openai): add file_search_call support to responses api
|
|
14
|
+
|
|
3
15
|
## 2.0.0
|
|
4
16
|
|
|
5
17
|
### Major Changes
|
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({
|
|
@@ -2422,6 +2460,11 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2422
2460
|
id: import_v414.z.string(),
|
|
2423
2461
|
status: import_v414.z.string().optional()
|
|
2424
2462
|
}),
|
|
2463
|
+
import_v414.z.object({
|
|
2464
|
+
type: import_v414.z.literal("file_search_call"),
|
|
2465
|
+
id: import_v414.z.string(),
|
|
2466
|
+
status: import_v414.z.string().optional()
|
|
2467
|
+
}),
|
|
2425
2468
|
import_v414.z.object({
|
|
2426
2469
|
type: import_v414.z.literal("reasoning"),
|
|
2427
2470
|
id: import_v414.z.string(),
|
|
@@ -2548,6 +2591,26 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2548
2591
|
});
|
|
2549
2592
|
break;
|
|
2550
2593
|
}
|
|
2594
|
+
case "file_search_call": {
|
|
2595
|
+
content.push({
|
|
2596
|
+
type: "tool-call",
|
|
2597
|
+
toolCallId: part.id,
|
|
2598
|
+
toolName: "file_search",
|
|
2599
|
+
input: "",
|
|
2600
|
+
providerExecuted: true
|
|
2601
|
+
});
|
|
2602
|
+
content.push({
|
|
2603
|
+
type: "tool-result",
|
|
2604
|
+
toolCallId: part.id,
|
|
2605
|
+
toolName: "file_search",
|
|
2606
|
+
result: {
|
|
2607
|
+
type: "file_search_tool_result",
|
|
2608
|
+
status: part.status || "completed"
|
|
2609
|
+
},
|
|
2610
|
+
providerExecuted: true
|
|
2611
|
+
});
|
|
2612
|
+
break;
|
|
2613
|
+
}
|
|
2551
2614
|
}
|
|
2552
2615
|
}
|
|
2553
2616
|
return {
|
|
@@ -2924,6 +2987,11 @@ var responseOutputItemAddedSchema = import_v414.z.object({
|
|
|
2924
2987
|
type: import_v414.z.literal("computer_call"),
|
|
2925
2988
|
id: import_v414.z.string(),
|
|
2926
2989
|
status: import_v414.z.string()
|
|
2990
|
+
}),
|
|
2991
|
+
import_v414.z.object({
|
|
2992
|
+
type: import_v414.z.literal("file_search_call"),
|
|
2993
|
+
id: import_v414.z.string(),
|
|
2994
|
+
status: import_v414.z.string()
|
|
2927
2995
|
})
|
|
2928
2996
|
])
|
|
2929
2997
|
});
|
|
@@ -2957,6 +3025,11 @@ var responseOutputItemDoneSchema = import_v414.z.object({
|
|
|
2957
3025
|
type: import_v414.z.literal("computer_call"),
|
|
2958
3026
|
id: import_v414.z.string(),
|
|
2959
3027
|
status: import_v414.z.literal("completed")
|
|
3028
|
+
}),
|
|
3029
|
+
import_v414.z.object({
|
|
3030
|
+
type: import_v414.z.literal("file_search_call"),
|
|
3031
|
+
id: import_v414.z.string(),
|
|
3032
|
+
status: import_v414.z.literal("completed")
|
|
2960
3033
|
})
|
|
2961
3034
|
])
|
|
2962
3035
|
});
|