@@ -40,7 +40,6 @@ def test_assistants_crud(self, client, api_type, api_version, **kwargs):
40
40
assert retrieved_assistant .created_at == assistant .created_at
41
41
assert retrieved_assistant .description == assistant .description
42
42
assert retrieved_assistant .metadata == assistant .metadata
43
- assert retrieved_assistant .file_ids == assistant .file_ids
44
43
assert retrieved_assistant .object == assistant .object
45
44
46
45
list_assistants = client .beta .assistants .list ()
@@ -59,69 +58,6 @@ def test_assistants_crud(self, client, api_type, api_version, **kwargs):
59
58
assert delete_assistant .id == assistant .id
60
59
assert delete_assistant .deleted is True
61
60
62
- @configure
63
- @pytest .mark .parametrize ("api_type, api_version" , [(ASST_AZURE , PREVIEW ), (GPT_4_OPENAI , "v1" )])
64
- def test_assistants_files_crud (self , client , api_type , api_version , ** kwargs ):
65
- file_name = f"test{ uuid .uuid4 ()} .txt"
66
- with open (file_name , "w" ) as f :
67
- f .write ("test" )
68
-
69
- path = pathlib .Path (file_name )
70
-
71
- file1 = client .files .create (
72
- file = open (path , "rb" ),
73
- purpose = "assistants"
74
- )
75
-
76
- file2 = client .files .create (
77
- file = open (path , "rb" ),
78
- purpose = "assistants"
79
- )
80
-
81
- try :
82
- assistant = client .beta .assistants .create (
83
- name = "python test" ,
84
- instructions = "You are a personal math tutor. Write and run code to answer math questions." ,
85
- tools = [{"type" : "code_interpreter" }],
86
- file_ids = [file1 .id ],
87
- ** kwargs
88
- )
89
- assert assistant .file_ids == [file1 .id ]
90
-
91
- created_assistant_file = client .beta .assistants .files .create (
92
- assistant_id = assistant .id ,
93
- file_id = file2 .id
94
- )
95
-
96
- retrieved_assistant_file = client .beta .assistants .files .retrieve (
97
- assistant_id = assistant .id ,
98
- file_id = file2 .id
99
- )
100
- assert retrieved_assistant_file .id == created_assistant_file .id
101
- assert retrieved_assistant_file .object == created_assistant_file .object
102
- assert retrieved_assistant_file .created_at == created_assistant_file .created_at
103
- assert retrieved_assistant_file .assistant_id == created_assistant_file .assistant_id
104
-
105
- list_assistants_files = client .beta .assistants .files .list (
106
- assistant_id = assistant .id
107
- )
108
- for asst_file in list_assistants_files :
109
- assert asst_file .id
110
-
111
- delete_assistant_file = client .beta .assistants .files .delete (
112
- assistant_id = assistant .id ,
113
- file_id = file2 .id
114
- )
115
- assert delete_assistant_file .id == retrieved_assistant_file .id
116
- assert delete_assistant_file .deleted is True
117
- finally :
118
- os .remove (path )
119
- delete_assistant = client .beta .assistants .delete (
120
- assistant_id = assistant .id
121
- )
122
- assert delete_assistant .id == assistant .id
123
- assert delete_assistant .deleted is True
124
-
125
61
@configure
126
62
@pytest .mark .parametrize ("api_type, api_version" , [(ASST_AZURE , PREVIEW ), (GPT_4_OPENAI , "v1" )])
127
63
def test_assistants_threads_crud (self , client , api_type , api_version , ** kwargs ):
@@ -156,6 +92,7 @@ def test_assistants_threads_crud(self, client, api_type, api_version, **kwargs):
156
92
assert delete_thread .id == thread .id
157
93
assert delete_thread .deleted is True
158
94
95
+ @pytest .mark .skip (reason = "AOAI doesn't support assistants v2 yet" )
159
96
@configure
160
97
@pytest .mark .parametrize ("api_type, api_version" , [(ASST_AZURE , PREVIEW ), (GPT_4_OPENAI , "v1" )])
161
98
def test_assistants_messages_crud (self , client , api_type , api_version , ** kwargs ):
@@ -186,7 +123,12 @@ def test_assistants_messages_crud(self, client, api_type, api_version, **kwargs)
186
123
role = "user" ,
187
124
content = "what is 2+2?" ,
188
125
metadata = {"math" : "addition" },
189
- file_ids = [file .id ]
126
+ attachments = [
127
+ {
128
+ "file_id" : file .id ,
129
+ "tools" : [{"type" : "code_interpreter" }]
130
+ }
131
+ ]
190
132
)
191
133
retrieved_message = client .beta .threads .messages .retrieve (
192
134
thread_id = thread .id ,
@@ -200,28 +142,12 @@ def test_assistants_messages_crud(self, client, api_type, api_version, **kwargs)
200
142
assert retrieved_message .role == message .role
201
143
assert retrieved_message .content == message .content
202
144
203
- retrieved_message_file = client .beta .threads .messages .files .retrieve (
204
- thread_id = thread .id ,
205
- message_id = message .id ,
206
- file_id = file .id
207
- )
208
- assert retrieved_message_file .id
209
- assert retrieved_message_file .message_id
210
- assert retrieved_message_file .created_at
211
-
212
145
list_messages = client .beta .threads .messages .list (
213
146
thread_id = thread .id
214
147
)
215
148
for msg in list_messages :
216
149
assert msg .id
217
150
218
- list_message_files = client .beta .threads .messages .files .list (
219
- thread_id = thread .id ,
220
- message_id = message .id
221
- )
222
- for msg_file in list_message_files :
223
- assert msg_file .id
224
-
225
151
modify_message = client .beta .threads .messages .update (
226
152
thread_id = thread .id ,
227
153
message_id = message .id ,
0 commit comments