@ai-sdk/openai 0.0.0-2f1ae29d-20260122140908 → 0.0.0-4115c213-20260122152721

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.
Files changed (63) hide show
  1. package/CHANGELOG.md +17 -2
  2. package/dist/index.js +15 -1
  3. package/dist/index.js.map +1 -1
  4. package/dist/index.mjs +15 -1
  5. package/dist/index.mjs.map +1 -1
  6. package/dist/internal/index.js +14 -0
  7. package/dist/internal/index.js.map +1 -1
  8. package/dist/internal/index.mjs +14 -0
  9. package/dist/internal/index.mjs.map +1 -1
  10. package/package.json +9 -5
  11. package/src/responses/convert-to-openai-responses-input.ts +20 -1
  12. package/src/chat/__fixtures__/azure-model-router.1.chunks.txt +0 -8
  13. package/src/chat/__snapshots__/openai-chat-language-model.test.ts.snap +0 -88
  14. package/src/chat/convert-to-openai-chat-messages.test.ts +0 -516
  15. package/src/chat/openai-chat-language-model.test.ts +0 -3496
  16. package/src/chat/openai-chat-prepare-tools.test.ts +0 -322
  17. package/src/completion/openai-completion-language-model.test.ts +0 -752
  18. package/src/embedding/__snapshots__/openai-embedding-model.test.ts.snap +0 -43
  19. package/src/embedding/openai-embedding-model.test.ts +0 -146
  20. package/src/image/openai-image-model.test.ts +0 -722
  21. package/src/openai-error.test.ts +0 -34
  22. package/src/openai-language-model-capabilities.test.ts +0 -93
  23. package/src/openai-provider.test.ts +0 -98
  24. package/src/responses/__fixtures__/openai-apply-patch-tool-delete.1.chunks.txt +0 -5
  25. package/src/responses/__fixtures__/openai-apply-patch-tool.1.chunks.txt +0 -38
  26. package/src/responses/__fixtures__/openai-apply-patch-tool.1.json +0 -69
  27. package/src/responses/__fixtures__/openai-code-interpreter-tool.1.chunks.txt +0 -393
  28. package/src/responses/__fixtures__/openai-code-interpreter-tool.1.json +0 -137
  29. package/src/responses/__fixtures__/openai-error.1.chunks.txt +0 -4
  30. package/src/responses/__fixtures__/openai-error.1.json +0 -8
  31. package/src/responses/__fixtures__/openai-file-search-tool.1.chunks.txt +0 -94
  32. package/src/responses/__fixtures__/openai-file-search-tool.1.json +0 -89
  33. package/src/responses/__fixtures__/openai-file-search-tool.2.chunks.txt +0 -93
  34. package/src/responses/__fixtures__/openai-file-search-tool.2.json +0 -112
  35. package/src/responses/__fixtures__/openai-image-generation-tool.1.chunks.txt +0 -16
  36. package/src/responses/__fixtures__/openai-image-generation-tool.1.json +0 -96
  37. package/src/responses/__fixtures__/openai-local-shell-tool.1.chunks.txt +0 -7
  38. package/src/responses/__fixtures__/openai-local-shell-tool.1.json +0 -70
  39. package/src/responses/__fixtures__/openai-mcp-tool-approval.1.chunks.txt +0 -11
  40. package/src/responses/__fixtures__/openai-mcp-tool-approval.1.json +0 -169
  41. package/src/responses/__fixtures__/openai-mcp-tool-approval.2.chunks.txt +0 -123
  42. package/src/responses/__fixtures__/openai-mcp-tool-approval.2.json +0 -176
  43. package/src/responses/__fixtures__/openai-mcp-tool-approval.3.chunks.txt +0 -11
  44. package/src/responses/__fixtures__/openai-mcp-tool-approval.3.json +0 -169
  45. package/src/responses/__fixtures__/openai-mcp-tool-approval.4.chunks.txt +0 -84
  46. package/src/responses/__fixtures__/openai-mcp-tool-approval.4.json +0 -182
  47. package/src/responses/__fixtures__/openai-mcp-tool.1.chunks.txt +0 -373
  48. package/src/responses/__fixtures__/openai-mcp-tool.1.json +0 -159
  49. package/src/responses/__fixtures__/openai-reasoning-encrypted-content.1.chunks.txt +0 -110
  50. package/src/responses/__fixtures__/openai-reasoning-encrypted-content.1.json +0 -117
  51. package/src/responses/__fixtures__/openai-shell-tool.1.chunks.txt +0 -182
  52. package/src/responses/__fixtures__/openai-shell-tool.1.json +0 -73
  53. package/src/responses/__fixtures__/openai-web-search-tool.1.chunks.txt +0 -185
  54. package/src/responses/__fixtures__/openai-web-search-tool.1.json +0 -266
  55. package/src/responses/__snapshots__/openai-responses-language-model.test.ts.snap +0 -10955
  56. package/src/responses/convert-to-openai-responses-input.test.ts +0 -2976
  57. package/src/responses/openai-responses-api.test.ts +0 -89
  58. package/src/responses/openai-responses-language-model.test.ts +0 -6927
  59. package/src/responses/openai-responses-prepare-tools.test.ts +0 -924
  60. package/src/speech/openai-speech-model.test.ts +0 -202
  61. package/src/tool/local-shell.test-d.ts +0 -20
  62. package/src/tool/web-search.test-d.ts +0 -13
  63. package/src/transcription/openai-transcription-model.test.ts +0 -507
