3
3
import pytest
4
4
import os
5
5
import sys
6
+ import openai
6
7
import autogen
7
8
from autogen import OpenAIWrapper
9
+ from autogen .agentchat .contrib .gpt_assistant_agent import GPTAssistantAgent
10
+ from autogen .oai .openai_utils import retrieve_assistants_by_name
8
11
9
12
sys .path .append (os .path .join (os .path .dirname (__file__ ), "../.." ))
10
- from conftest import skip_openai # noqa: E402
13
+ from conftest import skip_openai as skip # noqa: E402
11
14
12
15
sys .path .append (os .path .join (os .path .dirname (__file__ ), ".." ))
13
16
from test_assistant_agent import KEY_LOC , OAI_CONFIG_LIST # noqa: E402
14
17
15
- try :
16
- import openai
17
- from autogen .agentchat .contrib .gpt_assistant_agent import GPTAssistantAgent
18
- from autogen .oai .openai_utils import retrieve_assistants_by_name
19
-
20
- except ImportError :
21
- skip = True
22
- else :
23
- skip = False or skip_openai
24
-
25
18
if not skip :
26
19
openai_config_list = autogen .config_list_from_json (
27
20
OAI_CONFIG_LIST , file_location = KEY_LOC , filter_dict = {"api_type" : ["openai" ]}
34
27
35
28
36
29
@pytest .mark .skipif (
37
- sys . platform in [ "darwin" , "win32" ] or skip ,
38
- reason = "do not run on MacOS or windows OR dependency is not installed OR requested to skip" ,
30
+ skip ,
31
+ reason = "requested to skip" ,
39
32
)
40
33
def test_config_list () -> None :
41
34
assert len (openai_config_list ) > 0
42
35
assert len (aoai_config_list ) > 0
43
36
44
37
45
38
@pytest .mark .skipif (
46
- sys . platform in [ "darwin" , "win32" ] or skip ,
47
- reason = "do not run on MacOS or windows OR dependency is not installed OR requested to skip" ,
39
+ skip ,
40
+ reason = "requested to skip" ,
48
41
)
49
42
def test_gpt_assistant_chat () -> None :
50
43
for gpt_config in [openai_config_list , aoai_config_list ]:
@@ -101,7 +94,7 @@ def ask_ossinsight(question: str) -> str:
101
94
# check the question asked
102
95
ask_ossinsight_mock .assert_called_once ()
103
96
question_asked = ask_ossinsight_mock .call_args [0 ][0 ].lower ()
104
- for word in "microsoft autogen star github " .split (" " ):
97
+ for word in "microsoft autogen star" .split (" " ):
105
98
assert word in question_asked
106
99
107
100
# check the answer
@@ -115,8 +108,8 @@ def ask_ossinsight(question: str) -> str:
115
108
116
109
117
110
@pytest .mark .skipif (
118
- sys . platform in [ "darwin" , "win32" ] or skip ,
119
- reason = "do not run on MacOS or windows OR dependency is not installed OR requested to skip" ,
111
+ skip ,
112
+ reason = "requested to skip" ,
120
113
)
121
114
def test_get_assistant_instructions () -> None :
122
115
for gpt_config in [openai_config_list , aoai_config_list ]:
@@ -144,8 +137,8 @@ def _test_get_assistant_instructions(gpt_config) -> None:
144
137
145
138
146
139
@pytest .mark .skipif (
147
- sys . platform in [ "darwin" , "win32" ] or skip ,
148
- reason = "do not run on MacOS or windows OR dependency is not installed OR requested to skip" ,
140
+ skip ,
141
+ reason = "requested to skip" ,
149
142
)
150
143
def test_gpt_assistant_instructions_overwrite () -> None :
151
144
for gpt_config in [openai_config_list , aoai_config_list ]:
@@ -197,8 +190,7 @@ def _test_gpt_assistant_instructions_overwrite(gpt_config) -> None:
197
190
198
191
199
192
@pytest .mark .skipif (
200
- sys .platform in ["darwin" , "win32" ] or skip ,
201
- reason = "do not run on MacOS or windows OR dependency is not installed OR requested to skip" ,
193
+ reason = "requested to skip" ,
202
194
)
203
195
def test_gpt_assistant_existing_no_instructions () -> None :
204
196
"""
@@ -237,8 +229,8 @@ def test_gpt_assistant_existing_no_instructions() -> None:
237
229
238
230
239
231
@pytest .mark .skipif (
240
- sys . platform in [ "darwin" , "win32" ] or skip ,
241
- reason = "do not run on MacOS or windows OR dependency is not installed OR requested to skip" ,
232
+ skip ,
233
+ reason = "requested to skip" ,
242
234
)
243
235
def test_get_assistant_files () -> None :
244
236
"""
@@ -274,8 +266,8 @@ def test_get_assistant_files() -> None:
274
266
275
267
276
268
@pytest .mark .skipif (
277
- sys . platform in [ "darwin" , "win32" ] or skip ,
278
- reason = "do not run on MacOS or windows OR dependency is not installed OR requested to skip" ,
269
+ skip ,
270
+ reason = "requested to skip" ,
279
271
)
280
272
def test_assistant_retrieval () -> None :
281
273
"""
@@ -347,8 +339,8 @@ def test_assistant_retrieval() -> None:
347
339
348
340
349
341
@pytest .mark .skipif (
350
- sys . platform in [ "darwin" , "win32" ] or skip ,
351
- reason = "do not run on MacOS or windows OR dependency is not installed OR requested to skip" ,
342
+ skip ,
343
+ reason = "requested to skip" ,
352
344
)
353
345
def test_assistant_mismatch_retrieval () -> None :
354
346
"""Test function to check if the GPTAssistantAgent can filter out the mismatch assistant"""
@@ -468,8 +460,8 @@ def test_assistant_mismatch_retrieval() -> None:
468
460
469
461
470
462
@pytest .mark .skipif (
471
- sys . platform in [ "darwin" , "win32" ] or skip ,
472
- reason = "do not run on MacOS or windows OR dependency is not installed OR requested to skip" ,
463
+ skip ,
464
+ reason = "requested to skip" ,
473
465
)
474
466
def test_gpt_assistant_tools_overwrite () -> None :
475
467
"""
0 commit comments