@ai-sdk/openai 2.0.20 → 2.0.22
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 +21 -0
- package/dist/index.js +27 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +27 -17
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +27 -17
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +27 -17
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/internal/index.mjs
CHANGED
|
@@ -424,7 +424,7 @@ var webSearchPreview = createProviderDefinedToolFactory2({
|
|
|
424
424
|
action: z4.discriminatedUnion("type", [
|
|
425
425
|
z4.object({
|
|
426
426
|
type: z4.literal("search"),
|
|
427
|
-
query: z4.string()
|
|
427
|
+
query: z4.string().nullish()
|
|
428
428
|
}),
|
|
429
429
|
z4.object({
|
|
430
430
|
type: z4.literal("open_page"),
|
|
@@ -1938,8 +1938,12 @@ var OpenAITranscriptionModel = class {
|
|
|
1938
1938
|
include: openAIOptions.include,
|
|
1939
1939
|
language: openAIOptions.language,
|
|
1940
1940
|
prompt: openAIOptions.prompt,
|
|
1941
|
-
response_format
|
|
1942
|
-
//
|
|
1941
|
+
// https://platform.openai.com/docs/api-reference/audio/createTranscription#audio_createtranscription-response_format
|
|
1942
|
+
// prefer verbose_json to get segments for models that support it
|
|
1943
|
+
response_format: [
|
|
1944
|
+
"gpt-4o-transcribe",
|
|
1945
|
+
"gpt-4o-mini-transcribe"
|
|
1946
|
+
].includes(this.modelId) ? "json" : "verbose_json",
|
|
1943
1947
|
temperature: openAIOptions.temperature,
|
|
1944
1948
|
timestamp_granularities: openAIOptions.timestampGranularities
|
|
1945
1949
|
};
|
|
@@ -2490,7 +2494,7 @@ var webSearchCallItem = z16.object({
|
|
|
2490
2494
|
action: z16.discriminatedUnion("type", [
|
|
2491
2495
|
z16.object({
|
|
2492
2496
|
type: z16.literal("search"),
|
|
2493
|
-
query: z16.string()
|
|
2497
|
+
query: z16.string().nullish()
|
|
2494
2498
|
}),
|
|
2495
2499
|
z16.object({
|
|
2496
2500
|
type: z16.literal("open_page"),
|
|
@@ -2699,7 +2703,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2699
2703
|
};
|
|
2700
2704
|
}
|
|
2701
2705
|
async doGenerate(options) {
|
|
2702
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
2706
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
|
2703
2707
|
const { args: body, warnings } = await this.getArgs(options);
|
|
2704
2708
|
const url = this.config.url({
|
|
2705
2709
|
path: "/responses",
|
|
@@ -2745,10 +2749,12 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2745
2749
|
}),
|
|
2746
2750
|
z16.object({
|
|
2747
2751
|
type: z16.literal("file_citation"),
|
|
2748
|
-
start_index: z16.number(),
|
|
2749
|
-
end_index: z16.number(),
|
|
2750
2752
|
file_id: z16.string(),
|
|
2751
|
-
|
|
2753
|
+
filename: z16.string().nullish(),
|
|
2754
|
+
index: z16.number().nullish(),
|
|
2755
|
+
start_index: z16.number().nullish(),
|
|
2756
|
+
end_index: z16.number().nullish(),
|
|
2757
|
+
quote: z16.string().nullish()
|
|
2752
2758
|
})
|
|
2753
2759
|
])
|
|
2754
2760
|
)
|
|
@@ -2866,8 +2872,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2866
2872
|
sourceType: "document",
|
|
2867
2873
|
id: (_i = (_h = (_g = this.config).generateId) == null ? void 0 : _h.call(_g)) != null ? _i : generateId2(),
|
|
2868
2874
|
mediaType: "text/plain",
|
|
2869
|
-
title: annotation.quote,
|
|
2870
|
-
filename: annotation.file_id
|
|
2875
|
+
title: (_k = (_j = annotation.quote) != null ? _j : annotation.filename) != null ? _k : "Document",
|
|
2876
|
+
filename: (_l = annotation.filename) != null ? _l : annotation.file_id
|
|
2871
2877
|
});
|
|
2872
2878
|
}
|
|
2873
2879
|
}
|
|
@@ -2958,15 +2964,15 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
2958
2964
|
return {
|
|
2959
2965
|
content,
|
|
2960
2966
|
finishReason: mapOpenAIResponseFinishReason({
|
|
2961
|
-
finishReason: (
|
|
2967
|
+
finishReason: (_m = response.incomplete_details) == null ? void 0 : _m.reason,
|
|
2962
2968
|
hasToolCalls: content.some((part) => part.type === "tool-call")
|
|
2963
2969
|
}),
|
|
2964
2970
|
usage: {
|
|
2965
2971
|
inputTokens: response.usage.input_tokens,
|
|
2966
2972
|
outputTokens: response.usage.output_tokens,
|
|
2967
2973
|
totalTokens: response.usage.input_tokens + response.usage.output_tokens,
|
|
2968
|
-
reasoningTokens: (
|
|
2969
|
-
cachedInputTokens: (
|
|
2974
|
+
reasoningTokens: (_o = (_n = response.usage.output_tokens_details) == null ? void 0 : _n.reasoning_tokens) != null ? _o : void 0,
|
|
2975
|
+
cachedInputTokens: (_q = (_p = response.usage.input_tokens_details) == null ? void 0 : _p.cached_tokens) != null ? _q : void 0
|
|
2970
2976
|
},
|
|
2971
2977
|
request: { body },
|
|
2972
2978
|
response: {
|
|
@@ -3018,7 +3024,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3018
3024
|
controller.enqueue({ type: "stream-start", warnings });
|
|
3019
3025
|
},
|
|
3020
3026
|
transform(chunk, controller) {
|
|
3021
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
3027
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
|
|
3022
3028
|
if (options.includeRawChunks) {
|
|
3023
3029
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
3024
3030
|
}
|
|
@@ -3284,8 +3290,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
3284
3290
|
sourceType: "document",
|
|
3285
3291
|
id: (_r = (_q = (_p = self.config).generateId) == null ? void 0 : _q.call(_p)) != null ? _r : generateId2(),
|
|
3286
3292
|
mediaType: "text/plain",
|
|
3287
|
-
title: value.annotation.quote,
|
|
3288
|
-
filename: value.annotation.file_id
|
|
3293
|
+
title: (_t = (_s = value.annotation.quote) != null ? _s : value.annotation.filename) != null ? _t : "Document",
|
|
3294
|
+
filename: (_u = value.annotation.filename) != null ? _u : value.annotation.file_id
|
|
3289
3295
|
});
|
|
3290
3296
|
}
|
|
3291
3297
|
} else if (isErrorChunk(value)) {
|
|
@@ -3463,7 +3469,11 @@ var responseAnnotationAddedSchema = z16.object({
|
|
|
3463
3469
|
z16.object({
|
|
3464
3470
|
type: z16.literal("file_citation"),
|
|
3465
3471
|
file_id: z16.string(),
|
|
3466
|
-
|
|
3472
|
+
filename: z16.string().nullish(),
|
|
3473
|
+
index: z16.number().nullish(),
|
|
3474
|
+
start_index: z16.number().nullish(),
|
|
3475
|
+
end_index: z16.number().nullish(),
|
|
3476
|
+
quote: z16.string().nullish()
|
|
3467
3477
|
})
|
|
3468
3478
|
])
|
|
3469
3479
|
});
|