autogen.interop.PydanticAIInteroperability
PydanticAIInteroperability
A class implementing the Interoperable
protocol for converting Pydantic AI tools
into a general Tool
format.
This class takes a PydanticAITool
and converts it into a standard Tool
object,
ensuring compatibility between Pydantic AI tools and other systems that expect
the Tool
format. It also provides a mechanism for injecting context parameters
into the tool’s function.
Static Methods
convert_tool
Converts a given Pydantic AI tool into a general Tool
format.
This method verifies that the provided tool is a valid PydanticAITool
,
handles context dependencies if necessary, and returns a standardized Tool
object.
Name | Description |
---|---|
tool | The tool to convert, expected to be an instance of PydanticAITool .Type: Any |
deps | The dependencies to inject into the context, required if the tool takes a context. Defaults to None. Type: Any Default: None |
**kwargs | Additional arguments that are not used in this method. Type: Any |
Type | Description |
---|---|
autogen.interop.pydantic_ai.pydantic_ai_tool.PydanticAITool | AG2PydanticAITool: A standardized Tool object converted from the Pydantic AI tool. |
get_unsupported_reason
inject_params
Wraps the tool’s function to inject context parameters and handle retries.
This method ensures that context parameters are properly passed to the tool
when invoked and that retries are managed according to the tool’s settings.
Name | Description |
---|---|
ctx | The run context, which may include dependencies and retry information. Type: Any |
tool | The Pydantic AI tool whose function is to be wrapped. Type: Any |
Type | Description |
---|---|
Callable[..., Any] | Callable[…, Any]: A wrapped function that includes context injection and retry handling. |