@ai-sdk/openai-compatible 2.0.89 → 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/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: JSON.stringify(part.input)
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 = JSON.stringify(output.value);
284
+ contentValue = stringifyWithBigIntAndCycles(output.value);
272
285
  break;
273
286
  }
274
287
  const toolResponseMetadata = getOpenAIMetadata(toolResponse);
@@ -1821,7 +1834,7 @@ import {
1821
1834
  } from "@ai-sdk/provider-utils";
1822
1835
 
1823
1836
  // src/version.ts
1824
- var VERSION = true ? "2.0.89" : "0.0.0-test";
1837
+ var VERSION = true ? "2.0.90" : "0.0.0-test";
1825
1838
 
1826
1839
  // src/openai-compatible-provider.ts
1827
1840
  function createOpenAICompatible(options) {