@ai-sdk/openai 2.0.139 → 2.0.140
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 +11 -0
- package/dist/index.js +42 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +49 -9
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +2 -0
- package/dist/internal/index.d.ts +2 -0
- package/dist/internal/index.js +41 -7
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +48 -8
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +2 -2
|
@@ -168,6 +168,8 @@ type OpenAITranscriptionModelId = 'whisper-1' | 'gpt-4o-mini-transcribe' | 'gpt-
|
|
|
168
168
|
declare const openAITranscriptionProviderOptions: _ai_sdk_provider_utils.LazyValidator<{
|
|
169
169
|
include?: string[] | undefined;
|
|
170
170
|
language?: string | undefined;
|
|
171
|
+
languages?: string[] | undefined;
|
|
172
|
+
keywords?: string[] | undefined;
|
|
171
173
|
prompt?: string | undefined;
|
|
172
174
|
temperature?: number | undefined;
|
|
173
175
|
timestampGranularities?: ("word" | "segment")[] | undefined;
|
package/dist/internal/index.d.ts
CHANGED
|
@@ -168,6 +168,8 @@ type OpenAITranscriptionModelId = 'whisper-1' | 'gpt-4o-mini-transcribe' | 'gpt-
|
|
|
168
168
|
declare const openAITranscriptionProviderOptions: _ai_sdk_provider_utils.LazyValidator<{
|
|
169
169
|
include?: string[] | undefined;
|
|
170
170
|
language?: string | undefined;
|
|
171
|
+
languages?: string[] | undefined;
|
|
172
|
+
keywords?: string[] | undefined;
|
|
171
173
|
prompt?: string | undefined;
|
|
172
174
|
temperature?: number | undefined;
|
|
173
175
|
timestampGranularities?: ("word" | "segment")[] | undefined;
|
package/dist/internal/index.js
CHANGED
|
@@ -129,7 +129,18 @@ function getGptVersion(modelId) {
|
|
|
129
129
|
var import_provider = require("@ai-sdk/provider");
|
|
130
130
|
var import_provider_utils2 = require("@ai-sdk/provider-utils");
|
|
131
131
|
function serializeToolCallArguments(input) {
|
|
132
|
-
|
|
132
|
+
if (typeof input === "string") {
|
|
133
|
+
try {
|
|
134
|
+
const parsed = (0, import_provider_utils2.secureJsonParse)(input);
|
|
135
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
136
|
+
return "{}";
|
|
137
|
+
}
|
|
138
|
+
return input;
|
|
139
|
+
} catch (e) {
|
|
140
|
+
return "{}";
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return (0, import_provider_utils2.stringifyWithBigIntAndCycles)(
|
|
133
144
|
typeof input === "object" && input !== null && !Array.isArray(input) ? input : {}
|
|
134
145
|
);
|
|
135
146
|
}
|
|
@@ -352,7 +363,7 @@ function convertToOpenAIChatMessages({
|
|
|
352
363
|
case "content":
|
|
353
364
|
case "json":
|
|
354
365
|
case "error-json":
|
|
355
|
-
contentValue =
|
|
366
|
+
contentValue = (0, import_provider_utils2.stringifyWithBigIntAndCycles)(output.value);
|
|
356
367
|
break;
|
|
357
368
|
}
|
|
358
369
|
messages.push({
|
|
@@ -2024,6 +2035,16 @@ var openAITranscriptionProviderOptions = (0, import_provider_utils16.lazyValidat
|
|
|
2024
2035
|
* The language of the input audio in ISO-639-1 format.
|
|
2025
2036
|
*/
|
|
2026
2037
|
language: import_v411.z.string().optional(),
|
|
2038
|
+
/**
|
|
2039
|
+
* Expected languages for REST transcription, e.g. with gpt-transcribe.
|
|
2040
|
+
* Use this instead of language. The API validates model support.
|
|
2041
|
+
*/
|
|
2042
|
+
languages: import_v411.z.array(import_v411.z.string()).optional(),
|
|
2043
|
+
/**
|
|
2044
|
+
* Vocabulary hints for REST transcription, e.g. names or technical terms.
|
|
2045
|
+
* The API validates model support.
|
|
2046
|
+
*/
|
|
2047
|
+
keywords: import_v411.z.array(import_v411.z.string()).optional(),
|
|
2027
2048
|
/**
|
|
2028
2049
|
* An optional text to guide the model's style or continue a previous audio segment.
|
|
2029
2050
|
*/
|
|
@@ -2135,6 +2156,8 @@ var OpenAITranscriptionModel = class {
|
|
|
2135
2156
|
const transcriptionModelOptions = {
|
|
2136
2157
|
include: openAIOptions.include,
|
|
2137
2158
|
language: openAIOptions.language,
|
|
2159
|
+
languages: openAIOptions.languages,
|
|
2160
|
+
keywords: openAIOptions.keywords,
|
|
2138
2161
|
prompt: openAIOptions.prompt,
|
|
2139
2162
|
// https://platform.openai.com/docs/api-reference/audio/createTranscription#audio_createtranscription-response_format
|
|
2140
2163
|
// prefer verbose_json to get segments for models that support it
|
|
@@ -2898,7 +2921,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2898
2921
|
type: "function_call",
|
|
2899
2922
|
call_id: part.toolCallId,
|
|
2900
2923
|
name: part.toolName,
|
|
2901
|
-
arguments:
|
|
2924
|
+
arguments: serializeToolCallArguments2(part.input),
|
|
2902
2925
|
...isAsync != null && { async: isAsync },
|
|
2903
2926
|
id: canUseItemId ? id : void 0
|
|
2904
2927
|
});
|
|
@@ -2960,7 +2983,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2960
2983
|
} else if (reasoningMessage !== void 0) {
|
|
2961
2984
|
warnings.push({
|
|
2962
2985
|
type: "other",
|
|
2963
|
-
message: `Cannot append empty reasoning part to existing reasoning sequence. Skipping reasoning part: ${
|
|
2986
|
+
message: `Cannot append empty reasoning part to existing reasoning sequence. Skipping reasoning part: ${(0, import_provider_utils23.stringifyWithBigIntAndCycles)(part)}.`
|
|
2964
2987
|
});
|
|
2965
2988
|
}
|
|
2966
2989
|
if (reasoningMessage === void 0) {
|
|
@@ -2981,7 +3004,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2981
3004
|
} else {
|
|
2982
3005
|
warnings.push({
|
|
2983
3006
|
type: "other",
|
|
2984
|
-
message: `Non-OpenAI reasoning parts are not supported. Skipping reasoning part: ${
|
|
3007
|
+
message: `Non-OpenAI reasoning parts are not supported. Skipping reasoning part: ${(0, import_provider_utils23.stringifyWithBigIntAndCycles)(part)}.`
|
|
2985
3008
|
});
|
|
2986
3009
|
}
|
|
2987
3010
|
break;
|
|
@@ -3022,10 +3045,10 @@ async function convertToOpenAIResponsesInput({
|
|
|
3022
3045
|
break;
|
|
3023
3046
|
case "json":
|
|
3024
3047
|
case "error-json":
|
|
3025
|
-
contentValue = promptCacheBreakpoint == null ?
|
|
3048
|
+
contentValue = promptCacheBreakpoint == null ? (0, import_provider_utils23.stringifyWithBigIntAndCycles)(output.value) : [
|
|
3026
3049
|
{
|
|
3027
3050
|
type: "input_text",
|
|
3028
|
-
text:
|
|
3051
|
+
text: (0, import_provider_utils23.stringifyWithBigIntAndCycles)(output.value),
|
|
3029
3052
|
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3030
3053
|
}
|
|
3031
3054
|
];
|
|
@@ -3098,6 +3121,17 @@ var openaiResponsesReasoningProviderOptionsSchema = (0, import_provider_utils23.
|
|
|
3098
3121
|
})
|
|
3099
3122
|
)
|
|
3100
3123
|
);
|
|
3124
|
+
function serializeToolCallArguments2(input) {
|
|
3125
|
+
if (typeof input === "string") {
|
|
3126
|
+
try {
|
|
3127
|
+
(0, import_provider_utils23.secureJsonParse)(input);
|
|
3128
|
+
return input;
|
|
3129
|
+
} catch (e) {
|
|
3130
|
+
return (0, import_provider_utils23.stringifyWithBigIntAndCycles)(input);
|
|
3131
|
+
}
|
|
3132
|
+
}
|
|
3133
|
+
return (0, import_provider_utils23.stringifyWithBigIntAndCycles)(input === void 0 ? {} : input);
|
|
3134
|
+
}
|
|
3101
3135
|
|
|
3102
3136
|
// src/responses/map-openai-responses-finish-reason.ts
|
|
3103
3137
|
function mapOpenAIResponseFinishReason({
|