Skip to content

Commit

Permalink
test fixing
Browse files Browse the repository at this point in the history
  • Loading branch information
davorrunje committed Dec 19, 2024
1 parent 919c04e commit 88d6add
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 17 deletions.
1 change: 0 additions & 1 deletion autogen/interop/crewai/crewai.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
1 change: 0 additions & 1 deletion autogen/interop/langchain/langchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
1 change: 0 additions & 1 deletion autogen/interop/pydantic_ai/pydantic_ai.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
13 changes: 6 additions & 7 deletions test/interop/langchain/test_langchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand Down Expand Up @@ -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}"
Expand Down
4 changes: 2 additions & 2 deletions test/interop/pydantic_ai/test_pydantic_ai.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions test/interop/pydantic_ai/test_pydantic_ai_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down

0 comments on commit 88d6add

Please sign in to comment.