Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions autogen/interop/pydantic_ai/pydantic_ai.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ def convert_tool(cls, tool: Any, deps: Any = None, **kwargs: Any) -> AG2Pydantic
"""
from pydantic_ai import RunContext
from pydantic_ai.tools import Tool as PydanticAITool
from pydantic_ai.usage import Usage

if not isinstance(tool, PydanticAITool):
raise ValueError(f"Expected an instance of `pydantic_ai.tools.Tool`, got {type(tool)}")
Expand All @@ -127,6 +128,9 @@ def convert_tool(cls, tool: Any, deps: Any = None, **kwargs: Any) -> AG2Pydantic

ctx = (
RunContext(
model=None, # type: ignore [arg-type]
usage=Usage(),
prompt="",
deps=deps,
retry=0,
# All messages send to or returned by a model.
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ interop-crewai = [
"litellm<1.57.5; sys_platform=='win32'",
]
interop-langchain = ["langchain-community>=0.3.12,<1"]
interop-pydantic-ai = ["pydantic-ai==0.0.13"]
interop-pydantic-ai = ["pydantic-ai==0.0.22"]
interop =[
"pyautogen[interop-crewai, interop-langchain, interop-pydantic-ai]",
]
Expand Down
9 changes: 8 additions & 1 deletion test/interop/pydantic_ai/test_pydantic_ai.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@

with optional_import_block():
from pydantic_ai import RunContext
from pydantic_ai.models.test import TestModel
from pydantic_ai.tools import Tool as PydanticAITool
from pydantic_ai.usage import Usage


@pytest.mark.interop
Expand Down Expand Up @@ -79,6 +81,9 @@ def f(
return f"{city} {date} {ctx.deps}" # type: ignore[attr-defined]

ctx = RunContext(
model=TestModel(),
usage=Usage(),
prompt="",
deps=123,
retry=0,
messages=None, # type: ignore[arg-type]
Expand All @@ -103,6 +108,9 @@ def f(
raise ValueError("Retry")

ctx = RunContext(
model=TestModel(),
usage=Usage(),
prompt="",
deps=123,
retry=0,
messages=None, # type: ignore[arg-type]
Expand Down Expand Up @@ -173,7 +181,6 @@ def test_expected_tools(self) -> None:
"title": "Additional Info",
}
},
"required": ["additional_info"],
"type": "object",
"additionalProperties": False,
},
Expand Down
Loading