Skip to content

Commit

Permalink
Merge pull request #232 from ag2ai/fix-tool-imports-tests
Browse files Browse the repository at this point in the history
Fix tests
  • Loading branch information
rjambrecic authored Dec 18, 2024
2 parents 4ba90f5 + 00ecd98 commit cce8f12
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
5 changes: 4 additions & 1 deletion test/interop/pydantic_ai/test_pydantic_ai.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ def test_with_llm(self) -> None:
assert False, "No tool response found in chat messages"


@pytest.mark.skipif(
sys.version_info < (3, 9), reason="Only Python 3.9 and above are supported for LangchainInteroperability"
)
class TestPydanticAIInteroperabilityDependencyInjection:

def test_dependency_injection(self) -> None:
Expand Down Expand Up @@ -162,7 +165,7 @@ def get_player(ctx: RunContext[Player], additional_info: Optional[str] = None) -
self.tool = self.pydantic_ai_interop.convert_tool(tool=pydantic_ai_tool, deps=player)

def test_expected_tools(self) -> None:
config_list = [{"model": "gpt-4o", "api_key": os.environ["OPENAI_API_KEY"]}]
config_list = [{"model": "gpt-4o", "api_key": "abc"}]
chatbot = AssistantAgent(
name="chatbot",
llm_config={"config_list": config_list},
Expand Down
11 changes: 9 additions & 2 deletions test/interop/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@ def test_find_classes_implementing_protocol(self) -> None:

if sys.version_info >= (3, 9):
from autogen.interop.langchain import LangchainInteroperability
from autogen.interop.pydantic_ai import PydanticAIInteroperability

assert LangchainInteroperability in actual
expected_count += 1
assert PydanticAIInteroperability in actual
expected_count += 2

assert len(actual) == expected_count

Expand All @@ -53,8 +55,13 @@ def test_get_all_interoperability_classes(self) -> None:
if sys.version_info >= (3, 10) and sys.version_info < (3, 13):
from autogen.interop.crewai import CrewAIInteroperability
from autogen.interop.langchain import LangchainInteroperability
from autogen.interop.pydantic_ai import PydanticAIInteroperability

assert actual == {"crewai": CrewAIInteroperability, "langchain": LangchainInteroperability}
assert actual == {
"pydanticai": PydanticAIInteroperability,
"crewai": CrewAIInteroperability,
"langchain": LangchainInteroperability,
}

if (sys.version_info >= (3, 9) and sys.version_info < (3, 10)) and sys.version_info >= (3, 13):
from autogen.interop.langchain import LangchainInteroperability
Expand Down
6 changes: 3 additions & 3 deletions test/interop/test_interoperability.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ def test_supported_types(self) -> None:
assert actual == []

if sys.version_info >= (3, 9) and sys.version_info < (3, 10):
assert actual == ["langchain"]
assert actual == ["langchain", "pydanticai"]

if sys.version_info >= (3, 10) and sys.version_info < (3, 13):
assert actual == ["crewai", "langchain"]
assert actual == ["crewai", "langchain", "pydanticai"]

if sys.version_info >= (3, 13):
assert actual == ["langchain"]
assert actual == ["langchain", "pydanticai"]

def test_register_interoperability_class(self) -> None:
org_interoperability_classes = Interoperability._interoperability_classes
Expand Down

0 comments on commit cce8f12

Please sign in to comment.