Tool Converter
Overview
Section titled “Overview”The ToolConverter automatically detects tool formats and converts them to unified interfaces:
from langcrew.tools import ToolConverter, convert_tools
# Convert any toolconverted = ToolConverter.convert_tool(any_tool)
# Batch convert different formatsunified = convert_tools([crewai_tool, langchain_tool, my_function])Supported Conversions
Section titled “Supported Conversions”Convert CrewAI tools to LangChain format:
from crewai_tools import ScrapeWebsiteToolfrom langcrew.tools import ToolConverter
# Convert CrewAI toolcrewai_tool = ScrapeWebsiteTool()langchain_tool = ToolConverter.convert_crewai_tool(crewai_tool)
# Use with any LangChain-compatible agentresult = langchain_tool.run("https://example.com")Convert LangChain tools to CrewAI format:
from langchain_core.tools import BaseToolfrom langcrew.tools import convert_langchain_tool
class LangChainCalculator(BaseTool): name = "calculator" description = "Mathematical calculations"
def _run(self, expression: str) -> str: return str(eval(expression))
# Convert to CrewAIlangchain_tool = LangChainCalculator()crewai_tool = convert_langchain_tool(langchain_tool)Convert functions to tool formats:
from langcrew.tools import ToolConverter
def calculate_interest(principal: float, rate: float, time: int) -> float: """Calculate compound interest.""" return principal * (1 + rate) ** time
# Convert to LangChain tooltool = ToolConverter.convert_callable_tool(calculate_interest)result = tool.run({"principal": 1000, "rate": 0.05, "time": 10})Batch Conversion
Section titled “Batch Conversion”Convert multiple tools of different formats at once:
from langcrew.tools import convert_tools
# Mix different tool typestools = [crewai_tool, langchain_tool, my_function]unified_tools = convert_tools(tools) # All become LangChain toolsThe Tool Converter provides seamless interoperability between different tool formats, enabling you to use tools from any source in your LangCrew applications without compatibility concerns.