@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/index.mjs
CHANGED
|
@@ -2345,7 +2345,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2345
2345
|
};
|
|
2346
2346
|
}
|
|
2347
2347
|
async doGenerate(options) {
|
|
2348
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
2348
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
2349
2349
|
const { args: body, warnings } = await this.getArgs(options);
|
|
2350
2350
|
const url = this.config.url({
|
|
2351
2351
|
path: "/responses",
|
|
@@ -2381,13 +2381,22 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2381
2381
|
text: z13.string(),
|
|
2382
2382
|
logprobs: LOGPROBS_SCHEMA.nullish(),
|
|
2383
2383
|
annotations: z13.array(
|
|
2384
|
-
z13.
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2384
|
+
z13.discriminatedUnion("type", [
|
|
2385
|
+
z13.object({
|
|
2386
|
+
type: z13.literal("url_citation"),
|
|
2387
|
+
start_index: z13.number(),
|
|
2388
|
+
end_index: z13.number(),
|
|
2389
|
+
url: z13.string(),
|
|
2390
|
+
title: z13.string()
|
|
2391
|
+
}),
|
|
2392
|
+
z13.object({
|
|
2393
|
+
type: z13.literal("file_citation"),
|
|
2394
|
+
start_index: z13.number(),
|
|
2395
|
+
end_index: z13.number(),
|
|
2396
|
+
file_id: z13.string(),
|
|
2397
|
+
quote: z13.string()
|
|
2398
|
+
})
|
|
2399
|
+
])
|
|
2391
2400
|
)
|
|
2392
2401
|
})
|
|
2393
2402
|
)
|
|
@@ -2493,13 +2502,24 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2493
2502
|
}
|
|
2494
2503
|
});
|
|
2495
2504
|
for (const annotation of contentPart.annotations) {
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2505
|
+
if (annotation.type === "url_citation") {
|
|
2506
|
+
content.push({
|
|
2507
|
+
type: "source",
|
|
2508
|
+
sourceType: "url",
|
|
2509
|
+
id: (_f = (_e = (_d = this.config).generateId) == null ? void 0 : _e.call(_d)) != null ? _f : generateId2(),
|
|
2510
|
+
url: annotation.url,
|
|
2511
|
+
title: annotation.title
|
|
2512
|
+
});
|
|
2513
|
+
} else if (annotation.type === "file_citation") {
|
|
2514
|
+
content.push({
|
|
2515
|
+
type: "source",
|
|
2516
|
+
sourceType: "document",
|
|
2517
|
+
id: (_i = (_h = (_g = this.config).generateId) == null ? void 0 : _h.call(_g)) != null ? _i : generateId2(),
|
|
2518
|
+
mediaType: "text/plain",
|
|
2519
|
+
title: annotation.quote,
|
|
2520
|
+
filename: annotation.file_id
|
|
2521
|
+
});
|
|
2522
|
+
}
|
|
2503
2523
|
}
|
|
2504
2524
|
}
|
|
2505
2525
|
break;
|
|
@@ -2588,15 +2608,15 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2588
2608
|
return {
|
|
2589
2609
|
content,
|
|
2590
2610
|
finishReason: mapOpenAIResponseFinishReason({
|
|
2591
|
-
finishReason: (
|
|
2611
|
+
finishReason: (_j = response.incomplete_details) == null ? void 0 : _j.reason,
|
|
2592
2612
|
hasToolCalls: content.some((part) => part.type === "tool-call")
|
|
2593
2613
|
}),
|
|
2594
2614
|
usage: {
|
|
2595
2615
|
inputTokens: response.usage.input_tokens,
|
|
2596
2616
|
outputTokens: response.usage.output_tokens,
|
|
2597
2617
|
totalTokens: response.usage.input_tokens + response.usage.output_tokens,
|
|
2598
|
-
reasoningTokens: (
|
|
2599
|
-
cachedInputTokens: (
|
|
2618
|
+
reasoningTokens: (_l = (_k = response.usage.output_tokens_details) == null ? void 0 : _k.reasoning_tokens) != null ? _l : void 0,
|
|
2619
|
+
cachedInputTokens: (_n = (_m = response.usage.input_tokens_details) == null ? void 0 : _m.cached_tokens) != null ? _n : void 0
|
|
2600
2620
|
},
|
|
2601
2621
|
request: { body },
|
|
2602
2622
|
response: {
|
|
@@ -2648,7 +2668,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2648
2668
|
controller.enqueue({ type: "stream-start", warnings });
|
|
2649
2669
|
},
|
|
2650
2670
|
transform(chunk, controller) {
|
|
2651
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
2671
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
2652
2672
|
if (options.includeRawChunks) {
|
|
2653
2673
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
2654
2674
|
}
|
|
@@ -2903,13 +2923,24 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2903
2923
|
usage.reasoningTokens = (_h = (_g = value.response.usage.output_tokens_details) == null ? void 0 : _g.reasoning_tokens) != null ? _h : void 0;
|
|
2904
2924
|
usage.cachedInputTokens = (_j = (_i = value.response.usage.input_tokens_details) == null ? void 0 : _i.cached_tokens) != null ? _j : void 0;
|
|
2905
2925
|
} else if (isResponseAnnotationAddedChunk(value)) {
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2926
|
+
if (value.annotation.type === "url_citation") {
|
|
2927
|
+
controller.enqueue({
|
|
2928
|
+
type: "source",
|
|
2929
|
+
sourceType: "url",
|
|
2930
|
+
id: (_m = (_l = (_k = self.config).generateId) == null ? void 0 : _l.call(_k)) != null ? _m : generateId2(),
|
|
2931
|
+
url: value.annotation.url,
|
|
2932
|
+
title: value.annotation.title
|
|
2933
|
+
});
|
|
2934
|
+
} else if (value.annotation.type === "file_citation") {
|
|
2935
|
+
controller.enqueue({
|
|
2936
|
+
type: "source",
|
|
2937
|
+
sourceType: "document",
|
|
2938
|
+
id: (_p = (_o = (_n = self.config).generateId) == null ? void 0 : _o.call(_n)) != null ? _p : generateId2(),
|
|
2939
|
+
mediaType: "text/plain",
|
|
2940
|
+
title: value.annotation.quote,
|
|
2941
|
+
filename: value.annotation.file_id
|
|
2942
|
+
});
|
|
2943
|
+
}
|
|
2913
2944
|
} else if (isErrorChunk(value)) {
|
|
2914
2945
|
controller.enqueue({ type: "error", error: value });
|
|
2915
2946
|
}
|
|
@@ -3076,11 +3107,18 @@ var responseFunctionCallArgumentsDeltaSchema = z13.object({
|
|
|
3076
3107
|
});
|
|
3077
3108
|
var responseAnnotationAddedSchema = z13.object({
|
|
3078
3109
|
type: z13.literal("response.output_text.annotation.added"),
|
|
3079
|
-
annotation: z13.
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3110
|
+
annotation: z13.discriminatedUnion("type", [
|
|
3111
|
+
z13.object({
|
|
3112
|
+
type: z13.literal("url_citation"),
|
|
3113
|
+
url: z13.string(),
|
|
3114
|
+
title: z13.string()
|
|
3115
|
+
}),
|
|
3116
|
+
z13.object({
|
|
3117
|
+
type: z13.literal("file_citation"),
|
|
3118
|
+
file_id: z13.string(),
|
|
3119
|
+
quote: z13.string()
|
|
3120
|
+
})
|
|
3121
|
+
])
|
|
3084
3122
|
});
|
|
3085
3123
|
var responseReasoningSummaryPartAddedSchema = z13.object({
|
|
3086
3124
|
type: z13.literal("response.reasoning_summary_part.added"),
|