CrewAIInteroperability - AG2

CrewAIInteroperability

autogen.interop.CrewAIInteroperability

A class implementing the Interoperable protocol for converting CrewAI tools to a general Tool format.

This class takes a CrewAITool and converts it into a standard Tool object.

convert_tool`classmethod

convert_tool(tool, **kwargs)

Converts a given CrewAI tool into a general Tool format.

This method ensures that the provided tool is a valid CrewAITool, sanitizes the tool's name, processes its description, and prepares a function to interact with the tool's arguments. It then returns a standardized Tool object.

PARAMETER DESCRIPTION
tool The tool to convert, expected to be an instance of CrewAITool.
TYPE: Any
**kwargs Additional arguments, which are not supported by this method.
TYPE: Any DEFAULT: {}
RETURNS DESCRIPTION
Tool A standardized Tool object converted from the CrewAI tool.
TYPE: Tool
RAISES DESCRIPTION
ValueError If the provided tool is not an instance of CrewAITool, or if any additional arguments are passed.

Source code in autogen/interop/crewai/crewai.py

``` <br>@classmethod<br>@require_optional_import("crewai", "interop-crewai")<br>def convert_tool(cls, tool: Any, **kwargs: Any) -> Tool:<br> """Converts a given CrewAI tool into a general `Tool` format.<br> This method ensures that the provided tool is a valid `CrewAITool`, sanitizes<br> the tool's name, processes its description, and prepares a function to interact<br> with the tool's arguments. It then returns a standardized `Tool` object.<br> Args:<br> tool (Any): The tool to convert, expected to be an instance of `CrewAITool`.<br> **kwargs (Any): Additional arguments, which are not supported by this method.<br> Returns:<br> Tool: A standardized `Tool` object converted from the CrewAI tool.<br> Raises:<br> ValueError: If the provided tool is not an instance of `CrewAITool`, or if<br> any additional arguments are passed.<br> """<br> warnings.warn(<br> "CrewAIInteroperability is deprecated and will be removed in v0.14.",<br> DeprecationWarning,<br> stacklevel=2,<br> )<br> if not isinstance(tool, CrewAITool):<br> raise ValueError(f"Expected an instance of `crewai.tools.BaseTool`, got {type(tool)}")<br> if kwargs:<br> raise ValueError(f"The CrewAIInteroperability does not support any additional arguments, got {kwargs}")<br> # needed for type checking<br> crewai_tool: CrewAITool = tool # type: ignore[no-any-unimported]<br> name = _sanitize_name(crewai_tool.name)<br> description = (<br> crewai_tool.description.split("Tool Description: ")[-1]<br> + " (IMPORTANT: When using arguments, put them all in an `args` dictionary)"<br> )<br> def func(args: crewai_tool.args_schema) -> Any: # type: ignore[no-any-unimported]<br> return crewai_tool.run(**args.model_dump())<br> return Tool(<br> name=name,<br> description=description,<br> func_or_tool=func,<br> )<br>

get_unsupported_reason`classmethod

get_unsupported_reason()

Source code in autogen/interop/crewai/crewai.py

``` ```
@classmethod
def get_unsupported_reason(cls) -> str