@ai-sdk/xai 3.0.89 → 3.0.91
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 +13 -0
- package/dist/index.d.mts +5 -2
- package/dist/index.d.ts +5 -2
- package/dist/index.js +44 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +44 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/remove-additional-properties.ts +24 -0
- package/src/responses/xai-responses-language-model.ts +11 -9
- package/src/responses/xai-responses-prepare-tools.ts +2 -1
- package/src/xai-error.ts +13 -3
- package/src/xai-prepare-tools.ts +2 -1
package/dist/index.mjs
CHANGED
|
@@ -280,7 +280,7 @@ var xaiLanguageModelChatOptions = z.object({
|
|
|
280
280
|
// src/xai-error.ts
|
|
281
281
|
import { createJsonErrorResponseHandler } from "@ai-sdk/provider-utils";
|
|
282
282
|
import { z as z2 } from "zod/v4";
|
|
283
|
-
var
|
|
283
|
+
var chatCompletionsErrorSchema = z2.object({
|
|
284
284
|
error: z2.object({
|
|
285
285
|
message: z2.string(),
|
|
286
286
|
type: z2.string().nullish(),
|
|
@@ -288,15 +288,43 @@ var xaiErrorDataSchema = z2.object({
|
|
|
288
288
|
code: z2.union([z2.string(), z2.number()]).nullish()
|
|
289
289
|
})
|
|
290
290
|
});
|
|
291
|
+
var responsesErrorSchema = z2.object({
|
|
292
|
+
code: z2.string(),
|
|
293
|
+
error: z2.string()
|
|
294
|
+
});
|
|
295
|
+
var xaiErrorDataSchema = z2.union([
|
|
296
|
+
chatCompletionsErrorSchema,
|
|
297
|
+
responsesErrorSchema
|
|
298
|
+
]);
|
|
291
299
|
var xaiFailedResponseHandler = createJsonErrorResponseHandler({
|
|
292
300
|
errorSchema: xaiErrorDataSchema,
|
|
293
|
-
errorToMessage: (data) => data.error.message
|
|
301
|
+
errorToMessage: (data) => "code" in data ? `${data.code}: ${data.error}` : data.error.message
|
|
294
302
|
});
|
|
295
303
|
|
|
296
304
|
// src/xai-prepare-tools.ts
|
|
297
305
|
import {
|
|
298
306
|
UnsupportedFunctionalityError as UnsupportedFunctionalityError2
|
|
299
307
|
} from "@ai-sdk/provider";
|
|
308
|
+
|
|
309
|
+
// src/remove-additional-properties.ts
|
|
310
|
+
function removeAdditionalPropertiesFalse(value) {
|
|
311
|
+
if (Array.isArray(value)) {
|
|
312
|
+
return value.map(removeAdditionalPropertiesFalse);
|
|
313
|
+
}
|
|
314
|
+
if (value == null || typeof value !== "object") {
|
|
315
|
+
return value;
|
|
316
|
+
}
|
|
317
|
+
const result = {};
|
|
318
|
+
for (const [key, propertyValue] of Object.entries(value)) {
|
|
319
|
+
if (key === "additionalProperties" && propertyValue === false) {
|
|
320
|
+
continue;
|
|
321
|
+
}
|
|
322
|
+
result[key] = removeAdditionalPropertiesFalse(propertyValue);
|
|
323
|
+
}
|
|
324
|
+
return result;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
// src/xai-prepare-tools.ts
|
|
300
328
|
function prepareTools({
|
|
301
329
|
tools,
|
|
302
330
|
toolChoice
|
|
@@ -319,7 +347,7 @@ function prepareTools({
|
|
|
319
347
|
function: {
|
|
320
348
|
name: tool.name,
|
|
321
349
|
description: tool.description,
|
|
322
|
-
parameters: tool.inputSchema,
|
|
350
|
+
parameters: removeAdditionalPropertiesFalse(tool.inputSchema),
|
|
323
351
|
...tool.strict != null ? { strict: tool.strict } : {}
|
|
324
352
|
}
|
|
325
353
|
});
|
|
@@ -1991,7 +2019,7 @@ async function prepareResponsesTools({
|
|
|
1991
2019
|
type: "function",
|
|
1992
2020
|
name: tool.name,
|
|
1993
2021
|
description: tool.description,
|
|
1994
|
-
parameters: tool.inputSchema,
|
|
2022
|
+
parameters: removeAdditionalPropertiesFalse(tool.inputSchema),
|
|
1995
2023
|
...tool.strict != null ? { strict: tool.strict } : {}
|
|
1996
2024
|
});
|
|
1997
2025
|
}
|
|
@@ -2396,16 +2424,18 @@ var XaiResponsesLanguageModel = class {
|
|
|
2396
2424
|
}
|
|
2397
2425
|
if (event.type === "response.reasoning_summary_part.added") {
|
|
2398
2426
|
const blockId = `reasoning-${event.item_id}`;
|
|
2399
|
-
activeReasoning[event.item_id]
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2427
|
+
if (activeReasoning[event.item_id] == null) {
|
|
2428
|
+
activeReasoning[event.item_id] = {};
|
|
2429
|
+
controller.enqueue({
|
|
2430
|
+
type: "reasoning-start",
|
|
2431
|
+
id: blockId,
|
|
2432
|
+
providerMetadata: {
|
|
2433
|
+
xai: {
|
|
2434
|
+
itemId: event.item_id
|
|
2435
|
+
}
|
|
2406
2436
|
}
|
|
2407
|
-
}
|
|
2408
|
-
}
|
|
2437
|
+
});
|
|
2438
|
+
}
|
|
2409
2439
|
}
|
|
2410
2440
|
if (event.type === "response.reasoning_summary_text.delta") {
|
|
2411
2441
|
const blockId = `reasoning-${event.item_id}`;
|
|
@@ -2821,7 +2851,7 @@ var xaiTools = {
|
|
|
2821
2851
|
};
|
|
2822
2852
|
|
|
2823
2853
|
// src/version.ts
|
|
2824
|
-
var VERSION = true ? "3.0.
|
|
2854
|
+
var VERSION = true ? "3.0.91" : "0.0.0-test";
|
|
2825
2855
|
|
|
2826
2856
|
// src/xai-video-model.ts
|
|
2827
2857
|
import {
|