Skip to content

Commit 35fe06e

Browse files
committed
fix(api): correct types for message attachment tools (#787)
1 parent 7325009 commit 35fe06e

File tree

6 files changed

+269
-40
lines changed

6 files changed

+269
-40
lines changed

src/resources/beta/threads/messages.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import * as Core from 'openai/core';
44
import { APIResource } from 'openai/resource';
55
import { isRequestOptions } from 'openai/core';
66
import * as MessagesAPI from 'openai/resources/beta/threads/messages';
7+
import * as AssistantsAPI from 'openai/resources/beta/assistants';
78
import { CursorPage, type CursorPageParams } from 'openai/pagination';
89

910
export class Messages extends APIResource {
@@ -374,7 +375,10 @@ export namespace Message {
374375
*/
375376
file_id?: string;
376377

377-
tools?: Array<'file_search' | 'code_interpreter'>;
378+
/**
379+
* The tools to add this file to.
380+
*/
381+
tools?: Array<AssistantsAPI.CodeInterpreterTool | AssistantsAPI.FileSearchTool>;
378382
}
379383

380384
/**
@@ -528,7 +532,10 @@ export namespace MessageCreateParams {
528532
*/
529533
file_id?: string;
530534

531-
tools?: Array<'file_search' | 'code_interpreter'>;
535+
/**
536+
* The tools to add this file to.
537+
*/
538+
tools?: Array<AssistantsAPI.CodeInterpreterTool | AssistantsAPI.FileSearchTool>;
532539
}
533540
}
534541

src/resources/beta/threads/runs/runs.ts

+16-4
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,10 @@ export namespace RunCreateParams {
780780
*/
781781
file_id?: string;
782782

783-
tools?: Array<'file_search' | 'code_interpreter'>;
783+
/**
784+
* The tools to add this file to.
785+
*/
786+
tools?: Array<AssistantsAPI.CodeInterpreterTool | AssistantsAPI.FileSearchTool>;
784787
}
785788
}
786789

@@ -1028,7 +1031,10 @@ export namespace RunCreateAndPollParams {
10281031
*/
10291032
file_id?: string;
10301033

1031-
tools?: Array<'file_search' | 'code_interpreter'>;
1034+
/**
1035+
* The tools to add this file to.
1036+
*/
1037+
tools?: Array<AssistantsAPI.CodeInterpreterTool | AssistantsAPI.FileSearchTool>;
10321038
}
10331039
}
10341040

@@ -1229,7 +1235,10 @@ export namespace RunCreateAndStreamParams {
12291235
*/
12301236
file_id?: string;
12311237

1232-
tools?: Array<'file_search' | 'code_interpreter'>;
1238+
/**
1239+
* The tools to add this file to.
1240+
*/
1241+
tools?: Array<AssistantsAPI.CodeInterpreterTool | AssistantsAPI.FileSearchTool>;
12331242
}
12341243
}
12351244

@@ -1430,7 +1439,10 @@ export namespace RunStreamParams {
14301439
*/
14311440
file_id?: string;
14321441

1433-
tools?: Array<'file_search' | 'code_interpreter'>;
1442+
/**
1443+
* The tools to add this file to.
1444+
*/
1445+
tools?: Array<AssistantsAPI.CodeInterpreterTool | AssistantsAPI.FileSearchTool>;
14341446
}
14351447
}
14361448

src/resources/beta/threads/threads.ts

+16-4
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,10 @@ export namespace ThreadCreateParams {
318318
*/
319319
file_id?: string;
320320

321-
tools?: Array<'file_search' | 'code_interpreter'>;
321+
/**
322+
* The tools to add this file to.
323+
*/
324+
tools?: Array<AssistantsAPI.CodeInterpreterTool | AssistantsAPI.FileSearchTool>;
322325
}
323326
}
324327

@@ -653,7 +656,10 @@ export namespace ThreadCreateAndRunParams {
653656
*/
654657
file_id?: string;
655658

656-
tools?: Array<'file_search' | 'code_interpreter'>;
659+
/**
660+
* The tools to add this file to.
661+
*/
662+
tools?: Array<AssistantsAPI.CodeInterpreterTool | AssistantsAPI.FileSearchTool>;
657663
}
658664
}
659665

@@ -999,7 +1005,10 @@ export namespace ThreadCreateAndRunPollParams {
9991005
*/
10001006
file_id?: string;
10011007

1002-
tools?: Array<'file_search' | 'code_interpreter'>;
1008+
/**
1009+
* The tools to add this file to.
1010+
*/
1011+
tools?: Array<AssistantsAPI.CodeInterpreterTool | AssistantsAPI.FileSearchTool>;
10031012
}
10041013
}
10051014

