@ai-sdk/openai 2.0.13 → 2.0.14
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 +69 -31
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +69 -31
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +69 -31
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +69 -31
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/internal/index.mjs
CHANGED
|
@@ -2661,7 +2661,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2661
2661
|
};
|
|
2662
2662
|
}
|
|
2663
2663
|
async doGenerate(options) {
|
|
2664
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
2664
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
2665
2665
|
const { args: body, warnings } = await this.getArgs(options);
|
|
2666
2666
|
const url = this.config.url({
|
|
2667
2667
|
path: "/responses",
|
|
@@ -2697,13 +2697,22 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2697
2697
|
text: z16.string(),
|
|
2698
2698
|
logprobs: LOGPROBS_SCHEMA.nullish(),
|
|
2699
2699
|
annotations: z16.array(
|
|
2700
|
-
z16.
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2700
|
+
z16.discriminatedUnion("type", [
|
|
2701
|
+
z16.object({
|
|
2702
|
+
type: z16.literal("url_citation"),
|
|
2703
|
+
start_index: z16.number(),
|
|
2704
|
+
end_index: z16.number(),
|
|
2705
|
+
url: z16.string(),
|
|
2706
|
+
title: z16.string()
|
|
2707
|
+
}),
|
|
2708
|
+
z16.object({
|
|
2709
|
+
type: z16.literal("file_citation"),
|
|
2710
|
+
start_index: z16.number(),
|
|
2711
|
+
end_index: z16.number(),
|
|
2712
|
+
file_id: z16.string(),
|
|
2713
|
+
quote: z16.string()
|
|
2714
|
+
})
|
|
2715
|
+
])
|
|
2707
2716
|
)
|
|
2708
2717
|
})
|
|
2709
2718
|
)
|
|
@@ -2809,13 +2818,24 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2809
2818
|
}
|
|
2810
2819
|
});
|
|
2811
2820
|
for (const annotation of contentPart.annotations) {
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2821
|
+
if (annotation.type === "url_citation") {
|
|
2822
|
+
content.push({
|
|
2823
|
+
type: "source",
|
|
2824
|
+
sourceType: "url",
|
|
2825
|
+
id: (_f = (_e = (_d = this.config).generateId) == null ? void 0 : _e.call(_d)) != null ? _f : generateId2(),
|
|
2826
|
+
url: annotation.url,
|
|
2827
|
+
title: annotation.title
|
|
2828
|
+
});
|
|
2829
|
+
} else if (annotation.type === "file_citation") {
|
|
2830
|
+
content.push({
|
|
2831
|
+
type: "source",
|
|
2832
|
+
sourceType: "document",
|
|
2833
|
+
id: (_i = (_h = (_g = this.config).generateId) == null ? void 0 : _h.call(_g)) != null ? _i : generateId2(),
|
|
2834
|
+
mediaType: "text/plain",
|
|
2835
|
+
title: annotation.quote,
|
|
2836
|
+
filename: annotation.file_id
|
|
2837
|
+
});
|
|
2838
|
+
}
|
|
2819
2839
|
}
|
|
2820
2840
|
}
|
|
2821
2841
|
break;
|
|
@@ -2904,15 +2924,15 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2904
2924
|
return {
|
|
2905
2925
|
content,
|
|
2906
2926
|
finishReason: mapOpenAIResponseFinishReason({
|
|
2907
|
-
finishReason: (
|
|
2927
|
+
finishReason: (_j = response.incomplete_details) == null ? void 0 : _j.reason,
|
|
2908
2928
|
hasToolCalls: content.some((part) => part.type === "tool-call")
|
|
2909
2929
|
}),
|
|
2910
2930
|
usage: {
|
|
2911
2931
|
inputTokens: response.usage.input_tokens,
|
|
2912
2932
|
outputTokens: response.usage.output_tokens,
|
|
2913
2933
|
totalTokens: response.usage.input_tokens + response.usage.output_tokens,
|
|
2914
|
-
reasoningTokens: (
|
|
2915
|
-
cachedInputTokens: (
|
|
2934
|
+
reasoningTokens: (_l = (_k = response.usage.output_tokens_details) == null ? void 0 : _k.reasoning_tokens) != null ? _l : void 0,
|
|
2935
|
+
cachedInputTokens: (_n = (_m = response.usage.input_tokens_details) == null ? void 0 : _m.cached_tokens) != null ? _n : void 0
|
|
2916
2936
|
},
|
|
2917
2937
|
request: { body },
|
|
2918
2938
|
response: {
|
|
@@ -2964,7 +2984,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2964
2984
|
controller.enqueue({ type: "stream-start", warnings });
|
|
2965
2985
|
},
|
|
2966
2986
|
transform(chunk, controller) {
|
|
2967
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
2987
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
2968
2988
|
if (options.includeRawChunks) {
|
|
2969
2989
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
2970
2990
|
}
|
|
@@ -3219,13 +3239,24 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3219
3239
|
usage.reasoningTokens = (_h = (_g = value.response.usage.output_tokens_details) == null ? void 0 : _g.reasoning_tokens) != null ? _h : void 0;
|
|
3220
3240
|
usage.cachedInputTokens = (_j = (_i = value.response.usage.input_tokens_details) == null ? void 0 : _i.cached_tokens) != null ? _j : void 0;
|
|
3221
3241
|
} else if (isResponseAnnotationAddedChunk(value)) {
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3242
|
+
if (value.annotation.type === "url_citation") {
|
|
3243
|
+
controller.enqueue({
|
|
3244
|
+
type: "source",
|
|
3245
|
+
sourceType: "url",
|
|
3246
|
+
id: (_m = (_l = (_k = self.config).generateId) == null ? void 0 : _l.call(_k)) != null ? _m : generateId2(),
|
|
3247
|
+
url: value.annotation.url,
|
|
3248
|
+
title: value.annotation.title
|
|
3249
|
+
});
|
|
3250
|
+
} else if (value.annotation.type === "file_citation") {
|
|
3251
|
+
controller.enqueue({
|
|
3252
|
+
type: "source",
|
|
3253
|
+
sourceType: "document",
|
|
3254
|
+
id: (_p = (_o = (_n = self.config).generateId) == null ? void 0 : _o.call(_n)) != null ? _p : generateId2(),
|
|
3255
|
+
mediaType: "text/plain",
|
|
3256
|
+
title: value.annotation.quote,
|
|
3257
|
+
filename: value.annotation.file_id
|
|
3258
|
+
});
|
|
3259
|
+
}
|
|
3229
3260
|
} else if (isErrorChunk(value)) {
|
|
3230
3261
|
controller.enqueue({ type: "error", error: value });
|
|
3231
3262
|
}
|
|
@@ -3392,11 +3423,18 @@ var responseFunctionCallArgumentsDeltaSchema = z16.object({
|
|
|
3392
3423
|
});
|
|
3393
3424
|
var responseAnnotationAddedSchema = z16.object({
|
|
3394
3425
|
type: z16.literal("response.output_text.annotation.added"),
|
|
3395
|
-
annotation: z16.
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
|
|
3426
|
+
annotation: z16.discriminatedUnion("type", [
|
|
3427
|
+
z16.object({
|
|
3428
|
+
type: z16.literal("url_citation"),
|
|
3429
|
+
url: z16.string(),
|
|
3430
|
+
title: z16.string()
|
|
3431
|
+
}),
|
|
3432
|
+
z16.object({
|
|
3433
|
+
type: z16.literal("file_citation"),
|
|
3434
|
+
file_id: z16.string(),
|
|
3435
|
+
quote: z16.string()
|
|
3436
|
+
})
|
|
3437
|
+
])
|
|
3400
3438
|
});
|
|
3401
3439
|
var responseReasoningSummaryPartAddedSchema = z16.object({
|
|
3402
3440
|
type: z16.literal("response.reasoning_summary_part.added"),
|