@ai-sdk/xai 0.0.0-70e0935a-20260114150030 → 0.0.0-98261322-20260122142521
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 +64 -5
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/docs/01-xai.mdx +697 -0
- package/package.json +11 -6
- package/src/convert-to-xai-chat-messages.test.ts +243 -0
- package/src/convert-to-xai-chat-messages.ts +142 -0
- package/src/convert-xai-chat-usage.test.ts +240 -0
- package/src/convert-xai-chat-usage.ts +23 -0
- package/src/get-response-metadata.ts +19 -0
- package/src/index.ts +14 -0
- package/src/map-xai-finish-reason.ts +19 -0
- package/src/responses/__fixtures__/xai-code-execution-tool.1.json +68 -0
- package/src/responses/__fixtures__/xai-text-streaming.1.chunks.txt +698 -0
- package/src/responses/__fixtures__/xai-text-with-reasoning-streaming-store-false.1.chunks.txt +655 -0
- package/src/responses/__fixtures__/xai-text-with-reasoning-streaming.1.chunks.txt +679 -0
- package/src/responses/__fixtures__/xai-web-search-tool.1.chunks.txt +274 -0
- package/src/responses/__fixtures__/xai-web-search-tool.1.json +90 -0
- package/src/responses/__fixtures__/xai-x-search-tool.1.json +149 -0
- package/src/responses/__fixtures__/xai-x-search-tool.chunks.txt +1757 -0
- package/src/responses/__snapshots__/xai-responses-language-model.test.ts.snap +21929 -0
- package/src/responses/convert-to-xai-responses-input.test.ts +463 -0
- package/src/responses/convert-to-xai-responses-input.ts +206 -0
- package/src/responses/convert-xai-responses-usage.ts +24 -0
- package/src/responses/map-xai-responses-finish-reason.ts +20 -0
- package/src/responses/xai-responses-api.ts +393 -0
- package/src/responses/xai-responses-language-model.test.ts +1803 -0
- package/src/responses/xai-responses-language-model.ts +732 -0
- package/src/responses/xai-responses-options.ts +34 -0
- package/src/responses/xai-responses-prepare-tools.test.ts +497 -0
- package/src/responses/xai-responses-prepare-tools.ts +226 -0
- package/src/tool/code-execution.ts +17 -0
- package/src/tool/index.ts +15 -0
- package/src/tool/view-image.ts +20 -0
- package/src/tool/view-x-video.ts +18 -0
- package/src/tool/web-search.ts +56 -0
- package/src/tool/x-search.ts +63 -0
- package/src/version.ts +6 -0
- package/src/xai-chat-language-model.test.ts +1805 -0
- package/src/xai-chat-language-model.ts +681 -0
- package/src/xai-chat-options.ts +131 -0
- package/src/xai-chat-prompt.ts +44 -0
- package/src/xai-error.ts +19 -0
- package/src/xai-image-settings.ts +1 -0
- package/src/xai-prepare-tools.ts +95 -0
- package/src/xai-provider.test.ts +167 -0
- package/src/xai-provider.ts +162 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { z } from 'zod/v4';
|
|
2
|
+
|
|
3
|
+
export type XaiResponsesModelId =
|
|
4
|
+
| 'grok-4-1'
|
|
5
|
+
| 'grok-4-1-fast-reasoning'
|
|
6
|
+
| 'grok-4-1-fast-non-reasoning'
|
|
7
|
+
| 'grok-4'
|
|
8
|
+
| 'grok-4-fast'
|
|
9
|
+
| 'grok-4-fast-non-reasoning'
|
|
10
|
+
| (string & {});
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @see https://docs.x.ai/docs/api-reference#create-new-response
|
|
14
|
+
*/
|
|
15
|
+
export const xaiResponsesProviderOptions = z.object({
|
|
16
|
+
/**
|
|
17
|
+
* Constrains how hard a reasoning model thinks before responding.
|
|
18
|
+
* Possible values are `low` (uses fewer reasoning tokens), `medium` and `high` (uses more reasoning tokens).
|
|
19
|
+
*/
|
|
20
|
+
reasoningEffort: z.enum(['low', 'medium', 'high']).optional(),
|
|
21
|
+
/**
|
|
22
|
+
* Whether to store the input message(s) and model response for later retrieval.
|
|
23
|
+
* @default true
|
|
24
|
+
*/
|
|
25
|
+
store: z.boolean().optional(),
|
|
26
|
+
/**
|
|
27
|
+
* The ID of the previous response from the model.
|
|
28
|
+
*/
|
|
29
|
+
previousResponseId: z.string().optional(),
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
export type XaiResponsesProviderOptions = z.infer<
|
|
33
|
+
typeof xaiResponsesProviderOptions
|
|
34
|
+
>;
|
|
@@ -0,0 +1,497 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { prepareResponsesTools } from './xai-responses-prepare-tools';
|
|
3
|
+
|
|
4
|
+
describe('prepareResponsesTools', () => {
|
|
5
|
+
describe('web_search', () => {
|
|
6
|
+
it('should prepare web_search tool with no args', async () => {
|
|
7
|
+
const result = await prepareResponsesTools({
|
|
8
|
+
tools: [
|
|
9
|
+
{
|
|
10
|
+
type: 'provider',
|
|
11
|
+
id: 'xai.web_search',
|
|
12
|
+
name: 'web_search',
|
|
13
|
+
args: {},
|
|
14
|
+
},
|
|
15
|
+
],
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
expect(result).toMatchInlineSnapshot(`
|
|
19
|
+
{
|
|
20
|
+
"toolChoice": undefined,
|
|
21
|
+
"toolWarnings": [],
|
|
22
|
+
"tools": [
|
|
23
|
+
{
|
|
24
|
+
"allowed_domains": undefined,
|
|
25
|
+
"enable_image_understanding": undefined,
|
|
26
|
+
"excluded_domains": undefined,
|
|
27
|
+
"type": "web_search",
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
}
|
|
31
|
+
`);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('should prepare web_search tool with allowed domains', async () => {
|
|
35
|
+
const result = await prepareResponsesTools({
|
|
36
|
+
tools: [
|
|
37
|
+
{
|
|
38
|
+
type: 'provider',
|
|
39
|
+
id: 'xai.web_search',
|
|
40
|
+
name: 'web_search',
|
|
41
|
+
args: {
|
|
42
|
+
allowedDomains: ['wikipedia.org', 'example.com'],
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
expect(result.tools).toMatchInlineSnapshot(`
|
|
49
|
+
[
|
|
50
|
+
{
|
|
51
|
+
"allowed_domains": [
|
|
52
|
+
"wikipedia.org",
|
|
53
|
+
"example.com",
|
|
54
|
+
],
|
|
55
|
+
"enable_image_understanding": undefined,
|
|
56
|
+
"excluded_domains": undefined,
|
|
57
|
+
"type": "web_search",
|
|
58
|
+
},
|
|
59
|
+
]
|
|
60
|
+
`);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('should prepare web_search tool with excluded domains', async () => {
|
|
64
|
+
const result = await prepareResponsesTools({
|
|
65
|
+
tools: [
|
|
66
|
+
{
|
|
67
|
+
type: 'provider',
|
|
68
|
+
id: 'xai.web_search',
|
|
69
|
+
name: 'web_search',
|
|
70
|
+
args: {
|
|
71
|
+
excludedDomains: ['spam.com'],
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
],
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
expect(result.tools).toMatchInlineSnapshot(`
|
|
78
|
+
[
|
|
79
|
+
{
|
|
80
|
+
"allowed_domains": undefined,
|
|
81
|
+
"enable_image_understanding": undefined,
|
|
82
|
+
"excluded_domains": [
|
|
83
|
+
"spam.com",
|
|
84
|
+
],
|
|
85
|
+
"type": "web_search",
|
|
86
|
+
},
|
|
87
|
+
]
|
|
88
|
+
`);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it('should prepare web_search tool with image understanding', async () => {
|
|
92
|
+
const result = await prepareResponsesTools({
|
|
93
|
+
tools: [
|
|
94
|
+
{
|
|
95
|
+
type: 'provider',
|
|
96
|
+
id: 'xai.web_search',
|
|
97
|
+
name: 'web_search',
|
|
98
|
+
args: {
|
|
99
|
+
enableImageUnderstanding: true,
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
],
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
expect(result.tools).toMatchInlineSnapshot(`
|
|
106
|
+
[
|
|
107
|
+
{
|
|
108
|
+
"allowed_domains": undefined,
|
|
109
|
+
"enable_image_understanding": true,
|
|
110
|
+
"excluded_domains": undefined,
|
|
111
|
+
"type": "web_search",
|
|
112
|
+
},
|
|
113
|
+
]
|
|
114
|
+
`);
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
describe('x_search', () => {
|
|
119
|
+
it('should prepare x_search tool with no args', async () => {
|
|
120
|
+
const result = await prepareResponsesTools({
|
|
121
|
+
tools: [
|
|
122
|
+
{
|
|
123
|
+
type: 'provider',
|
|
124
|
+
id: 'xai.x_search',
|
|
125
|
+
name: 'x_search',
|
|
126
|
+
args: {},
|
|
127
|
+
},
|
|
128
|
+
],
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
expect(result.tools).toMatchInlineSnapshot(`
|
|
132
|
+
[
|
|
133
|
+
{
|
|
134
|
+
"allowed_x_handles": undefined,
|
|
135
|
+
"enable_image_understanding": undefined,
|
|
136
|
+
"enable_video_understanding": undefined,
|
|
137
|
+
"excluded_x_handles": undefined,
|
|
138
|
+
"from_date": undefined,
|
|
139
|
+
"to_date": undefined,
|
|
140
|
+
"type": "x_search",
|
|
141
|
+
},
|
|
142
|
+
]
|
|
143
|
+
`);
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
it('should prepare x_search tool with allowed handles', async () => {
|
|
147
|
+
const result = await prepareResponsesTools({
|
|
148
|
+
tools: [
|
|
149
|
+
{
|
|
150
|
+
type: 'provider',
|
|
151
|
+
id: 'xai.x_search',
|
|
152
|
+
name: 'x_search',
|
|
153
|
+
args: {
|
|
154
|
+
allowedXHandles: ['elonmusk', 'xai'],
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
],
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
expect(result.tools).toMatchInlineSnapshot(`
|
|
161
|
+
[
|
|
162
|
+
{
|
|
163
|
+
"allowed_x_handles": [
|
|
164
|
+
"elonmusk",
|
|
165
|
+
"xai",
|
|
166
|
+
],
|
|
167
|
+
"enable_image_understanding": undefined,
|
|
168
|
+
"enable_video_understanding": undefined,
|
|
169
|
+
"excluded_x_handles": undefined,
|
|
170
|
+
"from_date": undefined,
|
|
171
|
+
"to_date": undefined,
|
|
172
|
+
"type": "x_search",
|
|
173
|
+
},
|
|
174
|
+
]
|
|
175
|
+
`);
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
it('should prepare x_search tool with date range', async () => {
|
|
179
|
+
const result = await prepareResponsesTools({
|
|
180
|
+
tools: [
|
|
181
|
+
{
|
|
182
|
+
type: 'provider',
|
|
183
|
+
id: 'xai.x_search',
|
|
184
|
+
name: 'x_search',
|
|
185
|
+
args: {
|
|
186
|
+
fromDate: '2025-01-01',
|
|
187
|
+
toDate: '2025-12-31',
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
],
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
expect(result.tools).toMatchInlineSnapshot(`
|
|
194
|
+
[
|
|
195
|
+
{
|
|
196
|
+
"allowed_x_handles": undefined,
|
|
197
|
+
"enable_image_understanding": undefined,
|
|
198
|
+
"enable_video_understanding": undefined,
|
|
199
|
+
"excluded_x_handles": undefined,
|
|
200
|
+
"from_date": "2025-01-01",
|
|
201
|
+
"to_date": "2025-12-31",
|
|
202
|
+
"type": "x_search",
|
|
203
|
+
},
|
|
204
|
+
]
|
|
205
|
+
`);
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
it('should prepare x_search tool with video understanding', async () => {
|
|
209
|
+
const result = await prepareResponsesTools({
|
|
210
|
+
tools: [
|
|
211
|
+
{
|
|
212
|
+
type: 'provider',
|
|
213
|
+
id: 'xai.x_search',
|
|
214
|
+
name: 'x_search',
|
|
215
|
+
args: {
|
|
216
|
+
enableVideoUnderstanding: true,
|
|
217
|
+
enableImageUnderstanding: true,
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
|
+
],
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
expect(result.tools).toMatchInlineSnapshot(`
|
|
224
|
+
[
|
|
225
|
+
{
|
|
226
|
+
"allowed_x_handles": undefined,
|
|
227
|
+
"enable_image_understanding": true,
|
|
228
|
+
"enable_video_understanding": true,
|
|
229
|
+
"excluded_x_handles": undefined,
|
|
230
|
+
"from_date": undefined,
|
|
231
|
+
"to_date": undefined,
|
|
232
|
+
"type": "x_search",
|
|
233
|
+
},
|
|
234
|
+
]
|
|
235
|
+
`);
|
|
236
|
+
});
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
describe('code_execution', () => {
|
|
240
|
+
it('should prepare code_execution tool as code_interpreter', async () => {
|
|
241
|
+
const result = await prepareResponsesTools({
|
|
242
|
+
tools: [
|
|
243
|
+
{
|
|
244
|
+
type: 'provider',
|
|
245
|
+
id: 'xai.code_execution',
|
|
246
|
+
name: 'code_execution',
|
|
247
|
+
args: {},
|
|
248
|
+
},
|
|
249
|
+
],
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
expect(result.tools).toMatchInlineSnapshot(`
|
|
253
|
+
[
|
|
254
|
+
{
|
|
255
|
+
"type": "code_interpreter",
|
|
256
|
+
},
|
|
257
|
+
]
|
|
258
|
+
`);
|
|
259
|
+
});
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
describe('view_image', () => {
|
|
263
|
+
it('should prepare view_image tool', async () => {
|
|
264
|
+
const result = await prepareResponsesTools({
|
|
265
|
+
tools: [
|
|
266
|
+
{
|
|
267
|
+
type: 'provider',
|
|
268
|
+
id: 'xai.view_image',
|
|
269
|
+
name: 'view_image',
|
|
270
|
+
args: {},
|
|
271
|
+
},
|
|
272
|
+
],
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
expect(result.tools).toEqual([{ type: 'view_image' }]);
|
|
276
|
+
});
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
describe('view_x_video', () => {
|
|
280
|
+
it('should prepare view_x_video tool', async () => {
|
|
281
|
+
const result = await prepareResponsesTools({
|
|
282
|
+
tools: [
|
|
283
|
+
{
|
|
284
|
+
type: 'provider',
|
|
285
|
+
id: 'xai.view_x_video',
|
|
286
|
+
name: 'view_x_video',
|
|
287
|
+
args: {},
|
|
288
|
+
},
|
|
289
|
+
],
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
expect(result.tools).toEqual([{ type: 'view_x_video' }]);
|
|
293
|
+
});
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
describe('function tools', () => {
|
|
297
|
+
it('should prepare function tools', async () => {
|
|
298
|
+
const result = await prepareResponsesTools({
|
|
299
|
+
tools: [
|
|
300
|
+
{
|
|
301
|
+
type: 'function',
|
|
302
|
+
name: 'weather',
|
|
303
|
+
description: 'get weather information',
|
|
304
|
+
inputSchema: {
|
|
305
|
+
type: 'object',
|
|
306
|
+
properties: {
|
|
307
|
+
location: { type: 'string' },
|
|
308
|
+
},
|
|
309
|
+
required: ['location'],
|
|
310
|
+
},
|
|
311
|
+
},
|
|
312
|
+
],
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
expect(result.tools).toMatchInlineSnapshot(`
|
|
316
|
+
[
|
|
317
|
+
{
|
|
318
|
+
"description": "get weather information",
|
|
319
|
+
"name": "weather",
|
|
320
|
+
"parameters": {
|
|
321
|
+
"properties": {
|
|
322
|
+
"location": {
|
|
323
|
+
"type": "string",
|
|
324
|
+
},
|
|
325
|
+
},
|
|
326
|
+
"required": [
|
|
327
|
+
"location",
|
|
328
|
+
],
|
|
329
|
+
"type": "object",
|
|
330
|
+
},
|
|
331
|
+
"type": "function",
|
|
332
|
+
},
|
|
333
|
+
]
|
|
334
|
+
`);
|
|
335
|
+
});
|
|
336
|
+
});
|
|
337
|
+
|
|
338
|
+
describe('tool choice', () => {
|
|
339
|
+
it('should handle tool choice auto', async () => {
|
|
340
|
+
const result = await prepareResponsesTools({
|
|
341
|
+
tools: [
|
|
342
|
+
{
|
|
343
|
+
type: 'provider',
|
|
344
|
+
id: 'xai.web_search',
|
|
345
|
+
name: 'web_search',
|
|
346
|
+
args: {},
|
|
347
|
+
},
|
|
348
|
+
],
|
|
349
|
+
toolChoice: { type: 'auto' },
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
expect(result.toolChoice).toBe('auto');
|
|
353
|
+
});
|
|
354
|
+
|
|
355
|
+
it('should handle tool choice required', async () => {
|
|
356
|
+
const result = await prepareResponsesTools({
|
|
357
|
+
tools: [
|
|
358
|
+
{
|
|
359
|
+
type: 'provider',
|
|
360
|
+
id: 'xai.web_search',
|
|
361
|
+
name: 'web_search',
|
|
362
|
+
args: {},
|
|
363
|
+
},
|
|
364
|
+
],
|
|
365
|
+
toolChoice: { type: 'required' },
|
|
366
|
+
});
|
|
367
|
+
|
|
368
|
+
expect(result.toolChoice).toBe('required');
|
|
369
|
+
});
|
|
370
|
+
|
|
371
|
+
it('should handle tool choice none', async () => {
|
|
372
|
+
const result = await prepareResponsesTools({
|
|
373
|
+
tools: [
|
|
374
|
+
{
|
|
375
|
+
type: 'provider',
|
|
376
|
+
id: 'xai.web_search',
|
|
377
|
+
name: 'web_search',
|
|
378
|
+
args: {},
|
|
379
|
+
},
|
|
380
|
+
],
|
|
381
|
+
toolChoice: { type: 'none' },
|
|
382
|
+
});
|
|
383
|
+
|
|
384
|
+
expect(result.toolChoice).toBe('none');
|
|
385
|
+
});
|
|
386
|
+
|
|
387
|
+
it('should handle specific tool choice', async () => {
|
|
388
|
+
const result = await prepareResponsesTools({
|
|
389
|
+
tools: [
|
|
390
|
+
{
|
|
391
|
+
type: 'function',
|
|
392
|
+
name: 'weather',
|
|
393
|
+
description: 'get weather',
|
|
394
|
+
inputSchema: { type: 'object', properties: {} },
|
|
395
|
+
},
|
|
396
|
+
],
|
|
397
|
+
toolChoice: { type: 'tool', toolName: 'weather' },
|
|
398
|
+
});
|
|
399
|
+
|
|
400
|
+
expect(result.toolChoice).toEqual({
|
|
401
|
+
type: 'function',
|
|
402
|
+
name: 'weather',
|
|
403
|
+
});
|
|
404
|
+
});
|
|
405
|
+
|
|
406
|
+
it('should handle provider-defined tool choice mapping', async () => {
|
|
407
|
+
const result = await prepareResponsesTools({
|
|
408
|
+
tools: [
|
|
409
|
+
{
|
|
410
|
+
type: 'provider',
|
|
411
|
+
id: 'xai.web_search',
|
|
412
|
+
name: 'web_search',
|
|
413
|
+
args: {},
|
|
414
|
+
},
|
|
415
|
+
],
|
|
416
|
+
toolChoice: { type: 'tool', toolName: 'web_search' },
|
|
417
|
+
});
|
|
418
|
+
|
|
419
|
+
expect(result.toolChoice).toEqual({ type: 'web_search' });
|
|
420
|
+
});
|
|
421
|
+
});
|
|
422
|
+
|
|
423
|
+
describe('multiple tools', () => {
|
|
424
|
+
it('should handle multiple tools including provider-defined and functions', async () => {
|
|
425
|
+
const result = await prepareResponsesTools({
|
|
426
|
+
tools: [
|
|
427
|
+
{
|
|
428
|
+
type: 'function',
|
|
429
|
+
name: 'calculator',
|
|
430
|
+
description: 'calculate numbers',
|
|
431
|
+
inputSchema: { type: 'object', properties: {} },
|
|
432
|
+
},
|
|
433
|
+
{
|
|
434
|
+
type: 'provider',
|
|
435
|
+
id: 'xai.web_search',
|
|
436
|
+
name: 'web_search',
|
|
437
|
+
args: {},
|
|
438
|
+
},
|
|
439
|
+
{
|
|
440
|
+
type: 'provider',
|
|
441
|
+
id: 'xai.x_search',
|
|
442
|
+
name: 'x_search',
|
|
443
|
+
args: {},
|
|
444
|
+
},
|
|
445
|
+
],
|
|
446
|
+
});
|
|
447
|
+
|
|
448
|
+
expect(result.tools).toHaveLength(3);
|
|
449
|
+
expect(result.tools?.[0].type).toBe('function');
|
|
450
|
+
expect(result.tools?.[1].type).toBe('web_search');
|
|
451
|
+
expect(result.tools?.[2].type).toBe('x_search');
|
|
452
|
+
});
|
|
453
|
+
});
|
|
454
|
+
|
|
455
|
+
describe('empty tools', () => {
|
|
456
|
+
it('should return undefined for empty tools array', async () => {
|
|
457
|
+
const result = await prepareResponsesTools({
|
|
458
|
+
tools: [],
|
|
459
|
+
});
|
|
460
|
+
|
|
461
|
+
expect(result.tools).toBeUndefined();
|
|
462
|
+
expect(result.toolChoice).toBeUndefined();
|
|
463
|
+
});
|
|
464
|
+
|
|
465
|
+
it('should return undefined for undefined tools', async () => {
|
|
466
|
+
const result = await prepareResponsesTools({
|
|
467
|
+
tools: undefined,
|
|
468
|
+
});
|
|
469
|
+
|
|
470
|
+
expect(result.tools).toBeUndefined();
|
|
471
|
+
});
|
|
472
|
+
});
|
|
473
|
+
|
|
474
|
+
describe('unsupported tools', () => {
|
|
475
|
+
it('should warn about unsupported provider-defined tools', async () => {
|
|
476
|
+
const result = await prepareResponsesTools({
|
|
477
|
+
tools: [
|
|
478
|
+
{
|
|
479
|
+
type: 'provider',
|
|
480
|
+
id: 'unsupported.tool',
|
|
481
|
+
name: 'unsupported',
|
|
482
|
+
args: {},
|
|
483
|
+
},
|
|
484
|
+
],
|
|
485
|
+
});
|
|
486
|
+
|
|
487
|
+
expect(result.toolWarnings).toMatchInlineSnapshot(`
|
|
488
|
+
[
|
|
489
|
+
{
|
|
490
|
+
"feature": "provider-defined tool unsupported",
|
|
491
|
+
"type": "unsupported",
|
|
492
|
+
},
|
|
493
|
+
]
|
|
494
|
+
`);
|
|
495
|
+
});
|
|
496
|
+
});
|
|
497
|
+
});
|