@ai-sdk/openai 2.0.138 → 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 +18 -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 +4 -4
package/dist/internal/index.mjs
CHANGED
|
@@ -83,9 +83,24 @@ function getGptVersion(modelId) {
|
|
|
83
83
|
import {
|
|
84
84
|
UnsupportedFunctionalityError
|
|
85
85
|
} from "@ai-sdk/provider";
|
|
86
|
-
import {
|
|
86
|
+
import {
|
|
87
|
+
stringifyWithBigIntAndCycles,
|
|
88
|
+
secureJsonParse,
|
|
89
|
+
convertToBase64
|
|
90
|
+
} from "@ai-sdk/provider-utils";
|
|
87
91
|
function serializeToolCallArguments(input) {
|
|
88
|
-
|
|
92
|
+
if (typeof input === "string") {
|
|
93
|
+
try {
|
|
94
|
+
const parsed = secureJsonParse(input);
|
|
95
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
96
|
+
return "{}";
|
|
97
|
+
}
|
|
98
|
+
return input;
|
|
99
|
+
} catch (e) {
|
|
100
|
+
return "{}";
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return stringifyWithBigIntAndCycles(
|
|
89
104
|
typeof input === "object" && input !== null && !Array.isArray(input) ? input : {}
|
|
90
105
|
);
|
|
91
106
|
}
|
|
@@ -308,7 +323,7 @@ function convertToOpenAIChatMessages({
|
|
|
308
323
|
case "content":
|
|
309
324
|
case "json":
|
|
310
325
|
case "error-json":
|
|
311
|
-
contentValue =
|
|
326
|
+
contentValue = stringifyWithBigIntAndCycles(output.value);
|
|
312
327
|
break;
|
|
313
328
|
}
|
|
314
329
|
messages.push({
|
|
@@ -2032,6 +2047,16 @@ var openAITranscriptionProviderOptions = lazyValidator10(
|
|
|
2032
2047
|
* The language of the input audio in ISO-639-1 format.
|
|
2033
2048
|
*/
|
|
2034
2049
|
language: z11.string().optional(),
|
|
2050
|
+
/**
|
|
2051
|
+
* Expected languages for REST transcription, e.g. with gpt-transcribe.
|
|
2052
|
+
* Use this instead of language. The API validates model support.
|
|
2053
|
+
*/
|
|
2054
|
+
languages: z11.array(z11.string()).optional(),
|
|
2055
|
+
/**
|
|
2056
|
+
* Vocabulary hints for REST transcription, e.g. names or technical terms.
|
|
2057
|
+
* The API validates model support.
|
|
2058
|
+
*/
|
|
2059
|
+
keywords: z11.array(z11.string()).optional(),
|
|
2035
2060
|
/**
|
|
2036
2061
|
* An optional text to guide the model's style or continue a previous audio segment.
|
|
2037
2062
|
*/
|
|
@@ -2143,6 +2168,8 @@ var OpenAITranscriptionModel = class {
|
|
|
2143
2168
|
const transcriptionModelOptions = {
|
|
2144
2169
|
include: openAIOptions.include,
|
|
2145
2170
|
language: openAIOptions.language,
|
|
2171
|
+
languages: openAIOptions.languages,
|
|
2172
|
+
keywords: openAIOptions.keywords,
|
|
2146
2173
|
prompt: openAIOptions.prompt,
|
|
2147
2174
|
// https://platform.openai.com/docs/api-reference/audio/createTranscription#audio_createtranscription-response_format
|
|
2148
2175
|
// prefer verbose_json to get segments for models that support it
|
|
@@ -2361,6 +2388,8 @@ import {
|
|
|
2361
2388
|
UnsupportedFunctionalityError as UnsupportedFunctionalityError4
|
|
2362
2389
|
} from "@ai-sdk/provider";
|
|
2363
2390
|
import {
|
|
2391
|
+
stringifyWithBigIntAndCycles as stringifyWithBigIntAndCycles2,
|
|
2392
|
+
secureJsonParse as secureJsonParse2,
|
|
2364
2393
|
lazySchema as lazySchema4,
|
|
2365
2394
|
zodSchema as zodSchema16,
|
|
2366
2395
|
convertToBase64 as convertToBase642,
|
|
@@ -2944,7 +2973,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
2944
2973
|
type: "function_call",
|
|
2945
2974
|
call_id: part.toolCallId,
|
|
2946
2975
|
name: part.toolName,
|
|
2947
|
-
arguments:
|
|
2976
|
+
arguments: serializeToolCallArguments2(part.input),
|
|
2948
2977
|
...isAsync != null && { async: isAsync },
|
|
2949
2978
|
id: canUseItemId ? id : void 0
|
|
2950
2979
|
});
|
|
@@ -3006,7 +3035,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3006
3035
|
} else if (reasoningMessage !== void 0) {
|
|
3007
3036
|
warnings.push({
|
|
3008
3037
|
type: "other",
|
|
3009
|
-
message: `Cannot append empty reasoning part to existing reasoning sequence. Skipping reasoning part: ${
|
|
3038
|
+
message: `Cannot append empty reasoning part to existing reasoning sequence. Skipping reasoning part: ${stringifyWithBigIntAndCycles2(part)}.`
|
|
3010
3039
|
});
|
|
3011
3040
|
}
|
|
3012
3041
|
if (reasoningMessage === void 0) {
|
|
@@ -3027,7 +3056,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
3027
3056
|
} else {
|
|
3028
3057
|
warnings.push({
|
|
3029
3058
|
type: "other",
|
|
3030
|
-
message: `Non-OpenAI reasoning parts are not supported. Skipping reasoning part: ${
|
|
3059
|
+
message: `Non-OpenAI reasoning parts are not supported. Skipping reasoning part: ${stringifyWithBigIntAndCycles2(part)}.`
|
|
3031
3060
|
});
|
|
3032
3061
|
}
|
|
3033
3062
|
break;
|
|
@@ -3068,10 +3097,10 @@ async function convertToOpenAIResponsesInput({
|
|
|
3068
3097
|
break;
|
|
3069
3098
|
case "json":
|
|
3070
3099
|
case "error-json":
|
|
3071
|
-
contentValue = promptCacheBreakpoint == null ?
|
|
3100
|
+
contentValue = promptCacheBreakpoint == null ? stringifyWithBigIntAndCycles2(output.value) : [
|
|
3072
3101
|
{
|
|
3073
3102
|
type: "input_text",
|
|
3074
|
-
text:
|
|
3103
|
+
text: stringifyWithBigIntAndCycles2(output.value),
|
|
3075
3104
|
prompt_cache_breakpoint: promptCacheBreakpoint
|
|
3076
3105
|
}
|
|
3077
3106
|
];
|
|
@@ -3144,6 +3173,17 @@ var openaiResponsesReasoningProviderOptionsSchema = lazySchema4(
|
|
|
3144
3173
|
})
|
|
3145
3174
|
)
|
|
3146
3175
|
);
|
|
3176
|
+
function serializeToolCallArguments2(input) {
|
|
3177
|
+
if (typeof input === "string") {
|
|
3178
|
+
try {
|
|
3179
|
+
secureJsonParse2(input);
|
|
3180
|
+
return input;
|
|
3181
|
+
} catch (e) {
|
|
3182
|
+
return stringifyWithBigIntAndCycles2(input);
|
|
3183
|
+
}
|
|
3184
|
+
}
|
|
3185
|
+
return stringifyWithBigIntAndCycles2(input === void 0 ? {} : input);
|
|
3186
|
+
}
|
|
3147
3187
|
|
|
3148
3188
|
// src/responses/map-openai-responses-finish-reason.ts
|
|
3149
3189
|
function mapOpenAIResponseFinishReason({
|