@ai-sdk/xai 3.0.88 → 3.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 +14 -0
- package/dist/index.js +23 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/remove-additional-properties.ts +24 -0
- package/src/responses/xai-responses-prepare-tools.ts +2 -1
- package/src/xai-prepare-tools.ts +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/xai",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.90",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@ai-sdk/openai-compatible": "2.0.
|
|
32
|
+
"@ai-sdk/openai-compatible": "2.0.47",
|
|
33
33
|
"@ai-sdk/provider": "3.0.10",
|
|
34
|
-
"@ai-sdk/provider-utils": "4.0.
|
|
34
|
+
"@ai-sdk/provider-utils": "4.0.27"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/node": "20.17.24",
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Recursively removes `additionalProperties: false` entries from a JSON
|
|
3
|
+
* schema.
|
|
4
|
+
* Used to sanitize tool input schemas before sending them to the xAI API.
|
|
5
|
+
* https://docs.x.ai/developers/model-capabilities/text/structured-outputs#supported-types
|
|
6
|
+
*/
|
|
7
|
+
export function removeAdditionalPropertiesFalse(value: unknown): unknown {
|
|
8
|
+
if (Array.isArray(value)) {
|
|
9
|
+
return value.map(removeAdditionalPropertiesFalse);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
if (value == null || typeof value !== 'object') {
|
|
13
|
+
return value;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const result: Record<string, unknown> = {};
|
|
17
|
+
for (const [key, propertyValue] of Object.entries(value)) {
|
|
18
|
+
if (key === 'additionalProperties' && propertyValue === false) {
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
result[key] = removeAdditionalPropertiesFalse(propertyValue);
|
|
22
|
+
}
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
type SharedV3Warning,
|
|
5
5
|
} from '@ai-sdk/provider';
|
|
6
6
|
import { validateTypes } from '@ai-sdk/provider-utils';
|
|
7
|
+
import { removeAdditionalPropertiesFalse } from '../remove-additional-properties';
|
|
7
8
|
import { fileSearchArgsSchema } from '../tool/file-search';
|
|
8
9
|
import { mcpServerArgsSchema } from '../tool/mcp-server';
|
|
9
10
|
import { webSearchArgsSchema } from '../tool/web-search';
|
|
@@ -142,7 +143,7 @@ export async function prepareResponsesTools({
|
|
|
142
143
|
type: 'function',
|
|
143
144
|
name: tool.name,
|
|
144
145
|
description: tool.description,
|
|
145
|
-
parameters: tool.inputSchema,
|
|
146
|
+
parameters: removeAdditionalPropertiesFalse(tool.inputSchema),
|
|
146
147
|
...(tool.strict != null ? { strict: tool.strict } : {}),
|
|
147
148
|
});
|
|
148
149
|
}
|
package/src/xai-prepare-tools.ts
CHANGED
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
type LanguageModelV3CallOptions,
|
|
4
4
|
type SharedV3Warning,
|
|
5
5
|
} from '@ai-sdk/provider';
|
|
6
|
+
import { removeAdditionalPropertiesFalse } from './remove-additional-properties';
|
|
6
7
|
import type { XaiToolChoice } from './xai-chat-prompt';
|
|
7
8
|
|
|
8
9
|
export function prepareTools({
|
|
@@ -58,7 +59,7 @@ export function prepareTools({
|
|
|
58
59
|
function: {
|
|
59
60
|
name: tool.name,
|
|
60
61
|
description: tool.description,
|
|
61
|
-
parameters: tool.inputSchema,
|
|
62
|
+
parameters: removeAdditionalPropertiesFalse(tool.inputSchema),
|
|
62
63
|
...(tool.strict != null ? { strict: tool.strict } : {}),
|
|
63
64
|
},
|
|
64
65
|
});
|