@@ -1324,7 +1333,10 @@ export namespace ThreadCreateAndRunStreamParams {
13241333
*/
13251334
file_id?: string;
13261335

1327-
tools?: Array<'file_search' | 'code_interpreter'>;
1336+
/**
1337+
* The tools to add this file to.
1338+
*/
1339+
tools?: Array<AssistantsAPI.CodeInterpreterTool | AssistantsAPI.FileSearchTool>;
13281340
}
13291341
}
13301342

tests/api-resources/beta/threads/messages.test.ts

+12-3
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,18 @@ describe('resource messages', () => {
2525
content: 'x',
2626
role: 'user',
2727
attachments: [
28-
{ file_id: 'string', tools: ['file_search', 'code_interpreter'] },
29-
{ file_id: 'string', tools: ['file_search', 'code_interpreter'] },
30-
{ file_id: 'string', tools: ['file_search', 'code_interpreter'] },
28+
{
29+
file_id: 'string',
30+
tools: [{ type: 'code_interpreter' }, { type: 'code_interpreter' }, { type: 'code_interpreter' }],
31+
},
32+
{
33+
file_id: 'string',
34+
tools: [{ type: 'code_interpreter' }, { type: 'code_interpreter' }, { type: 'code_interpreter' }],
35+
},
36+
{
37+
file_id: 'string',
38+
tools: [{ type: 'code_interpreter' }, { type: 'code_interpreter' }, { type: 'code_interpreter' }],
39+
},
3140
],
3241
metadata: {},
3342
});

tests/api-resources/beta/threads/runs/runs.test.ts

+72-9
Original file line numberDiff line numberDiff line change
@@ -29,29 +29,92 @@ describe('resource runs', () => {
2929
role: 'user',
3030
content: 'x',
3131
attachments: [
32-
{ file_id: 'string', tools: ['file_search', 'code_interpreter'] },
33-
{ file_id: 'string', tools: ['file_search', 'code_interpreter'] },
34-
{ file_id: 'string', tools: ['file_search', 'code_interpreter'] },
32+
{
33+
file_id: 'string',
34+
tools: [
35+
{ type: 'code_interpreter' },
36+
{ type: 'code_interpreter' },
37+
{ type: 'code_interpreter' },
38+
],
39+
},
40+
{
41+
file_id: 'string',
42+
tools: [
43+
{ type: 'code_interpreter' },
44+
{ type: 'code_interpreter' },
45+
{ type: 'code_interpreter' },
46+
],
47+
},
48+
{
49+
file_id: 'string',
50+
tools: [
51+
{ type: 'code_interpreter' },
52+
{ type: 'code_interpreter' },
53+
{ type: 'code_interpreter' },
54+
],
55+
},
3556
],
3657
metadata: {},
3758
},
3859
{
3960
role: 'user',
4061
content: 'x',
4162
attachments: [
42-
{ file_id: 'string', tools: ['file_search', 'code_interpreter'] },
43-
{ file_id: 'string', tools: ['file_search', 'code_interpreter'] },
44-
{ file_id: 'string', tools: ['file_search', 'code_interpreter'] },
63+
{
64+
file_id: 'string',
65+
tools: [
66+
{ type: 'code_interpreter' },
67+
{ type: 'code_interpreter' },
68+
{ type: 'code_interpreter' },
69+
],
70+
},
71+
{
72+
file_id: 'string',
73+
tools: [
74+
{ type: 'code_interpreter' },
75+
{ type: 'code_interpreter' },
76+
{ type: 'code_interpreter' },
77+
],
78+
},
79+
{
80+
file_id: 'string',
81+
tools: [
82+
{ type: 'code_interpreter' },
83+
{ type: 'code_interpreter' },
84+
{ type: 'code_interpreter' },
85+
],
86+
},
4587
],
4688
metadata: {},
4789
},
4890
{
4991
role: 'user',
5092
content: 'x',
5193
attachments: [
52-
{ file_id: 'string', tools: ['file_search', 'code_interpreter'] },
53-
{ file_id: 'string', tools: ['file_search', 'code_interpreter'] },
54-
{ file_id: 'string', tools: ['file_search', 'code_interpreter'] },
94+
{
95+
file_id: 'string',
96+
tools: [
97+
{ type: 'code_interpreter' },
98+
{ type: 'code_interpreter' },
99+
{ type: 'code_interpreter' },
100+
],
101+
},
102+
{
103+
file_id: 'string',
104+
tools: [
105+
{ type: 'code_interpreter' },
106+
{ type: 'code_interpreter' },
107+
{ type: 'code_interpreter' },
108+
],
109+
},
110+
{
111+
file_id: 'string',
112+
tools: [
113+
{ type: 'code_interpreter' },
114+
{ type: 'code_interpreter' },
115+
{ type: 'code_interpreter' },
116+
],
117+
},
55118
],
56119
metadata: {},
57120
},

0 commit comments

Comments
 (0)