From 5d26276622ba5eba145271f658c9392386291cbb Mon Sep 17 00:00:00 2001 From: Chi Wang Date: Wed, 17 Apr 2024 13:10:18 -0700 Subject: [PATCH] improve test speed (#2406) * improve test speed * speed up test * speed up test --- test/agentchat/test_agent_logging.py | 2 +- test/agentchat/test_agent_usage.py | 6 +- test/agentchat/test_assistant_agent.py | 35 +++++------ test/agentchat/test_async.py | 40 ++++-------- test/agentchat/test_async_chats.py | 9 +-- test/agentchat/test_async_get_human_input.py | 21 +++---- test/agentchat/test_chats.py | 62 +++++++++++-------- test/agentchat/test_conversable_agent.py | 25 ++++---- .../agentchat/test_function_call_groupchat.py | 15 ++--- test/agentchat/test_human_input.py | 2 +- test/agentchat/test_math_user_proxy_agent.py | 5 +- test/agentchat/test_nested.py | 18 ++++-- 12 files changed, 116 insertions(+), 124 deletions(-) diff --git a/test/agentchat/test_agent_logging.py b/test/agentchat/test_agent_logging.py index 969bb395aa05..a776173253da 100644 --- a/test/agentchat/test_agent_logging.py +++ b/test/agentchat/test_agent_logging.py @@ -39,7 +39,7 @@ config_list = autogen.config_list_from_json( OAI_CONFIG_LIST, filter_dict={ - "model": ["gpt-4", "gpt-4-0314", "gpt-4-32k", "gpt-4-32k-0314", "gpt-4-32k-v0314"], + "model": ["gpt-3.5-turbo"], }, file_location=KEY_LOC, ) diff --git a/test/agentchat/test_agent_usage.py b/test/agentchat/test_agent_usage.py index 72d018fe27ef..5ce8d1c1875d 100755 --- a/test/agentchat/test_agent_usage.py +++ b/test/agentchat/test_agent_usage.py @@ -85,15 +85,14 @@ def test_agent_usage(): config_list = autogen.config_list_from_json( OAI_CONFIG_LIST, file_location=KEY_LOC, + filter_dict={"tags": ["gpt-3.5-turbo"]}, ) assistant = AssistantAgent( "assistant", system_message="You are a helpful assistant.", llm_config={ - "timeout": 600, "cache_seed": None, "config_list": config_list, - "model": "gpt-3.5-turbo-0613", }, ) @@ -104,7 +103,6 @@ def test_agent_usage(): code_execution_config=False, llm_config={ "config_list": config_list, - "model": "gpt-3.5-turbo-0613", }, # In the system message the "user" always refers to the other agent. system_message="You ask a user for help. You check the answer from the user and provide feedback.", @@ -140,5 +138,5 @@ def test_agent_usage(): if __name__ == "__main__": - test_gathering() + # test_gathering() test_agent_usage() diff --git a/test/agentchat/test_assistant_agent.py b/test/agentchat/test_assistant_agent.py index a2c99ba636c7..c3bfe4045e80 100755 --- a/test/agentchat/test_assistant_agent.py +++ b/test/agentchat/test_assistant_agent.py @@ -9,14 +9,7 @@ from autogen.agentchat import AssistantAgent, UserProxyAgent sys.path.append(os.path.join(os.path.dirname(__file__), "..")) -from conftest import skip_openai # noqa: E402 - -try: - from openai import OpenAI -except ImportError: - skip = True -else: - skip = False or skip_openai +from conftest import reason, skip_openai # noqa: E402 KEY_LOC = "notebook" OAI_CONFIG_LIST = "OAI_CONFIG_LIST" @@ -24,8 +17,8 @@ @pytest.mark.skipif( - sys.platform in ["darwin", "win32"] or skip, - reason="do not run on MacOS or windows OR openai not installed OR requested to skip", + sys.platform in ["darwin", "win32"] or skip_openai, + reason="do not run on MacOS or windows OR " + reason, ) def test_ai_user_proxy_agent(): conversations = {} @@ -34,6 +27,7 @@ def test_ai_user_proxy_agent(): config_list = autogen.config_list_from_json( OAI_CONFIG_LIST, file_location=KEY_LOC, + filter_dict={"tags": ["gpt-3.5-turbo"]}, ) assistant = AssistantAgent( "assistant", @@ -67,7 +61,7 @@ def test_ai_user_proxy_agent(): print("Result summary:", res.summary) -@pytest.mark.skipif(skip, reason="openai not installed OR requested to skip") +@pytest.mark.skipif(skip_openai, reason=reason) def test_gpt35(human_input_mode="NEVER", max_consecutive_auto_reply=5): config_list = autogen.config_list_from_json( OAI_CONFIG_LIST, @@ -111,9 +105,13 @@ def test_gpt35(human_input_mode="NEVER", max_consecutive_auto_reply=5): assert not isinstance(user.use_docker, bool) # None or str -@pytest.mark.skipif(skip, reason="openai not installed OR requested to skip") -def test_create_execute_script(human_input_mode="NEVER", max_consecutive_auto_reply=10): - config_list = autogen.config_list_from_json(OAI_CONFIG_LIST, file_location=KEY_LOC) +@pytest.mark.skipif(skip_openai, reason=reason) +def test_create_execute_script(human_input_mode="NEVER", max_consecutive_auto_reply=3): + config_list = autogen.config_list_from_json( + OAI_CONFIG_LIST, + file_location=KEY_LOC, + filter_dict={"tags": ["gpt-3.5-turbo"]}, + ) conversations = {} # autogen.ChatCompletion.start_logging(conversations) llm_config = { @@ -160,13 +158,13 @@ def test_create_execute_script(human_input_mode="NEVER", max_consecutive_auto_re # autogen.ChatCompletion.stop_logging() -@pytest.mark.skipif(skip, reason="openai not installed OR requested to skip") -def test_tsp(human_input_mode="NEVER", max_consecutive_auto_reply=10): +@pytest.mark.skipif(skip_openai, reason=reason) +def test_tsp(human_input_mode="NEVER", max_consecutive_auto_reply=2): config_list = autogen.config_list_from_json( OAI_CONFIG_LIST, file_location=KEY_LOC, filter_dict={ - "model": ["gpt-4", "gpt4", "gpt-4-32k", "gpt-4-32k-0314", "gpt-4-32k-v0314"], + "tags": ["gpt-4", "gpt-4-32k"], }, ) hard_questions = [ @@ -207,4 +205,5 @@ def tsp_message(sender, recipient, context): # when GPT-4, i.e., the DEFAULT_MODEL, is used, conversation in the following test # should terminate in 2-3 rounds of interactions (because is_termination_msg should be true after 2-3 rounds) # although the max_consecutive_auto_reply is set to 10. - test_tsp(human_input_mode="NEVER", max_consecutive_auto_reply=10) + test_tsp(human_input_mode="NEVER", max_consecutive_auto_reply=2) + # test_ai_user_proxy_agent() diff --git a/test/agentchat/test_async.py b/test/agentchat/test_async.py index 5d6db1ab7d37..c2cfb23973c3 100755 --- a/test/agentchat/test_async.py +++ b/test/agentchat/test_async.py @@ -10,14 +10,7 @@ import autogen sys.path.append(os.path.join(os.path.dirname(__file__), "..")) -from conftest import skip_openai # noqa: E402 - -try: - from openai import OpenAI -except ImportError: - skip = True -else: - skip = False or skip_openai +from conftest import reason, skip_openai # noqa: E402 def get_market_news(ind, ind_upper): @@ -61,24 +54,15 @@ def get_market_news(ind, ind_upper): return feeds_summary -@pytest.mark.skipif(skip, reason="openai not installed OR requested to skip") +@pytest.mark.skipif(skip_openai, reason=reason) @pytest.mark.asyncio async def test_async_groupchat(): - config_list = autogen.config_list_from_json(OAI_CONFIG_LIST, KEY_LOC) - - llm_config = { - "timeout": 600, - "cache_seed": 41, - "config_list": config_list, - "temperature": 0, - } + config_list = autogen.config_list_from_json(OAI_CONFIG_LIST, KEY_LOC, filter_dict={"tags": ["gpt-3.5-turbo"]}) # create an AssistantAgent instance named "assistant" assistant = autogen.AssistantAgent( name="assistant", llm_config={ - "timeout": 600, - "cache_seed": 41, "config_list": config_list, "temperature": 0, }, @@ -93,20 +77,21 @@ async def test_async_groupchat(): default_auto_reply=None, ) - groupchat = autogen.GroupChat(agents=[user_proxy, assistant], messages=[], max_round=12) + groupchat = autogen.GroupChat( + agents=[user_proxy, assistant], messages=[], max_round=3, speaker_selection_method="round_robin" + ) manager = autogen.GroupChatManager( groupchat=groupchat, - llm_config=llm_config, is_termination_msg=lambda x: "TERMINATE" in x.get("content", ""), ) - await user_proxy.a_initiate_chat(manager, message="""Have a short conversation with the assistant.""") + await user_proxy.a_initiate_chat(manager, message="""223434*3422=?.""") assert len(user_proxy.chat_messages) > 0 -@pytest.mark.skipif(skip, reason="openai not installed OR requested to skip") +@pytest.mark.skipif(skip_openai, reason=reason) @pytest.mark.asyncio async def test_stream(): - config_list = autogen.config_list_from_json(OAI_CONFIG_LIST, KEY_LOC) + config_list = autogen.config_list_from_json(OAI_CONFIG_LIST, KEY_LOC, filter_dict={"tags": ["gpt-3.5-turbo"]}) data = asyncio.Future() async def add_stock_price_data(): @@ -167,9 +152,10 @@ async def add_data_reply(recipient, messages, sender, config): while not data_task.done() and not data_task.cancelled(): reply = await user_proxy.a_generate_reply(sender=assistant) if reply is not None: - res = await user_proxy.a_send(reply, assistant) - print("Chat summary and cost:", res.summary, res.cost) + await user_proxy.a_send(reply, assistant) + # print("Chat summary and cost:", res.summary, res.cost) if __name__ == "__main__": - asyncio.run(test_stream()) + # asyncio.run(test_stream()) + asyncio.run(test_async_groupchat()) diff --git a/test/agentchat/test_async_chats.py b/test/agentchat/test_async_chats.py index 6b04658dc977..ff5be06cb098 100755 --- a/test/agentchat/test_async_chats.py +++ b/test/agentchat/test_async_chats.py @@ -17,9 +17,10 @@ @pytest.mark.skipif(skip_openai, reason="requested to skip openai tests") @pytest.mark.asyncio async def test_async_chats(): - config_list = autogen.config_list_from_json( + config_list_35 = autogen.config_list_from_json( OAI_CONFIG_LIST, file_location=KEY_LOC, + filter_dict={"tags": ["gpt-3.5-turbo"]}, ) financial_tasks = [ @@ -32,16 +33,16 @@ async def test_async_chats(): financial_assistant_1 = AssistantAgent( name="Financial_assistant_1", - llm_config={"config_list": config_list}, + llm_config={"config_list": config_list_35}, system_message="You are a knowledgeable AI Assistant. Reply TERMINATE when everything is done.", ) financial_assistant_2 = AssistantAgent( name="Financial_assistant_2", - llm_config={"config_list": config_list}, + llm_config={"config_list": config_list_35}, ) writer = AssistantAgent( name="Writer", - llm_config={"config_list": config_list}, + llm_config={"config_list": config_list_35}, is_termination_msg=lambda x: x.get("content", "").find("TERMINATE") >= 0, system_message=""" You are a professional writer, known for diff --git a/test/agentchat/test_async_get_human_input.py b/test/agentchat/test_async_get_human_input.py index bcc2a1cc918f..c0b0ca6be792 100755 --- a/test/agentchat/test_async_get_human_input.py +++ b/test/agentchat/test_async_get_human_input.py @@ -11,26 +11,19 @@ import autogen sys.path.append(os.path.join(os.path.dirname(__file__), "..")) -from conftest import skip_openai # noqa: E402 +from conftest import reason, skip_openai # noqa: E402 -try: - from openai import OpenAI -except ImportError: - skip = True -else: - skip = False or skip_openai - -@pytest.mark.skipif(skip, reason="openai not installed OR requested to skip") +@pytest.mark.skipif(skip_openai, reason=reason) @pytest.mark.asyncio async def test_async_get_human_input(): - config_list = autogen.config_list_from_json(OAI_CONFIG_LIST, KEY_LOC) + config_list = autogen.config_list_from_json(OAI_CONFIG_LIST, KEY_LOC, filter_dict={"tags": ["gpt-3.5-turbo"]}) # create an AssistantAgent instance named "assistant" assistant = autogen.AssistantAgent( name="assistant", max_consecutive_auto_reply=2, - llm_config={"seed": 41, "config_list": config_list, "temperature": 0}, + llm_config={"config_list": config_list, "temperature": 0}, ) user_proxy = autogen.UserProxyAgent(name="user", human_input_mode="ALWAYS", code_execution_config=False) @@ -48,10 +41,10 @@ async def test_async_get_human_input(): print("Human input:", res.human_input) -@pytest.mark.skipif(skip, reason="openai not installed OR requested to skip") +@pytest.mark.skipif(skip_openai, reason=reason) @pytest.mark.asyncio async def test_async_max_turn(): - config_list = autogen.config_list_from_json(OAI_CONFIG_LIST, KEY_LOC) + config_list = autogen.config_list_from_json(OAI_CONFIG_LIST, KEY_LOC, filter_dict={"tags": ["gpt-3.5-turbo"]}) # create an AssistantAgent instance named "assistant" assistant = autogen.AssistantAgent( @@ -79,5 +72,5 @@ async def test_async_max_turn(): if __name__ == "__main__": - asyncio.run(test_async_get_human_input()) + # asyncio.run(test_async_get_human_input()) asyncio.run(test_async_max_turn()) diff --git a/test/agentchat/test_chats.py b/test/agentchat/test_chats.py index d31199fa3e54..480a28051b4b 100755 --- a/test/agentchat/test_chats.py +++ b/test/agentchat/test_chats.py @@ -9,10 +9,10 @@ from typing_extensions import Annotated import autogen -from autogen import AssistantAgent, GroupChat, GroupChatManager, UserProxyAgent, initiate_chats +from autogen import AssistantAgent, GroupChat, GroupChatManager, UserProxyAgent, filter_config, initiate_chats sys.path.append(os.path.join(os.path.dirname(__file__), "..")) -from conftest import skip_openai # noqa: E402 +from conftest import reason, skip_openai # noqa: E402 config_list = ( [] @@ -23,6 +23,18 @@ ) ) +config_list_35 = ( + [] + if skip_openai + else autogen.config_list_from_json( + OAI_CONFIG_LIST, + file_location=KEY_LOC, + filter_dict={"tags": ["gpt-3.5-turbo"]}, + ) +) + +config_list_tool = filter_config(config_list_35, {"tags": ["tool"]}) + def test_chat_messages_for_summary(): assistant = UserProxyAgent(name="assistant", human_input_mode="NEVER", code_execution_config={"use_docker": False}) @@ -45,7 +57,7 @@ def test_chat_messages_for_summary(): assert len(messages) == 2 -@pytest.mark.skipif(skip_openai, reason="requested to skip openai tests") +@pytest.mark.skipif(skip_openai, reason=reason) def test_chats_group(): financial_tasks = [ """What are the full names of NVDA and TESLA.""", @@ -68,12 +80,12 @@ def test_chats_group(): financial_assistant = AssistantAgent( name="Financial_assistant", - llm_config={"config_list": config_list}, + llm_config={"config_list": config_list_35}, ) writer = AssistantAgent( name="Writer", - llm_config={"config_list": config_list}, + llm_config={"config_list": config_list_35}, system_message=""" You are a professional writer, known for your insightful and engaging articles. @@ -87,7 +99,7 @@ def test_chats_group(): system_message="""Critic. Double check plan, claims, code from other agents and provide feedback. Check whether the plan includes adding verifiable info such as source URL. Reply "TERMINATE" in the end when everything is done. """, - llm_config={"config_list": config_list}, + llm_config={"config_list": config_list_35}, ) groupchat_1 = GroupChat(agents=[user_proxy, financial_assistant, critic], messages=[], max_round=3) @@ -97,7 +109,7 @@ def test_chats_group(): manager_1 = GroupChatManager( groupchat=groupchat_1, name="Research_manager", - llm_config={"config_list": config_list}, + llm_config={"config_list": config_list_35}, code_execution_config={ "last_n_messages": 1, "work_dir": "groupchat", @@ -108,7 +120,7 @@ def test_chats_group(): manager_2 = GroupChatManager( groupchat=groupchat_2, name="Writing_manager", - llm_config={"config_list": config_list}, + llm_config={"config_list": config_list_35}, code_execution_config={ "last_n_messages": 1, "work_dir": "groupchat", @@ -154,7 +166,7 @@ def test_chats_group(): print(all_res[1].summary) -@pytest.mark.skipif(skip_openai, reason="requested to skip openai tests") +@pytest.mark.skipif(skip_openai, reason=reason) def test_chats(): import random @@ -182,17 +194,17 @@ def luck_number_message(sender, recipient, context): func = Function() financial_assistant_1 = AssistantAgent( name="Financial_assistant_1", - llm_config={"config_list": config_list}, + llm_config={"config_list": config_list_35}, function_map={"get_random_number": func.get_random_number}, ) financial_assistant_2 = AssistantAgent( name="Financial_assistant_2", - llm_config={"config_list": config_list}, + llm_config={"config_list": config_list_35}, function_map={"get_random_number": func.get_random_number}, ) writer = AssistantAgent( name="Writer", - llm_config={"config_list": config_list}, + llm_config={"config_list": config_list_35}, is_termination_msg=lambda x: x.get("content", "").find("TERMINATE") >= 0, system_message=""" You are a professional writer, known for @@ -284,7 +296,7 @@ def my_summary_method(recipient, sender, summary_args): # print(blogpost.summary, insights_and_blogpost) -@pytest.mark.skipif(skip_openai, reason="requested to skip openai tests") +@pytest.mark.skipif(skip_openai, reason=reason) def test_chats_general(): financial_tasks = [ """What are the full names of NVDA and TESLA.""", @@ -296,15 +308,15 @@ def test_chats_general(): financial_assistant_1 = AssistantAgent( name="Financial_assistant_1", - llm_config={"config_list": config_list}, + llm_config={"config_list": config_list_35}, ) financial_assistant_2 = AssistantAgent( name="Financial_assistant_2", - llm_config={"config_list": config_list}, + llm_config={"config_list": config_list_35}, ) writer = AssistantAgent( name="Writer", - llm_config={"config_list": config_list}, + llm_config={"config_list": config_list_35}, is_termination_msg=lambda x: x.get("content", "").find("TERMINATE") >= 0, system_message=""" You are a professional writer, known for @@ -388,7 +400,7 @@ def my_summary_method(recipient, sender, summary_args): # print(blogpost.summary, insights_and_blogpost) -@pytest.mark.skipif(skip_openai, reason="requested to skip openai tests") +@pytest.mark.skipif(skip_openai, reason=reason) def test_chats_exceptions(): financial_tasks = [ """What are the full names of NVDA and TESLA.""", @@ -472,10 +484,10 @@ def test_chats_exceptions(): ) -@pytest.mark.skipif(skip_openai, reason="requested to skip openai tests") +@pytest.mark.skipif(skip_openai, reason=reason) def test_chats_w_func(): llm_config = { - "config_list": config_list, + "config_list": config_list_tool, "timeout": 120, } @@ -528,9 +540,9 @@ def currency_calculator( print(res.summary, res.cost, res.chat_history) -@pytest.mark.skipif(skip_openai, reason="requested to skip openai tests") +@pytest.mark.skipif(skip_openai, reason=reason) def test_udf_message_in_chats(): - llm_config = {"config_list": config_list} + llm_config_35 = {"config_list": config_list_35} research_task = """ ## NVDA (NVIDIA Corporation) @@ -560,11 +572,11 @@ def my_writing_task(sender, recipient, context): researcher = autogen.AssistantAgent( name="Financial_researcher", - llm_config=llm_config, + llm_config=llm_config_35, ) writer = autogen.AssistantAgent( name="Writer", - llm_config=llm_config, + llm_config=llm_config_35, system_message=""" You are a professional writer, known for your insightful and engaging articles. @@ -609,8 +621,8 @@ def my_writing_task(sender, recipient, context): if __name__ == "__main__": - # test_chats() - test_chats_general() + test_chats() + # test_chats_general() # test_chats_exceptions() # test_chats_group() # test_chats_w_func() diff --git a/test/agentchat/test_conversable_agent.py b/test/agentchat/test_conversable_agent.py index f1818d9dbca2..19d724ff854b 100755 --- a/test/agentchat/test_conversable_agent.py +++ b/test/agentchat/test_conversable_agent.py @@ -21,10 +21,9 @@ from autogen.exception_utils import InvalidCarryOverType, SenderRequired sys.path.append(os.path.join(os.path.dirname(__file__), "..")) -from conftest import MOCK_OPEN_AI_API_KEY, skip_openai # noqa: E402 +from conftest import MOCK_OPEN_AI_API_KEY, reason, skip_openai # noqa: E402 here = os.path.abspath(os.path.dirname(__file__)) -REASON = "requested to skip openai tests" @pytest.fixture @@ -918,13 +917,13 @@ def exec_python(cell: Annotated[str, "Valid Python cell to execute."]) -> str: @pytest.mark.skipif( skip_openai, - reason=REASON, + reason=reason, ) def test_function_registration_e2e_sync() -> None: config_list = autogen.config_list_from_json( OAI_CONFIG_LIST, filter_dict={ - "model": ["gpt-4", "gpt-4-0314", "gpt4", "gpt-4-32k", "gpt-4-32k-0314", "gpt-4-32k-v0314"], + "tags": ["tool"], }, file_location=KEY_LOC, ) @@ -995,7 +994,7 @@ def stopwatch(num_seconds: Annotated[str, "Number of seconds in the stopwatch."] @pytest.mark.skipif( skip_openai, - reason=REASON, + reason=reason, ) @pytest.mark.asyncio() async def test_function_registration_e2e_async() -> None: @@ -1071,15 +1070,15 @@ def stopwatch(num_seconds: Annotated[str, "Number of seconds in the stopwatch."] stopwatch_mock.assert_called_once_with(num_seconds="2") -@pytest.mark.skipif(skip_openai, reason=REASON) +@pytest.mark.skipif(skip_openai, reason=reason) def test_max_turn(): - config_list = autogen.config_list_from_json(OAI_CONFIG_LIST, KEY_LOC) + config_list = autogen.config_list_from_json(OAI_CONFIG_LIST, KEY_LOC, filter_dict={"model": ["gpt-3.5-turbo"]}) # create an AssistantAgent instance named "assistant" assistant = autogen.AssistantAgent( name="assistant", max_consecutive_auto_reply=10, - llm_config={"timeout": 600, "cache_seed": 41, "config_list": config_list}, + llm_config={"config_list": config_list}, ) user_proxy = autogen.UserProxyAgent(name="user", human_input_mode="ALWAYS", code_execution_config=False) @@ -1093,7 +1092,7 @@ def test_max_turn(): assert len(res.chat_history) <= 6 -@pytest.mark.skipif(skip_openai, reason=REASON) +@pytest.mark.skipif(skip_openai, reason=reason) def test_message_func(): import random @@ -1149,7 +1148,7 @@ def my_message_play(sender, recipient, context): print(chat_res_play.summary) -@pytest.mark.skipif(skip_openai, reason=REASON) +@pytest.mark.skipif(skip_openai, reason=reason) def test_summary(): import random @@ -1161,8 +1160,7 @@ def get_random_number(self): return random.randint(0, 100) config_list = autogen.config_list_from_json( - OAI_CONFIG_LIST, - file_location=KEY_LOC, + OAI_CONFIG_LIST, file_location=KEY_LOC, filter_dict={"tags": ["gpt-3.5-turbo"]} ) def my_message_play(sender, recipient, context): @@ -1322,5 +1320,6 @@ def test_messages_with_carryover(): # test_no_llm_config() # test_max_turn() # test_process_before_send() - test_message_func() + # test_message_func() test_summary() + # test_function_registration_e2e_sync() diff --git a/test/agentchat/test_function_call_groupchat.py b/test/agentchat/test_function_call_groupchat.py index 0dc174d54dca..c1205ad24322 100755 --- a/test/agentchat/test_function_call_groupchat.py +++ b/test/agentchat/test_function_call_groupchat.py @@ -45,21 +45,18 @@ def get_random_number(self): self.call_count += 1 return random.randint(0, 100) - config_list_gpt4 = autogen.config_list_from_json( + # llm_config without functions + config_list_35 = autogen.config_list_from_json( OAI_CONFIG_LIST, - filter_dict={ - "model": ["gpt-4", "gpt-4-0314", "gpt4", "gpt-4-32k", "gpt-4-32k-0314", "gpt-4-32k-v0314"], - }, file_location=KEY_LOC, + filter_dict={"tags": ["gpt-3.5-turbo", "gpt-3.5-turbo-16k"]}, ) + llm_config_no_function = {"config_list": config_list_35} + config_list_tool = autogen.filter_config(config_list_35, {"tags": ["tool"]}) llm_config = { - "config_list": config_list_gpt4, - "cache_seed": 42, + "config_list": config_list_tool, key: value, } - # llm_config without functions - llm_config_no_function = llm_config.copy() - del llm_config_no_function[key] func = Function() user_proxy = autogen.UserProxyAgent( diff --git a/test/agentchat/test_human_input.py b/test/agentchat/test_human_input.py index 7c5f7fde7d74..a24f94a072a4 100755 --- a/test/agentchat/test_human_input.py +++ b/test/agentchat/test_human_input.py @@ -15,7 +15,7 @@ @pytest.mark.skipif(skip_openai, reason=reason) def test_get_human_input(): - config_list = autogen.config_list_from_json(OAI_CONFIG_LIST, KEY_LOC) + config_list = autogen.config_list_from_json(OAI_CONFIG_LIST, KEY_LOC, filter_dict={"tags": ["gpt-3.5-turbo"]}) # create an AssistantAgent instance named "assistant" assistant = autogen.AssistantAgent( diff --git a/test/agentchat/test_math_user_proxy_agent.py b/test/agentchat/test_math_user_proxy_agent.py index 1e85a7481a0e..8df8caf6421b 100755 --- a/test/agentchat/test_math_user_proxy_agent.py +++ b/test/agentchat/test_math_user_proxy_agent.py @@ -38,14 +38,13 @@ def test_math_user_proxy_agent(): OAI_CONFIG_LIST, file_location=KEY_LOC, filter_dict={ - "model": ["gpt-4", "gpt4", "gpt-4-32k", "gpt-4-32k-0314", "gpt-4-32k-v0314"], + "tags": ["gpt-3.5-turbo"], }, ) assistant = AssistantAgent( "assistant", system_message="You are a helpful assistant.", llm_config={ - "timeout": 600, "cache_seed": 42, "config_list": config_list, }, @@ -127,5 +126,5 @@ def test_generate_prompt(): if __name__ == "__main__": # test_add_remove_print() # test_execute_one_python_code() - test_generate_prompt() + # test_generate_prompt() test_math_user_proxy_agent() diff --git a/test/agentchat/test_nested.py b/test/agentchat/test_nested.py index d6e9b492b3d8..ee8da793fdec 100755 --- a/test/agentchat/test_nested.py +++ b/test/agentchat/test_nested.py @@ -16,6 +16,11 @@ @pytest.mark.skipif(skip_openai, reason=reason) def test_nested(): config_list = autogen.config_list_from_json(env_or_file=OAI_CONFIG_LIST, file_location=KEY_LOC) + config_list_35 = autogen.config_list_from_json( + OAI_CONFIG_LIST, + file_location=KEY_LOC, + filter_dict={"tags": ["gpt-3.5-turbo"]}, + ) llm_config = {"config_list": config_list} tasks = [ @@ -60,13 +65,13 @@ def test_nested(): assistant = autogen.AssistantAgent( name="Assistant", - llm_config={"config_list": config_list}, + llm_config=False, # is_termination_msg=lambda x: x.get("content", "") == "", ) assistant_2 = autogen.AssistantAgent( name="Assistant", - llm_config={"config_list": config_list}, + llm_config={"config_list": config_list_35}, # is_termination_msg=lambda x: x.get("content", "") == "", ) @@ -94,7 +99,7 @@ def test_nested(): writer = autogen.AssistantAgent( name="Writer", - llm_config={"config_list": config_list}, + llm_config={"config_list": config_list_35}, system_message=""" You are a professional writer, known for your insightful and engaging articles. @@ -105,7 +110,7 @@ def test_nested(): autogen.AssistantAgent( name="Reviewer", - llm_config={"config_list": config_list}, + llm_config={"config_list": config_list_35}, system_message=""" You are a compliance reviewer, known for your thoroughness and commitment to standards. Your task is to scrutinize content for any harmful elements or regulatory violations, ensuring @@ -130,7 +135,10 @@ def writing_message(recipient, messages, sender, config): trigger=user, ) user.initiate_chats( - [{"recipient": assistant, "message": tasks[0], "max_turns": 1}, {"recipient": assistant_2, "message": tasks[1]}] + [ + {"recipient": assistant, "message": tasks[0], "max_turns": 1}, + {"recipient": assistant_2, "message": tasks[1], "max_turns": 1}, + ] )