Tool

class Tool(BaseTool)

Representation of a tool, which is a function that can be called by the agent.

Arguments:

  • id str - The unique identifier of the tool.
  • name str - The name of the function.
  • tags List[str] - Metadata tags.
  • source_code str - The source code of the function.
  • json_schema Dict - The JSON schema of the function.

to_dict

def to_dict()

Convert tool into OpenAI representation.

from_langchain

@classmethod
def from_langchain(cls, langchain_tool) -> "Tool"

Class method to create an instance of Tool from a Langchain tool (must be from langchain_community.tools).

Arguments:

  • langchain_tool LangchainTool - An instance of a crewAI BaseTool (BaseTool from crewai)

Returns:

  • Tool - A Letta Tool initialized with attributes derived from the provided crewAI BaseTool object.

from_crewai

@classmethod
def from_crewai(cls, crewai_tool) -> "Tool"

Class method to create an instance of Tool from a crewAI BaseTool object.

Arguments:

  • crewai_tool CrewAIBaseTool - An instance of a crewAI BaseTool (BaseTool from crewai)

Returns:

  • Tool - A Letta Tool initialized with attributes derived from the provided crewAI BaseTool object.