From 88d6add6ee897fc1ddf50150ebc37e012aec1a4a Mon Sep 17 00:00:00 2001 From: Davor Runje Date: Thu, 19 Dec 2024 16:35:08 +0100 Subject: [PATCH] test fixing --- autogen/interop/crewai/crewai.py | 1 - autogen/interop/langchain/langchain.py | 1 - autogen/interop/pydantic_ai/pydantic_ai.py | 1 - test/interop/langchain/test_langchain.py | 13 ++++++------- test/interop/pydantic_ai/test_pydantic_ai.py | 4 ++-- test/interop/pydantic_ai/test_pydantic_ai_tool.py | 10 +++++----- 6 files changed, 13 insertions(+), 17 deletions(-) diff --git a/autogen/interop/crewai/crewai.py b/autogen/interop/crewai/crewai.py index 1588ccd529..cfaa9f5ada 100644 --- a/autogen/interop/crewai/crewai.py +++ b/autogen/interop/crewai/crewai.py @@ -7,7 +7,6 @@ from typing import Any, Optional from ...tools import Tool -from ..interoperable import Interoperable from ..registry import register_interoperable_class __all__ = ["CrewAIInteroperability"] diff --git a/autogen/interop/langchain/langchain.py b/autogen/interop/langchain/langchain.py index 3471e83203..a6689d4dad 100644 --- a/autogen/interop/langchain/langchain.py +++ b/autogen/interop/langchain/langchain.py @@ -6,7 +6,6 @@ from typing import Any, Optional from ...tools import Tool -from ..interoperable import Interoperable from ..registry import register_interoperable_class __all__ = ["LangChainInteroperability"] diff --git a/autogen/interop/pydantic_ai/pydantic_ai.py b/autogen/interop/pydantic_ai/pydantic_ai.py index db2e22dd4b..78c48dc0cd 100644 --- a/autogen/interop/pydantic_ai/pydantic_ai.py +++ b/autogen/interop/pydantic_ai/pydantic_ai.py @@ -9,7 +9,6 @@ from inspect import signature from typing import Any, Callable, Optional -from ..interoperability import Interoperable from ..registry import register_interoperable_class from .pydantic_ai_tool import PydanticAITool as AG2PydanticAITool diff --git a/test/interop/langchain/test_langchain.py b/test/interop/langchain/test_langchain.py index 376612ad11..cbd038d8a5 100644 --- a/test/interop/langchain/test_langchain.py +++ b/test/interop/langchain/test_langchain.py @@ -14,12 +14,11 @@ from autogen.interop import Interoperable if sys.version_info >= (3, 9): - from langchain.tools import tool - - from autogen.interop.langchain import LangChainInteroperability + from langchain.tools import tool as langchain_tool else: - tool = unittest.mock.MagicMock() - LangChainInteroperability = unittest.mock.MagicMock() + langchain_tool = unittest.mock.MagicMock() + +from autogen.interop.langchain import LangChainInteroperability # skip if python version is not >= 3.9 @@ -32,7 +31,7 @@ def setup(self) -> None: class SearchInput(BaseModel): query: str = Field(description="should be a search query") - @tool("search-tool", args_schema=SearchInput, return_direct=True) # type: ignore[misc] + @langchain_tool("search-tool", args_schema=SearchInput, return_direct=True) # type: ignore[misc] def search(query: SearchInput) -> str: """Look up things online.""" return "LangChain Integration" @@ -90,7 +89,7 @@ def test_get_unsupported_reason(self) -> None: class TestLangChainInteroperabilityWithoutPydanticInput: @pytest.fixture(autouse=True) def setup(self) -> None: - @tool + @langchain_tool def search(query: str, max_length: int) -> str: """Look up things online.""" return f"LangChain Integration, max_length: {max_length}" diff --git a/test/interop/pydantic_ai/test_pydantic_ai.py b/test/interop/pydantic_ai/test_pydantic_ai.py index 764a44e855..4f0a2da458 100644 --- a/test/interop/pydantic_ai/test_pydantic_ai.py +++ b/test/interop/pydantic_ai/test_pydantic_ai.py @@ -20,11 +20,11 @@ from pydantic_ai import RunContext from pydantic_ai.tools import Tool as PydanticAITool - from autogen.interop.pydantic_ai import PydanticAIInteroperability else: RunContext = unittest.mock.MagicMock() PydanticAITool = unittest.mock.MagicMock() - PydanticAIInteroperability = unittest.mock.MagicMock() + +from autogen.interop.pydantic_ai import PydanticAIInteroperability # skip if python version is not >= 3.9 diff --git a/test/interop/pydantic_ai/test_pydantic_ai_tool.py b/test/interop/pydantic_ai/test_pydantic_ai_tool.py index d6c1d942f9..f5588ad8b6 100644 --- a/test/interop/pydantic_ai/test_pydantic_ai_tool.py +++ b/test/interop/pydantic_ai/test_pydantic_ai_tool.py @@ -10,12 +10,12 @@ from autogen import AssistantAgent if sys.version_info >= (3, 9): - from pydantic_ai.tools import Tool + from pydantic_ai.tools import Tool as PydanticAITool - from autogen.interop.pydantic_ai.pydantic_ai_tool import PydanticAITool as AG2PydanticAITool else: - Tool = unittest.mock.MagicMock() - AG2PydanticAITool = unittest.mock.MagicMock() + PydanticAITool = unittest.mock.MagicMock() + +from autogen.interop.pydantic_ai.pydantic_ai_tool import PydanticAITool as AG2PydanticAITool # skip if python version is not >= 3.9 @@ -34,7 +34,7 @@ def foobar(a: int, b: str, c: dict[str, list[float]]) -> str: # type: ignore[mi """ return f"{a} {b} {c}" - tool = Tool(foobar) + tool = PydanticAITool(foobar) ag2_tool = AG2PydanticAITool( name=tool.name, description=tool.description,