@ai-sdk/xai 3.0.0-beta.46 → 3.0.0-beta.48
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 +20 -0
- package/dist/index.d.mts +10 -10
- package/dist/index.d.ts +10 -10
- package/dist/index.js +12 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -22
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @ai-sdk/xai
|
|
2
2
|
|
|
3
|
+
## 3.0.0-beta.48
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 544d4e8: chore(specification): rename v3 provider defined tool to provider tool
|
|
8
|
+
- Updated dependencies [544d4e8]
|
|
9
|
+
- @ai-sdk/openai-compatible@2.0.0-beta.41
|
|
10
|
+
- @ai-sdk/provider-utils@4.0.0-beta.40
|
|
11
|
+
- @ai-sdk/provider@3.0.0-beta.22
|
|
12
|
+
|
|
13
|
+
## 3.0.0-beta.47
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- 954c356: feat(openai): allow custom names for provider-defined tools
|
|
18
|
+
- Updated dependencies [954c356]
|
|
19
|
+
- @ai-sdk/provider-utils@4.0.0-beta.39
|
|
20
|
+
- @ai-sdk/provider@3.0.0-beta.21
|
|
21
|
+
- @ai-sdk/openai-compatible@2.0.0-beta.40
|
|
22
|
+
|
|
3
23
|
## 3.0.0-beta.46
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -73,7 +73,7 @@ type XaiResponsesProviderOptions = z.infer<typeof xaiResponsesProviderOptions>;
|
|
|
73
73
|
|
|
74
74
|
type XaiImageModelId = 'grok-2-image' | (string & {});
|
|
75
75
|
|
|
76
|
-
declare const codeExecutionToolFactory: _ai_sdk_provider_utils.
|
|
76
|
+
declare const codeExecutionToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
|
|
77
77
|
output: string;
|
|
78
78
|
error?: string | undefined;
|
|
79
79
|
}, object>;
|
|
@@ -82,7 +82,7 @@ declare const codeExecution: (args?: Parameters<typeof codeExecutionToolFactory>
|
|
|
82
82
|
error?: string | undefined;
|
|
83
83
|
}>;
|
|
84
84
|
|
|
85
|
-
declare const viewImageToolFactory: _ai_sdk_provider_utils.
|
|
85
|
+
declare const viewImageToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
|
|
86
86
|
description: string;
|
|
87
87
|
objects?: string[] | undefined;
|
|
88
88
|
}, object>;
|
|
@@ -91,7 +91,7 @@ declare const viewImage: (args?: Parameters<typeof viewImageToolFactory>[0]) =>
|
|
|
91
91
|
objects?: string[] | undefined;
|
|
92
92
|
}>;
|
|
93
93
|
|
|
94
|
-
declare const viewXVideoToolFactory: _ai_sdk_provider_utils.
|
|
94
|
+
declare const viewXVideoToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
|
|
95
95
|
description: string;
|
|
96
96
|
transcript?: string | undefined;
|
|
97
97
|
duration?: number | undefined;
|
|
@@ -102,7 +102,7 @@ declare const viewXVideo: (args?: Parameters<typeof viewXVideoToolFactory>[0]) =
|
|
|
102
102
|
duration?: number | undefined;
|
|
103
103
|
}>;
|
|
104
104
|
|
|
105
|
-
declare const webSearchToolFactory: _ai_sdk_provider_utils.
|
|
105
|
+
declare const webSearchToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
|
|
106
106
|
query: string;
|
|
107
107
|
sources: Array<{
|
|
108
108
|
title: string;
|
|
@@ -123,7 +123,7 @@ declare const webSearch: (args?: Parameters<typeof webSearchToolFactory>[0]) =>
|
|
|
123
123
|
}>;
|
|
124
124
|
}>;
|
|
125
125
|
|
|
126
|
-
declare const xSearchToolFactory: _ai_sdk_provider_utils.
|
|
126
|
+
declare const xSearchToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
|
|
127
127
|
query: string;
|
|
128
128
|
posts: Array<{
|
|
129
129
|
author: string;
|
|
@@ -150,21 +150,21 @@ declare const xSearch: (args?: Parameters<typeof xSearchToolFactory>[0]) => _ai_
|
|
|
150
150
|
}>;
|
|
151
151
|
|
|
152
152
|
declare const xaiTools: {
|
|
153
|
-
codeExecution: (args?: Parameters<_ai_sdk_provider_utils.
|
|
153
|
+
codeExecution: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
|
|
154
154
|
output: string;
|
|
155
155
|
error?: string | undefined;
|
|
156
156
|
}, object>>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
|
|
157
157
|
output: string;
|
|
158
158
|
error?: string | undefined;
|
|
159
159
|
}>;
|
|
160
|
-
viewImage: (args?: Parameters<_ai_sdk_provider_utils.
|
|
160
|
+
viewImage: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
|
|
161
161
|
description: string;
|
|
162
162
|
objects?: string[] | undefined;
|
|
163
163
|
}, object>>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
|
|
164
164
|
description: string;
|
|
165
165
|
objects?: string[] | undefined;
|
|
166
166
|
}>;
|
|
167
|
-
viewXVideo: (args?: Parameters<_ai_sdk_provider_utils.
|
|
167
|
+
viewXVideo: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
|
|
168
168
|
description: string;
|
|
169
169
|
transcript?: string | undefined;
|
|
170
170
|
duration?: number | undefined;
|
|
@@ -173,7 +173,7 @@ declare const xaiTools: {
|
|
|
173
173
|
transcript?: string | undefined;
|
|
174
174
|
duration?: number | undefined;
|
|
175
175
|
}>;
|
|
176
|
-
webSearch: (args?: Parameters<_ai_sdk_provider_utils.
|
|
176
|
+
webSearch: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
|
|
177
177
|
query: string;
|
|
178
178
|
sources: Array<{
|
|
179
179
|
title: string;
|
|
@@ -192,7 +192,7 @@ declare const xaiTools: {
|
|
|
192
192
|
snippet: string;
|
|
193
193
|
}>;
|
|
194
194
|
}>;
|
|
195
|
-
xSearch: (args?: Parameters<_ai_sdk_provider_utils.
|
|
195
|
+
xSearch: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
|
|
196
196
|
query: string;
|
|
197
197
|
posts: Array<{
|
|
198
198
|
author: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -73,7 +73,7 @@ type XaiResponsesProviderOptions = z.infer<typeof xaiResponsesProviderOptions>;
|
|
|
73
73
|
|
|
74
74
|
type XaiImageModelId = 'grok-2-image' | (string & {});
|
|
75
75
|
|
|
76
|
-
declare const codeExecutionToolFactory: _ai_sdk_provider_utils.
|
|
76
|
+
declare const codeExecutionToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
|
|
77
77
|
output: string;
|
|
78
78
|
error?: string | undefined;
|
|
79
79
|
}, object>;
|
|
@@ -82,7 +82,7 @@ declare const codeExecution: (args?: Parameters<typeof codeExecutionToolFactory>
|
|
|
82
82
|
error?: string | undefined;
|
|
83
83
|
}>;
|
|
84
84
|
|
|
85
|
-
declare const viewImageToolFactory: _ai_sdk_provider_utils.
|
|
85
|
+
declare const viewImageToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
|
|
86
86
|
description: string;
|
|
87
87
|
objects?: string[] | undefined;
|
|
88
88
|
}, object>;
|
|
@@ -91,7 +91,7 @@ declare const viewImage: (args?: Parameters<typeof viewImageToolFactory>[0]) =>
|
|
|
91
91
|
objects?: string[] | undefined;
|
|
92
92
|
}>;
|
|
93
93
|
|
|
94
|
-
declare const viewXVideoToolFactory: _ai_sdk_provider_utils.
|
|
94
|
+
declare const viewXVideoToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
|
|
95
95
|
description: string;
|
|
96
96
|
transcript?: string | undefined;
|
|
97
97
|
duration?: number | undefined;
|
|
@@ -102,7 +102,7 @@ declare const viewXVideo: (args?: Parameters<typeof viewXVideoToolFactory>[0]) =
|
|
|
102
102
|
duration?: number | undefined;
|
|
103
103
|
}>;
|
|
104
104
|
|
|
105
|
-
declare const webSearchToolFactory: _ai_sdk_provider_utils.
|
|
105
|
+
declare const webSearchToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
|
|
106
106
|
query: string;
|
|
107
107
|
sources: Array<{
|
|
108
108
|
title: string;
|
|
@@ -123,7 +123,7 @@ declare const webSearch: (args?: Parameters<typeof webSearchToolFactory>[0]) =>
|
|
|
123
123
|
}>;
|
|
124
124
|
}>;
|
|
125
125
|
|
|
126
|
-
declare const xSearchToolFactory: _ai_sdk_provider_utils.
|
|
126
|
+
declare const xSearchToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
|
|
127
127
|
query: string;
|
|
128
128
|
posts: Array<{
|
|
129
129
|
author: string;
|
|
@@ -150,21 +150,21 @@ declare const xSearch: (args?: Parameters<typeof xSearchToolFactory>[0]) => _ai_
|
|
|
150
150
|
}>;
|
|
151
151
|
|
|
152
152
|
declare const xaiTools: {
|
|
153
|
-
codeExecution: (args?: Parameters<_ai_sdk_provider_utils.
|
|
153
|
+
codeExecution: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
|
|
154
154
|
output: string;
|
|
155
155
|
error?: string | undefined;
|
|
156
156
|
}, object>>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
|
|
157
157
|
output: string;
|
|
158
158
|
error?: string | undefined;
|
|
159
159
|
}>;
|
|
160
|
-
viewImage: (args?: Parameters<_ai_sdk_provider_utils.
|
|
160
|
+
viewImage: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
|
|
161
161
|
description: string;
|
|
162
162
|
objects?: string[] | undefined;
|
|
163
163
|
}, object>>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
|
|
164
164
|
description: string;
|
|
165
165
|
objects?: string[] | undefined;
|
|
166
166
|
}>;
|
|
167
|
-
viewXVideo: (args?: Parameters<_ai_sdk_provider_utils.
|
|
167
|
+
viewXVideo: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
|
|
168
168
|
description: string;
|
|
169
169
|
transcript?: string | undefined;
|
|
170
170
|
duration?: number | undefined;
|
|
@@ -173,7 +173,7 @@ declare const xaiTools: {
|
|
|
173
173
|
transcript?: string | undefined;
|
|
174
174
|
duration?: number | undefined;
|
|
175
175
|
}>;
|
|
176
|
-
webSearch: (args?: Parameters<_ai_sdk_provider_utils.
|
|
176
|
+
webSearch: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
|
|
177
177
|
query: string;
|
|
178
178
|
sources: Array<{
|
|
179
179
|
title: string;
|
|
@@ -192,7 +192,7 @@ declare const xaiTools: {
|
|
|
192
192
|
snippet: string;
|
|
193
193
|
}>;
|
|
194
194
|
}>;
|
|
195
|
-
xSearch: (args?: Parameters<_ai_sdk_provider_utils.
|
|
195
|
+
xSearch: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
|
|
196
196
|
query: string;
|
|
197
197
|
posts: Array<{
|
|
198
198
|
author: string;
|
package/dist/index.js
CHANGED
|
@@ -291,7 +291,7 @@ function prepareTools({
|
|
|
291
291
|
}
|
|
292
292
|
const xaiTools2 = [];
|
|
293
293
|
for (const tool of tools) {
|
|
294
|
-
if (tool.type === "provider
|
|
294
|
+
if (tool.type === "provider") {
|
|
295
295
|
toolWarnings.push({
|
|
296
296
|
type: "unsupported",
|
|
297
297
|
feature: `provider-defined tool ${tool.name}`
|
|
@@ -1242,9 +1242,8 @@ var webSearchOutputSchema = (0, import_provider_utils4.lazySchema)(
|
|
|
1242
1242
|
})
|
|
1243
1243
|
)
|
|
1244
1244
|
);
|
|
1245
|
-
var webSearchToolFactory = (0, import_provider_utils4.
|
|
1245
|
+
var webSearchToolFactory = (0, import_provider_utils4.createProviderToolFactoryWithOutputSchema)({
|
|
1246
1246
|
id: "xai.web_search",
|
|
1247
|
-
name: "web_search",
|
|
1248
1247
|
inputSchema: (0, import_provider_utils4.lazySchema)(() => (0, import_provider_utils4.zodSchema)(import_v46.z.object({}))),
|
|
1249
1248
|
outputSchema: webSearchOutputSchema
|
|
1250
1249
|
});
|
|
@@ -1280,9 +1279,8 @@ var xSearchOutputSchema = (0, import_provider_utils5.lazySchema)(
|
|
|
1280
1279
|
})
|
|
1281
1280
|
)
|
|
1282
1281
|
);
|
|
1283
|
-
var xSearchToolFactory = (0, import_provider_utils5.
|
|
1282
|
+
var xSearchToolFactory = (0, import_provider_utils5.createProviderToolFactoryWithOutputSchema)({
|
|
1284
1283
|
id: "xai.x_search",
|
|
1285
|
-
name: "x_search",
|
|
1286
1284
|
inputSchema: (0, import_provider_utils5.lazySchema)(() => (0, import_provider_utils5.zodSchema)(import_v47.z.object({}))),
|
|
1287
1285
|
outputSchema: xSearchOutputSchema
|
|
1288
1286
|
});
|
|
@@ -1302,7 +1300,7 @@ async function prepareResponsesTools({
|
|
|
1302
1300
|
const toolByName = /* @__PURE__ */ new Map();
|
|
1303
1301
|
for (const tool of normalizedTools) {
|
|
1304
1302
|
toolByName.set(tool.name, tool);
|
|
1305
|
-
if (tool.type === "provider
|
|
1303
|
+
if (tool.type === "provider") {
|
|
1306
1304
|
switch (tool.id) {
|
|
1307
1305
|
case "xai.web_search": {
|
|
1308
1306
|
const args = await (0, import_provider_utils6.validateTypes)({
|
|
@@ -1401,7 +1399,7 @@ async function prepareResponsesTools({
|
|
|
1401
1399
|
toolWarnings
|
|
1402
1400
|
};
|
|
1403
1401
|
}
|
|
1404
|
-
if (selectedTool.type === "provider
|
|
1402
|
+
if (selectedTool.type === "provider") {
|
|
1405
1403
|
switch (selectedTool.id) {
|
|
1406
1404
|
case "xai.web_search":
|
|
1407
1405
|
return {
|
|
@@ -1503,13 +1501,13 @@ var XaiResponsesLanguageModel = class {
|
|
|
1503
1501
|
warnings.push({ type: "unsupported", feature: "stopSequences" });
|
|
1504
1502
|
}
|
|
1505
1503
|
const webSearchToolName = (_b = tools == null ? void 0 : tools.find(
|
|
1506
|
-
(tool) => tool.type === "provider
|
|
1504
|
+
(tool) => tool.type === "provider" && tool.id === "xai.web_search"
|
|
1507
1505
|
)) == null ? void 0 : _b.name;
|
|
1508
1506
|
const xSearchToolName = (_c = tools == null ? void 0 : tools.find(
|
|
1509
|
-
(tool) => tool.type === "provider
|
|
1507
|
+
(tool) => tool.type === "provider" && tool.id === "xai.x_search"
|
|
1510
1508
|
)) == null ? void 0 : _c.name;
|
|
1511
1509
|
const codeExecutionToolName = (_d = tools == null ? void 0 : tools.find(
|
|
1512
|
-
(tool) => tool.type === "provider
|
|
1510
|
+
(tool) => tool.type === "provider" && tool.id === "xai.code_execution"
|
|
1513
1511
|
)) == null ? void 0 : _d.name;
|
|
1514
1512
|
const { input, inputWarnings } = await convertToXaiResponsesInput({
|
|
1515
1513
|
prompt,
|
|
@@ -1944,9 +1942,8 @@ var codeExecutionOutputSchema = import_v48.z.object({
|
|
|
1944
1942
|
output: import_v48.z.string().describe("the output of the code execution"),
|
|
1945
1943
|
error: import_v48.z.string().optional().describe("any error that occurred")
|
|
1946
1944
|
});
|
|
1947
|
-
var codeExecutionToolFactory = (0, import_provider_utils8.
|
|
1945
|
+
var codeExecutionToolFactory = (0, import_provider_utils8.createProviderToolFactoryWithOutputSchema)({
|
|
1948
1946
|
id: "xai.code_execution",
|
|
1949
|
-
name: "code_execution",
|
|
1950
1947
|
inputSchema: import_v48.z.object({}).describe("no input parameters"),
|
|
1951
1948
|
outputSchema: codeExecutionOutputSchema
|
|
1952
1949
|
});
|
|
@@ -1959,9 +1956,8 @@ var viewImageOutputSchema = import_v49.z.object({
|
|
|
1959
1956
|
description: import_v49.z.string().describe("description of the image"),
|
|
1960
1957
|
objects: import_v49.z.array(import_v49.z.string()).optional().describe("objects detected in the image")
|
|
1961
1958
|
});
|
|
1962
|
-
var viewImageToolFactory = (0, import_provider_utils9.
|
|
1959
|
+
var viewImageToolFactory = (0, import_provider_utils9.createProviderToolFactoryWithOutputSchema)({
|
|
1963
1960
|
id: "xai.view_image",
|
|
1964
|
-
name: "view_image",
|
|
1965
1961
|
inputSchema: import_v49.z.object({}).describe("no input parameters"),
|
|
1966
1962
|
outputSchema: viewImageOutputSchema
|
|
1967
1963
|
});
|
|
@@ -1975,9 +1971,8 @@ var viewXVideoOutputSchema = import_v410.z.object({
|
|
|
1975
1971
|
description: import_v410.z.string().describe("description of the video content"),
|
|
1976
1972
|
duration: import_v410.z.number().optional().describe("duration in seconds")
|
|
1977
1973
|
});
|
|
1978
|
-
var viewXVideoToolFactory = (0, import_provider_utils10.
|
|
1974
|
+
var viewXVideoToolFactory = (0, import_provider_utils10.createProviderToolFactoryWithOutputSchema)({
|
|
1979
1975
|
id: "xai.view_x_video",
|
|
1980
|
-
name: "view_x_video",
|
|
1981
1976
|
inputSchema: import_v410.z.object({}).describe("no input parameters"),
|
|
1982
1977
|
outputSchema: viewXVideoOutputSchema
|
|
1983
1978
|
});
|
|
@@ -1993,7 +1988,7 @@ var xaiTools = {
|
|
|
1993
1988
|
};
|
|
1994
1989
|
|
|
1995
1990
|
// src/version.ts
|
|
1996
|
-
var VERSION = true ? "3.0.0-beta.
|
|
1991
|
+
var VERSION = true ? "3.0.0-beta.48" : "0.0.0-test";
|
|
1997
1992
|
|
|
1998
1993
|
// src/xai-provider.ts
|
|
1999
1994
|
var xaiErrorStructure = {
|