@@ -1,924 +0,0 @@
1
- import { ToolNameMapping } from '@ai-sdk/provider-utils';
2
- import { prepareResponsesTools } from './openai-responses-prepare-tools';
3
- import { describe, it, expect } from 'vitest';
4
-
5
- describe('prepareResponsesTools', () => {
6
- describe('function tools strict mode', () => {
7
- it('should pass through strict mode when strict is true', async () => {
8
- const result = await prepareResponsesTools({
9
- tools: [
10
- {
11
- type: 'function',
12
- name: 'testFunction',
13
- description: 'A test function',
14
- inputSchema: { type: 'object', properties: {} },
15
- strict: true,
16
- },
17
- ],
18
- toolChoice: undefined,
19
- });
20
-
21
- expect(result).toMatchInlineSnapshot(`
22
- {
23
- "toolChoice": undefined,
24
- "toolWarnings": [],
25
- "tools": [
26
- {
27
- "description": "A test function",
28
- "name": "testFunction",
29
- "parameters": {
30
- "properties": {},
31
- "type": "object",
32
- },
33
- "strict": true,
34
- "type": "function",
35
- },
36
- ],
37
- }
38
- `);
39
- });
40
-
41
- it('should pass through strict mode when strict is false', async () => {
42
- const result = await prepareResponsesTools({
43
- tools: [
44
- {
45
- type: 'function',
46
- name: 'testFunction',
47
- description: 'A test function',
48
- inputSchema: { type: 'object', properties: {} },
49
- strict: false,
50
- },
51
- ],
52
- toolChoice: undefined,
53
- });
54
-
55
- expect(result).toMatchInlineSnapshot(`
56
- {
57
- "toolChoice": undefined,
58
- "toolWarnings": [],
59
- "tools": [
60
- {
61
- "description": "A test function",
62
- "name": "testFunction",
63
- "parameters": {
64
- "properties": {},
65
- "type": "object",
66
- },
67
- "strict": false,
68
- "type": "function",
69
- },
70
- ],
71
- }
72
- `);
73
- });
74
-
75
- it('should not include strict mode when strict is undefined', async () => {
76
- const result = await prepareResponsesTools({
77
- tools: [
78
- {
79
- type: 'function',
80
- name: 'testFunction',
81
- description: 'A test function',
82
- inputSchema: { type: 'object', properties: {} },
83
- },
84
- ],
85
- toolChoice: undefined,
86
- });
87
-
88
- expect(result).toMatchInlineSnapshot(`
89
- {
90
- "toolChoice": undefined,
91
- "toolWarnings": [],
92
- "tools": [
93
- {
94
- "description": "A test function",
95
- "name": "testFunction",
96
- "parameters": {
97
- "properties": {},
98
- "type": "object",
99
- },
100
- "type": "function",
101
- },
102
- ],
103
- }
104
- `);
105
- });
106
-
107
- it('should pass through strict mode for multiple tools with different strict settings', async () => {
108
- const result = await prepareResponsesTools({
109
- tools: [
110
- {
111
- type: 'function',
112
- name: 'strictTool',
113
- description: 'A strict tool',
114
- inputSchema: { type: 'object', properties: {} },
115
- strict: true,
116
- },
117
- {
118
- type: 'function',
119
- name: 'nonStrictTool',
120
- description: 'A non-strict tool',
121
- inputSchema: { type: 'object', properties: {} },
122
- strict: false,
123
- },
124
- {
125
- type: 'function',
126
- name: 'defaultTool',
127
- description: 'A tool without strict setting',
128
- inputSchema: { type: 'object', properties: {} },
129
- },
130
- ],
131
- toolChoice: undefined,
132
- });
133
-
134
- expect(result).toMatchInlineSnapshot(`
135
- {
136
- "toolChoice": undefined,
137
- "toolWarnings": [],
138
- "tools": [
139
- {
140
- "description": "A strict tool",
141
- "name": "strictTool",
142
- "parameters": {
143
- "properties": {},
144
- "type": "object",
145
- },
146
- "strict": true,
147
- "type": "function",
148
- },
149
- {
150
- "description": "A non-strict tool",
151
- "name": "nonStrictTool",
152
- "parameters": {
153
- "properties": {},
154
- "type": "object",
155
- },
156
- "strict": false,
157
- "type": "function",
158
- },
159
- {
160
- "description": "A tool without strict setting",
161
- "name": "defaultTool",
162
- "parameters": {
163
- "properties": {},
164
- "type": "object",
165
- },
166
- "type": "function",
167
- },
168
- ],
169
- }
170
- `);
171
- });
172
- });
173
-
174
- describe('code interpreter', () => {
175
- it('should prepare code interpreter tool with no container (auto mode)', async () => {
176
- const result = await prepareResponsesTools({
177
- tools: [
178
- {
179
- type: 'provider',
180
- id: 'openai.code_interpreter',
181
- name: 'code_interpreter',
182
- args: {},
183
- },
184
- ],
185
- toolChoice: undefined,
186
- });
187
-
188
- expect(result).toMatchInlineSnapshot(`
189
- {
190
- "toolChoice": undefined,
191
- "toolWarnings": [],
192
- "tools": [
193
- {
194
- "container": {
195
- "file_ids": undefined,
196
- "type": "auto",
197
- },
198
- "type": "code_interpreter",
199
- },
200
- ],
201
- }
202
- `);
203
- });
204
-
205
- it('should prepare code interpreter tool with string container ID', async () => {
206
- const result = await prepareResponsesTools({
207
- tools: [
208
- {
209
- type: 'provider',
210
- id: 'openai.code_interpreter',
211
- name: 'code_interpreter',
212
- args: {
213
- container: 'container-123',
214
- },
215
- },
216
- ],
217
- toolChoice: undefined,
218
- });
219
-
220
- expect(result).toMatchInlineSnapshot(`
221
- {
222
- "toolChoice": undefined,
223
- "toolWarnings": [],
224
- "tools": [
225
- {
226
- "container": "container-123",
227
- "type": "code_interpreter",
228
- },
229
- ],
230
- }
231
- `);
232
- });
233
-
234
- it('should prepare code interpreter tool with file IDs container', async () => {
235
- const result = await prepareResponsesTools({
236
- tools: [
237
- {
238
- type: 'provider',
239
- id: 'openai.code_interpreter',
240
- name: 'code_interpreter',
241
- args: {
242
- container: {
243
- fileIds: ['file-1', 'file-2', 'file-3'],
244
- },
245
- },
246
- },
247
- ],
248
- toolChoice: undefined,
249
- });
250
-
251
- expect(result).toMatchInlineSnapshot(`
252
- {
253
- "toolChoice": undefined,
254
- "toolWarnings": [],
255
- "tools": [
256
- {
257
- "container": {
258
- "file_ids": [
259
- "file-1",
260
- "file-2",
261
- "file-3",
262
- ],
263
- "type": "auto",
264
- },
265
- "type": "code_interpreter",
266
- },
267
- ],
268
- }
269
- `);
270
- });
271
-
272
- it('should prepare code interpreter tool with empty file IDs array', async () => {
273
- const result = await prepareResponsesTools({
274
- tools: [
275
- {
276
- type: 'provider',
277
- id: 'openai.code_interpreter',
278
- name: 'code_interpreter',
279
- args: {
280
- container: {
281
- fileIds: [],
282
- },
283
- },
284
- },
285
- ],
286
- toolChoice: undefined,
287
- });
288
-
289
- expect(result).toMatchInlineSnapshot(`
290
- {
291
- "toolChoice": undefined,
292
- "toolWarnings": [],
293
- "tools": [
294
- {
295
- "container": {
296
- "file_ids": [],
297
- "type": "auto",
298
- },
299
- "type": "code_interpreter",
300
- },
301
- ],
302
- }
303
- `);
304
- });
305
-
306
- it('should prepare code interpreter tool with undefined file IDs', async () => {
307
- const result = await prepareResponsesTools({
308
- tools: [
309
- {
310
- type: 'provider',
311
- id: 'openai.code_interpreter',
312
- name: 'code_interpreter',
313
- args: {
314
- container: {
315
- fileIds: undefined,
316
- },
317
- },
318
- },
319
- ],
320
- toolChoice: undefined,
321
- });
322
-
323
- expect(result).toMatchInlineSnapshot(`
324
- {
325
- "toolChoice": undefined,
326
- "toolWarnings": [],
327
- "tools": [
328
- {
329
- "container": {
330
- "file_ids": undefined,
331
- "type": "auto",
332
- },
333
- "type": "code_interpreter",
334
- },
335
- ],
336
- }
337
- `);
338
- });
339
-
340
- it('should handle tool choice selection with code interpreter', async () => {
341
- const result = await prepareResponsesTools({
342
- tools: [
343
- {
344
- type: 'provider',
345
- id: 'openai.code_interpreter',
346
- name: 'code_interpreter',
347
- args: {},
348
- },
349
- ],
350
- toolChoice: {
351
- type: 'tool',
352
- toolName: 'code_interpreter',
353
- },
354
- });
355
-
356
- expect(result).toMatchInlineSnapshot(`
357
- {
358
- "toolChoice": {
359
- "type": "code_interpreter",
360
- },
361
- "toolWarnings": [],
362
- "tools": [
363
- {
364
- "container": {
365
- "file_ids": undefined,
366
- "type": "auto",
367
- },
368
- "type": "code_interpreter",
369
- },
370
- ],
371
- }
372
- `);
373
- });
374
-
375
- it('should handle multiple tools including code interpreter', async () => {
376
- const result = await prepareResponsesTools({
377
- tools: [
378
- {
379
- type: 'function',
380
- name: 'testFunction',
381
- description: 'A test function',
382
- inputSchema: {
383
- type: 'object',
384
- properties: {
385
- input: { type: 'string' },
386
- },
387
- },
388
- },
389
- {
390
- type: 'provider',
391
- id: 'openai.code_interpreter',
392
- name: 'code_interpreter',
393
- args: {
394
- container: 'my-container',
395
- },
396
- },
397
- ],
398
- toolChoice: undefined,
399
- });
400
-
401
- expect(result).toMatchInlineSnapshot(`
402
- {
403
- "toolChoice": undefined,
404
- "toolWarnings": [],
405
- "tools": [
406
- {
407
- "description": "A test function",
408
- "name": "testFunction",
409
- "parameters": {
410
- "properties": {
411
- "input": {
412
- "type": "string",
413
- },
414
- },
415
- "type": "object",
416
- },
417
- "type": "function",
418
- },
419
- {
420
- "container": "my-container",
421
- "type": "code_interpreter",
422
- },
423
- ],
424
- }
425
- `);
426
- });
427
- });
428
-
429
- describe('image generation', () => {
430
- it('should prepare image_generation tool with all options', async () => {
431
- const result = await prepareResponsesTools({
432
- tools: [
433
- {
434
- type: 'provider',
435
- id: 'openai.image_generation',
436
- name: 'image_generation',
437
- args: {
438
- background: 'opaque',
439
- size: '1536x1024',
440
- quality: 'high',
441
- moderation: 'auto',
442
- outputFormat: 'png',
443
- outputCompression: 100,
444
- },
445
- },
446
- ],
447
- toolChoice: undefined,
448
- });
449
-
450
- expect(result).toMatchInlineSnapshot(`
451
- {
452
- "toolChoice": undefined,
453
- "toolWarnings": [],
454
- "tools": [
455
- {
456
- "background": "opaque",
457
- "input_fidelity": undefined,
458
- "input_image_mask": undefined,
459
- "model": undefined,
460
- "moderation": "auto",
461
- "output_compression": 100,
462
- "output_format": "png",
463
- "partial_images": undefined,
464
- "quality": "high",
465
- "size": "1536x1024",
466
- "type": "image_generation",
467
- },
468
- ],
469
- }
470
- `);
471
- });
472
-
473
- it('should support tool choice selection for image_generation', async () => {
474
- const result = await prepareResponsesTools({
475
- tools: [
476
- {
477
- type: 'provider',
478
- id: 'openai.image_generation',
479
- name: 'image_generation',
480
- args: {},
481
- },
482
- ],
483
- toolChoice: { type: 'tool', toolName: 'image_generation' },
484
- });
485
-
486
- expect(result.tools).toMatchInlineSnapshot(`
487
- [
488
- {
489
- "background": undefined,
490
- "input_fidelity": undefined,
491
- "input_image_mask": undefined,
492
- "model": undefined,
493
- "moderation": undefined,
494
- "output_compression": undefined,
495
- "output_format": undefined,
496
- "partial_images": undefined,
497
- "quality": undefined,
498
- "size": undefined,
499
- "type": "image_generation",
500
- },
501
- ]
502
- `);
503
- });
504
- });
505
-
506
- describe('local shell', () => {
507
- it('should prepare local_shell tool', async () => {
508
- const result = await prepareResponsesTools({
509
- tools: [
510
- {
511
- type: 'provider',
512
- id: 'openai.local_shell',
513
- name: 'local_shell',
514
- args: {},
515
- },
516
- ],
517
- toolChoice: undefined,
518
- });
519
-
520
- expect(result).toMatchInlineSnapshot(`
521
- {
522
- "toolChoice": undefined,
523
- "toolWarnings": [],
524
- "tools": [
525
- {
526
- "type": "local_shell",
527
- },
528
- ],
529
- }
530
- `);
531
- });
532
- });
533
-
534
- describe('web search', () => {
535
- it('should prepare web_search tool with no options', async () => {
536
- const result = await prepareResponsesTools({
537
- tools: [
538
- {
539
- type: 'provider',
540
- id: 'openai.web_search',
541
- name: 'web_search',
542
- args: {},
543
- },
544
- ],
545
- toolChoice: undefined,
546
- });
547
-
548
- expect(result).toMatchInlineSnapshot(`
549
- {
550
- "toolChoice": undefined,
551
- "toolWarnings": [],
552
- "tools": [
553
- {
554
- "external_web_access": undefined,
555
- "filters": undefined,
556
- "search_context_size": undefined,
557
- "type": "web_search",
558
- "user_location": undefined,
559
- },
560
- ],
561
- }
562
- `);
563
- });
564
-
565
- it('should prepare web_search tool with externalWebAccess set to true', async () => {
566
- const result = await prepareResponsesTools({
567
- tools: [
568
- {
569
- type: 'provider',
570
- id: 'openai.web_search',
571
- name: 'web_search',
572
- args: {
573
- externalWebAccess: true,
574
- },
575
- },
576
- ],
577
- toolChoice: undefined,
578
- });
579
-
580
- expect(result).toMatchInlineSnapshot(`
581
- {
582
- "toolChoice": undefined,
583
- "toolWarnings": [],
584
- "tools": [
585
- {
586
- "external_web_access": true,
587
- "filters": undefined,
588
- "search_context_size": undefined,
589
- "type": "web_search",
590
- "user_location": undefined,
591
- },
592
- ],
593
- }
594
- `);
595
- });
596
-
597
- it('should prepare web_search tool with externalWebAccess set to false', async () => {
598
- const result = await prepareResponsesTools({
599
- tools: [
600
- {
601
- type: 'provider',
602
- id: 'openai.web_search',
603
- name: 'web_search',
604
- args: {
605
- externalWebAccess: false,
606
- },
607
- },
608
- ],
609
- toolChoice: undefined,
610
- });
611
-
612
- expect(result).toMatchInlineSnapshot(`
613
- {
614
- "toolChoice": undefined,
615
- "toolWarnings": [],
616
- "tools": [
617
- {
618
- "external_web_access": false,
619
- "filters": undefined,
620
- "search_context_size": undefined,
621
- "type": "web_search",
622
- "user_location": undefined,
623
- },
624
- ],
625
- }
626
- `);
627
- });
628
-
629
- it('should prepare web_search tool with all options including externalWebAccess', async () => {
630
- const result = await prepareResponsesTools({
631
- tools: [
632
- {
633
- type: 'provider',
634
- id: 'openai.web_search',
635
- name: 'web_search',
636
- args: {
637
- externalWebAccess: true,
638
- filters: {
639
- allowedDomains: ['example.com', 'test.org'],
640
- },
641
- searchContextSize: 'high',
642
- userLocation: {
643
- type: 'approximate',
644
- country: 'US',
645
- city: 'San Francisco',
646
- region: 'California',
647
- timezone: 'America/Los_Angeles',
648
- },
649
- },
650
- },
651
- ],
652
- toolChoice: undefined,
653
- });
654
-
655
- expect(result).toMatchInlineSnapshot(`
656
- {
657
- "toolChoice": undefined,
658
- "toolWarnings": [],
659
- "tools": [
660
- {
661
- "external_web_access": true,
662
- "filters": {
663
- "allowed_domains": [
664
- "example.com",
665
- "test.org",
666
- ],
667
- },
668
- "search_context_size": "high",
669
- "type": "web_search",
670
- "user_location": {
671
- "city": "San Francisco",
672
- "country": "US",
673
- "region": "California",
674
- "timezone": "America/Los_Angeles",
675
- "type": "approximate",
676
- },
677
- },
678
- ],
679
- }
680
- `);
681
- });
682
-
683
- it('should prepare web_search tool with filters but no externalWebAccess', async () => {
684
- const result = await prepareResponsesTools({
685
- tools: [
686
- {
687
- type: 'provider',
688
- id: 'openai.web_search',
689
- name: 'web_search',
690
- args: {
691
- filters: {
692
- allowedDomains: ['example.com'],
693
- },
694
- },
695
- },
696
- ],
697
- toolChoice: undefined,
698
- });
699
-
700
- expect(result).toMatchInlineSnapshot(`
701
- {
702
- "toolChoice": undefined,
703
- "toolWarnings": [],
704
- "tools": [
705
- {
706
- "external_web_access": undefined,
707
- "filters": {
708
- "allowed_domains": [
709
- "example.com",
710
- ],
711
- },
712
- "search_context_size": undefined,
713
- "type": "web_search",
714
- "user_location": undefined,
715
- },
716
- ],
717
- }
718
- `);
719
- });
720
-
721
- it('should handle tool choice selection with web_search', async () => {
722
- const result = await prepareResponsesTools({
723
- tools: [
724
- {
725
- type: 'provider',
726
- id: 'openai.web_search',
727
- name: 'web_search',
728
- args: {
729
- externalWebAccess: true,
730
- },
731
- },
732
- ],
733
- toolChoice: {
734
- type: 'tool',
735
- toolName: 'web_search',
736
- },
737
- });
738
-
739
- expect(result).toMatchInlineSnapshot(`
740
- {
741
- "toolChoice": {
742
- "type": "web_search",
743
- },
744
- "toolWarnings": [],
745
- "tools": [
746
- {
747
- "external_web_access": true,
748
- "filters": undefined,
749
- "search_context_size": undefined,
750
- "type": "web_search",
751
- "user_location": undefined,
752
- },
753
- ],
754
- }
755
- `);
756
- });
757
-
758
- it('should handle multiple tools including web_search', async () => {
759
- const result = await prepareResponsesTools({
760
- tools: [
761
- {
762
- type: 'function',
763
- name: 'testFunction',
764
- description: 'A test function',
765
- inputSchema: {
766
- type: 'object',
767
- properties: {
768
- input: { type: 'string' },
769
- },
770
- },
771
- },
772
- {
773
- type: 'provider',
774
- id: 'openai.web_search',
775
- name: 'web_search',
776
- args: {
777
- externalWebAccess: false,
778
- searchContextSize: 'medium',
779
- },
780
- },
781
- ],
782
- toolChoice: undefined,
783
- });
784
-
785
- expect(result).toMatchInlineSnapshot(`
786
- {
787
- "toolChoice": undefined,
788
- "toolWarnings": [],
789
- "tools": [
790
- {
791
- "description": "A test function",
792
- "name": "testFunction",
793
- "parameters": {
794
- "properties": {
795
- "input": {
796
- "type": "string",
797
- },
798
- },
799
- "type": "object",
800
- },
801
- "type": "function",
802
- },
803
- {
804
- "external_web_access": false,
805
- "filters": undefined,
806
- "search_context_size": "medium",
807
- "type": "web_search",
808
- "user_location": undefined,
809
- },
810
- ],
811
- }
812
- `);
813
- });
814
- });
815
-
816
- describe('apply_patch', () => {
817
- it('should prepare apply_patch tool', async () => {
818
- const result = await prepareResponsesTools({
819
- tools: [
820
- {
821
- type: 'provider',
822
- id: 'openai.apply_patch',
823
- name: 'apply_patch',
824
- args: {},
825
- },
826
- ],
827
- toolChoice: undefined,
828
- });
829
-
830
- expect(result).toMatchInlineSnapshot(`
831
- {
832
- "toolChoice": undefined,
833
- "toolWarnings": [],
834
- "tools": [
835
- {
836
- "type": "apply_patch",
837
- },
838
- ],
839
- }
840
- `);
841
- });
842
-
843
- it('should handle tool choice selection with apply_patch', async () => {
844
- const result = await prepareResponsesTools({
845
- tools: [
846
- {
847
- type: 'provider',
848
- id: 'openai.apply_patch',
849
- name: 'apply_patch',
850
- args: {},
851
- },
852
- ],
853
- toolChoice: {
854
- type: 'tool',
855
- toolName: 'apply_patch',
856
- },
857
- });
858
-
859
- expect(result).toMatchInlineSnapshot(`
860
- {
861
- "toolChoice": {
862
- "type": "apply_patch",
863
- },
864
- "toolWarnings": [],
865
- "tools": [
866
- {
867
- "type": "apply_patch",
868
- },
869
- ],
870
- }
871
- `);
872
- });
873
-
874
- it('should handle multiple tools including apply_patch', async () => {
875
- const result = await prepareResponsesTools({
876
- tools: [
877
- {
878
- type: 'function',
879
- name: 'testFunction',
880
- description: 'A test function',
881
- inputSchema: {
882
- type: 'object',
883
- properties: {
884
- input: { type: 'string' },
885
- },
886
- },
887
- },
888
- {
889
- type: 'provider',
890
- id: 'openai.apply_patch',
891
- name: 'apply_patch',
892
- args: {},
893
- },
894
- ],
895
- toolChoice: undefined,
896
- });
897
-
898
- expect(result).toMatchInlineSnapshot(`
899
- {
900
- "toolChoice": undefined,
901
- "toolWarnings": [],
902
- "tools": [
903
- {
904
- "description": "A test function",
905
- "name": "testFunction",
906
- "parameters": {
907
- "properties": {
908
- "input": {
909
- "type": "string",
910
- },
911
- },
912
- "type": "object",
913
- },
914
- "type": "function",
915
- },
916
- {
917
- "type": "apply_patch",
918
- },
919
- ],
920
- }
921
- `);
922
- });
923
- });
924
- });