diff --git a/test/__init__.py b/test/__init__.py new file mode 100644 index 0000000000..bcd5401d54 --- /dev/null +++ b/test/__init__.py @@ -0,0 +1,3 @@ +# Copyright (c) 2023 - 2024, Owners of https://github.com/ag2ai +# +# SPDX-License-Identifier: Apache-2.0 diff --git a/test/agentchat/__init__.py b/test/agentchat/__init__.py new file mode 100644 index 0000000000..bcd5401d54 --- /dev/null +++ b/test/agentchat/__init__.py @@ -0,0 +1,3 @@ +# Copyright (c) 2023 - 2024, Owners of https://github.com/ag2ai +# +# SPDX-License-Identifier: Apache-2.0 diff --git a/test/agentchat/contrib/__init__.py b/test/agentchat/contrib/__init__.py new file mode 100644 index 0000000000..bcd5401d54 --- /dev/null +++ b/test/agentchat/contrib/__init__.py @@ -0,0 +1,3 @@ +# Copyright (c) 2023 - 2024, Owners of https://github.com/ag2ai +# +# SPDX-License-Identifier: Apache-2.0 diff --git a/test/agentchat/contrib/agent_eval/__init__.py b/test/agentchat/contrib/agent_eval/__init__.py new file mode 100644 index 0000000000..bcd5401d54 --- /dev/null +++ b/test/agentchat/contrib/agent_eval/__init__.py @@ -0,0 +1,3 @@ +# Copyright (c) 2023 - 2024, Owners of https://github.com/ag2ai +# +# SPDX-License-Identifier: Apache-2.0 diff --git a/test/agentchat/contrib/agent_eval/test_agent_eval.py b/test/agentchat/contrib/agent_eval/test_agent_eval.py index d5f7306528..7345a13576 100644 --- a/test/agentchat/contrib/agent_eval/test_agent_eval.py +++ b/test/agentchat/contrib/agent_eval/test_agent_eval.py @@ -9,13 +9,14 @@ import json import pytest -from conftest import reason, skip_openai # noqa: E402 import autogen from autogen.agentchat.contrib.agent_eval.agent_eval import generate_criteria, quantify_criteria from autogen.agentchat.contrib.agent_eval.criterion import Criterion from autogen.agentchat.contrib.agent_eval.task import Task +from ....conftest import reason, skip_openai # noqa: E402 + KEY_LOC = "notebook" OAI_CONFIG_LIST = "OAI_CONFIG_LIST" diff --git a/test/agentchat/contrib/capabilities/__init__.py b/test/agentchat/contrib/capabilities/__init__.py new file mode 100644 index 0000000000..bcd5401d54 --- /dev/null +++ b/test/agentchat/contrib/capabilities/__init__.py @@ -0,0 +1,3 @@ +# Copyright (c) 2023 - 2024, Owners of https://github.com/ag2ai +# +# SPDX-License-Identifier: Apache-2.0 diff --git a/test/agentchat/contrib/capabilities/chat_with_teachable_agent.py b/test/agentchat/contrib/capabilities/chat_with_teachable_agent.py index e1c47432fb..581ac8b815 100755 --- a/test/agentchat/contrib/capabilities/chat_with_teachable_agent.py +++ b/test/agentchat/contrib/capabilities/chat_with_teachable_agent.py @@ -6,15 +6,11 @@ # SPDX-License-Identifier: MIT #!/usr/bin/env python3 -m pytest -import os -import sys - from autogen import ConversableAgent, UserProxyAgent, config_list_from_json from autogen.agentchat.contrib.capabilities.teachability import Teachability from autogen.formatting_utils import colored -sys.path.append(os.path.join(os.path.dirname(__file__), "../..")) -from test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST # noqa: E402 +from ...test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST # noqa: E402 # Specify the model to use. GPT-3.5 is less reliable than GPT-4 at learning from user input. filter_dict = {"model": ["gpt-4o-mini"]} diff --git a/test/agentchat/contrib/capabilities/test_image_generation_capability.py b/test/agentchat/contrib/capabilities/test_image_generation_capability.py index 39f5e4daf9..4175d664fd 100644 --- a/test/agentchat/contrib/capabilities/test_image_generation_capability.py +++ b/test/agentchat/contrib/capabilities/test_image_generation_capability.py @@ -8,7 +8,7 @@ import os import sys import tempfile -from typing import Any, Dict, Tuple +from typing import Any import pytest @@ -28,9 +28,7 @@ else: skip_requirement = False -sys.path.append(os.path.join(os.path.dirname(__file__), "../../..")) -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, skip_openai # noqa: E402 filter_dict = {"model": ["gpt-4o-mini"]} diff --git a/test/agentchat/contrib/capabilities/test_teachable_agent.py b/test/agentchat/contrib/capabilities/test_teachable_agent.py index 8d8525c9d2..c5ab3a9853 100755 --- a/test/agentchat/contrib/capabilities/test_teachable_agent.py +++ b/test/agentchat/contrib/capabilities/test_teachable_agent.py @@ -6,19 +6,13 @@ # SPDX-License-Identifier: MIT #!/usr/bin/env python3 -m pytest -import os -import sys - import pytest from autogen import ConversableAgent, config_list_from_json from autogen.formatting_utils import colored -sys.path.append(os.path.join(os.path.dirname(__file__), "../../..")) -from conftest import skip_openai # noqa: E402 - -sys.path.append(os.path.join(os.path.dirname(__file__), "../..")) -from test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST # noqa: E402 +from ....conftest import skip_openai # noqa: E402 +from ...test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST # noqa: E402 try: from autogen.agentchat.contrib.capabilities.teachability import Teachability diff --git a/test/agentchat/contrib/capabilities/test_transform_messages.py b/test/agentchat/contrib/capabilities/test_transform_messages.py index b3dee65d1b..bb86cf55f7 100644 --- a/test/agentchat/contrib/capabilities/test_transform_messages.py +++ b/test/agentchat/contrib/capabilities/test_transform_messages.py @@ -4,10 +4,7 @@ # # Portions derived from https://github.com/microsoft/autogen are under the MIT License. # SPDX-License-Identifier: MIT -import os -import sys import tempfile -from typing import Any, Dict, List, Union import pytest @@ -15,11 +12,8 @@ from autogen.agentchat.contrib.capabilities.transform_messages import TransformMessages from autogen.agentchat.contrib.capabilities.transforms import MessageHistoryLimiter, MessageTokenLimiter -sys.path.append(os.path.join(os.path.dirname(__file__), "../../..")) -from conftest import skip_openai # noqa: E402 - -sys.path.append(os.path.join(os.path.dirname(__file__), "..", "..")) -from test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST # noqa: E402 +from ....conftest import skip_openai # noqa: E402 +from ...test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST # noqa: E402 @pytest.mark.skipif(skip_openai, reason="Requested to skip openai test.") diff --git a/test/agentchat/contrib/graph_rag/__init__.py b/test/agentchat/contrib/graph_rag/__init__.py new file mode 100644 index 0000000000..bcd5401d54 --- /dev/null +++ b/test/agentchat/contrib/graph_rag/__init__.py @@ -0,0 +1,3 @@ +# Copyright (c) 2023 - 2024, Owners of https://github.com/ag2ai +# +# SPDX-License-Identifier: Apache-2.0 diff --git a/test/agentchat/contrib/graph_rag/test_falkor_graph_rag.py b/test/agentchat/contrib/graph_rag/test_falkor_graph_rag.py index 0e23414b43..a52a43112c 100644 --- a/test/agentchat/contrib/graph_rag/test_falkor_graph_rag.py +++ b/test/agentchat/contrib/graph_rag/test_falkor_graph_rag.py @@ -7,9 +7,10 @@ import sys import pytest -from conftest import reason, skip_openai # noqa: E402 from graphrag_sdk import Attribute, AttributeType, Entity, Ontology, Relation +from ....conftest import reason, skip_openai # noqa: E402 + try: from autogen.agentchat.contrib.graph_rag.document import Document, DocumentType from autogen.agentchat.contrib.graph_rag.falkor_graph_query_engine import ( diff --git a/test/agentchat/contrib/graph_rag/test_neo4j_graph_rag.py b/test/agentchat/contrib/graph_rag/test_neo4j_graph_rag.py index f7e891b975..f668596f8f 100644 --- a/test/agentchat/contrib/graph_rag/test_neo4j_graph_rag.py +++ b/test/agentchat/contrib/graph_rag/test_neo4j_graph_rag.py @@ -8,7 +8,8 @@ from typing import Literal import pytest -from conftest import reason, skip_openai # noqa: E402 + +from ....conftest import reason, skip_openai # noqa: E402 try: from autogen.agentchat.contrib.graph_rag.document import Document, DocumentType diff --git a/test/agentchat/contrib/retrievechat/__init__.py b/test/agentchat/contrib/retrievechat/__init__.py new file mode 100644 index 0000000000..bcd5401d54 --- /dev/null +++ b/test/agentchat/contrib/retrievechat/__init__.py @@ -0,0 +1,3 @@ +# Copyright (c) 2023 - 2024, Owners of https://github.com/ag2ai +# +# SPDX-License-Identifier: Apache-2.0 diff --git a/test/agentchat/contrib/retrievechat/test_pgvector_retrievechat.py b/test/agentchat/contrib/retrievechat/test_pgvector_retrievechat.py index 3d64b1dc76..231baa404c 100644 --- a/test/agentchat/contrib/retrievechat/test_pgvector_retrievechat.py +++ b/test/agentchat/contrib/retrievechat/test_pgvector_retrievechat.py @@ -7,18 +7,14 @@ #!/usr/bin/env python3 -m pytest import os -import sys import pytest from sentence_transformers import SentenceTransformer from autogen import AssistantAgent, config_list_from_json -sys.path.append(os.path.join(os.path.dirname(__file__), "../../..")) -from conftest import skip_openai # noqa: E402 - -sys.path.append(os.path.join(os.path.dirname(__file__), "../..")) -from test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST # noqa: E402 +from ....conftest import skip_openai # noqa: E402 +from ...test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST # noqa: E402 try: import pgvector diff --git a/test/agentchat/contrib/retrievechat/test_qdrant_retrievechat.py b/test/agentchat/contrib/retrievechat/test_qdrant_retrievechat.py index cca4d8029b..8fb93e6018 100755 --- a/test/agentchat/contrib/retrievechat/test_qdrant_retrievechat.py +++ b/test/agentchat/contrib/retrievechat/test_qdrant_retrievechat.py @@ -13,11 +13,8 @@ from autogen import AssistantAgent, config_list_from_json -sys.path.append(os.path.join(os.path.dirname(__file__), "../../..")) -from conftest import skip_openai # noqa: E402 - -sys.path.append(os.path.join(os.path.dirname(__file__), "../..")) -from test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST # noqa: E402 +from ....conftest import skip_openai # noqa: E402 +from ...test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST # noqa: E402 try: import fastembed diff --git a/test/agentchat/contrib/retrievechat/test_retrievechat.py b/test/agentchat/contrib/retrievechat/test_retrievechat.py index 76879f8765..f5561e8ebb 100755 --- a/test/agentchat/contrib/retrievechat/test_retrievechat.py +++ b/test/agentchat/contrib/retrievechat/test_retrievechat.py @@ -6,18 +6,14 @@ # SPDX-License-Identifier: MIT #!/usr/bin/env python3 -m pytest -import os import sys import pytest import autogen -sys.path.append(os.path.join(os.path.dirname(__file__), "../../..")) -from conftest import reason, skip_openai # noqa: E402 - -sys.path.append(os.path.join(os.path.dirname(__file__), "../..")) -from test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST # noqa: E402 +from ....conftest import reason, skip_openai # noqa: E402 +from ...test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST # noqa: E402 try: import chromadb diff --git a/test/agentchat/contrib/test_agent_builder.py b/test/agentchat/contrib/test_agent_builder.py index e16468ad62..8966333db9 100755 --- a/test/agentchat/contrib/test_agent_builder.py +++ b/test/agentchat/contrib/test_agent_builder.py @@ -8,16 +8,13 @@ import json import os -import sys import pytest from autogen.agentchat.contrib.agent_builder import AgentBuilder -sys.path.append(os.path.join(os.path.dirname(__file__), "..")) -sys.path.append(os.path.join(os.path.dirname(__file__), "../..")) -from conftest import reason, skip_openai # noqa: E402 -from test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST # noqa: E402 +from ...conftest import reason, skip_openai # noqa: E402 +from ..test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST # noqa: E402 try: import chromadb diff --git a/test/agentchat/contrib/test_agent_optimizer.py b/test/agentchat/contrib/test_agent_optimizer.py index 88323f56d8..472dfe15b1 100644 --- a/test/agentchat/contrib/test_agent_optimizer.py +++ b/test/agentchat/contrib/test_agent_optimizer.py @@ -5,7 +5,6 @@ # Portions derived from https://github.com/microsoft/autogen are under the MIT License. # SPDX-License-Identifier: MIT import os -import sys import pytest @@ -13,10 +12,8 @@ from autogen import AssistantAgent, UserProxyAgent from autogen.agentchat.contrib.agent_optimizer import AgentOptimizer -sys.path.append(os.path.join(os.path.dirname(__file__), "..")) -sys.path.append(os.path.join(os.path.dirname(__file__), "../..")) -from conftest import reason, skip_openai -from test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST +from ...conftest import reason, skip_openai +from ..test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST here = os.path.abspath(os.path.dirname(__file__)) diff --git a/test/agentchat/contrib/test_captainagent.py b/test/agentchat/contrib/test_captainagent.py index c8a554aae4..50c1233c62 100644 --- a/test/agentchat/contrib/test_captainagent.py +++ b/test/agentchat/contrib/test_captainagent.py @@ -2,20 +2,14 @@ # # SPDX-License-Identifier: Apache-2.0 import os -import re -import sys import pytest -from autogen import AssistantAgent, UserProxyAgent, config_list_from_json +from autogen import UserProxyAgent, config_list_from_json from autogen.agentchat.contrib.captainagent import CaptainAgent -from autogen.agentchat.contrib.tool_retriever import ToolBuilder -sys.path.append(os.path.join(os.path.dirname(__file__), "../..")) -from conftest import MOCK_OPEN_AI_API_KEY, reason, skip_openai # noqa: E402 - -sys.path.append(os.path.join(os.path.dirname(__file__), "..")) -from test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST # noqa: E402 +from ...conftest import reason, skip_openai # noqa: E402 +from ..test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST # noqa: E402 try: import chromadb diff --git a/test/agentchat/contrib/test_gpt_assistant.py b/test/agentchat/contrib/test_gpt_assistant.py index ce29c7651c..5d0ec9ec4e 100755 --- a/test/agentchat/contrib/test_gpt_assistant.py +++ b/test/agentchat/contrib/test_gpt_assistant.py @@ -19,11 +19,8 @@ from autogen.agentchat.contrib.gpt_assistant_agent import GPTAssistantAgent from autogen.oai.openai_utils import detect_gpt_assistant_api_version, retrieve_assistants_by_name -sys.path.append(os.path.join(os.path.dirname(__file__), "../..")) -from conftest import reason, skip_openai # noqa: E402 - -sys.path.append(os.path.join(os.path.dirname(__file__), "..")) -from test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST # noqa: E402 +from ...conftest import reason, skip_openai # noqa: E402 +from ..test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST # noqa: E402 if not skip_openai: openai_config_list = autogen.config_list_from_json( diff --git a/test/agentchat/contrib/test_llamaindex_conversable_agent.py b/test/agentchat/contrib/test_llamaindex_conversable_agent.py index bc9bec4fd1..2f8a3fa900 100644 --- a/test/agentchat/contrib/test_llamaindex_conversable_agent.py +++ b/test/agentchat/contrib/test_llamaindex_conversable_agent.py @@ -6,21 +6,15 @@ # SPDX-License-Identifier: MIT #!/usr/bin/env python3 -m pytest -import os -import sys -import unittest from unittest.mock import MagicMock, patch import pytest -from conftest import MOCK_OPEN_AI_API_KEY from autogen import GroupChat, GroupChatManager from autogen.agentchat.contrib.llamaindex_conversable_agent import LLamaIndexConversableAgent from autogen.agentchat.conversable_agent import ConversableAgent -sys.path.append(os.path.join(os.path.dirname(__file__), "../..")) -sys.path.append(os.path.join(os.path.dirname(__file__), "..")) -from conftest import reason, skip_openai +from ...conftest import MOCK_OPEN_AI_API_KEY, reason, skip_openai skip_reasons = [reason] try: diff --git a/test/agentchat/contrib/test_llava.py b/test/agentchat/contrib/test_llava.py index 01935f99ad..118c83ccb1 100755 --- a/test/agentchat/contrib/test_llava.py +++ b/test/agentchat/contrib/test_llava.py @@ -10,10 +10,11 @@ from unittest.mock import MagicMock, patch import pytest -from conftest import MOCK_OPEN_AI_API_KEY import autogen +from ...conftest import MOCK_OPEN_AI_API_KEY + try: from autogen.agentchat.contrib.llava_agent import LLaVAAgent, _llava_call_binary_with_config, llava_call except ImportError: diff --git a/test/agentchat/contrib/test_lmm.py b/test/agentchat/contrib/test_lmm.py index 43ee8d88a3..d1e42cfeef 100755 --- a/test/agentchat/contrib/test_lmm.py +++ b/test/agentchat/contrib/test_lmm.py @@ -10,11 +10,12 @@ from unittest.mock import MagicMock import pytest -from conftest import MOCK_OPEN_AI_API_KEY import autogen from autogen.agentchat.conversable_agent import ConversableAgent +from ...conftest import MOCK_OPEN_AI_API_KEY + try: from autogen.agentchat.contrib.img_utils import get_pil_image from autogen.agentchat.contrib.multimodal_conversable_agent import MultimodalConversableAgent diff --git a/test/agentchat/contrib/test_reasoning_agent.py b/test/agentchat/contrib/test_reasoning_agent.py index dbca346360..28d0afa281 100644 --- a/test/agentchat/contrib/test_reasoning_agent.py +++ b/test/agentchat/contrib/test_reasoning_agent.py @@ -17,10 +17,9 @@ import autogen from autogen.agentchat.contrib.reasoning_agent import ReasoningAgent, ThinkNode, visualize_tree -from autogen.agentchat.user_proxy_agent import UserProxyAgent sys.path.append(os.path.join(os.path.dirname(__file__), "../..")) -from conftest import reason, skip_openai # noqa: E402 +from ...conftest import reason, skip_openai # noqa: E402 skip_reasons = [reason] try: diff --git a/test/agentchat/contrib/test_society_of_mind_agent.py b/test/agentchat/contrib/test_society_of_mind_agent.py index 1e70ebf47f..10d09f4e1d 100755 --- a/test/agentchat/contrib/test_society_of_mind_agent.py +++ b/test/agentchat/contrib/test_society_of_mind_agent.py @@ -15,11 +15,8 @@ import autogen from autogen.agentchat.contrib.society_of_mind_agent import SocietyOfMindAgent -sys.path.append(os.path.join(os.path.dirname(__file__), "..")) -from test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST # noqa: E402 - -sys.path.append(os.path.join(os.path.dirname(__file__), "../..")) -from conftest import skip_openai # noqa: E402 +from ...conftest import skip_openai # noqa: E402 +from ..test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST # noqa: E402 if not skip_openai: config_list = autogen.config_list_from_json(env_or_file=OAI_CONFIG_LIST, file_location=KEY_LOC) diff --git a/test/agentchat/contrib/test_web_surfer.py b/test/agentchat/contrib/test_web_surfer.py index c6d6e714ee..4b41019975 100755 --- a/test/agentchat/contrib/test_web_surfer.py +++ b/test/agentchat/contrib/test_web_surfer.py @@ -8,18 +8,14 @@ import os import re -import sys import pytest from autogen import UserProxyAgent, config_list_from_json from autogen.oai.openai_utils import filter_config -sys.path.append(os.path.join(os.path.dirname(__file__), "../..")) -from conftest import MOCK_OPEN_AI_API_KEY, reason, skip_openai # noqa: E402 - -sys.path.append(os.path.join(os.path.dirname(__file__), "..")) -from test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST # noqa: E402 +from ...conftest import MOCK_OPEN_AI_API_KEY, reason, skip_openai # noqa: E402 +from ..test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST # noqa: E402 BLOG_POST_URL = "https://docs.ag2.ai/blog/2023-04-21-LLM-tuning-math" BLOG_POST_TITLE = "Does Model and Inference Parameter Matter in LLM Applications? - A Case Study for MATH - AG2" diff --git a/test/agentchat/contrib/vectordb/__init__.py b/test/agentchat/contrib/vectordb/__init__.py new file mode 100644 index 0000000000..bcd5401d54 --- /dev/null +++ b/test/agentchat/contrib/vectordb/__init__.py @@ -0,0 +1,3 @@ +# Copyright (c) 2023 - 2024, Owners of https://github.com/ag2ai +# +# SPDX-License-Identifier: Apache-2.0 diff --git a/test/agentchat/contrib/vectordb/test_pgvectordb.py b/test/agentchat/contrib/vectordb/test_pgvectordb.py index 15f96809b8..8e3a52bc0c 100644 --- a/test/agentchat/contrib/vectordb/test_pgvectordb.py +++ b/test/agentchat/contrib/vectordb/test_pgvectordb.py @@ -9,9 +9,8 @@ import urllib.parse import pytest -from conftest import reason -sys.path.append(os.path.join(os.path.dirname(__file__), "..")) +from ....conftest import reason try: import pgvector diff --git a/test/agentchat/extensions/__init__.py b/test/agentchat/extensions/__init__.py index e69de29bb2..bcd5401d54 100644 --- a/test/agentchat/extensions/__init__.py +++ b/test/agentchat/extensions/__init__.py @@ -0,0 +1,3 @@ +# Copyright (c) 2023 - 2024, Owners of https://github.com/ag2ai +# +# SPDX-License-Identifier: Apache-2.0 diff --git a/test/agentchat/realtime_agent/test_e2e.py b/test/agentchat/realtime_agent/test_e2e.py index 9aae990691..90e3e31aec 100644 --- a/test/agentchat/realtime_agent/test_e2e.py +++ b/test/agentchat/realtime_agent/test_e2e.py @@ -9,14 +9,14 @@ import pytest from anyio import Event, move_on_after, sleep from asyncer import create_task_group -from conftest import reason, skip_openai # noqa: E402 from fastapi import FastAPI, WebSocket from fastapi.testclient import TestClient -from test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST import autogen from autogen.agentchat.realtime_agent import RealtimeAgent, RealtimeObserver, WebSocketAudioAdapter +from ...conftest import reason, skip_openai # noqa: E402 +from ..test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST from .realtime_test_utils import text_to_speech, trace logger = getLogger(__name__) diff --git a/test/agentchat/realtime_agent/test_oai_realtime_client.py b/test/agentchat/realtime_agent/test_oai_realtime_client.py index 1e894b7d56..e719b8620b 100644 --- a/test/agentchat/realtime_agent/test_oai_realtime_client.py +++ b/test/agentchat/realtime_agent/test_oai_realtime_client.py @@ -7,14 +7,14 @@ import pytest from anyio import move_on_after -from asyncer import create_task_group -from conftest import MOCK_OPEN_AI_API_KEY, reason, skip_openai # noqa: E402 -from test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST import autogen from autogen.agentchat.realtime_agent.oai_realtime_client import OpenAIRealtimeClient from autogen.agentchat.realtime_agent.realtime_client import RealtimeClientProtocol +from ...conftest import MOCK_OPEN_AI_API_KEY, reason, skip_openai # noqa: E402 +from ..test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST + class TestOAIRealtimeClient: @pytest.fixture diff --git a/test/agentchat/test_agent_file_logging.py b/test/agentchat/test_agent_file_logging.py index 78755ab270..f3a2701788 100644 --- a/test/agentchat/test_agent_file_logging.py +++ b/test/agentchat/test_agent_file_logging.py @@ -13,12 +13,6 @@ import pytest -sys.path.append(os.path.join(os.path.dirname(__file__), "..")) -sys.path.append(os.path.join(os.path.dirname(__file__), "../..")) - -from conftest import skip_openai # noqa: E402 -from test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST # noqa: E402 - import autogen import autogen.runtime_logging from autogen.logger.file_logger import FileLogger diff --git a/test/agentchat/test_agent_logging.py b/test/agentchat/test_agent_logging.py index c8418bd8a6..ba9317945c 100644 --- a/test/agentchat/test_agent_logging.py +++ b/test/agentchat/test_agent_logging.py @@ -12,16 +12,12 @@ import pytest -sys.path.append(os.path.join(os.path.dirname(__file__), "..")) -sys.path.append(os.path.join(os.path.dirname(__file__), "../..")) - - -from conftest import skip_openai # noqa: E402 -from test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST # noqa: E402 - import autogen import autogen.runtime_logging +from ..conftest import skip_openai # noqa: E402 +from .test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST # noqa: E402 + TEACHER_MESSAGE = """ You are roleplaying a math teacher, and your job is to help your students with linear algebra. Keep your explanations short. diff --git a/test/agentchat/test_agent_setup_with_use_docker_settings.py b/test/agentchat/test_agent_setup_with_use_docker_settings.py index 8846d5499d..dc3440db78 100644 --- a/test/agentchat/test_agent_setup_with_use_docker_settings.py +++ b/test/agentchat/test_agent_setup_with_use_docker_settings.py @@ -15,8 +15,7 @@ is_docker_running, ) -sys.path.append(os.path.join(os.path.dirname(__file__), "..")) -from conftest import reason, skip_openai +from ..conftest import reason, skip_openai def docker_running(): diff --git a/test/agentchat/test_agent_usage.py b/test/agentchat/test_agent_usage.py index 02df221a3f..903b11c351 100755 --- a/test/agentchat/test_agent_usage.py +++ b/test/agentchat/test_agent_usage.py @@ -7,18 +7,15 @@ #!/usr/bin/env python3 -m pytest import io -import os -import sys from contextlib import redirect_stdout import pytest -from test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST import autogen from autogen import AssistantAgent, UserProxyAgent, gather_usage_summary -sys.path.append(os.path.join(os.path.dirname(__file__), "..")) -from conftest import reason, skip_openai # noqa: E402 +from ..conftest import reason, skip_openai # noqa: E402 +from .test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST @pytest.mark.skipif(skip_openai, reason=reason) diff --git a/test/agentchat/test_assistant_agent.py b/test/agentchat/test_assistant_agent.py index 3e96ecee14..2d4c077ac9 100755 --- a/test/agentchat/test_assistant_agent.py +++ b/test/agentchat/test_assistant_agent.py @@ -14,8 +14,7 @@ import autogen from autogen.agentchat import AssistantAgent, UserProxyAgent -sys.path.append(os.path.join(os.path.dirname(__file__), "..")) -from conftest import reason, skip_openai # noqa: E402 +from ..conftest import reason, skip_openai # noqa: E402 KEY_LOC = "notebook" OAI_CONFIG_LIST = "OAI_CONFIG_LIST" diff --git a/test/agentchat/test_async.py b/test/agentchat/test_async.py index a40d4441f4..ed3d123068 100755 --- a/test/agentchat/test_async.py +++ b/test/agentchat/test_async.py @@ -7,16 +7,13 @@ #!/usr/bin/env python3 -m pytest import asyncio -import os -import sys import pytest -from test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST import autogen -sys.path.append(os.path.join(os.path.dirname(__file__), "..")) -from conftest import reason, skip_openai # noqa: E402 +from ..conftest import reason, skip_openai # noqa: E402 +from .test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST def get_market_news(ind, ind_upper): diff --git a/test/agentchat/test_async_chats.py b/test/agentchat/test_async_chats.py index 1167ff4d07..1b1e3a1a4a 100755 --- a/test/agentchat/test_async_chats.py +++ b/test/agentchat/test_async_chats.py @@ -7,17 +7,14 @@ #!/usr/bin/env python3 -m pytest import asyncio -import os -import sys import pytest -from test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST import autogen from autogen import AssistantAgent, UserProxyAgent -sys.path.append(os.path.join(os.path.dirname(__file__), "..")) -from conftest import skip_openai # noqa: E402 +from ..conftest import skip_openai # noqa: E402 +from .test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST @pytest.mark.skipif(skip_openai, reason="requested to skip openai tests") diff --git a/test/agentchat/test_async_get_human_input.py b/test/agentchat/test_async_get_human_input.py index e68c3c6892..d9fa2115d4 100755 --- a/test/agentchat/test_async_get_human_input.py +++ b/test/agentchat/test_async_get_human_input.py @@ -7,17 +7,14 @@ #!/usr/bin/env python3 -m pytest import asyncio -import os -import sys from unittest.mock import AsyncMock import pytest -from test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST import autogen -sys.path.append(os.path.join(os.path.dirname(__file__), "..")) -from conftest import reason, skip_openai # noqa: E402 +from ..conftest import reason, skip_openai # noqa: E402 +from .test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST @pytest.mark.skipif(skip_openai, reason=reason) diff --git a/test/agentchat/test_cache_agent.py b/test/agentchat/test_cache_agent.py index 805a5be9f3..e54d6c9b20 100644 --- a/test/agentchat/test_cache_agent.py +++ b/test/agentchat/test_cache_agent.py @@ -5,19 +5,17 @@ # Portions derived from https://github.com/microsoft/autogen are under the MIT License. # SPDX-License-Identifier: MIT import os -import sys import tempfile import time import pytest -from test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST import autogen from autogen.agentchat import AssistantAgent, UserProxyAgent from autogen.cache import Cache -sys.path.append(os.path.join(os.path.dirname(__file__), "..")) -from conftest import skip_openai, skip_redis # noqa: E402 +from ..conftest import skip_openai, skip_redis # noqa: E402 +from .test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST try: from openai import OpenAI diff --git a/test/agentchat/test_chats.py b/test/agentchat/test_chats.py index 6f3504bbdb..7a2cb57600 100755 --- a/test/agentchat/test_chats.py +++ b/test/agentchat/test_chats.py @@ -11,14 +11,13 @@ from typing import Annotated, Literal import pytest -from test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST import autogen from autogen import AssistantAgent, GroupChat, GroupChatManager, UserProxyAgent, filter_config, initiate_chats from autogen.agentchat.chat import _post_process_carryover_item -sys.path.append(os.path.join(os.path.dirname(__file__), "..")) -from conftest import reason, skip_openai # noqa: E402 +from ..conftest import reason, skip_openai # noqa: E402 +from .test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST config_list = ( [] diff --git a/test/agentchat/test_conversable_agent.py b/test/agentchat/test_conversable_agent.py index 45775a55d7..3bc5bff6c2 100755 --- a/test/agentchat/test_conversable_agent.py +++ b/test/agentchat/test_conversable_agent.py @@ -10,24 +10,21 @@ import copy import inspect import os -import sys import time import unittest -from typing import Annotated, Any, Callable, Dict, Literal +from typing import Annotated, Any, Callable, Literal from unittest.mock import MagicMock import pytest from pydantic import BaseModel, Field -from test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST import autogen from autogen.agentchat import ConversableAgent, UserProxyAgent from autogen.agentchat.conversable_agent import register_function from autogen.exception_utils import InvalidCarryOverType, SenderRequired -from autogen.tools.tool import Tool -sys.path.append(os.path.join(os.path.dirname(__file__), "..")) -from conftest import MOCK_OPEN_AI_API_KEY, reason, skip_openai # noqa: E402 +from ..conftest import MOCK_OPEN_AI_API_KEY, reason, skip_openai # noqa: E402 +from .test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST here = os.path.abspath(os.path.dirname(__file__)) diff --git a/test/agentchat/test_function_call.py b/test/agentchat/test_function_call.py index 1567a31fc4..ed52f55cf1 100755 --- a/test/agentchat/test_function_call.py +++ b/test/agentchat/test_function_call.py @@ -6,19 +6,16 @@ # SPDX-License-Identifier: MIT #!/usr/bin/env python3 -m pytest -import asyncio import json -import os import sys import pytest -from test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST import autogen from autogen.math_utils import eval_math_responses -sys.path.append(os.path.join(os.path.dirname(__file__), "..")) -from conftest import skip_openai # noqa: E402 +from ..conftest import skip_openai # noqa: E402 +from .test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST try: from openai import OpenAI diff --git a/test/agentchat/test_function_call_groupchat.py b/test/agentchat/test_function_call_groupchat.py index 8a45ea7c06..6812e14dff 100755 --- a/test/agentchat/test_function_call_groupchat.py +++ b/test/agentchat/test_function_call_groupchat.py @@ -7,16 +7,13 @@ #!/usr/bin/env python3 -m pytest import asyncio -import os -import sys import pytest -from test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST import autogen -sys.path.append(os.path.join(os.path.dirname(__file__), "..")) -from conftest import reason, skip_openai +from ..conftest import reason, skip_openai +from .test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST func_def = { "name": "get_random_number", diff --git a/test/agentchat/test_groupchat.py b/test/agentchat/test_groupchat.py index a3063011a9..ef9420eedc 100755 --- a/test/agentchat/test_groupchat.py +++ b/test/agentchat/test_groupchat.py @@ -11,11 +11,10 @@ import json import logging from types import SimpleNamespace -from typing import Any, Dict, List, Optional -from unittest import TestCase, mock +from typing import Any, Optional +from unittest import mock import pytest -from test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST import autogen from autogen import Agent, AssistantAgent, GroupChat, GroupChatManager diff --git a/test/agentchat/test_human_input.py b/test/agentchat/test_human_input.py index 826aed609c..54fd68597f 100755 --- a/test/agentchat/test_human_input.py +++ b/test/agentchat/test_human_input.py @@ -6,17 +6,14 @@ # SPDX-License-Identifier: MIT #!/usr/bin/env python3 -m pytest -import os -import sys from unittest.mock import MagicMock import pytest -from test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST import autogen -sys.path.append(os.path.join(os.path.dirname(__file__), "..")) -from conftest import reason, skip_openai # noqa: E402 +from ..conftest import reason, skip_openai # noqa: E402 +from .test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST @pytest.mark.skipif(skip_openai, reason=reason) diff --git a/test/agentchat/test_math_user_proxy_agent.py b/test/agentchat/test_math_user_proxy_agent.py index 5248fac233..343fbd3ba7 100755 --- a/test/agentchat/test_math_user_proxy_agent.py +++ b/test/agentchat/test_math_user_proxy_agent.py @@ -10,7 +10,6 @@ import sys import pytest -from test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST import autogen from autogen.agentchat.contrib.math_user_proxy_agent import ( @@ -19,8 +18,8 @@ _remove_print, ) -sys.path.append(os.path.join(os.path.dirname(__file__), "..")) -from conftest import skip_openai # noqa: E402 +from ..conftest import skip_openai # noqa: E402 +from .test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST try: from openai import OpenAI diff --git a/test/agentchat/test_nested.py b/test/agentchat/test_nested.py index f47371628f..b63a0c70ac 100755 --- a/test/agentchat/test_nested.py +++ b/test/agentchat/test_nested.py @@ -6,19 +6,13 @@ # SPDX-License-Identifier: MIT #!/usr/bin/env python3 -m pytest -import os -import sys -from typing import List - import pytest import autogen from autogen.agentchat.contrib.capabilities.agent_capability import AgentCapability -sys.path.append(os.path.join(os.path.dirname(__file__), "..")) -sys.path.append(os.path.join(os.path.dirname(__file__), "../..")) -from conftest import reason, skip_openai # noqa: E402 -from test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST # noqa: E402 +from ..conftest import reason, skip_openai # noqa: E402 +from .test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST # noqa: E402 class MockAgentReplies(AgentCapability): diff --git a/test/agentchat/test_structured_output.py b/test/agentchat/test_structured_output.py index 4c1c671cb7..4c5ad3e771 100644 --- a/test/agentchat/test_structured_output.py +++ b/test/agentchat/test_structured_output.py @@ -5,20 +5,16 @@ # Portions derived from https://github.com/microsoft/autogen are under the MIT License. # SPDX-License-Identifier: MIT -import os -import sys -from typing import List from unittest.mock import MagicMock import pytest from openai.types.chat.parsed_chat_completion import ChatCompletion, ChatCompletionMessage, Choice from pydantic import BaseModel, ValidationError -from test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST import autogen -sys.path.append(os.path.join(os.path.dirname(__file__), "..")) -from conftest import MOCK_OPEN_AI_API_KEY, reason, skip_openai # noqa: E402 +from ..conftest import MOCK_OPEN_AI_API_KEY, reason, skip_openai # noqa: E402 +from .test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST @pytest.mark.skipif(skip_openai, reason=reason) diff --git a/test/agentchat/test_tool_calls.py b/test/agentchat/test_tool_calls.py index 3583e541bc..8804e86a20 100755 --- a/test/agentchat/test_tool_calls.py +++ b/test/agentchat/test_tool_calls.py @@ -12,19 +12,19 @@ import sys import pytest -from test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST import autogen from autogen.math_utils import eval_math_responses from autogen.oai.client import TOOL_ENABLED +from .test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST + try: from openai import OpenAI except ImportError: skip_openai = True else: - sys.path.append(os.path.join(os.path.dirname(__file__), "..")) - from conftest import skip_openai + from ..conftest import skip_openai @pytest.mark.skipif(skip_openai or not TOOL_ENABLED, reason="openai>=1.1.0 not installed or requested to skip") diff --git a/test/cache/__init__.py b/test/cache/__init__.py new file mode 100644 index 0000000000..1a50e0984e --- /dev/null +++ b/test/cache/__init__.py @@ -0,0 +1,5 @@ +#! /bin/env bash + +# Copyright (c) 2023 - 2024, Owners of https://github.com/ag2ai +# +# SPDX-License-Identifier: Apache-2.0 diff --git a/test/interop/crewai/test_crewai.py b/test/interop/crewai/test_crewai.py index 32a7f48aeb..43b11f2212 100644 --- a/test/interop/crewai/test_crewai.py +++ b/test/interop/crewai/test_crewai.py @@ -2,21 +2,19 @@ # # SPDX-License-Identifier: Apache-2.0 -import os import sys from tempfile import TemporaryDirectory from unittest.mock import MagicMock import pytest -sys.path.append(os.path.join(os.path.dirname(__file__), "../../agentchat")) -from conftest import MOCK_OPEN_AI_API_KEY, reason, skip_openai -from test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST - import autogen from autogen import AssistantAgent, UserProxyAgent from autogen.interop import Interoperable +from ...agentchat.test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST +from ...conftest import MOCK_OPEN_AI_API_KEY, reason, skip_openai + if sys.version_info >= (3, 10) and sys.version_info < (3, 13): from autogen.interop.crewai import CrewAIInteroperability else: diff --git a/test/interop/langchain/test_langchain.py b/test/interop/langchain/test_langchain.py index fe129a6e1c..50bd0d3f50 100644 --- a/test/interop/langchain/test_langchain.py +++ b/test/interop/langchain/test_langchain.py @@ -4,17 +4,19 @@ import os import sys -import unittest import pytest -from conftest import reason, skip_openai from langchain.tools import tool as langchain_tool from pydantic import BaseModel, Field +import autogen from autogen import AssistantAgent, UserProxyAgent from autogen.interop import Interoperable from autogen.interop.langchain import LangChainInteroperability +from ...agentchat.test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST +from ...conftest import reason, skip_openai + # skip if python version is not >= 3.9 @pytest.mark.skipif( @@ -50,7 +52,13 @@ def test_convert_tool(self) -> None: @pytest.mark.skipif(skip_openai, reason=reason) def test_with_llm(self) -> None: - config_list = [{"model": "gpt-4o", "api_key": os.environ["OPENAI_API_KEY"]}] + config_list = autogen.config_list_from_json( + OAI_CONFIG_LIST, + filter_dict={ + "tags": ["gpt-4o"], + }, + file_location=KEY_LOC, + ) user_proxy = UserProxyAgent( name="User", human_input_mode="NEVER", @@ -101,7 +109,13 @@ def test_convert_tool(self) -> None: @pytest.mark.skipif(skip_openai, reason=reason) def test_with_llm(self) -> None: - config_list = [{"model": "gpt-4o", "api_key": os.environ["OPENAI_API_KEY"]}] + config_list = autogen.config_list_from_json( + OAI_CONFIG_LIST, + filter_dict={ + "tags": ["gpt-4o"], + }, + file_location=KEY_LOC, + ) user_proxy = UserProxyAgent( name="User", human_input_mode="NEVER", @@ -110,6 +124,15 @@ def test_with_llm(self) -> None: chatbot = AssistantAgent( name="chatbot", llm_config={"config_list": config_list}, + system_message=""" +When using the search tool, input should be: +{ + "tool_input": { + "query": ..., + "max_length": ... + } +} +""", ) self.tool.register_for_execution(user_proxy) diff --git a/test/interop/pydantic_ai/test_pydantic_ai.py b/test/interop/pydantic_ai/test_pydantic_ai.py index 605e40923b..dd1dd40fde 100644 --- a/test/interop/pydantic_ai/test_pydantic_ai.py +++ b/test/interop/pydantic_ai/test_pydantic_ai.py @@ -5,20 +5,22 @@ import os import random import sys -import unittest from inspect import signature -from typing import Any, Dict, Optional +from typing import Any, Optional import pytest -from conftest import reason, skip_openai from pydantic import BaseModel from pydantic_ai import RunContext from pydantic_ai.tools import Tool as PydanticAITool +import autogen from autogen import AssistantAgent, UserProxyAgent from autogen.interop import Interoperable from autogen.interop.pydantic_ai import PydanticAIInteroperability +from ...agentchat.test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST +from ...conftest import reason, skip_openai + # skip if python version is not >= 3.9 @pytest.mark.skipif( @@ -47,7 +49,13 @@ def test_convert_tool(self) -> None: @pytest.mark.skipif(skip_openai, reason=reason) def test_with_llm(self) -> None: - config_list = [{"model": "gpt-4o", "api_key": os.environ["OPENAI_API_KEY"]}] + config_list = autogen.config_list_from_json( + OAI_CONFIG_LIST, + filter_dict={ + "tags": ["gpt-4o"], + }, + file_location=KEY_LOC, + ) user_proxy = UserProxyAgent( name="User", human_input_mode="NEVER", @@ -193,7 +201,13 @@ def test_expected_tools(self) -> None: @pytest.mark.skipif(skip_openai, reason=reason) def test_with_llm(self) -> None: - config_list = [{"model": "gpt-4o", "api_key": os.environ["OPENAI_API_KEY"]}] + config_list = autogen.config_list_from_json( + OAI_CONFIG_LIST, + filter_dict={ + "tags": ["gpt-4o"], + }, + file_location=KEY_LOC, + ) user_proxy = UserProxyAgent( name="User", human_input_mode="NEVER", diff --git a/test/interop/test_interoperability.py b/test/interop/test_interoperability.py index a2e5e4051e..412b632613 100644 --- a/test/interop/test_interoperability.py +++ b/test/interop/test_interoperability.py @@ -4,13 +4,13 @@ import sys from tempfile import TemporaryDirectory -from typing import Any import pytest -from conftest import MOCK_OPEN_AI_API_KEY from autogen.interop import Interoperability +from ..conftest import MOCK_OPEN_AI_API_KEY + class TestInteroperability: def test_supported_types(self) -> None: diff --git a/test/io/__init__.py b/test/io/__init__.py new file mode 100644 index 0000000000..1a50e0984e --- /dev/null +++ b/test/io/__init__.py @@ -0,0 +1,5 @@ +#! /bin/env bash + +# Copyright (c) 2023 - 2024, Owners of https://github.com/ag2ai +# +# SPDX-License-Identifier: Apache-2.0 diff --git a/test/io/test_websockets.py b/test/io/test_websockets.py index 322f29dfc8..14b7475d70 100644 --- a/test/io/test_websockets.py +++ b/test/io/test_websockets.py @@ -8,7 +8,6 @@ from typing import Dict import pytest -from conftest import skip_openai from websockets.exceptions import ConnectionClosed import autogen @@ -17,6 +16,8 @@ from autogen.io.base import IOStream from autogen.messages.agent_messages import TextMessage +from ..conftest import skip_openai + KEY_LOC = "notebook" OAI_CONFIG_LIST = "OAI_CONFIG_LIST" diff --git a/test/oai/__init__.py b/test/oai/__init__.py new file mode 100644 index 0000000000..1a50e0984e --- /dev/null +++ b/test/oai/__init__.py @@ -0,0 +1,5 @@ +#! /bin/env bash + +# Copyright (c) 2023 - 2024, Owners of https://github.com/ag2ai +# +# SPDX-License-Identifier: Apache-2.0 diff --git a/test/oai/test_client.py b/test/oai/test_client.py index 4b37166eba..963f9b7752 100755 --- a/test/oai/test_client.py +++ b/test/oai/test_client.py @@ -8,7 +8,6 @@ import os import shutil -import sys import time import pytest @@ -17,8 +16,7 @@ from autogen.cache.cache import Cache from autogen.oai.client import LEGACY_CACHE_DIR, LEGACY_DEFAULT_CACHE_SEED -sys.path.append(os.path.join(os.path.dirname(__file__), "..")) -from conftest import skip_openai # noqa: E402 +from ..conftest import skip_openai # noqa: E402 TOOL_ENABLED = False try: diff --git a/test/oai/test_client_stream.py b/test/oai/test_client_stream.py index 1ce72e0e77..125e1dfb46 100755 --- a/test/oai/test_client_stream.py +++ b/test/oai/test_client_stream.py @@ -6,17 +6,14 @@ # SPDX-License-Identifier: MIT #!/usr/bin/env python3 -m pytest -import os -import sys -from typing import Any, Dict, List, Optional, Union +from typing import Any, Optional, Union from unittest.mock import MagicMock import pytest from autogen import OpenAIWrapper, config_list_from_json -sys.path.append(os.path.join(os.path.dirname(__file__), "..")) -from conftest import skip_openai # noqa: E402 +from ..conftest import skip_openai # noqa: E402 try: from openai import OpenAI diff --git a/test/oai/test_utils.py b/test/oai/test_utils.py index 1f8d1f4855..8eb7c0dbc4 100755 --- a/test/oai/test_utils.py +++ b/test/oai/test_utils.py @@ -15,11 +15,12 @@ from unittest.mock import patch import pytest -from conftest import MOCK_OPEN_AI_API_KEY import autogen # noqa: E402 from autogen.oai.openai_utils import DEFAULT_AZURE_API_VERSION, filter_config, is_valid_api_key +from ..conftest import MOCK_OPEN_AI_API_KEY + # Example environment variables ENV_VARS = { "OPENAI_API_KEY": "sk-********************", diff --git a/test/test_browser_utils.py b/test/test_browser_utils.py index 58591e4ebb..1bc5bf3914 100755 --- a/test/test_browser_utils.py +++ b/test/test_browser_utils.py @@ -10,11 +10,11 @@ import math import os import re -import sys import pytest import requests -from agentchat.test_assistant_agent import KEY_LOC # noqa: E402 + +from .agentchat.test_assistant_agent import KEY_LOC # noqa: E402 BLOG_POST_URL = "https://docs.ag2.ai/blog/2023-04-21-LLM-tuning-math" BLOG_POST_TITLE = "Does Model and Inference Parameter Matter in LLM Applications? - A Case Study for MATH - AG2" diff --git a/test/test_code_utils.py b/test/test_code_utils.py index 2a951eae3d..0e702bb441 100755 --- a/test/test_code_utils.py +++ b/test/test_code_utils.py @@ -7,7 +7,6 @@ #!/usr/bin/env python3 -m pytest import os -import sys import tempfile import unittest from io import StringIO @@ -15,7 +14,6 @@ from unittest.mock import patch import pytest -from conftest import skip_docker import autogen from autogen.code_utils import ( @@ -34,6 +32,8 @@ is_docker_running, ) +from .conftest import skip_docker + KEY_LOC = "notebook" OAI_CONFIG_LIST = "OAI_CONFIG_LIST" here = os.path.abspath(os.path.dirname(__file__)) diff --git a/test/test_notebook.py b/test/test_notebook.py index fb746a2ecb..533df8b623 100755 --- a/test/test_notebook.py +++ b/test/test_notebook.py @@ -10,7 +10,8 @@ import sys import pytest -from conftest import skip_openai + +from .conftest import skip_openai try: import openai