@ai-sdk/openai-compatible 2.0.88 → 2.0.90
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 +16 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +21 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -5
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +13 -2
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +15 -2
- package/dist/internal/index.mjs.map +1 -1
- package/docs/index.mdx +3 -1
- package/package.json +2 -2
- package/src/chat/convert-to-openai-compatible-chat-messages.ts +16 -2
- package/src/chat/openai-compatible-chat-language-model.ts +5 -1
- package/src/chat/openai-compatible-chat-options.ts +4 -1
package/dist/index.mjs
CHANGED
|
@@ -90,6 +90,8 @@ import {
|
|
|
90
90
|
UnsupportedFunctionalityError
|
|
91
91
|
} from "@ai-sdk/provider";
|
|
92
92
|
import {
|
|
93
|
+
secureJsonParse,
|
|
94
|
+
stringifyWithBigIntAndCycles,
|
|
93
95
|
convertBase64ToUint8Array,
|
|
94
96
|
convertToBase64
|
|
95
97
|
} from "@ai-sdk/provider-utils";
|
|
@@ -108,6 +110,17 @@ function getAudioFormat(mediaType) {
|
|
|
108
110
|
return null;
|
|
109
111
|
}
|
|
110
112
|
}
|
|
113
|
+
function serializeToolCallArguments(input) {
|
|
114
|
+
if (typeof input === "string") {
|
|
115
|
+
try {
|
|
116
|
+
secureJsonParse(input);
|
|
117
|
+
return input;
|
|
118
|
+
} catch (e) {
|
|
119
|
+
return JSON.stringify(input);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return stringifyWithBigIntAndCycles(input);
|
|
123
|
+
}
|
|
111
124
|
function convertToOpenAICompatibleChatMessages(prompt) {
|
|
112
125
|
var _a, _b, _c;
|
|
113
126
|
const messages = [];
|
|
@@ -225,7 +238,7 @@ function convertToOpenAICompatibleChatMessages(prompt) {
|
|
|
225
238
|
type: "function",
|
|
226
239
|
function: {
|
|
227
240
|
name: part.toolName,
|
|
228
|
-
arguments:
|
|
241
|
+
arguments: serializeToolCallArguments(part.input)
|
|
229
242
|
},
|
|
230
243
|
...partMetadata,
|
|
231
244
|
// Include extra_content for Google Gemini thought signatures
|
|
@@ -268,7 +281,7 @@ function convertToOpenAICompatibleChatMessages(prompt) {
|
|
|
268
281
|
case "content":
|
|
269
282
|
case "json":
|
|
270
283
|
case "error-json":
|
|
271
|
-
contentValue =
|
|
284
|
+
contentValue = stringifyWithBigIntAndCycles(output.value);
|
|
272
285
|
break;
|
|
273
286
|
}
|
|
274
287
|
const toolResponseMetadata = getOpenAIMetadata(toolResponse);
|
|
@@ -330,8 +343,11 @@ var openaiCompatibleLanguageModelChatOptions = z2.object({
|
|
|
330
343
|
user: z2.string().optional(),
|
|
331
344
|
/**
|
|
332
345
|
* Reasoning effort for reasoning models. Defaults to `medium`.
|
|
346
|
+
*
|
|
347
|
+
* Set to `null` to send `"reasoning_effort": null`, for providers that treat
|
|
348
|
+
* an explicit `null` differently from an omitted field.
|
|
333
349
|
*/
|
|
334
|
-
reasoningEffort: z2.string().
|
|
350
|
+
reasoningEffort: z2.string().nullish(),
|
|
335
351
|
/**
|
|
336
352
|
* Controls the verbosity of the generated text. Defaults to `medium`.
|
|
337
353
|
*/
|
|
@@ -541,7 +557,9 @@ var OpenAICompatibleChatLanguageModel = class {
|
|
|
541
557
|
).includes(key)
|
|
542
558
|
)
|
|
543
559
|
),
|
|
544
|
-
reasoning_effort
|
|
560
|
+
// Preserve explicit null and avoid overwriting a raw reasoning_effort
|
|
561
|
+
// provider option when reasoningEffort is unset.
|
|
562
|
+
...compatibleOptions.reasoningEffort !== void 0 ? { reasoning_effort: compatibleOptions.reasoningEffort } : {},
|
|
545
563
|
verbosity: compatibleOptions.textVerbosity,
|
|
546
564
|
// messages:
|
|
547
565
|
messages: convertToOpenAICompatibleChatMessages(prompt),
|
|
@@ -1816,7 +1834,7 @@ import {
|
|
|
1816
1834
|
} from "@ai-sdk/provider-utils";
|
|
1817
1835
|
|
|
1818
1836
|
// src/version.ts
|
|
1819
|
-
var VERSION = true ? "2.0.
|
|
1837
|
+
var VERSION = true ? "2.0.90" : "0.0.0-test";
|
|
1820
1838
|
|
|
1821
1839
|
// src/openai-compatible-provider.ts
|
|
1822
1840
|
function createOpenAICompatible(options) {
|