@ai-sdk/xai 3.0.132 → 3.0.133
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 +6 -0
- package/dist/index.js +3 -23
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3 -23
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/responses/xai-responses-prepare-tools.ts +1 -2
- package/src/xai-prepare-tools.ts +1 -2
- package/src/remove-additional-properties.ts +0 -24
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/xai",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.133",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"tsup": "^8",
|
|
39
39
|
"typescript": "5.8.3",
|
|
40
40
|
"zod": "3.25.76",
|
|
41
|
-
"@ai-
|
|
42
|
-
"@
|
|
41
|
+
"@vercel/ai-tsconfig": "0.0.0",
|
|
42
|
+
"@ai-sdk/test-server": "1.0.6"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"zod": "^3.25.76 || ^4.1.8"
|
|
@@ -4,7 +4,6 @@ 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';
|
|
8
7
|
import { fileSearchArgsSchema } from '../tool/file-search';
|
|
9
8
|
import { mcpServerArgsSchema } from '../tool/mcp-server';
|
|
10
9
|
import { webSearchArgsSchema } from '../tool/web-search';
|
|
@@ -144,7 +143,7 @@ export async function prepareResponsesTools({
|
|
|
144
143
|
type: 'function',
|
|
145
144
|
name: tool.name,
|
|
146
145
|
description: tool.description,
|
|
147
|
-
parameters:
|
|
146
|
+
parameters: tool.inputSchema,
|
|
148
147
|
...(tool.strict != null ? { strict: tool.strict } : {}),
|
|
149
148
|
});
|
|
150
149
|
}
|
package/src/xai-prepare-tools.ts
CHANGED
|
@@ -3,7 +3,6 @@ import {
|
|
|
3
3
|
type LanguageModelV3CallOptions,
|
|
4
4
|
type SharedV3Warning,
|
|
5
5
|
} from '@ai-sdk/provider';
|
|
6
|
-
import { removeAdditionalPropertiesFalse } from './remove-additional-properties';
|
|
7
6
|
import type { XaiToolChoice } from './xai-chat-prompt';
|
|
8
7
|
|
|
9
8
|
export function prepareTools({
|
|
@@ -59,7 +58,7 @@ export function prepareTools({
|
|
|
59
58
|
function: {
|
|
60
59
|
name: tool.name,
|
|
61
60
|
description: tool.description,
|
|
62
|
-
parameters:
|
|
61
|
+
parameters: tool.inputSchema,
|
|
63
62
|
...(tool.strict != null ? { strict: tool.strict } : {}),
|
|
64
63
|
},
|
|
65
64
|
});
|
|
@@ -1,24 +0,0 @@
|
|
|
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
|
-
}
|